simuhw package

Subpackages

Module contents

class simuhw.Unknown

Bases: object

The unknown state.

class simuhw.HighZ

Bases: object

The high impedance state.

class simuhw.Signal(word: bytes | type[Unknown | HighZ], time: float)

Bases: object

A signal.

__init__(word: bytes | type[Unknown | HighZ], time: float) None

Creates a signal.

Parameters:
  • word – The word.

  • time – The time in seconds.

property time: float

The time in seconds.

property word: bytes | type[Unknown | HighZ]

The word.

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 word width in bits.

append(item: Signal) None
property name: str

The probe name.

reset() None

Resets the states.

abstractmethod classmethod typename() str

The probe type string.

property width: int

The word width in bits.

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

Bases: Probe

A probe to record timings of channel word change.

__init__(name: str, width: int) None

Creates a channel probe.

Parameters:
  • name – The probe name.

  • width – The 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 word change.

__init__(name: str, width: int) None

Creates a memory probe.

Parameters:
  • name – The probe name.

  • width – The word width in bits.

classmethod typename() str

The probe type string.

class simuhw.LogicAnalyzer

Bases: object

A logic analyzer to save the collected timings of word 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 word 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.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 signals from an output port.

__init__(width: int) None

Creates an input port.

Parameters:

width – The word width in bits.

property changed: bool

True if the signal word has been changed, False otherwise.

property connected: bool

True if connected to an output port, False otherwise.

mark_as_changed() None

Marks the signal word 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 signal word as unchanged.

post(signal: Signal) None

Posts the signal to this port.

Parameters:

signal – The signal to be posted.

class simuhw.OutputPort(width: int)

Bases: Port

An output port to send signals to an input port.

__init__(width: int) None

Creates an output port.

Parameters:

width – The 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 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(signal: Signal) None

Posts the signal to this port.

Parameters:

signal – The signal to be posted.

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 signal, and the next resuming time in seconds. The next resuming time can be None if resumable anytime.

class simuhw.Source(width: int, signals: Iterable[Signal | tuple[bytes | type[Unknown | HighZ], float]])

Bases: Device

A source device to emit signals.

__init__(width: int, signals: Iterable[Signal | tuple[bytes | type[Unknown | HighZ], float]]) None

Creates a source device.

Parameters:
  • width – The word width in bits.

  • signals – The iterator to supply signals.

property port_o: OutputPort

The output port.

reset() None

Resets the states.

property width: int

The 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 signal, 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 hold a logic-low word.

__init__(width: int) None

Creates a source device to hold a logic-low word.

Parameters:

width – The word width in bits.

class simuhw.LogicHighSource(width: int)

Bases: Source

A source device to hold a logic-high word.

__init__(width: int) None

Creates a source device to hold a logic-high word.

Parameters:

width – The word width in bits.

class simuhw.LogicUnknownSource(width: int)

Bases: Source

A source device to hold a logic-unknown word.

__init__(width: int) None

Creates a source device to hold a logic-unknown word.

Parameters:

width – The word width in bits.

class simuhw.HighZSource(width: int)

Bases: Source

A source device to hold high impedance.

__init__(width: int) None

Creates a source device to hold high impedance.

Parameters:

width – The word width in bits.

class simuhw.Drain(width: int)

Bases: Device

A drain device to absorb signals.

__init__(width: int) None

Creates a drain device.

Parameters:

width – The word width in bits.

property port_i: InputPort

The input port.

reset() None

Resets the states.

property width: int

The 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 signal, 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 signal, 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 word 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 word transfer.

Parameters:
  • width – The 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 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 signal, 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 signal, and the next resuming time in seconds. The next resuming time can be None if resumable anytime.

class simuhw.WordCombiner(widths: Iterable[int])

Bases: Device

A word combiner.

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

__init__(widths: Iterable[int]) None

Creates a word combiner.

Parameters:

widths – The input 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 signal, and the next resuming time in seconds. The next resuming time can be None if resumable anytime.

class simuhw.WordSplitter(widths: Iterable[int])

Bases: Device

A word splitter.

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

__init__(widths: Iterable[int]) None

Creates a word splitter.

Parameters:

widths – The output 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 signal, 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 word width in bits.

  • ninputs – The number of the input ports.

property port_o: OutputPort

The output port.

property port_s: InputPort

The selection port.

property ports_i: tuple[InputPort, ...]

The input ports.

reset() None

Resets the states.

property width: int

The word width in bits.

property width_s: int

The selection port 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 signal, 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 | type[~simuhw._type.Unknown | ~simuhw._type.HighZ] = <class 'simuhw._type.Unknown'>)

Bases: Device

A demultiplexer.

__init__(width: int, noutputs: int, *, deselected: bytes | type[~simuhw._type.Unknown | ~simuhw._type.HighZ] = <class 'simuhw._type.Unknown'>) None

Creates a demultiplexer.

Parameters:
  • width – The word width in bits.

  • noutputs – The number of the output ports.

  • deselected – The word to be output to ports not selected.

property port_i: InputPort

The input port.

property port_s: InputPort

The selection port.

property ports_o: tuple[OutputPort, ...]

The output ports.

reset() None

Resets the states.

property width: int

The word width in bits.

property width_s: int

The selection port 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 signal, and the next resuming time in seconds. The next resuming time can be None if resumable anytime.

class simuhw.WordRetainingDemultiplexer(width: int, noutputs: int)

Bases: Demultiplexer

A demultiplexer to retain word in the unselected ports.

__init__(width: int, noutputs: int) None

Creates a demultiplexer to retain word in the unselected ports.

Parameters:
  • width – The 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 signal, and the next resuming time in seconds. The next resuming time can be None if resumable anytime.

class simuhw.Junction(width: int, ninputs: int)

Bases: Device

A junction.

This device merges multiple inputs. Its behavior is that of directly connected multiple input wires.

__init__(width: int, ninputs: int) None

Creates a junction.

Parameters:
  • width – The 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 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 signal, 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.

This device forwards the input word to multiple output ports. Its behavior is that of directly connected multiple output wires.

__init__(width: int, noutputs: int) None

Creates a distributor.

Parameters:
  • width – The word width in bits.

  • noutputs – The number of the output ports.

property port_i: InputPort

The input port.

property ports_o: tuple[OutputPort, ...]

The output ports.

reset() None

Resets the states.

property width: int

The 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 signal, 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 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 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 signal, and the next resuming time in seconds. The next resuming time can be None if resumable anytime.

class simuhw.Operator(width_i: int, width_o: int, *, ninputs: int)

Bases: Device

The super class for all operators.

__init__(width_i: int, width_o: int, *, ninputs: int) None

Creates an operator.

Parameters:
  • width_i – The input word width in bits.

  • width_o – The output 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_i: int

The input word width in bits.

property width_o: int

The output word width in bits.

class simuhw.UnaryOperator(width_i: int, width_o: int = -1)

Bases: Operator

The super class for all unary operators.

__init__(width_i: int, width_o: int = -1) None

Creates a unary operators.

Parameters:
  • width_i – The input word width in bits.

  • width_o – The output word width in bits. If a negative value is specified, width_i is used instead.

property port_i: InputPort

The input port.

class simuhw.BinaryOperator(width_i: int, width_o: int = -1)

Bases: Operator

The super class for all binary operators.

__init__(width_i: int, width_o: int = -1) None

Creates a binary operators.

Parameters:
  • width_i – The input word width in bits.

  • width_o – The output word width in bits. If a negative value is specified, width_i is used instead.

property port_i0: InputPort

The input port 0.

property port_i1: InputPort

The input port 1.

class simuhw.TernaryOperator(width_i: int, width_o: int = -1)

Bases: Operator

The super class for all binary operators.

__init__(width_i: int, width_o: int = -1) None

Creates a binary operators.

Parameters:
  • width_i – The input word width in bits.

  • width_o – The output word width in bits. If a negative value is specified, width_i is used instead.

property port_i0: InputPort

The input port 0.

property port_i1: InputPort

The input port 1.

property port_i2: InputPort

The input port 2.

class simuhw.SIMD_Operator(width_i: int, dsize_i: int | Iterable[int], width_o: int, *, ninputs: int)

Bases: Operator

The super class for all SIMD operators.

__init__(width_i: int, dsize_i: int | Iterable[int], width_o: int, *, ninputs: int) None

Creates a SIMD operator.

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

  • dsize_i – The selectable input word width or widths in bits.

  • width_o – The total width of output words in bits.

  • ninputs – The number of the input ports.

Raises:

ValueError – If width_i is not divisible by any of dsize_i, or if width_o is inconsistent with them.

property dsize_i: tuple[int, ...]

The selectable input word widths in bits.

property dsize_o: tuple[int, ...]

The selectable output word widths in bits.

property multi: tuple[int, ...]

The selectable operation multiplicities.

property port_s: InputPort

The input port to select the input word width.

reset() None

Resets the states.

class simuhw.SIMD_UnaryOperator(width_i: int, dsize_i: int | Iterable[int], width_o: int = -1)

Bases: SIMD_Operator

The super class for all SIMD unary operators.

__init__(width_i: int, dsize_i: int | Iterable[int], width_o: int = -1) None

Creates a SIMD unary operator.

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

  • dsize_i – The selectable input word width or widths in bits.

  • width_o – The total width of output words in bits. If a negative value is specified, width_i is used instead.

Raises:

ValueError – If width_i is not divisible by any of dsize_i, or if width_o is inconsistent with them.

property port_i: InputPort

The input port.

class simuhw.SIMD_BinaryOperator(width_i: int, dsize_i: int | Iterable[int], width_o: int = -1)

Bases: SIMD_Operator

The super class for all SIMD binary operators.

__init__(width_i: int, dsize_i: int | Iterable[int], width_o: int = -1) None

Creates a SIMD binary operator.

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

  • dsize_i – The selectable input word width or widths in bits.

  • width_o – The total width of output words in bits. If a negative value is specified, width_i is used instead.

Raises:

ValueError – If width_i is not divisible by any of dsize_i, or if width_o is inconsistent with them.

property port_i0: InputPort

The input port 0.

property port_i1: InputPort

The input port 1.

class simuhw.SIMD_TernaryOperator(width_i: int, dsize_i: int | Iterable[int], width_o: int = -1)

Bases: SIMD_Operator

The super class for all SIMD ternary operators.

__init__(width_i: int, dsize_i: int | Iterable[int], width_o: int = -1) None

Creates a SIMD ternary operator.

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

  • dsize_i – The selectable input word width or widths in bits.

  • width_o – The total width of output words in bits. If a negative value is specified, width_i is used instead.

Raises:

ValueError – If width_i is not divisible by any of dsize_i, or if width_o is inconsistent with them.

property port_i0: InputPort

The input port 0.

property port_i1: InputPort

The input port 1.

property port_i2: InputPort

The input port 2.

class simuhw.Buffer(width: int)

Bases: UnaryOperator

A buffer.

__init__(width: int) None

Creates a buffer.

Parameters:

width – The 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 signal, and the next resuming time in seconds. The next resuming time can be None if resumable anytime.

class simuhw.Inverter(width: int)

Bases: Buffer

An inverter.

__init__(width: int) None

Creates an inverter.

Parameters:

width – The 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 signal, and the next resuming time in seconds. The next resuming time can be None if resumable anytime.

class simuhw.TriStateBuffer(width: int, *, active_high: bool = True)

Bases: UnaryOperator

A tri-state buffer.

__init__(width: int, *, active_high: bool = True) None

Creates a tri-state buffer.

Parameters:
  • width – The word width in bits.

  • active_highTrue if the control port is active-high, False if it is active-low.

property active_high: bool

True if the control port is active-high, False if it is active-low.

property port_c: InputPort

The control port.

property port_i: InputPort

The input port.

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 signal, and the next resuming time in seconds. The next resuming time can be None if resumable anytime.

class simuhw.TriStateInverter(width: int, *, active_high: bool = True)

Bases: TriStateBuffer

A tri-state inverter.

__init__(width: int, *, active_high: bool = True) None

Creates a tri-state inverter.

Parameters:
  • width – The word width in bits.

  • active_highTrue if the control port is active-high, False if it is active-low.

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 signal, 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: Operator

An AND gate.

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

Creates an AND gate.

Parameters:
  • width – The 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 signal, 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: Operator

An OR gate.

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

Creates an OR gate.

Parameters:
  • width – The 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 signal, 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: Operator

An XOR gate.

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

Creates an XOR gate.

Parameters:
  • width – The 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 signal, 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: Operator

A NAND gate.

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

Creates a NAND gate.

Parameters:
  • width – The 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 signal, 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: Operator

A NOR gate.

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

Creates a NOR gate.

Parameters:
  • width – The 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 signal, 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: Operator

An XNOR gate.

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

Creates an XNOR gate.

Parameters:
  • width – The 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 signal, 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 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 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 signal, 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 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 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 signal, and the next resuming time in seconds. The next resuming time can be None if resumable anytime.

class simuhw.Shifter(width: int)

Bases: BinaryOperator

The super class for all barrel shifters.

__init__(width: int) None

Creates a barrel shifter.

Parameters:

width – The 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 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 signal, 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 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 signal, 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 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 signal, 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 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 signal, 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 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 signal, 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: SIMD_BinaryOperator

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 words in bits.

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

Raises:

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

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 words in bits.

  • dsize – The selectable 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 signal, 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 words in bits.

  • dsize – The selectable 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 signal, 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 words in bits.

  • dsize – The selectable 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 signal, 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 words in bits.

  • dsize – The selectable 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 signal, 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 words in bits.

  • dsize – The selectable 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 signal, and the next resuming time in seconds. The next resuming time can be None if resumable anytime.

class simuhw.BitOperator(width: int)

Bases: UnaryOperator

The super class for all bit operators.

__init__(width: int) None

Creates a bit operator.

Parameters:

width – The 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 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 signal, 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 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 signal, 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 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 signal, 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 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 signal, 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: SIMD_UnaryOperator

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 words in bits.

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

Raises:

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

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 words in bits.

  • dsize – The selectable 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 signal, 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 words in bits.

  • dsize – The selectable 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 signal, 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 words in bits.

  • dsize – The selectable 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 signal, 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 words in bits.

  • dsize – The selectable 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 signal, and the next resuming time in seconds. The next resuming time can be None if resumable anytime.

class simuhw.Negator(width: int)

Bases: UnaryOperator

A negator.

This device negates the sign of a binary integer.

__init__(width: int) None

Creates a negator.

Parameters:

width – The 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 signal, and the next resuming time in seconds. The next resuming time can be None if resumable anytime.

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

Bases: SIMD_UnaryOperator

A SIMD negator.

This device negates the respective sign of multiple binary integers simultaneously.

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

Creates a SIMD negator.

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

  • dsize – The selectable 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 signal, and the next resuming time in seconds. The next resuming time can be None if resumable anytime.

class simuhw.Adder(width: int)

Bases: BinaryOperator

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 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 signal, 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 word width in bits.

property port_co: OutputPort

The carry output port.

The width is 1 bit.

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 signal, 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 word width in bits.

property port_ci: InputPort

The carry input port.

The width is 1 bit.

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 signal, 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: SIMD_BinaryOperator

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 words in bits.

  • dsize – The selectable 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 signal, and the next resuming time in seconds. The next resuming time can be None if resumable anytime.

class simuhw.Subtractor(width: int)

Bases: BinaryOperator

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 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 signal, 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 word width in bits.

property port_co: OutputPort

The borrow output port.

The width is 1 bit.

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 signal, 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 word width in bits.

property port_ci: InputPort

The borrow input port.

The width is 1 bit.

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 signal, 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: SIMD_BinaryOperator

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 words in bits.

  • dsize – The selectable 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 signal, and the next resuming time in seconds. The next resuming time can be None if resumable anytime.

class simuhw.Multiplier(width: int)

Bases: BinaryOperator

A multiplier.

This device calculates a multiplication of two unsigned binary integers.

__init__(width: int) None

Creates a multiplier.

Parameters:

width – The word width in bits.

property port_e: OutputPort

The output port to emit overflow exception.

The width is 1 bit.

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 signal, 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 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 signal, 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: SIMD_BinaryOperator

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 words in bits.

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

Raises:

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

property port_e: OutputPort

The output port to emit overflow exception.

The width is 1 bit.

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 signal, 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 words in bits.

  • dsize – The selectable 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 signal, and the next resuming time in seconds. The next resuming time can be None if resumable anytime.

class simuhw.Divider(width: int)

Bases: BinaryOperator

A divider.

This device calculates a division of two unsigned binary integers.

__init__(width: int) None

Creates a divider.

Parameters:

width – The word width in bits.

property port_e: OutputPort

The output port to emit overflow exception.

The width is 1 bit.

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 signal, 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 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 signal, 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: SIMD_BinaryOperator

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 words in bits.

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

Raises:

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

property port_e: OutputPort

The output port to emit overflow exception.

The width is 1 bit.

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 signal, 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 words in bits.

  • dsize – The selectable 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 signal, and the next resuming time in seconds. The next resuming time can be None if resumable anytime.

class simuhw.Remainder(width: int)

Bases: BinaryOperator

A remainder calculator.

This device calculates a remainder of two unsigned binary integers.

__init__(width: int) None

Creates a remainder calculator.

Parameters:

width – The word width in bits.

property port_e: OutputPort

The output port to emit overflow exception.

The width is 1 bit.

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 signal, 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 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 signal, 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: SIMD_BinaryOperator

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 words in bits.

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

Raises:

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

property port_e: OutputPort

The output port to emit overflow exception.

The width is 1 bit.

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 signal, 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 words in bits.

  • dsize – The selectable 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 signal, and the next resuming time in seconds. The next resuming time can be None if resumable anytime.

class simuhw.Comparator(width: int)

Bases: BinaryOperator

A comparator.

This device compares two unsigned binary integers. It outputs -1 (‘less than’), 1 (‘greater than’), or 0 (‘equal to’) as a signed binary integer with the same number of bits.

__init__(width: int) None

Creates a comparator.

Parameters:

width – The 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 signal, and the next resuming time in seconds. The next resuming time can be None if resumable anytime.

class simuhw.SignedComparator(width: int)

Bases: Comparator

A signed comparator.

This device compares two signed binary integers. It outputs -1 (‘less than’), 1 (‘greater than’), or 0 (‘equal to’) as a signed binary integer with the same number of bits.

__init__(width: int) None

Creates a signed comparator.

Parameters:

width – The 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 signal, and the next resuming time in seconds. The next resuming time can be None if resumable anytime.

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

Bases: SIMD_BinaryOperator

A SIMD comparator.

This device makes respective comparisons of multiple pairs of unsigned binary integers simultaneously. Each output element is to have -1 (‘less than’), 1 (‘greater than’), or 0 (‘equal to’) as a signed binary integer with the same number of bits.

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

Creates a SIMD comparator.

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

  • dsize – The selectable 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 signal, and the next resuming time in seconds. The next resuming time can be None if resumable anytime.

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

Bases: SIMD_Comparator

A SIMD signed comparator.

This device makes respective comparisons of multiple pairs of signed binary integers simultaneously. Each output element is to have -1 (‘less than’), 1 (‘greater than’), or 0 (‘equal to’) as a signed binary integer with the same number of bits.

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

Creates a SIMD signed comparator.

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

  • dsize – The selectable 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 signal, and the next resuming time in seconds. The next resuming time can be None if resumable anytime.

class simuhw.IntegerConverter(width_i: int, width_o: int)

Bases: UnaryOperator

An integer converter.

This device converts the unsigned binary integer to that with different bit size.

__init__(width_i: int, width_o: int) None

Creates an integer converter.

Parameters:
  • width_i – The input word width in bits.

  • width_o – The output 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 signal, and the next resuming time in seconds. The next resuming time can be None if resumable anytime.

class simuhw.SignedIntegerConverter(width_i: int, width_o: int)

Bases: IntegerConverter

A signed integer converter.

This device converts the signed binary integer to that with different bit size.

__init__(width_i: int, width_o: int) None

Creates a signed integer converter.

Parameters:
  • width_i – The input word width in bits.

  • width_o – The output 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 signal, and the next resuming time in seconds. The next resuming time can be None if resumable anytime.

class simuhw.SIMD_IntegerConverter(multi: int, dsize_i: int, dsize_o: int)

Bases: SIMD_UnaryOperator

A SIMD integer converter.

This device converts the respective unsigned binary integers to those with different bit size simultaneously.

__init__(multi: int, dsize_i: int, dsize_o: int) None

Creates a SIMD integer converter.

Parameters:
  • multi – The number of SIMD elements.

  • dsize_i – The input word width in bits.

  • dsize_o – The output 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 signal, and the next resuming time in seconds. The next resuming time can be None if resumable anytime.

class simuhw.SIMD_SignedIntegerConverter(multi: int, dsize_i: int, dsize_o: int)

Bases: SIMD_IntegerConverter

A SIMD signed integer converter.

This device converts the respective signed binary integers to those with different bit size simultaneously.

__init__(multi: int, dsize_i: int, dsize_o: int) None

Creates a SIMD signed integer converter.

Parameters:
  • multi – The number of SIMD elements.

  • dsize_i – The input word width in bits.

  • dsize_o – The output 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 signal, and the next resuming time in seconds. The next resuming time can be None if resumable anytime.

class simuhw.LookupTable(width_i: int, width_o: int, table: Iterable[bytes])

Bases: UnaryOperator

A lookup Table device.

This device outputs words according to inputs by referring to the preset lookup table.

__init__(width_i: int, width_o: int, table: Iterable[bytes]) None

Creates a lookup table device.

Parameters:
  • width_i – The input word width in bits.

  • width_o – The output word width in bits. If a negative value is specified, width_i is used instead.

  • table – The table data. The bit width of every list element must be width_o, and the number of list elements must be 2 to the power of width_i.

Raises:

ValueError – If the size of the table data and width_i are inconsistent.

Caution

As width_i is large, the amount of memory required to retain the table data becomes huge exponentially.

updata_table(table: Iterable[bytes]) None

Updates the table data.

Parameters:

table – The table data. The bit width of every list element must be width_o, and the number of list elements must be 2 to the power of width_i.

Raises:

ValueError – If the size of the table data and width_i are inconsistent.

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 signal, and the next resuming time in seconds. The next resuming time can be None if resumable anytime.