simuhw.memory package

Subpackages

Module contents

class simuhw.memory.Memory(width: int, width_a: int, model: MemorizingModel)

Bases: Device

The super class for all memory devices.

__init__(width: int, width_a: int, model: MemorizingModel) None

Creates a memory device.

Parameters:
  • width – The data word width in bits.

  • width_a – The address word width in bits.

  • model – The memorizing model.

add_probe(probe: MemoryProbe, address: bytes) None

Adds a memory probe.

Parameters:
  • probe – The memory probe to be added.

  • address – The probe address.

Raises:

ValueError – If a memory probe with a different data word width is specified in probe.

property port_a: InputPort

The address port.

property port_i: InputPort

The input port.

property port_o: OutputPort

The output port.

remove_all_probes() None

Removes all memory probes.

remove_probe(probe: MemoryProbe) None

Removes a memory probe.

Parameters:

probe – The memory probe to be removed.

Raises:

ValueError – If a memory probe not yet added is specified in probe.

reset() None

Resets the states.

property width: int

The data word width in bits.

property width_a: int

The address word width in bits.

class simuhw.memory.LevelTriggeredMemory(width: int, width_a: int, *, model: ~simuhw.memory.model._base.MemorizingModel = <simuhw.memory.model._real.RealMemorizingModel object>, neg_leveled: bool = False)

Bases: Memory

A level-triggered memory device.

__init__(width: int, width_a: int, *, model: ~simuhw.memory.model._base.MemorizingModel = <simuhw.memory.model._real.RealMemorizingModel object>, neg_leveled: bool = False) None

Creates a level-triggered memory device.

Parameters:
  • width – The data word width in bits.

  • width_a – The address word width in bits.

  • model – The memorizing model.

  • neg_leveledTrue if negative-leveled, False otherwise.

property negative_leveled: bool

True if negative-leveled, False otherwise.

property port_g: InputPort

The gate port.

reset() None

Resets the states.

work(time: float | None) tuple[list[InputPort], float | None]

Makes the device work.

Parameters:

time – The current time in seconds. None when starting to make the device work.

Returns:

A tuple of the list of the input ports that are to be watched receive a data word, and the next resuming time in seconds. The next resuming time can be None if resumable anytime.

class simuhw.memory.EdgeTriggeredMemory(width: int, width_a: int, *, model: ~simuhw.memory.model._base.MemorizingModel = <simuhw.memory.model._real.RealMemorizingModel object>, neg_edged: bool = False, neg_enable: bool = False)

Bases: Memory

An edge-triggered memory device.

__init__(width: int, width_a: int, *, model: ~simuhw.memory.model._base.MemorizingModel = <simuhw.memory.model._real.RealMemorizingModel object>, neg_edged: bool = False, neg_enable: bool = False) None

Creates an edge-triggered memory device.

Parameters:
  • width – The data word width in bits.

  • width_a – The address word width in bits.

  • model – The memorizing model.

  • neg_edgedTrue if negative-edged, False otherwise.

  • neg_enableTrue if enabled by 0, False otherwise.

property negative_edged: bool

True if negative-edged, False otherwise.

property negative_enabling: bool

True if enabled by 0, False otherwise.

property port_c: InputPort

The clock port.

property port_e: InputPort

The enable port.

reset() None

Resets the states.

work(time: float | None) tuple[list[InputPort], float | None]

Makes the device work.

Parameters:

time – The current time in seconds. None when starting to make the device work.

Returns:

A tuple of the list of the input ports that are to be watched receive a data word, and the next resuming time in seconds. The next resuming time can be None if resumable anytime.