Memory Map

class torii.lib.soc.memory.ResourceInfo(resource: object, name: str | Iterable[str], start: int, end: int, width: int)

Resource metadata.

A wrapper class for resource objects, with their assigned name and address range.

Parameters:
  • resource (object) – Arbitrary object representing a resource. See MemoryMap.add_resource() for details.

  • name (iter(str)) – Name assigned to the resource. It is prefixed by the name of each window sitting between the resource and the memory map from which this ResourceInfo was obtained. See MemoryMap.add_window() for details.

  • start (int) – Start of the address range assigned to the resource.

  • end (int) – End of the address range assigned to the resource.

  • width (int) – Amount of data bits accessed at each address. It may be equal to the data width of the memory map from which this ResourceInfo was obtained, or less if the resource is located behind a window that uses sparse addressing.

class torii.lib.soc.memory.MemoryMap(*, addr_width: int, data_width: int, alignment: int = 0, name: str | None = None)

Memory map.

A memory map is a hierarchical description of an address space, describing the structure of address decoders of peripherals as well as bus bridges. It is built by adding resources (range allocations for registers, memory, etc) and windows (range allocations for bus bridges), and can be queried later to determine the address of any given resource from a specific vantage point in the design.

Address assignment

To simplify address assignment, each memory map has an implicit next address, starting at 0. If a resource or a window is added without specifying an address explicitly, the implicit next address is used. In any case, the implicit next address is set to the address immediately following the newly added resource or window.

param addr_width:

Address width.

type addr_width:

int

param data_width:

Data width.

type data_width:

int

param alignment:

Range alignment. Each added resource and window will be placed at an address that is a multiple of 2 ** alignment, and its size will be rounded up to be a multiple of 2 ** alignment.

type alignment:

log2 of int

param name:

Name of the address range. Optional.

type name:

str