This PR adds "single netlist" mode, where an SbNetwork can be simulated in a single Verilator or Icarus simulator instance. This is accomplished by generating Verilog code that implements the network that is specified by .connect() and .external() statements.
Prerequistes
morty
Single netlist mode currently requires morty for Verilog processing, which adds a unique suffix to module definitions used by each unique SbDut. To see why this is necessary, suppose that the network contains two SbDuts, each using an RTL module called memory with different implementations. When a single netlist is constructed, the module definitions for memory will conflict. (This is not a problem outside of single-netlist mode, since the two SbDuts are compiled separately)
To install morty:
Install Rust if you don't have it already:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Check if morty is in the path: which morty. If nothing is returned, add $HOME/.cargo/bin to the path.
In the future, we can explore packaging morty with switchboard, or solving this problem another way.
Update packages
The lambdalib version needs to be updated for the example below to work, and this update is included in examples/requirements.txt. Please run
pip install -r examples/requirements.txt
Testing the PR
cd into examples/network and run ./test.py --single-netlist (or ./test.py --tool icarus --single-netlist). If you're curious, you can see the generated Verilog code in build/testbench-*/testbench.sv.
Enabling single netlist mode is just a matter of setting SbNetwork(..., single_netlist=True) or including --single-netlist as a command-line option if cmdline=True has been set. However, there is a caveat, which is that SbDuts used in the network must have autowrap=False and subcomponent=True
To make it easier to define SbDuts that can be used in either single-netlist mode or distributed mode, this PR provides a new method, SbNetwork.make_dut(), that automatically fills in autowrap and subcomponent based on whether single netlist mode is being used. It also passes through command-line arguments automatically. make_dut accepts the same arguments as the SbDut constructor.
If you take a look at examples/network/tests.py, you can see usage examples for make_dut: it just replaces the SbDut constructor where it was being used before.
Allow SbNetworks with single_netlist=True to be instantiated in an SbNetwork. This will enable hierarchical simulation of large networks.
See whether it is possible to avoid the need to have autowrap and subcomponent set to specific values when using SbDuts in single-netlist mode (a bit tricky due to some of the different ways SbDuts are used)
This PR adds "single netlist" mode, where an SbNetwork can be simulated in a single Verilator or Icarus simulator instance. This is accomplished by generating Verilog code that implements the network that is specified by
.connect()
and.external()
statements.Prerequistes
morty
Single netlist mode currently requires
morty
for Verilog processing, which adds a unique suffix to module definitions used by each unique SbDut. To see why this is necessary, suppose that the network contains two SbDuts, each using an RTL module calledmemory
with different implementations. When a single netlist is constructed, the module definitions formemory
will conflict. (This is not a problem outside of single-netlist mode, since the two SbDuts are compiled separately)To install
morty
:Install Rust if you don't have it already:
Install morty (will take a few minutes)
Check if
morty
is in the path:which morty
. If nothing is returned, add$HOME/.cargo/bin
to the path.In the future, we can explore packaging morty with switchboard, or solving this problem another way.
Update packages
The lambdalib version needs to be updated for the example below to work, and this update is included in
examples/requirements.txt
. Please runTesting the PR
cd
intoexamples/network
and run./test.py --single-netlist
(or./test.py --tool icarus --single-netlist
). If you're curious, you can see the generated Verilog code inbuild/testbench-*/testbench.sv
.Enabling single netlist mode is just a matter of setting
SbNetwork(..., single_netlist=True)
or including--single-netlist
as a command-line option ifcmdline=True
has been set. However, there is a caveat, which is that SbDuts used in the network must haveautowrap=False
andsubcomponent=True
To make it easier to define SbDuts that can be used in either single-netlist mode or distributed mode, this PR provides a new method,
SbNetwork.make_dut()
, that automatically fills inautowrap
andsubcomponent
based on whether single netlist mode is being used. It also passes through command-line arguments automatically.make_dut
accepts the same arguments as theSbDut
constructor.If you take a look at
examples/network/tests.py
, you can see usage examples formake_dut
: it just replaces theSbDut
constructor where it was being used before.https://github.com/zeroasiccorp/switchboard/blob/c26ed38323e1b63bbd7d29844e1616a7808a3c48/examples/network/test.py#L170-L171
Future work
single_netlist=True
to be instantiated in an SbNetwork. This will enable hierarchical simulation of large networks.autowrap
andsubcomponent
set to specific values when using SbDuts in single-netlist mode (a bit tricky due to some of the different ways SbDuts are used)