Events

class torii.lib.soc.event.EventMap None

Event map.

An event map is a description of a set of events. It is built by adding event sources and can be queried later to determine their index. Event indexing is done implicitly by increment, starting at 0.

property size: int

Size of the event map.

Returns:

int – The number of event sources in the map.

freeze() None

Freeze the event map.

Once the event map is frozen, sources cannot be added anymore.

add(src: Source) None

Add an event source.

Parameters:

src (Source) – Event source.

Raises:

ValueError – If the event map is frozen.

index(src: Source) int

Get the index corresponding to an event source.

Parameters:

src (Source) – Event source.

Return type:

int

Returns:

int – The index of the source.

Raises:

KeyError – If the source is not found.

sources() Generator[tuple[Source, int]]

Iterate event sources.

Return type:

Generator[tuple[Source, int]]

Returns:

Generator[tuple[Source, int]] – A generator that yields tuples of src, index corresponding to an event source and its index.

class torii.lib.soc.event.Monitor(event_map: EventMap, *, trigger: Trigger = 'level') None

Event monitor.

A monitor for subordinate event sources.

Parameters:
Attributes:
  • src (Source) – Event source. Its input is asserted when a subordinate event is enabled and pending.

  • enable (Signal(event_map.size), bit mask, in) – Enabled events.

  • pending (Signal(event_map.size), bit mask, out) – Pending events.

  • clear (Signal(event_map.size), bit mask, in) – Clear selected pending events.

elaborate(platform) Module
Return type:

Module

Todo

Document Me

class torii.lib.soc.event.Source(*, trigger: Trigger = 'level', name: str | None = None, src_loc_at: int = 0) None

Event source interface.

Parameters:
  • trigger (Source.Trigger) – Trigger mode. An event can be edge- or level-triggered by the input line.

  • name (str) – Name of the underlying record.

Attributes:
  • i (Signal()) – Input line. Sampled in order to detect an event.

  • trg (Signal()) – Event trigger. Asserted when an event occurs, according to the trigger mode.

class Trigger(value)

Event trigger mode.

LEVEL = 'level'
RISE = 'rise'
FALL = 'fall'
property event_map: EventMap

Event map.

Returns:

EventMap – An EventMap describing subordinate event sources.

Raises:

NotImplementedError – If the source does not have an event map.