-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
841 additions
and
239 deletions.
There are no files selected for viewing
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
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
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 |
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
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 |
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
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() |
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
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
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
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 |
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
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
Oops, something went wrong.