eight_bit_computer.decimal_display module

Generate the data for the decimal display rom.

eight_bit_computer.decimal_display.gen_display_romdatas()[source]

Generate the romdatas that make up the display rom

Returns:List of romdatas (unsorted) that make up the display rom.
Return type:list(RomData)
eight_bit_computer.decimal_display.to_2s_compliment(value)[source]

Convert an unsigned value to it’s 2’s compliment equivalent.

Parameters:value (int) – The unsigned 8 bit value (0-255) to convert
Returns:The 2’s compliment equivalent.
Return type:int
eight_bit_computer.decimal_display.assemble_romdata(raw_value, disp_chars, base_bitdef, binary_mode_bitdef)[source]

Assemble the romdatas for the given display configuration.

Parameters:
  • raw_value (int) – The unsigned 8 bit value to convert to display rom values.
  • disp_chars (string) – The display characters that will make up this value on the seven segment displays
  • base_bitdef (str) – A bitdef signifying which base the display should be in - hex or decimal. Forms part of the address of the rom.
  • binary_mode_bitdef (str) – Whether the raw value should be displayed in unsigned or two’s compliment interpreted value.
Returns:

List of the romdatas that make up this display configuration.

Return type:

list(RomData)

eight_bit_computer.decimal_display.value_to_addr_bitdef(value)[source]

Place the bitdef of the value in the address bitdef.

The address bitdef is 15 bits wide but the value is only 8. Pad this to the correct size by forcing the 3 unused bits in the 3 most significate places to be zero and leaving 4 bits for the base and interpretation (unsigned vs 2’s compliment) in the next most significant bits. The valye goes in the 8 least significant bits.

Parameters:value (int) – Unsigned 8 bit value (0-255) to place in the address bitdef.
Returns:Address bitdef with value in place.
Return type:str
eight_bit_computer.decimal_display.character_to_bitdef(character)[source]

Generate a bitdef for the given character.

Bitdefs are mapped to correspond to a 5641AH 7 segment display:

    A
  - - -
 |     |
F|     |B
 |  G  |
  - - -
 |     |
E|     |C
 |     |
  - - -
    D

A = 0000 0001
B = 0000 0010
C = 0000 0100
D = 0000 1000
E = 0001 0000
F = 0010 0000
G = 0100 0000
Parameters:character (str) – Character to get the bidef for.
Returns:Bitdef that represents the segments to illuminate for that character.
Return type:str
Raises:ValueError – If the character to convert isn’t supported.