eight_bit_computer.rom module

Create and export roms for the computer

eight_bit_computer.rom.get_rom()[source]

Get complete representation of the rom.

Returns:All the defined microcode.
Return type:list(RomData)
Raises:RuntimeError – When the romdata dataset has duplicate addresses.
eight_bit_computer.rom.collect_language_datatemplates()[source]

Get all the datatemplates from all the defined operations.

Returns:
All the data templates from the defined
operations
Return type:list(DataTemplate)
eight_bit_computer.rom.collapse_datatemplates_to_romdatas(datatemplates)[source]

Collapse any addresses in datatemplates to real values.

If an address does need collapsing the original data is copied out to all the collapsed addresses.

Parameters:list (datatemplates) – A list of templates to collapse.
Returns:The expanded datatemplates
Return type:list(RomData)
eight_bit_computer.rom.populate_empty_addresses(romdatas, all_addresses, default_data)[source]

Form a complete set of rom data by filling any undefined addresses.

Parameters:
  • list (romdatas) – The romdatas defined by the instructions.
  • all_addresses (list(str)) – List of bitdefs representing every address in the rom
  • default_data (str) – The value to set for any address that isn’t in romdatas.
Returns:

List of RomDatas representing a completely full

rom

Return type:

list(RomData)

eight_bit_computer.rom.romdatas_have_duplicate_addresses(romdatas)[source]

Check if any of the romdatas have duplicate addresses.

Parameters:list (romdatas) – List of romdatas to check.
Returns:Whether or not there were any duplicated addresses.
Return type:Bool
eight_bit_computer.rom.slice_rom(rom)[source]

Slice a rom into chunks 8 bits wide.

This is to prepare the data to write into the roms. To take a single RomData as an example, if it looked like this (spaces added for clarity):

RomData(
    address="0000000 0000 000",
    data="10101010 11111111 00000000 11001100"
)

We would end up with:

{
    0: RomData(
        address="0000000 0000 000",
        data="11001100"
    ),
    1: RomData(
        address="0000000 0000 000",
        data="00000000"
    ),
    2: RomData(
        address="0000000 0000 000",
        data="11111111"
    ),
    3: RomData(
        address="0000000 0000 000",
        data="10101010"
    )
}
Parameters:rom (list(RomData)) – The complete ROM
Returns:list(RomData)) Dictionary of ROM slices
Return type:dict(int
eight_bit_computer.rom.get_num_bytes(bitstring)[source]

Get the number of bytes needed to store this bitdef.

Parameters:bitstring (str) – Bitstring representing the bits to store.
Returns:The number of bytes needed to store the bitstring.
Return type:int
eight_bit_computer.rom.get_romdata_slice(romdatas, end, start)[source]

Get a slice of the data in the romdatas.

Parameters:
  • romdatas (list(RomData)) – The romdatas to get a slice from
  • end (int) – The index for the end of the slice. Starts at zero at the rightmost (least significant) bit.
  • start (int) – The index for the start of the slice. Starts at zero at the rightmost (least significant) bit.
Returns:

The sliced list of romdatas

Return type:

list(RomData)

eight_bit_computer.rom.get_decimal_rom()[source]

Get complete representation of the decimal rom.

Returns:All the defined data for the decima rom.
Return type:list(RomData)
Raises:RuntimeError – When the decimal romdata dataset has duplicate addresses.