x_heep_gen.system module

class x_heep_gen.system.BusType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: Enum

Enumeration of all supported bus types

NtoM = 'NtoM'
onetoM = 'onetoM'
class x_heep_gen.system.Override(bus_type: BusType | None, numbanks: int | None, numbanks_il: int | None)

Bases: object

Bundles information that can be overriden in the XHeep class.

bus_type: BusType | None
numbanks: int | None
numbanks_il: int | None
class x_heep_gen.system.XHeep(bus_type: BusType, ram_start_address: int = 0, override: Override | None = None)

Bases: object

This object represents the whole mcu.

An instance of this object is also passed to the mako templates.

Parameters:
  • bus_type (BusType) – The bus type chosen for this mcu.

  • ram_start_address (int) – The address of the first ram bank. For now only 0 is tested. Defaults to 0.

  • override (Optional[Override]) – configs to be overriden

Raises:

TypeError – when parameters are of incorrect type.

IL_COMPATIBLE_BUS_TYPES: Set[BusType] = {BusType.NtoM}

Constant set of bus types that support interleaved memory banks

add_linker_section(section: LinkerSection)

Function to add a linker section. :param LinkerSection section: Linker section to add. :param str name: the name of the section. :raise ValueError: if the name was allready used for another section or the first and second are not code and data.

add_linker_section_for_banks(banks: List[Bank], name: str)

Function to add linker sections coupled to some banks. :param List[Bank] banks: list of banks that compose the section, assumed to be continuous in memory :param str name: the name of the section. :raise ValueError: if the name was allready used for another section or the first and second are not code and data.

add_ram_banks(bank_sizes: List[int], section_name: str = '')

Add ram banks in continuous address mode to the system. The bank size should be a power of two and at least 1kiB.

Parameters:
  • bank_sizes (List[int]) – list of bank sizes in kiB that should be added to the system

  • section_name (str) – If not empty adds automatically a linker section for this banks. The names must be unique and not be used by the linker for other purposes.

Raises:
  • TypeError – when arguments are of wrong type

  • ValueError – when banks have an incorrect size.

  • ValueError – if the name was allready used for another section or the first and second are not code and data.

  • ValueError – if bank_sizes list is empty

add_ram_banks_il(num: int, bank_size: int, section_name: str = '', ignore_ignore: bool = False)

Add ram banks in interleaved mode to the system. The bank size should be a power of two and at least 1kiB, the number of banks should also be a power of two.

Parameters:
  • num (int) – number of banks to add

  • bank_size (int) – size of the banks in kiB

  • section_name (str) – If not empty adds automatically a linker section for this banks. The names must be unique and not be used by the linker for other purposes.

  • ignore_ignore (bool) – Ignores the fact that an override was set. For internal uses to apply this override.

Raises:
  • TypeError – when arguments are of wrong type

  • ValueError – when banks have an incorrect size or their number is not a power of two.

  • ValueError – if the name was allready used for another section or the first and second are not code and data.

build()

Makes the system ready to be used.

  • Aplies the overrides for the interleaved memory as the normal memory needs to be configured first.

  • Sorts the linker sections by starting address.

  • Inferes the missing linker section ends with the start of the next section if present. If not it uses the end of the last memory bank.

bus_type() BusType
Returns:

the configured bus type

Return type:

BusType

has_il_ram() bool
Returns:

True if the system has interleaved ram.

Return type:

bool

iter_bank_numwords() Generator[int, None, None]

Iterates over the size of the ram banks in number of words.

Returns:

Generator over the sizes

Return type:

Generator[int, None, None]

iter_cont_ram_banks() Iterable[Bank]
Returns:

an iterator over all continuous banks.

Return type:

Iterable[Bank]

iter_il_groups() Iterable[ILRamGroup]
Returns:

an iterator over the interleaved ram bank groups.

Return type:

Iterable[ILRamGroup]

iter_il_ram_banks() Iterable[Bank]
Returns:

an iterator over all interleaved banks.

Return type:

Iterable[Bank]

iter_linker_sections() Iterable[LinkerSection]
Returns:

an iterator over the linker sections

Return type:

Iterable[LinkerSection]

iter_ram_banks() Iterable[Bank]
Returns:

an iterator over all banks.

Return type:

Iterable[Bank]

ram_il_size() int
Returns:

the memory size of the interleaved sizes.

Return type:

int

ram_numbanks() int
Returns:

the number of banks.

Return type:

int

ram_numbanks_cont() int
Returns:

the number of continuous banks.

Return type:

int

ram_numbanks_il() int
Returns:

the number of interleaved banks.

Return type:

int

ram_size_address() int
Returns:

the size of the addressable ram memory.

Return type:

int

ram_start_address() int
Returns:

the address of the first ram bank.

Return type:

int

validate() bool

Does some basics checks on the configuration

This should be called before using the XHeep object to generate the project.

Returns:

the validity of the configuration

Return type:

bool