SimuHW
Overview
SimuHW is a behavioral hardware simulator provided as a Python module.
Python 3.11 or later is required.
The GitHub page is https://github.com/arithy/simuhw.
Installation
Release Version
You can install the release version by the following command.
$ python -m pip install simuhw
Development Version
You can install the development version by the following commands.
$ cd simuhw # the repository root directory
$ make req
$ make clean
$ make dist
$ python -m pip install --no-index --find-links=./dist simuhw
Usage
Concept
- Word: a chunk of bits being transferred by wires.
- Device: a hardware element such as a wire, switching devices, and memory devices.
- Channel: a wire to transfer words.
- Memory: a memory device to memorize words associated with specific addresses.
- Port: an endpoint provided by a device to input or output words.
- Probe: an entity to record word values with the respective times, whenever the value of the word passing through a specific port or stored at a specific address in a memory changes.
Import of Module
To use SimuHW, import simuhw module. An example is shown below.
import simuhw as hw
Simulation of Hardware Devices
-
Create instances of the derived classes of
Deviceclass. As of version 0.3.0, the following device classes are available.- Utility
- Clock
- Channel
- Branch
- Elementary Combinational Circuit
- Elementary Sequential Circuit
- Lookup Table
- Bit Operation
LeftShifterRightShifterArithmeticRightShifterLeftRotatorRightRotatorPopulationCounterLeadingZeroCounterTrailingZeroCounterBitReverserSIMD_LeftShifterSIMD_RightShifterSIMD_ArithmeticRightShifterSIMD_LeftRotatorSIMD_RightRotatorSIMD_PopulationCounterSIMD_LeadingZeroCounterSIMD_TrailingZeroCounterSIMD_BitReverser
- Integer Arithmetic
- Floating-Point Arithmetic
Available only if an appropriate version of softfloatpy module is found.
fp.FPNegatorfp.FPAdderfp.FPSubtractorfp.FPMultiplierfp.FPFusedMultiplyAdderfp.FPDividerfp.FPRemainderfp.FPSquareRootfp.FPComparatorfp.FPClassifierfp.FPToIntegerRounderfp.FPToIntegerConverterfp.FPToSignedIntegerConverterfp.FPFromIntegerRounderfp.FPFromSignedIntegerConverterfp.FPConverterfp.SIMD_FPNegatorfp.SIMD_FPAdderfp.SIMD_FPSubtractorfp.SIMD_FPMultiplierfp.SIMD_FPFusedMultiplyAdderfp.SIMD_FPDividerfp.SIMD_FPRemainderfp.SIMD_FPSquareRootfp.SIMD_FPComparatorfp.SIMD_FPClassifierfp.SIMD_FPToIntegerRounderfp.SIMD_FPToIntegerConverterfp.SIMD_FPToSignedIntegerConverterfp.SIMD_FPFromIntegerConverterfp.SIMD_FPFromSignedIntegerConverterfp.SIMD_FPConverterfp.riscv.FRec7fp.riscv.FRSqrt7fp.riscv.SIMD_FRec7fp.riscv.SIMD_FRSqrt7
- Arithmetic Logic Unit
- Counter
- Memory
An example is shown below.
width: int = 16 # Word size in bits source: hw.Source = hw.Source(width, [ (b'\x00\x01', 0.0e-9), (b'\xc1\x85', 3.0e-9), (b'\xd3\xbb', 6.0e-9), (b'\xf2\x3a', 10.0e-9) ]) drain: hw.Drain = hw.Drain(width)
-
Connect the output ports to the input ports of the device class instances. An example is shown below.
source.port_o.connect(drain.port_i)
-
Create instances of
ChannelProbeclass orMemoryProbeclass.ChannelProbeclass instances can be added to input ports or output ports, andMemoryProbeclass instances can be added to instances of the derived classes ofMemoryclass. An example is shown below.probe: hw.ChannelProbe = hw.ChannelProbe('out', width)
-
Add the probes to the ports or the memory. An example is shown below.
drain.port_i.add_probe(probe)
-
Create an instances of
LogicAnalyzerclass. An example is shown below.la: hw.LogicAnalyzer = hw.LogicAnalyzer()
-
Add the probes to the logic analyzer. An example is shown below.
la.add_probe(probe)
-
Create an instance of
Simulatorclass. An example is shown below.sim: hw.Simulator = hw.Simulator([source, drain])
-
Start the simulation. An example is shown below.
sim.start()
-
Save the word value change timings recorded in the probes to a VCD file. An example is shown below.
with open('test.vcd', mode='w') as file: la.save_as_vcd(file)
-
View the VCD file using a waveform viewer such as GTKWave.
The whole source code of the example above is shown below.
import simuhw as hw
width: int = 16 # Word size in bits
source: hw.Source = hw.Source(width, [
(b'\x00\x01', 0.0e-9),
(b'\xc1\x85', 3.0e-9),
(b'\xd3\xbb', 6.0e-9),
(b'\xf2\x3a', 10.0e-9)
])
drain: hw.Drain = hw.Drain(width)
source.port_o.connect(drain.port_i)
probe: hw.ChannelProbe = hw.ChannelProbe('out', width)
drain.port_i.add_probe(probe)
la: hw.LogicAnalyzer = hw.LogicAnalyzer()
la.add_probe(probe)
sim: hw.Simulator = hw.Simulator([source, drain])
sim.start()
with open('test.vcd', mode='w') as file:
la.save_as_vcd(file)
This example simulates a Source device and a Drain device which are connected directly, and saves word value change timings at the input port of the Drain device to the file test.vcd.
Metadata
Release files for simuhw 0.7.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| simuhw-0.7.3.tar.gz | 46.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| simuhw-0.7.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 171.7 kB
Release files / simuhw-0.7.3.tar.gz
| Download URL | simuhw-0.7.3.tar.gz |
|---|---|
| Size | 46.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7dedda2c8d9a23fa16107c907a017ce94aaa6a1ef4925661f1805eaf93689d4f
|
|
BLAKE2b-256 checksum How to use checksums |
a69e529615ee0b18b0bfd80e283b72a70a6e33543e7f73078c18d98122bd1a12
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 20, 2026.
Transparency logRelease files / simuhw-0.7.3-py3-none-any.whl
| Download URL | simuhw-0.7.3-py3-none-any.whl |
|---|---|
| Size | 125.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
07c2dfc6ef8e20edce3f13edeb799880d485c53978fccbe9060aee6887ae8951
|
|
BLAKE2b-256 checksum How to use checksums |
9240c1d242d6038732aa506c529c54da5c6b9a09065f6ab32a5c0cfb5afb36a7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 20, 2026.
Transparency log