xheep_gen.peripherals.abstractions module

class xheep_gen.peripherals.abstractions.BasePeripheral(offset=None, length=None)

Bases: Peripheral, ABC

Abstract class representing always-on peripherals. This class cannot be instantiated.

class xheep_gen.peripherals.abstractions.Peripheral(offset=None, length=None)

Bases: ABC

Basic description of a peripheral. These peripherals are not linked to a hjson file, they only have a memory range. This class cannot be instantiated.

Parameters:
  • address (int) – The virtual (in peripheral domain) memory address of the peripheral, the start address should be known by the creator of the class.

  • length (int) – The size taken in memory by the peripheral

get_address()
Returns:

The virtual (in peripheral domain) memory address of the peripheral. If not set, return None.

Return type:

int

get_length()
Returns:

The length of the peripheral.

Return type:

int

get_name()
Returns:

The name of the peripheral.

Return type:

str

set_address(address)

Set the virtual (in peripheral domain) memory address of the peripheral.

class xheep_gen.peripherals.abstractions.PeripheralDomain(name: str, start_address: int, length: int)

Bases: ABC

Abstract class representing a peripheral domain. This class cannot be instantiated.

Parameters:
  • name (str) – The name of the peripheral domain. Convention : starts with a capital letter and is in singular form (no “peripheral domain” at the end)

  • start_address (int) – The start address of the peripheral domain.

  • length (int) – The length of the peripheral domain.

  • peripherals (list[Peripheral]) – The list of peripherals in the domain. There can be more than one instance of the same peripheral.

abstract add_peripheral(peripheral: Peripheral)

Add a peripheral to the domain. The peripheral should be fully configured when added. If the peripheral has no offset, it will be automatically computed during build. Must be defined by the subclass.

Parameters:

peripheral (Peripheral) – The peripheral to add.

build()

Build the peripheral domain. This function will compute the offset of the peripherals that have no offset.

contains_peripheral(peripheral_name: str)

Check if the peripheral domain contains a peripheral with the given name.

Parameters:

peripheral_name (str) – The name of the peripheral to check (case sensitive).

Returns:

True if the peripheral domain contains a peripheral with the given name, False otherwise.

Return type:

bool

get_length()
Returns:

The length of the peripheral domain.

Return type:

int

get_peripherals()
Returns:

A copy of the list of peripherals in the domain.

Return type:

list[Peripheral]

get_start_address()
Returns:

The start address of the peripheral domain.

Return type:

int

abstract remove_peripheral(peripheral: Peripheral)

Remove a peripheral from the domain. Must be defined by the subclass.

Parameters:

peripheral (Peripheral) – The peripheral to remove.

validate()

Validate the peripheral domain.

Checks if the peripherals do not overlap and if the peripheral domain is within the bounds.

class xheep_gen.peripherals.abstractions.UserPeripheral(offset=None, length=None)

Bases: Peripheral, ABC

Abstract class representing user-configurable peripherals. This class cannot be instantiated.