Skip to content
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 23 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
d54e0be
add surelog + morty flattening
sgherbst May 9, 2024
40b9906
Merge remote-tracking branch 'origin/main' into sgh/single-netlist
sgherbst May 13, 2024
9395acc
first pass of single netlist mode working
sgherbst May 13, 2024
034dc9f
network example updated to work with both distributed and single-netl…
sgherbst May 13, 2024
16986ec
fix bug with max reset delay calculation
sgherbst May 13, 2024
693ccd3
fix resetall and max-rate issues
sgherbst May 14, 2024
badd07c
use newer version of lambdalib
sgherbst May 14, 2024
2872d73
try running single-netlist mode in regression tests
sgherbst May 14, 2024
08729bc
use the latest lambdalib version
sgherbst May 14, 2024
60232db
fix packaging
sgherbst May 14, 2024
5937dec
improve build directory naming
sgherbst May 14, 2024
afa32f6
run examples using the latest umi release
sgherbst May 14, 2024
ae8589c
rename "netlist" as "single-netlist", improve pytest visibility
sgherbst May 15, 2024
44f9f8d
try to fix issue with morty path
sgherbst May 15, 2024
18e5f99
remove path to morty (should be part of docker image now)
sgherbst May 15, 2024
359928d
clean up step that removes `resetall
sgherbst May 15, 2024
33992ae
add network-fifo-chain example, clean script
sgherbst May 15, 2024
c26ed38
bump version
sgherbst May 15, 2024
86c8be0
Merge branch 'main' into sgh/single-netlist
sgherbst May 15, 2024
4b6157f
add threads argument
sgherbst May 16, 2024
ad3f2ab
Merge branch 'sgh/single-netlist' of github.com:zeroasiccorp/switchbo…
sgherbst May 16, 2024
aa05279
first network-in-network simulation works
sgherbst May 16, 2024
16a4710
clean up passing of interfaces
sgherbst May 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/regression.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ jobs:

- name: Run pytest
working-directory: examples
run: pytest --durations=0 -s
run: |
pytest --durations=0 -s

- name: Run tests
working-directory: tests
Expand Down
12 changes: 12 additions & 0 deletions examples/clean.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

# Loop through subdirectories, running 'make clean'

for dir in */; do
# Run 'make clean' if a Makefile exists

if [ -f "${dir}Makefile" ]; then
echo "Running 'make clean' in $dir"
(cd "$dir" && make clean)
fi
done
25 changes: 25 additions & 0 deletions examples/network-fifo-chain/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright (c) 2024 Zero ASIC Corporation
# This code is licensed under Apache License 2.0 (see LICENSE for details)

.PHONY: verilator
verilator:
./test.py --tool verilator --start-delay 5 --max-rate 1e3

.PHONY: verilator-single-netlist
verilator-single-netlist:
./test.py --tool verilator --single-netlist

.PHONY: icarus
icarus:
./test.py --tool icarus --start-delay 2 --max-rate 1e3 --fifos 125

.PHONY: icarus-single-netlist
icarus-single-netlist:
./test.py --tool icarus --single-netlist

.PHONY: clean
clean:
rm -f queue-* *.q
rm -f *.vcd *.fst *.fst.hier
rm -rf obj_dir build
rm -f *.o *.vpi
130 changes: 130 additions & 0 deletions examples/network-fifo-chain/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
#!/usr/bin/env python3

# Example showing how to wire up various modules using SbNetwork

# Copyright (c) 2024 Zero ASIC Corporation
# This code is licensed under Apache License 2.0 (see LICENSE for details)

import umi
from switchboard import SbNetwork, umi_loopback
from switchboard.cmdline import get_cmdline_args

from pathlib import Path
THIS_DIR = Path(__file__).resolve().parent


def main():
# create network

extra_args = {
'--packets': dict(type=int, default=1000, help='Number of'
' transactions to send into the FIFO during the test.'),
'--fifos': dict(type=int, default=500, help='Number of'
' FIFOs to instantiate in series for this test.'),
'--fifos-per-sim': dict(type=int, default=1, help='Number of'
' FIFOs to include in each simulation.')
}

# workaround - need to see what type of simulation we're running
# (network of simulations, network of networks, single netlist)

args = get_cmdline_args(extra_args=extra_args)

assert args.fifos % args.fifos_per_sim == 0, \
'Number of FIFOs must be divisible by the number of FIFOs per simulation'

if args.fifos_per_sim in [1, args.fifos]:
# single network
net = SbNetwork(cmdline=True, single_netlist=args.fifos_per_sim == args.fifos)
subnet = net
n = args.fifos
else:
# network of networks
net = SbNetwork(cmdline=True, single_netlist=False)
subnet = SbNetwork(name='subnet', cmdline=True, single_netlist=True)
n = args.fifos_per_sim

subblock = make_umi_fifo(subnet)

subblocks = [subnet.instantiate(subblock) for _ in range(n)]

for i in range(len(subblocks) - 1):
subnet.connect(subblocks[i].umi_out, subblocks[i + 1].umi_in)

if n < args.fifos:
subnet.external(subblocks[0].umi_in, name='umi_in')
subnet.external(subblocks[-1].umi_out, name='umi_out')

blocks = [net.instantiate(subnet) for _ in range(args.fifos // args.fifos_per_sim)]

for i in range(len(blocks) - 1):
net.connect(blocks[i].umi_out, blocks[i + 1].umi_in)
else:
blocks = subblocks

net.external(blocks[0].umi_in, txrx='umi')
net.external(blocks[-1].umi_out, txrx='umi')

# build simulator

net.build()

# launch the simulation

net.simulate()

# interact with the simulation

umi_loopback(net.intfs['umi'], packets=args.packets)


def make_umi_fifo(net):
dw = 256
aw = 64
cw = 32

parameters = dict(
DW=dw,
AW=aw,
CW=cw
)

tieoffs = dict(
bypass="1'b0",
chaosmode="1'b0",
fifo_full=None,
fifo_empty=None,
vdd="1'b1",
vss="1'b0"
)

interfaces = {
'umi_in': dict(type='umi', dw=dw, aw=aw, cw=cw, direction='input'),
'umi_out': dict(type='umi', dw=dw, aw=aw, cw=cw, direction='output')
}

clocks = [
'umi_in_clk',
'umi_out_clk'
]

resets = [
'umi_in_nreset',
'umi_out_nreset'
]

dut = net.make_dut('umi_fifo', parameters=parameters, interfaces=interfaces,
clocks=clocks, resets=resets, tieoffs=tieoffs)

dut.use(umi)
dut.add('option', 'library', 'umi')
dut.add('option', 'library', 'lambdalib_stdlib')
dut.add('option', 'library', 'lambdalib_ramlib')

dut.input('umi/rtl/umi_fifo.v', package='umi')

return dut


if __name__ == '__main__':
main()
8 changes: 8 additions & 0 deletions examples/network/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,18 @@
verilator:
./test.py --tool verilator --start-delay 1 --max-rate 1e3

.PHONY: verilator-single-netlist
verilator-single-netlist:
./test.py --tool verilator --single-netlist

.PHONY: icarus
icarus:
./test.py --tool icarus --start-delay 1 --max-rate 1e3

.PHONY: icarus-single-netlist
icarus-single-netlist:
./test.py --tool icarus --single-netlist

.PHONY: clean
clean:
rm -f queue-* *.q
Expand Down
30 changes: 17 additions & 13 deletions examples/network/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import numpy as np

import umi
from switchboard import SbDut, SbNetwork
from switchboard import SbNetwork

from pathlib import Path
THIS_DIR = Path(__file__).resolve().parent
Expand All @@ -21,9 +21,9 @@ def main():

# create the building blocks

umi_fifo = make_umi_fifo(args=net.args)
umi2axil = make_umi2axil(args=net.args)
axil_ram = make_axil_ram(args=net.args)
umi_fifo = make_umi_fifo(net)
umi2axil = make_umi2axil(net)
axil_ram = make_axil_ram(net)

# connect them together

Expand Down Expand Up @@ -68,7 +68,7 @@ def main():
assert wrdata == rddata


def make_umi_fifo(args):
def make_umi_fifo(net):
dw = 256
aw = 64
cw = 32
Expand Down Expand Up @@ -103,18 +103,20 @@ def make_umi_fifo(args):
'umi_out_nreset'
]

dut = SbDut('umi_fifo', autowrap=True, parameters=parameters, interfaces=interfaces,
clocks=clocks, resets=resets, tieoffs=tieoffs, args=args)
dut = net.make_dut('umi_fifo', parameters=parameters, interfaces=interfaces,
clocks=clocks, resets=resets, tieoffs=tieoffs)

dut.use(umi)
dut.add('option', 'library', 'umi')
dut.add('option', 'library', 'lambdalib_stdlib')
dut.add('option', 'library', 'lambdalib_ramlib')

dut.input('umi/rtl/umi_fifo.v', package='umi')

return dut


def make_axil_ram(args):
def make_axil_ram(net):
dw = 64
aw = 13

Expand All @@ -129,8 +131,8 @@ def make_axil_ram(args):

resets = [dict(name='rst', delay=8)]

dut = SbDut('axil_ram', autowrap=True, parameters=parameters, interfaces=interfaces,
resets=resets, args=args)
dut = net.make_dut('axil_ram', parameters=parameters,
interfaces=interfaces, resets=resets)

dut.register_package_source(
'verilog-axi',
Expand All @@ -146,7 +148,7 @@ def make_axil_ram(args):
return dut


def make_umi2axil(args):
def make_umi2axil(net):
dw = 64
aw = 64
cw = 32
Expand All @@ -165,14 +167,16 @@ def make_umi2axil(args):

resets = ['nreset']

dut = SbDut('umi2axilite', autowrap=True, parameters=parameters, interfaces=interfaces,
resets=resets, args=args)
dut = net.make_dut('umi2axilite', parameters=parameters,
interfaces=interfaces, resets=resets)

dut.use(umi)
dut.add('option', 'library', 'umi')
dut.add('option', 'library', 'lambdalib_stdlib')
dut.add('option', 'library', 'lambdalib_ramlib')

dut.input('utils/rtl/umi2axilite.v', package='umi')

return dut


Expand Down
2 changes: 1 addition & 1 deletion examples/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Examples dependencies
umi @ git+https://github.com/zeroasiccorp/umi.git@f6d8fea9e6270b89a2c38860a4af512383cbc6ef
umi @ git+https://github.com/zeroasiccorp/umi.git@main
2 changes: 2 additions & 0 deletions examples/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
['minimal', 'PASS!', 'verilator'],
['network', None, 'verilator'],
['network', None, 'icarus'],
['network', None, 'verilator-single-netlist'],
['network', None, 'icarus-single-netlist'],
['python', 'PASS!', None],
['router', 'PASS!', None],
['stream', 'PASS!', None],
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from setuptools import setup, find_packages
from pybind11.setup_helpers import Pybind11Extension, build_ext

__version__ = "0.2.1"
__version__ = "0.2.2"

#################################################################################
# parse_reqs, long_desc from https://github.com/siliconcompiler/siliconcompiler #
Expand Down
Loading