simuhw package

Subpackages

Module contents

class simuhw.LogicAnalyzer

Bases: object

A logic analyzer to save the collected timings of data change.

__init__() None

Creates a logic analyzer.

add_probe(probe: Probe) None

Adds a probe.

Parameters:

probe – The probe to be added.

remove_all_probes() None

Removes all probes.

remove_probe(probe: Probe) None

Removes a probe.

Parameters:

probe – The probe to be removed.

Raises:

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

save_as_vcd(file: IO[str]) None

Collects the timings of data change at all probes, and saves them into a file in the VCD format.

Parameters:

file – The file in which the collected timings are saved.

class simuhw.Probe(name: str, width: int)

Bases: object

The super class for all probes.

__init__(name: str, width: int) None

Creates a probe.

Parameters:
  • name – The probe name.

  • width – The data word width in bits.

property data: list[tuple[bytes | None, float]]

The list of the data words recorded.

property name: str

The probe name.

reset() None

Resets the states.

abstractmethod classmethod typename() str

The probe type string.

property width: int

The data word width in bits.

class simuhw.ChannelProbe(name: str, width: int)

Bases: Probe

A probe to record timings of channel data change.

__init__(name: str, width: int) None

Creates a channel probe.

Parameters:
  • name – The probe name.

  • width – The data word width in bits.

classmethod typename() str

The probe type string.

class simuhw.MemoryProbe(name: str, width: int)

Bases: Probe

A probe to record timings of memory data change.

__init__(name: str, width: int) None

Creates a memory probe.

Parameters:
  • name – The probe name.

  • width – The data word width in bits.

classmethod typename() str

The probe type string.

class simuhw.Simulator(devices: Iterable[Device])

Bases: object

A simulator.

It executes behavioral simulation of devices.

__init__(devices: Iterable[Device]) None

Creates a simulator.

Parameters:

devices – The devices.

default_max_iter: int | None = 1000

The default maximum iteration count during the same current time. No limit in iteration if None.

property devices: tuple[Device, ...]

The devices.

resume(*, duration: float | None = None, max_iter: int | None = 1000, show_time: bool = False, first: bool = False) None

Resumes the simulation.

Parameters:
  • duration – The duration time. No limit in duration if None.

  • max_iter – The maximum iteration count during the same current time. No limit in iteration if None.

start(*, duration: float | None = None, max_iter: int | None = 1000, show_time: bool = False) None

Starts the simulation.

Parameters:
  • duration – The duration time. No limit in duration if None.

  • max_iter – The maximum iteration count during the same current time. No limit in iteration if None.

property time: float

The current time in the simulation.

class simuhw.InputPort(width: int)

Bases: Port

An input port to receive data word from an output port.

__init__(width: int) None

Creates an input port.

Parameters:

width – The data word width in bits.

property changed: bool

True if the data has been changed, False otherwise.

property connected: bool

True if connected to an output port, False otherwise.

mark_as_changed() None

Marks the data as changed.

mark_as_connected() None

Marks this object as connected to an output port.

mark_as_disconnected() None

Marks this object as disconnected from an output port.

mark_as_unchanged() None

Marks the data as unchanged.

post(data: tuple[bytes | None, float]) None

Posts the data word to this port.

Parameters:

data – The data word with the arrival time in seconds.

class simuhw.OutputPort(width: int)

Bases: Port

An output port to send data words to an input port.

__init__(width: int) None

Creates an output port.

Parameters:

width – The data word width in bits.

connect(peer: InputPort | None) None

Connects to an input port, or disconnect.

Parameters:

peer – The input port. The connected input port is disconnected if None.

Raises:

ValueError – If an input port with a different data word width is specified in peer.

property connected: bool

True if connected to an input port, False otherwise.

property peer: InputPort | None

The input port. None if no connected input port.

post(data: tuple[bytes | None, float]) None

Posts the data word to this port.

Parameters:

data – The data word with the arrival time in seconds.

class simuhw.Device

Bases: object

The super class for all devices.

__init__() None

Creates a device.

abstractmethod reset() None

Resets the states.

property time: float

The next resuming time in seconds.

abstractmethod 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.Source(width: int, data: Iterable[tuple[bytes | None, float]])

Bases: Device

A source device to emit data words.

__init__(width: int, data: Iterable[tuple[bytes | None, float]]) None

Creates a source device.

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

  • data – The iterator to supply data words.

property port_o: OutputPort

The output port.

reset() None

Resets the states.

property width: int

The data word width in bits.

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.LogicLowSource(width: int)

Bases: Source

A source device to emit logic-low data words.

__init__(width: int) None

Creates a source device to emit logic-low data words.

Parameters:

width – The data word width in bits.

class simuhw.LogicHighSource(width: int)

Bases: Source

A source device to emit logic-high data words.

__init__(width: int) None

Creates a source device to emit logic-high data words.

Parameters:

width – The data word width in bits.

class simuhw.LogicUnknownSource(width: int)

Bases: Source

A source device to emit logic-unknown data words.

__init__(width: int) None

Creates a source device to emit logic-unknown data words.

Parameters:

width – The data word width in bits.

class simuhw.Drain(width: int)

Bases: Device

A drain device to absorb data words.

__init__(width: int) None

Creates a drain device.

Parameters:

width – The data word width in bits.

property port_i: InputPort

The input port.

reset() None

Resets the states.

property width: int

The data word width in bits.

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.Group(devices: Iterable[Device])

Bases: Device

A device made by grouping multiple devices.

__init__(devices: Iterable[Device]) None

Creates a device made by grouping multiple devices.

Parameters:

devices – The devices to be grouped.

property devices: tuple[Device, ...]

The grouped devices.

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.Delay(width: int, *, delay: float)

Bases: Device

A device to delay data transfer.

This device can be also utilized to compose a realistic device with delay in signal transmission and gate switching.

__init__(width: int, *, delay: float) None

Creates a device to delay data transfer.

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

  • delay – The delay in seconds.

property delay: float

The delay in seconds.

property port_i: InputPort

The input port.

property port_o: OutputPort

The output port.

reset() None

Resets the states.

property width: int

The data word width in bits.

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.Clock(period: float, *, phase: float = 0.0)

Bases: Device

A clock generator.

__init__(period: float, *, phase: float = 0.0) None

Creates a clock generator.

Parameters:
  • period – The period in seconds.

  • phase – The phase in seconds.

property period: float

The period in seconds.

property phase: float

The phase in seconds.

property port_o: OutputPort

The output 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.Gate(width: int, *, ninputs: int)

Bases: Device

The super class for all gates.

__init__(width: int, *, ninputs: int) None

Creates a gate.

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

  • ninputs – The number of the input ports.

property port_o: OutputPort

The output port.

property ports_i: tuple[InputPort, ...]

The input ports.

reset() None

Resets the states.

property width: int

The data word width in bits.

class simuhw.UnaryGate(width: int)

Bases: Gate

The super class for all 1-input gates.

__init__(width: int) None

Creates a 1-input gate.

Parameters:

width – The data word width in bits.

property port_i: InputPort

The input port.

class simuhw.BinaryGate(width: int)

Bases: Gate

The super class for all 2-input gates.

__init__(width: int) None

Creates a 2-input gate.

Parameters:

width – The data word width in bits.

class simuhw.BufferGate(width: int)

Bases: UnaryGate

A buffer gate.

__init__(width: int) None

Creates a buffer gate.

Parameters:

width – The data word width in bits.

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.NOTGate(width: int)

Bases: UnaryGate

A NOT gate.

__init__(width: int) None

Creates a NOT gate.

Parameters:

width – The data word width in bits.

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.ANDGate(width: int, *, ninputs: int = 2)

Bases: Gate

An AND gate.

__init__(width: int, *, ninputs: int = 2) None

Creates an AND gate.

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

  • ninputs – The number of the input ports.

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.ORGate(width: int, *, ninputs: int = 2)

Bases: Gate

An OR gate.

__init__(width: int, *, ninputs: int = 2) None

Creates an OR gate.

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

  • ninputs – The number of the input ports.

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.XORGate(width: int, *, ninputs: int = 2)

Bases: Gate

An XOR gate.

__init__(width: int, *, ninputs: int = 2) None

Creates an XOR gate.

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

  • ninputs – The number of the input ports.

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.NANDGate(width: int, *, ninputs: int = 2)

Bases: Gate

A NAND gate.

__init__(width: int, *, ninputs: int = 2) None

Creates a NAND gate.

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

  • ninputs – The number of the input ports.

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.NORGate(width: int, *, ninputs: int = 2)

Bases: Gate

A NOR gate.

__init__(width: int, *, ninputs: int = 2) None

Creates a NOR gate.

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

  • ninputs – The number of the input ports.

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.XNORGate(width: int, *, ninputs: int = 2)

Bases: Gate

An XNOR gate.

__init__(width: int, *, ninputs: int = 2) None

Creates an XNOR gate.

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

  • ninputs – The number of the input ports.

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.DataCombiner(widths: Iterable[int])

Bases: Device

A data word combiner.

This device combines multiple input data words into one data word. The data word from the first input port will be the most significant bits in the output data word.

__init__(widths: Iterable[int]) None

Creates a data word combiner.

Parameters:

widths – The input data word widths in bits.

property port_o: OutputPort

The output port.

property ports_i: tuple[InputPort, ...]

The input ports.

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.DataSplitter(widths: Iterable[int])

Bases: Device

A data word splitter.

This device splits an input data word into multiple data words. The most significant bits in the input data word will be output to the first output port.

__init__(widths: Iterable[int]) None

Creates a data word splitter.

Parameters:

widths – The output data word widths in bits.

property port_i: InputPort

The input port.

property ports_o: tuple[OutputPort, ...]

The output ports.

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.Arbitrator(width: int, ninputs: int, *, policy: ~simuhw.arbitrate.policy._base.ArbitrationPolicy = <simuhw.arbitrate.policy._time_order.TimeOrderArbitrationPolicy object>)

Bases: Device

An arbitrator.

__init__(width: int, ninputs: int, *, policy: ~simuhw.arbitrate.policy._base.ArbitrationPolicy = <simuhw.arbitrate.policy._time_order.TimeOrderArbitrationPolicy object>) None

Creates an arbitrator.

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

  • ninputs – The number of the input ports.

  • policy – The arbitration policy.

property policy: ArbitrationPolicy

The arbitration policy.

property port_o: OutputPort

The output port for the data word from the selected input port.

property port_s: OutputPort

The output port for the selection bit flags of the input ports.

property ports_i: tuple[InputPort, ...]

The input ports.

reset() None

Resets the states.

property width: int

The data word width in bits.

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.Multiplexer(width: int, ninputs: int)

Bases: Device

A multiplexer.

__init__(width: int, ninputs: int) None

Creates a multiplexer.

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

  • ninputs – The number of the input ports.

property port_o: OutputPort

The output port.

property port_s: InputPort

The input port for the selection bit flags of the input ports for the data word.

property ports_i: tuple[InputPort, ...]

The input ports for the data word.

reset() None

Resets the states.

property width: int

The data word width in bits.

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.Demultiplexer(width: int, noutputs: int, *, deselected: bytes | None = None)

Bases: Device

A demultiplexer.

__init__(width: int, noutputs: int, *, deselected: bytes | None = None) None

Creates a demultiplexer.

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

  • noutputs – The number of the output ports.

property port_i: InputPort

The input port for the data word.

property port_s: InputPort

The input port for the selection bit flags of the output ports.

property ports_o: tuple[OutputPort, ...]

The output ports.

reset() None

Resets the states.

property width: int

The data word width in bits.

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.DataRetainingDemultiplexer(width: int, noutputs: int)

Bases: Demultiplexer

A demultiplexer to retain data in the unselected ports.

__init__(width: int, noutputs: int) None

Creates a demultiplexer to retain data in the unselected ports.

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

  • noutputs – The number of the output ports.

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.Distributor(width: int, noutputs: int)

Bases: Device

A distributor.

__init__(width: int, noutputs: int) None

Creates a distributor.

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

  • noutputs – The number of the output ports.

property port_i: InputPort

The input port for the data word.

property ports_o: tuple[OutputPort, ...]

The output ports.

reset() None

Resets the states.

property width: int

The data word width in bits.

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.Channel(width: int, *, latency: float, throughput: float)

Bases: Device

A channel.

__init__(width: int, *, latency: float, throughput: float) None

Creates a channel.

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

  • latency – The latency in seconds.

  • throughput – The throughput in words per second.

property latency: float

The latency in seconds.

property port_i: InputPort

The input port.

property port_o: OutputPort

The output port.

reset() None

Resets the states.

property throughput: float

The throughput in words per second.

property width: int

The data word width in bits.

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.MultiplexChannel(width: int, multi: int, *, latency: float, throughput: float, policy: ~simuhw.arbitrate.policy._base.ArbitrationPolicy = <simuhw.arbitrate.policy._time_order.TimeOrderArbitrationPolicy object>)

Bases: Device

A multiplex channel.

__init__(width: int, multi: int, *, latency: float, throughput: float, policy: ~simuhw.arbitrate.policy._base.ArbitrationPolicy = <simuhw.arbitrate.policy._time_order.TimeOrderArbitrationPolicy object>) None

Creates a multiplex channel.

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

  • multi – The multiplexity.

  • latency – The latency in seconds.

  • throughput – The throughput in words per second.

property latency: float

The latency in seconds.

property ports_i: tuple[InputPort, ...]

The input ports.

property ports_o: tuple[OutputPort, ...]

The output ports.

reset() None

Resets the states.

property throughput: float

The throughput in words per second.

property width: int

The data word width in bits.

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.DLatch(width: int, *, neg_leveled: bool = False)

Bases: Device

A D latch.

__init__(width: int, *, neg_leveled: bool = False) None

Creates a D latch.

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

  • neg_leveledTrue if negative-leveled, False otherwise.

property negative_leveled: bool

True if negative-leveled, False otherwise.

property port_g: InputPort

The gate port.

property port_i: InputPort

The input port.

property port_o: OutputPort

The output port.

reset() None

Resets the states.

property width: int

The data word width in bits.

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.DFlipFlop(width: int, *, neg_edged: bool = False)

Bases: Device

A D flip-flop.

__init__(width: int, *, neg_edged: bool = False) None

Creates a D flip-flop.

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

  • neg_edgedTrue if negative-edged, False otherwise.

property negative_edged: bool

True if negative-edged, False otherwise.

property port_c: InputPort

The clock port.

property port_i: InputPort

The input port.

property port_o: OutputPort

The output port.

reset() None

Resets the states.

property width: int

The data word width in bits.

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.Shifter(width: int)

Bases: BinaryGate

The super class for all barrel shifters.

__init__(width: int) None

Creates a barrel shifter.

Parameters:

width – The data word width in bits.

class simuhw.LeftShifter(width: int)

Bases: Shifter

A left barrel shifter.

__init__(width: int) None

Creates a left barrel shifter.

Parameters:

width – The data word width in bits.

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.RightShifter(width: int)

Bases: Shifter

A right barrel shifter.

__init__(width: int) None

Creates a right barrel shifter.

Parameters:

width – The data word width in bits.

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.ArithmeticRightShifter(width: int)

Bases: Shifter

An arithmetic right barrel shifter.

__init__(width: int) None

Creates an arithmetic right barrel shifter.

Parameters:

width – The data word width in bits.

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.LeftRotator(width: int)

Bases: Shifter

A left barrel rotator.

__init__(width: int) None

Creates a left barrel rotator.

Parameters:

width – The data word width in bits.

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.RightRotator(width: int)

Bases: Shifter

A right barrel rotator.

__init__(width: int) None

Creates a right barrel rotator.

Parameters:

width – The data word width in bits.

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.SIMD_Shifter(width: int, dsize: int | Iterable[int])

Bases: BinaryGate

The super class for all SIMD barrel shifters.

__init__(width: int, dsize: int | Iterable[int]) None

Creates a SIMD barrel shifter.

Parameters:
  • width – The total width of data words in bits.

  • dsize – The selectable data word width or widths in bits.

Raises:

ValueError – If width is not divisible by any of dsize.

property dsize: tuple[int, ...]

The selectable data word widths in bits.

property port_s: InputPort

The input port to select the data word width.

reset() None

Resets the states.

class simuhw.SIMD_LeftShifter(width: int, dsize: int | Iterable[int])

Bases: SIMD_Shifter

A SIMD left barrel shifter.

__init__(width: int, dsize: int | Iterable[int]) None

Creates a SIMD left barrel shifter.

Parameters:
  • width – The total width of data words in bits.

  • dsize – The selectable data word width or widths in bits.

Raises:

ValueError – If width is not divisible by any of dsize.

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.SIMD_RightShifter(width: int, dsize: int | Iterable[int])

Bases: SIMD_Shifter

A SIMD right barrel shifter.

__init__(width: int, dsize: int | Iterable[int]) None

Creates a SIMD right barrel shifter.

Parameters:
  • width – The total width of data words in bits.

  • dsize – The selectable data word width or widths in bits.

Raises:

ValueError – If width is not divisible by any of dsize.

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.SIMD_ArithmeticRightShifter(width: int, dsize: int | Iterable[int])

Bases: SIMD_Shifter

A SIMD arithmetic right barrel shifter.

__init__(width: int, dsize: int | Iterable[int]) None

Creates a SIMD arithmetic right barrel shifter.

Parameters:
  • width – The total width of data words in bits.

  • dsize – The selectable data word width or widths in bits.

Raises:

ValueError – If width is not divisible by any of dsize.

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.SIMD_LeftRotator(width: int, dsize: int | Iterable[int])

Bases: SIMD_Shifter

A SIMD left barrel rotator.

__init__(width: int, dsize: int | Iterable[int]) None

Creates a SIMD left barrel rotator.

Parameters:
  • width – The total width of data words in bits.

  • dsize – The selectable data word width or widths in bits.

Raises:

ValueError – If width is not divisible by any of dsize.

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.SIMD_RightRotator(width: int, dsize: int | Iterable[int])

Bases: SIMD_Shifter

A SIMD right barrel rotator.

__init__(width: int, dsize: int | Iterable[int]) None

Creates a SIMD right barrel rotator.

Parameters:
  • width – The total width of data words in bits.

  • dsize – The selectable data word width or widths in bits.

Raises:

ValueError – If width is not divisible by any of dsize.

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.BitOperator(width: int)

Bases: UnaryGate

The super class for all bit operators.

__init__(width: int) None

Creates a bit operator.

Parameters:

width – The data word width in bits.

class simuhw.PopulationCounter(width: int)

Bases: BitOperator

A bit population counter.

__init__(width: int) None

Creates a bit population counter.

Parameters:

width – The data word width in bits.

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.LeadingZeroCounter(width: int)

Bases: BitOperator

A leading bit-0 counter.

__init__(width: int) None

Creates a leading bit-0 counter.

Parameters:

width – The data word width in bits.

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.TrailingZeroCounter(width: int)

Bases: BitOperator

A trailing bit-0 counter.

__init__(width: int) None

Creates a trailing bit-0 counter.

Parameters:

width – The data word width in bits.

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.BitReverser(width: int)

Bases: BitOperator

A bit reverser.

__init__(width: int) None

Creates a bit reverser.

Parameters:

width – The data word width in bits.

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.SIMD_BitOperator(width: int, dsize: int | Iterable[int])

Bases: UnaryGate

The super class for all SIMD bit operators.

__init__(width: int, dsize: int | Iterable[int]) None

Creates a SIMD bit operator.

Parameters:
  • width – The total width of data words in bits.

  • dsize – The selectable data word width or widths in bits.

Raises:

ValueError – If width is not divisible by any of dsize.

property dsize: tuple[int, ...]

The selectable data word widths in bits.

property port_s: InputPort

The input port to select the data word width.

reset() None

Resets the states.

class simuhw.SIMD_PopulationCounter(width: int, dsize: int | Iterable[int])

Bases: SIMD_BitOperator

A SIMD bit population counter.

__init__(width: int, dsize: int | Iterable[int]) None

Creates a SIMD bit population counter.

Parameters:
  • width – The total width of data words in bits.

  • dsize – The selectable data word width or widths in bits.

Raises:

ValueError – If width is not divisible by any of dsize.

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.SIMD_LeadingZeroCounter(width: int, dsize: int | Iterable[int])

Bases: SIMD_BitOperator

A SIMD leading bit-0 counter.

__init__(width: int, dsize: int | Iterable[int]) None

Creates a SIMD leading bit-0 counter.

Parameters:
  • width – The total width of data words in bits.

  • dsize – The selectable data word width or widths in bits.

Raises:

ValueError – If width is not divisible by any of dsize.

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.SIMD_TrailingZeroCounter(width: int, dsize: int | Iterable[int])

Bases: SIMD_BitOperator

A SIMD trailing bit-0 counter.

__init__(width: int, dsize: int | Iterable[int]) None

Creates a SIMD trailing bit-0 counter.

Parameters:
  • width – The total width of data words in bits.

  • dsize – The selectable data word width or widths in bits.

Raises:

ValueError – If width is not divisible by any of dsize.

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.SIMD_BitReverser(width: int, dsize: int | Iterable[int])

Bases: SIMD_BitOperator

A SIMD bit reverser.

__init__(width: int, dsize: int | Iterable[int]) None

Creates a SIMD bit reverser.

Parameters:
  • width – The total width of data words in bits.

  • dsize – The selectable data word width or widths in bits.

Raises:

ValueError – If width is not divisible by any of dsize.

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.Adder(width: int)

Bases: BinaryGate

An adder.

This device calculates an addition of two binary integers. It has no carry input and no carry output.

__init__(width: int) None

Creates an adder.

Parameters:

width – The data word width in bits.

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.HalfAdder(width: int)

Bases: Adder

A half adder.

This device calculates an addition of two binary integers. It has carry output, but has no carry input.

__init__(width: int) None

Creates a half adder.

Parameters:

width – The data word width in bits.

property port_co: OutputPort

The carry output 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.FullAdder(width: int)

Bases: HalfAdder

A full adder.

This device calculates an addition of two binary integers. It has carry input and carry output.

__init__(width: int) None

Creates a full adder.

Parameters:

width – The data word width in bits.

property port_ci: InputPort

The carry input 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.SIMD_Adder(width: int, dsize: int | Iterable[int])

Bases: BinaryGate

A SIMD adder.

This device calculates respective additions of multiple pairs of binary integers simultaneously.

__init__(width: int, dsize: int | Iterable[int]) None

Creates a SIMD adder.

Parameters:
  • width – The total width of data words in bits.

  • dsize – The selectable data word width or widths in bits.

Raises:

ValueError – If width is not divisible by any of dsize.

property dsize: tuple[int, ...]

The selectable data word widths in bits.

property port_s: InputPort

The input port to select the data word width.

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.Subtractor(width: int)

Bases: BinaryGate

A subtractor.

This device calculates a subtraction of two binary integers. It has no borrow input and no borrow output.

__init__(width: int) None

Creates a subtractor.

Parameters:

width – The data word width in bits.

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.HalfSubtractor(width: int)

Bases: Subtractor

A half subtractor.

This device calculates a subtraction of two binary integers. It has borrow output, but has no borrow input.

__init__(width: int) None

Creates a half subtractor.

Parameters:

width – The data word width in bits.

property port_co: OutputPort

The borrow output 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.FullSubtractor(width: int)

Bases: HalfSubtractor

A full subtractor.

This device calculates a subtraction of two binary integers. It has borrow input and borrow output.

__init__(width: int) None

Creates a full subtractor.

Parameters:

width – The data word width in bits.

property port_ci: InputPort

The borrow input 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.SIMD_Subtractor(width: int, dsize: int | Iterable[int])

Bases: BinaryGate

A SIMD subtractor.

This device calculates respective subtractions of multiple pairs of binary integers simultaneously.

__init__(width: int, dsize: int | Iterable[int]) None

Creates a SIMD subtractor.

Parameters:
  • width – The total width of data words in bits.

  • dsize – The selectable data word width or widths in bits.

Raises:

ValueError – If width is not divisible by any of dsize.

property dsize: tuple[int, ...]

The selectable data word widths in bits.

property port_s: InputPort

The input port to select the data word width.

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.Multiplier(width: int)

Bases: BinaryGate

A multiplier.

This device calculates a multiplication of two unsigned binary integers.

__init__(width: int) None

Creates a multiplier.

Parameters:

width – The data word width in bits.

property port_e: OutputPort

The output port to emit overflow exception.

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.SignedMultiplier(width: int)

Bases: Multiplier

A signed multiplier.

This device calculates a multiplication of two signed binary integers.

__init__(width: int) None

Creates a signed multiplier.

Parameters:

width – The data word width in bits.

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.SIMD_Multiplier(width: int, dsize: int | Iterable[int])

Bases: BinaryGate

A SIMD multiplier.

This device calculates respective multiplications of multiple pairs of unsigned binary integers simultaneously.

__init__(width: int, dsize: int | Iterable[int]) None

Creates a SIMD multiplier.

Parameters:
  • width – The total width of data words in bits.

  • dsize – The selectable data word width or widths in bits.

Raises:

ValueError – If width is not divisible by any of dsize.

property dsize: tuple[int, ...]

The selectable data word widths in bits.

property port_e: OutputPort

The output port to emit overflow exception.

property port_s: InputPort

The input port to select the data word width.

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.SIMD_SignedMultiplier(width: int, dsize: int | Iterable[int])

Bases: SIMD_Multiplier

A SIMD signed multiplier.

This device calculates respective multiplications of multiple pairs of signed binary integers simultaneously.

__init__(width: int, dsize: int | Iterable[int]) None

Creates a SIMD signed multiplier.

Parameters:
  • width – The total width of data words in bits.

  • dsize – The selectable data word width or widths in bits.

Raises:

ValueError – If width is not divisible by any of dsize.

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.Divider(width: int)

Bases: BinaryGate

A divider.

This device calculates a division of two unsigned binary integers.

__init__(width: int) None

Creates a divider.

Parameters:

width – The data word width in bits.

property port_e: OutputPort

The output port to emit overflow exception.

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.SignedDivider(width: int)

Bases: Divider

A signed divider.

This device calculates a division of two signed binary integers.

__init__(width: int) None

Creates a signed divider.

Parameters:

width – The data word width in bits.

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.SIMD_Divider(width: int, dsize: int | Iterable[int])

Bases: BinaryGate

A SIMD divider.

This device calculates respective divisions of multiple pairs of unsigned binary integers simultaneously.

__init__(width: int, dsize: int | Iterable[int]) None

Creates a SIMD divider.

Parameters:
  • width – The total width of data words in bits.

  • dsize – The selectable data word width or widths in bits.

Raises:

ValueError – If width is not divisible by any of dsize.

property dsize: tuple[int, ...]

The selectable data word widths in bits.

property port_e: OutputPort

The output port to emit overflow exception.

property port_s: InputPort

The input port to select the data word width.

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.SIMD_SignedDivider(width: int, dsize: int | Iterable[int])

Bases: SIMD_Divider

A SIMD signed divider.

This device calculates respective divisions of multiple pairs of signed binary integers simultaneously.

__init__(width: int, dsize: int | Iterable[int]) None

Creates a SIMD signed divider.

Parameters:
  • width – The total width of data words in bits.

  • dsize – The selectable data word width or widths in bits.

Raises:

ValueError – If width is not divisible by any of dsize.

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.Remainder(width: int)

Bases: BinaryGate

A remainder calculator.

This device calculates a remainder of two unsigned binary integers.

__init__(width: int) None

Creates a remainder calculator.

Parameters:

width – The data word width in bits.

property port_e: OutputPort

The output port to emit overflow exception.

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.SignedRemainder(width: int)

Bases: Remainder

A signed remainder calculator.

This device calculates a remainder of two signed binary integers.

__init__(width: int) None

Creates a signed remainder calculator.

Parameters:

width – The data word width in bits.

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.SIMD_Remainder(width: int, dsize: int | Iterable[int])

Bases: BinaryGate

A SIMD remainder calculator.

This device calculates respective remainders of multiple pairs of unsigned binary integers simultaneously.

__init__(width: int, dsize: int | Iterable[int]) None

Creates a SIMD remainder calculator.

Parameters:
  • width – The total width of data words in bits.

  • dsize – The selectable data word width or widths in bits.

Raises:

ValueError – If width is not divisible by any of dsize.

property dsize: tuple[int, ...]

The selectable data word widths in bits.

property port_e: OutputPort

The output port to emit overflow exception.

property port_s: InputPort

The input port to select the data word width.

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.SIMD_SignedRemainder(width: int, dsize: int | Iterable[int])

Bases: SIMD_Remainder

A SIMD signed remainder calculator.

This device calculates respective remainders of multiple pairs of signed binary integers simultaneously.

__init__(width: int, dsize: int | Iterable[int]) None

Creates a SIMD signed remainder calculator.

Parameters:
  • width – The total width of data words in bits.

  • dsize – The selectable data word width or widths in bits.

Raises:

ValueError – If width is not divisible by any of dsize.

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.