simuhw package
Subpackages
Module contents
- class simuhw.LogicAnalyzer
Bases:
objectA logic analyzer to save the collected timings of data change.
- __init__() None
Creates a logic analyzer.
- 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:
objectThe 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:
ProbeA 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:
ProbeA 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:
objectA simulator.
It executes behavioral simulation of devices.
- default_max_iter: int | None = 1000
The default maximum iteration count during the same current time. No limit in iteration if None.
- 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:
PortAn 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:
PortAn 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.
- 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:
objectThe 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:
DeviceA 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:
SourceA 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:
SourceA 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:
SourceA 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:
DeviceA drain device to absorb data words.
- __init__(width: int) None
Creates a drain device.
- Parameters:
width – The data word width in bits.
- 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:
DeviceA 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.
- 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:
DeviceA 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_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:
DeviceA 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:
DeviceThe 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.
- reset() None
Resets the states.
- property width: int
The data word width in bits.
- class simuhw.UnaryGate(width: int)
Bases:
GateThe super class for all 1-input gates.
- __init__(width: int) None
Creates a 1-input gate.
- Parameters:
width – The data word width in bits.
- class simuhw.BinaryGate(width: int)
Bases:
GateThe 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:
UnaryGateA 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:
UnaryGateA 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:
GateAn 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:
GateAn 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:
GateAn 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:
GateA 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:
GateA 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:
GateAn 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:
DeviceA 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.
- 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:
DeviceA 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 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:
DeviceAn 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.
- 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:
DeviceA 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.
- 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:
DeviceA 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 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:
DemultiplexerA 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:
DeviceA 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 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:
DeviceA 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_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:
DeviceA 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_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:
DeviceA D latch.
- __init__(width: int, *, neg_leveled: bool = False) None
Creates a D latch.
- Parameters:
width – The data word width in bits.
neg_leveled – True if negative-leveled, False otherwise.
- property negative_leveled: bool
True if negative-leveled, False otherwise.
- 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:
DeviceA 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_edged – True if negative-edged, False otherwise.
- property negative_edged: bool
True if negative-edged, False otherwise.
- 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:
BinaryGateThe 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:
ShifterA 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:
ShifterA 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:
ShifterAn 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:
ShifterA 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:
ShifterA 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:
BinaryGateThe 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.
- reset() None
Resets the states.
- class simuhw.SIMD_LeftShifter(width: int, dsize: int | Iterable[int])
Bases:
SIMD_ShifterA 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_ShifterA 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_ShifterA 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_ShifterA 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_ShifterA 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:
UnaryGateThe 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:
BitOperatorA 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:
BitOperatorA 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:
BitOperatorA 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:
BitOperatorA 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:
UnaryGateThe 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.
- reset() None
Resets the states.
- class simuhw.SIMD_PopulationCounter(width: int, dsize: int | Iterable[int])
Bases:
SIMD_BitOperatorA 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_BitOperatorA 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_BitOperatorA 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_BitOperatorA 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:
BinaryGateAn 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:
AdderA 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:
HalfAdderA 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.
- 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:
BinaryGateA 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.
- 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:
BinaryGateA 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:
SubtractorA 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:
HalfSubtractorA 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.
- 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:
BinaryGateA 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.
- 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:
BinaryGateA 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:
MultiplierA 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:
BinaryGateA 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.
- 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_MultiplierA 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:
BinaryGateA 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:
DividerA 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:
BinaryGateA 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.
- 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_DividerA 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:
BinaryGateA 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:
RemainderA 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:
BinaryGateA 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.
- 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_RemainderA 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.