simuhw package
Subpackages
- simuhw.alu package
- Module contents
GenericArithmeticLogicUnitGenericArithmeticLogicUnit.__init__()GenericArithmeticLogicUnit.find_op_indices()GenericArithmeticLogicUnit.opsGenericArithmeticLogicUnit.port_ciGenericArithmeticLogicUnit.port_coGenericArithmeticLogicUnit.port_eGenericArithmeticLogicUnit.port_fe_iGenericArithmeticLogicUnit.port_fe_oGenericArithmeticLogicUnit.port_frGenericArithmeticLogicUnit.port_ftGenericArithmeticLogicUnit.port_oGenericArithmeticLogicUnit.port_opGenericArithmeticLogicUnit.port_sGenericArithmeticLogicUnit.ports_iGenericArithmeticLogicUnit.reset()GenericArithmeticLogicUnit.width_feGenericArithmeticLogicUnit.width_frGenericArithmeticLogicUnit.width_ftGenericArithmeticLogicUnit.width_iGenericArithmeticLogicUnit.width_oGenericArithmeticLogicUnit.width_opGenericArithmeticLogicUnit.width_sGenericArithmeticLogicUnit.work()
FullArithmeticLogicUnitSIMD_FullArithmeticLogicUnit
- Module contents
- simuhw.counter package
- simuhw.fp package
- Subpackages
- Module contents
is_available()get_required_softfloatpy_least_version()raise_exception_if_not_available()TininessModeRoundingModeExceptionFlagFloat16Float32Float64Float128dsize_to_dtype()FPStateFPUnaryOperatorFPBinaryOperatorFPTernaryOperatorSIMD_FPUnaryOperatorSIMD_FPBinaryOperatorSIMD_FPTernaryOperatorFPNegatorSIMD_FPNegatorFPAdderSIMD_FPAdderFPSubtractorSIMD_FPSubtractorFPMultiplierSIMD_FPMultiplierFPMultiplyAdderSIMD_FPMultiplyAdderFPDividerSIMD_FPDividerFPRemainderSIMD_FPRemainderFPSquareRootSIMD_FPSquareRootFPComparatorSIMD_FPComparatorFPClassifierSIMD_FPClassifierFPToIntegerRounderSIMD_FPToIntegerRounderFPToIntegerConverterSIMD_FPToIntegerConverterFPFromIntegerConverterSIMD_FPFromIntegerConverterFPToSignedIntegerConverterSIMD_FPToSignedIntegerConverterFPFromSignedIntegerConverterSIMD_FPFromSignedIntegerConverterFPConverterSIMD_FPConverter
- simuhw.memory package
Module contents
- class simuhw.Unknown
Bases:
objectThe unknown state.
- class simuhw.HighZ
Bases:
objectThe high impedance state.
- class simuhw.Signal(word: bytes | type[Unknown | HighZ], time: float)
Bases:
objectA 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.
- 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 word width in bits.
- 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:
ProbeA 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:
ProbeA 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:
objectA logic analyzer to save the collected timings of word 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 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:
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 signals from an output port.
- __init__(width: int) None
Creates an input port.
- Parameters:
width – The word width in bits.
- property changed: bool
Trueif the signal word has been changed,Falseotherwise.
- property connected: bool
Trueif connected to an output port,Falseotherwise.
- 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.
- class simuhw.OutputPort(width: int)
Bases:
PortAn 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
Trueif connected to an input port,Falseotherwise.
- 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.
Nonewhen 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
Noneif resumable anytime.
- class simuhw.Source(width: int, signals: Iterable[Signal | tuple[bytes | type[Unknown | HighZ], float]])
Bases:
DeviceA 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.
Nonewhen 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
Noneif resumable anytime.
- class simuhw.LogicLowSource(width: int)
Bases:
SourceA 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:
SourceA 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:
SourceA 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:
SourceA 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:
DeviceA drain device to absorb signals.
- __init__(width: int) None
Creates a drain device.
- Parameters:
width – The word width in bits.
- 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.
Nonewhen 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
Noneif 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.
Nonewhen 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
Noneif resumable anytime.
- class simuhw.Delay(width: int, *, delay: float)
Bases:
DeviceA 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_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.
Nonewhen 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
Noneif 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.
Nonewhen 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
Noneif resumable anytime.
- class simuhw.WordCombiner(widths: Iterable[int])
Bases:
DeviceA 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.
- 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.
Nonewhen 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
Noneif resumable anytime.
- class simuhw.WordSplitter(widths: Iterable[int])
Bases:
DeviceA 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 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.
Nonewhen 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
Noneif resumable anytime.
- class simuhw.Multiplexer(width: int, ninputs: int)
Bases:
DeviceA 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.
- 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.
Nonewhen 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
Noneif resumable anytime.
- class simuhw.Demultiplexer(width: int, noutputs: int, *, deselected: bytes | type[~simuhw._type.Unknown | ~simuhw._type.HighZ] = <class 'simuhw._type.Unknown'>)
Bases:
DeviceA 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 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.
Nonewhen 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
Noneif resumable anytime.
- class simuhw.WordRetainingDemultiplexer(width: int, noutputs: int)
Bases:
DemultiplexerA 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.
Nonewhen 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
Noneif resumable anytime.
- class simuhw.Junction(width: int, ninputs: int)
Bases:
DeviceA 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.
- 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.
Nonewhen 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
Noneif resumable anytime.
- class simuhw.Distributor(width: int, noutputs: int)
Bases:
DeviceA 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 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.
Nonewhen 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
Noneif 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 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 word width in bits.
- work(time: float | None) tuple[list[InputPort], float | None]
Makes the device work.
- Parameters:
time – The current time in seconds.
Nonewhen 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
Noneif resumable anytime.
- class simuhw.Operator(width_i: int, width_o: int, *, ninputs: int)
Bases:
DeviceThe 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.
- 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:
OperatorThe 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_iis used instead.
- class simuhw.BinaryOperator(width_i: int, width_o: int = -1)
Bases:
OperatorThe 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_iis used instead.
- class simuhw.TernaryOperator(width_i: int, width_o: int = -1)
Bases:
OperatorThe 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_iis used instead.
- class simuhw.SIMD_Operator(width_i: int, dsize_i: int | Iterable[int], width_o: int, *, ninputs: int)
Bases:
OperatorThe 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_iis not divisible by any ofdsize_i, or ifwidth_ois 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.
- reset() None
Resets the states.
- class simuhw.SIMD_UnaryOperator(width_i: int, dsize_i: int | Iterable[int], width_o: int = -1)
Bases:
SIMD_OperatorThe 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_iis used instead.
- Raises:
ValueError – If
width_iis not divisible by any ofdsize_i, or ifwidth_ois inconsistent with them.
- class simuhw.SIMD_BinaryOperator(width_i: int, dsize_i: int | Iterable[int], width_o: int = -1)
Bases:
SIMD_OperatorThe 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_iis used instead.
- Raises:
ValueError – If
width_iis not divisible by any ofdsize_i, or ifwidth_ois inconsistent with them.
- class simuhw.SIMD_TernaryOperator(width_i: int, dsize_i: int | Iterable[int], width_o: int = -1)
Bases:
SIMD_OperatorThe 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_iis used instead.
- Raises:
ValueError – If
width_iis not divisible by any ofdsize_i, or ifwidth_ois inconsistent with them.
- class simuhw.Buffer(width: int)
Bases:
UnaryOperatorA 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.
Nonewhen 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
Noneif resumable anytime.
- class simuhw.Inverter(width: int)
Bases:
BufferAn 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.
Nonewhen 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
Noneif resumable anytime.
- class simuhw.TriStateBuffer(width: int, *, active_high: bool = True)
Bases:
UnaryOperatorA tri-state buffer.
- __init__(width: int, *, active_high: bool = True) None
Creates a tri-state buffer.
- Parameters:
width – The word width in bits.
active_high –
Trueif the control port is active-high,Falseif it is active-low.
- property active_high: bool
Trueif the control port is active-high,Falseif it is active-low.
- work(time: float | None) tuple[list[InputPort], float | None]
Makes the device work.
- Parameters:
time – The current time in seconds.
Nonewhen 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
Noneif resumable anytime.
- class simuhw.TriStateInverter(width: int, *, active_high: bool = True)
Bases:
TriStateBufferA tri-state inverter.
- __init__(width: int, *, active_high: bool = True) None
Creates a tri-state inverter.
- Parameters:
width – The word width in bits.
active_high –
Trueif the control port is active-high,Falseif it is active-low.
- work(time: float | None) tuple[list[InputPort], float | None]
Makes the device work.
- Parameters:
time – The current time in seconds.
Nonewhen 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
Noneif resumable anytime.
- class simuhw.ANDGate(width: int, *, ninputs: int = 2)
Bases:
OperatorAn 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.
Nonewhen 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
Noneif resumable anytime.
- class simuhw.ORGate(width: int, *, ninputs: int = 2)
Bases:
OperatorAn 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.
Nonewhen 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
Noneif resumable anytime.
- class simuhw.XORGate(width: int, *, ninputs: int = 2)
Bases:
OperatorAn 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.
Nonewhen 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
Noneif resumable anytime.
- class simuhw.NANDGate(width: int, *, ninputs: int = 2)
Bases:
OperatorA 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.
Nonewhen 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
Noneif resumable anytime.
- class simuhw.NORGate(width: int, *, ninputs: int = 2)
Bases:
OperatorA 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.
Nonewhen 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
Noneif resumable anytime.
- class simuhw.XNORGate(width: int, *, ninputs: int = 2)
Bases:
OperatorAn 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.
Nonewhen 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
Noneif 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 word width in bits.
neg_leveled –
Trueif negative-leveled,Falseotherwise.
- property negative_leveled: bool
Trueif negative-leveled,Falseotherwise.
- 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.
Nonewhen 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
Noneif 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 word width in bits.
neg_edged –
Trueif negative-edged,Falseotherwise.
- property negative_edged: bool
Trueif negative-edged,Falseotherwise.
- 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.
Nonewhen 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
Noneif resumable anytime.
- class simuhw.Shifter(width: int)
Bases:
BinaryOperatorThe 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:
ShifterA 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.
Nonewhen 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
Noneif resumable anytime.
- class simuhw.RightShifter(width: int)
Bases:
ShifterA 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.
Nonewhen 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
Noneif 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 word width in bits.
- work(time: float | None) tuple[list[InputPort], float | None]
Makes the device work.
- Parameters:
time – The current time in seconds.
Nonewhen 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
Noneif resumable anytime.
- class simuhw.LeftRotator(width: int)
Bases:
ShifterA 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.
Nonewhen 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
Noneif resumable anytime.
- class simuhw.RightRotator(width: int)
Bases:
ShifterA 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.
Nonewhen 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
Noneif resumable anytime.
- class simuhw.SIMD_Shifter(width: int, dsize: int | Iterable[int])
Bases:
SIMD_BinaryOperatorThe 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
widthis not divisible by any ofdsize.
- 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 words in bits.
dsize – The selectable word width or widths in bits.
- Raises:
ValueError – If
widthis not divisible by any ofdsize.
- work(time: float | None) tuple[list[InputPort], float | None]
Makes the device work.
- Parameters:
time – The current time in seconds.
Nonewhen 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
Noneif 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 words in bits.
dsize – The selectable word width or widths in bits.
- Raises:
ValueError – If
widthis not divisible by any ofdsize.
- work(time: float | None) tuple[list[InputPort], float | None]
Makes the device work.
- Parameters:
time – The current time in seconds.
Nonewhen 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
Noneif 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 words in bits.
dsize – The selectable word width or widths in bits.
- Raises:
ValueError – If
widthis not divisible by any ofdsize.
- work(time: float | None) tuple[list[InputPort], float | None]
Makes the device work.
- Parameters:
time – The current time in seconds.
Nonewhen 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
Noneif 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 words in bits.
dsize – The selectable word width or widths in bits.
- Raises:
ValueError – If
widthis not divisible by any ofdsize.
- work(time: float | None) tuple[list[InputPort], float | None]
Makes the device work.
- Parameters:
time – The current time in seconds.
Nonewhen 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
Noneif 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 words in bits.
dsize – The selectable word width or widths in bits.
- Raises:
ValueError – If
widthis not divisible by any ofdsize.
- work(time: float | None) tuple[list[InputPort], float | None]
Makes the device work.
- Parameters:
time – The current time in seconds.
Nonewhen 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
Noneif resumable anytime.
- class simuhw.BitOperator(width: int)
Bases:
UnaryOperatorThe 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:
BitOperatorA 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.
Nonewhen 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
Noneif 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 word width in bits.
- work(time: float | None) tuple[list[InputPort], float | None]
Makes the device work.
- Parameters:
time – The current time in seconds.
Nonewhen 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
Noneif 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 word width in bits.
- work(time: float | None) tuple[list[InputPort], float | None]
Makes the device work.
- Parameters:
time – The current time in seconds.
Nonewhen 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
Noneif resumable anytime.
- class simuhw.BitReverser(width: int)
Bases:
BitOperatorA 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.
Nonewhen 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
Noneif resumable anytime.
- class simuhw.SIMD_BitOperator(width: int, dsize: int | Iterable[int])
Bases:
SIMD_UnaryOperatorThe 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
widthis not divisible by any ofdsize.
- 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 words in bits.
dsize – The selectable word width or widths in bits.
- Raises:
ValueError – If
widthis not divisible by any ofdsize.
- work(time: float | None) tuple[list[InputPort], float | None]
Makes the device work.
- Parameters:
time – The current time in seconds.
Nonewhen 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
Noneif 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 words in bits.
dsize – The selectable word width or widths in bits.
- Raises:
ValueError – If
widthis not divisible by any ofdsize.
- work(time: float | None) tuple[list[InputPort], float | None]
Makes the device work.
- Parameters:
time – The current time in seconds.
Nonewhen 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
Noneif 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 words in bits.
dsize – The selectable word width or widths in bits.
- Raises:
ValueError – If
widthis not divisible by any ofdsize.
- work(time: float | None) tuple[list[InputPort], float | None]
Makes the device work.
- Parameters:
time – The current time in seconds.
Nonewhen 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
Noneif 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 words in bits.
dsize – The selectable word width or widths in bits.
- Raises:
ValueError – If
widthis not divisible by any ofdsize.
- work(time: float | None) tuple[list[InputPort], float | None]
Makes the device work.
- Parameters:
time – The current time in seconds.
Nonewhen 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
Noneif resumable anytime.
- class simuhw.Negator(width: int)
Bases:
UnaryOperatorA 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.
Nonewhen 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
Noneif resumable anytime.
- class simuhw.SIMD_Negator(width: int, dsize: int | Iterable[int])
Bases:
SIMD_UnaryOperatorA 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
widthis not divisible by any ofdsize.
- work(time: float | None) tuple[list[InputPort], float | None]
Makes the device work.
- Parameters:
time – The current time in seconds.
Nonewhen 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
Noneif resumable anytime.
- class simuhw.Adder(width: int)
Bases:
BinaryOperatorAn 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.
Nonewhen 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
Noneif 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 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.
Nonewhen 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
Noneif 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 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.
Nonewhen 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
Noneif resumable anytime.
- class simuhw.SIMD_Adder(width: int, dsize: int | Iterable[int])
Bases:
SIMD_BinaryOperatorA 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
widthis not divisible by any ofdsize.
- work(time: float | None) tuple[list[InputPort], float | None]
Makes the device work.
- Parameters:
time – The current time in seconds.
Nonewhen 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
Noneif resumable anytime.
- class simuhw.Subtractor(width: int)
Bases:
BinaryOperatorA 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.
Nonewhen 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
Noneif 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 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.
Nonewhen 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
Noneif 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 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.
Nonewhen 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
Noneif resumable anytime.
- class simuhw.SIMD_Subtractor(width: int, dsize: int | Iterable[int])
Bases:
SIMD_BinaryOperatorA 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
widthis not divisible by any ofdsize.
- work(time: float | None) tuple[list[InputPort], float | None]
Makes the device work.
- Parameters:
time – The current time in seconds.
Nonewhen 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
Noneif resumable anytime.
- class simuhw.Multiplier(width: int)
Bases:
BinaryOperatorA 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.
Nonewhen 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
Noneif 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 word width in bits.
- work(time: float | None) tuple[list[InputPort], float | None]
Makes the device work.
- Parameters:
time – The current time in seconds.
Nonewhen 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
Noneif resumable anytime.
- class simuhw.SIMD_Multiplier(width: int, dsize: int | Iterable[int])
Bases:
SIMD_BinaryOperatorA 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
widthis not divisible by any ofdsize.
- 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.
Nonewhen 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
Noneif 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 words in bits.
dsize – The selectable word width or widths in bits.
- Raises:
ValueError – If
widthis not divisible by any ofdsize.
- work(time: float | None) tuple[list[InputPort], float | None]
Makes the device work.
- Parameters:
time – The current time in seconds.
Nonewhen 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
Noneif resumable anytime.
- class simuhw.Divider(width: int)
Bases:
BinaryOperatorA 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.
Nonewhen 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
Noneif 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 word width in bits.
- work(time: float | None) tuple[list[InputPort], float | None]
Makes the device work.
- Parameters:
time – The current time in seconds.
Nonewhen 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
Noneif resumable anytime.
- class simuhw.SIMD_Divider(width: int, dsize: int | Iterable[int])
Bases:
SIMD_BinaryOperatorA 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
widthis not divisible by any ofdsize.
- 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.
Nonewhen 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
Noneif 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 words in bits.
dsize – The selectable word width or widths in bits.
- Raises:
ValueError – If
widthis not divisible by any ofdsize.
- work(time: float | None) tuple[list[InputPort], float | None]
Makes the device work.
- Parameters:
time – The current time in seconds.
Nonewhen 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
Noneif resumable anytime.
- class simuhw.Remainder(width: int)
Bases:
BinaryOperatorA 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.
Nonewhen 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
Noneif 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 word width in bits.
- work(time: float | None) tuple[list[InputPort], float | None]
Makes the device work.
- Parameters:
time – The current time in seconds.
Nonewhen 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
Noneif resumable anytime.
- class simuhw.SIMD_Remainder(width: int, dsize: int | Iterable[int])
Bases:
SIMD_BinaryOperatorA 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
widthis not divisible by any ofdsize.
- 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.
Nonewhen 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
Noneif 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 words in bits.
dsize – The selectable word width or widths in bits.
- Raises:
ValueError – If
widthis not divisible by any ofdsize.
- work(time: float | None) tuple[list[InputPort], float | None]
Makes the device work.
- Parameters:
time – The current time in seconds.
Nonewhen 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
Noneif resumable anytime.
- class simuhw.Comparator(width: int)
Bases:
BinaryOperatorA 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.
Nonewhen 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
Noneif resumable anytime.
- class simuhw.SignedComparator(width: int)
Bases:
ComparatorA 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.
Nonewhen 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
Noneif resumable anytime.
- class simuhw.SIMD_Comparator(width: int, dsize: int | Iterable[int])
Bases:
SIMD_BinaryOperatorA 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
widthis not divisible by any ofdsize.
- work(time: float | None) tuple[list[InputPort], float | None]
Makes the device work.
- Parameters:
time – The current time in seconds.
Nonewhen 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
Noneif resumable anytime.
- class simuhw.SIMD_SignedComparator(width: int, dsize: int | Iterable[int])
Bases:
SIMD_ComparatorA 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
widthis not divisible by any ofdsize.
- work(time: float | None) tuple[list[InputPort], float | None]
Makes the device work.
- Parameters:
time – The current time in seconds.
Nonewhen 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
Noneif resumable anytime.
- class simuhw.IntegerConverter(width_i: int, width_o: int)
Bases:
UnaryOperatorAn 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.
Nonewhen 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
Noneif resumable anytime.
- class simuhw.SignedIntegerConverter(width_i: int, width_o: int)
Bases:
IntegerConverterA 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.
Nonewhen 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
Noneif resumable anytime.
- class simuhw.SIMD_IntegerConverter(multi: int, dsize_i: int, dsize_o: int)
Bases:
SIMD_UnaryOperatorA 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.
Nonewhen 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
Noneif resumable anytime.
- class simuhw.SIMD_SignedIntegerConverter(multi: int, dsize_i: int, dsize_o: int)
Bases:
SIMD_IntegerConverterA 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.
Nonewhen 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
Noneif resumable anytime.
- class simuhw.LookupTable(width_i: int, width_o: int, table: Iterable[bytes])
Bases:
UnaryOperatorA 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_iis 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 ofwidth_i.
- Raises:
ValueError – If the size of the table data and
width_iare inconsistent.
Caution
As
width_iis 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 ofwidth_i.- Raises:
ValueError – If the size of the table data and
width_iare inconsistent.
- work(time: float | None) tuple[list[InputPort], float | None]
Makes the device work.
- Parameters:
time – The current time in seconds.
Nonewhen 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
Noneif resumable anytime.