Peripherals

class torii.lib.soc.periph.ConstantBool(value: bool) None

Boolean constant.

Parameters:

value (bool) – Constant value.

property value: bool

The value of this constant.

class torii.lib.soc.periph.ConstantInt(value: int, *, width: int | None = None, signed: bool | None = None) None

Integer constant.

Parameters:
  • value (int) – Constant value.

  • width (int | None) – Width of value in bits. If None it is calculated by using bits_for to derive it from value.

  • signed (bool | None) – If the value is signed. If None this is determined by checking if value > 0.

property value: int

The value of this constant.

property width: int

The width in bits needed to represent this constant.

property signed: bool

If the value in this constant is signed or not.

class torii.lib.soc.periph.ConstantMap(**constants: dict[str, ConstantValue]) None

Named constant map.

A read-only container for named constants. Keys are iterated in insertion order.

Parameters:

**constants (dict[str, ConstantValue]) – Named constants.

Examples

>>> ConstantMap(RX_FIFO_DEPTH = 16)
ConstantMap([('RX_FIFO_DEPTH', ConstantInt(16, width = 5, signed = False))])
class torii.lib.soc.periph.ConstantValue

Todo

Document Me

class torii.lib.soc.periph.PeripheralInfo(*, memory_map: MemoryMap, irq: Source | None = None, constant_map: ConstantMap | None = None) None

Peripheral metadata.

A unified description of the local resources of a peripheral. It may be queried in order to recover its memory windows, CSR registers, event sources and configuration constants.

Parameters:
  • memory_map (MemoryMap) – Memory map of the peripheral.

  • irq (event.Source | None) – IRQ line of the peripheral.

  • constant_map (ConstantMap | None) – Constant map of the peripheral.

property memory_map: MemoryMap

Memory map.

Returns:

MemoryMap – The memory map describing the local address space of the peripheral.

property irq: Source

IRQ line.

Returns:

event.Source – An event source used by the peripheral to request interrupts. If provided, its event map describes local events.

Raises:

NotImplementedError – If peripheral info does not have an IRQ line.

property constant_map: ConstantMap

Constant map.

Returns:

ConstantMap – The map containing the configuration constants of the peripheral.