-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Single netlist mode #223
Merged
Merged
Single netlist mode #223
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
also: introduce SbNetwork.make_dut
azaidy
approved these changes
May 20, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
:curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
cargo install --git https://github.com/pulp-platform/morty.git
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 runpip install -r examples/requirements.txt
Testing 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.switchboard/examples/network/test.py
Lines 170 to 171 in c26ed38
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)