switchboard-hw 0.3.0__cp314-cp314-macosx_11_0_arm64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- _switchboard.cpython-314-darwin.so +0 -0
- switchboard/__init__.py +24 -0
- switchboard/ams.py +668 -0
- switchboard/apb.py +278 -0
- switchboard/autowrap.py +1000 -0
- switchboard/axi.py +571 -0
- switchboard/axil.py +348 -0
- switchboard/bitvector.py +112 -0
- switchboard/cmdline.py +142 -0
- switchboard/cpp/Makefile +13 -0
- switchboard/cpp/bitutil.h +39 -0
- switchboard/cpp/pagemap.h +91 -0
- switchboard/cpp/pciedev.h +86 -0
- switchboard/cpp/router.cc +89 -0
- switchboard/cpp/spsc_queue.h +267 -0
- switchboard/cpp/switchboard.hpp +257 -0
- switchboard/cpp/switchboard_pcie.hpp +234 -0
- switchboard/cpp/switchboard_tlm.hpp +98 -0
- switchboard/cpp/umilib.h +144 -0
- switchboard/cpp/umilib.hpp +113 -0
- switchboard/cpp/umisb.hpp +364 -0
- switchboard/cpp/xyce.hpp +90 -0
- switchboard/deps/__init__.py +0 -0
- switchboard/deps/verilog_axi.py +23 -0
- switchboard/dpi/__init__.py +0 -0
- switchboard/dpi/switchboard_dpi.cc +119 -0
- switchboard/dpi/switchboard_dpi.py +13 -0
- switchboard/dpi/xyce_dpi.cc +43 -0
- switchboard/gpio.py +108 -0
- switchboard/icarus.py +85 -0
- switchboard/loopback.py +157 -0
- switchboard/network.py +714 -0
- switchboard/pytest_plugin.py +11 -0
- switchboard/sbdesign.py +55 -0
- switchboard/sbdut.py +744 -0
- switchboard/sbtcp.py +345 -0
- switchboard/sc/__init__.py +0 -0
- switchboard/sc/morty/__init__.py +0 -0
- switchboard/sc/morty/uniquify.py +67 -0
- switchboard/sc/sed/__init__.py +0 -0
- switchboard/sc/sed/sed_remove.py +47 -0
- switchboard/sc/standalone_netlist_flow.py +25 -0
- switchboard/switchboard.py +53 -0
- switchboard/test_util.py +46 -0
- switchboard/uart_xactor.py +66 -0
- switchboard/umi.py +793 -0
- switchboard/util.py +131 -0
- switchboard/verilator/__init__.py +0 -0
- switchboard/verilator/config.vlt +13 -0
- switchboard/verilator/testbench.cc +143 -0
- switchboard/verilator/verilator.py +13 -0
- switchboard/verilator_run.py +31 -0
- switchboard/verilog/__init__.py +0 -0
- switchboard/verilog/common/__init__.py +0 -0
- switchboard/verilog/common/common.py +26 -0
- switchboard/verilog/common/switchboard.vh +429 -0
- switchboard/verilog/common/uart_xactor.sv +247 -0
- switchboard/verilog/common/umi_gpio.v +236 -0
- switchboard/verilog/fpga/__init__.py +0 -0
- switchboard/verilog/fpga/axi_reader.sv +82 -0
- switchboard/verilog/fpga/axi_writer.sv +111 -0
- switchboard/verilog/fpga/config_registers.sv +249 -0
- switchboard/verilog/fpga/fpga.py +21 -0
- switchboard/verilog/fpga/include/sb_queue_regmap.vh +21 -0
- switchboard/verilog/fpga/include/spsc_queue.vh +7 -0
- switchboard/verilog/fpga/memory_fault.sv +40 -0
- switchboard/verilog/fpga/sb_fpga_queues.sv +416 -0
- switchboard/verilog/fpga/sb_rx_fpga.sv +303 -0
- switchboard/verilog/fpga/sb_tx_fpga.sv +294 -0
- switchboard/verilog/fpga/umi_fpga_queues.sv +146 -0
- switchboard/verilog/sim/__init__.py +0 -0
- switchboard/verilog/sim/auto_stop_sim.sv +25 -0
- switchboard/verilog/sim/perf_meas_sim.sv +97 -0
- switchboard/verilog/sim/queue_to_sb_sim.sv +176 -0
- switchboard/verilog/sim/queue_to_umi_sim.sv +66 -0
- switchboard/verilog/sim/sb_apb_m.sv +146 -0
- switchboard/verilog/sim/sb_axi_m.sv +199 -0
- switchboard/verilog/sim/sb_axil_m.sv +180 -0
- switchboard/verilog/sim/sb_axil_s.sv +180 -0
- switchboard/verilog/sim/sb_clk_gen.sv +89 -0
- switchboard/verilog/sim/sb_jtag_rbb_sim.sv +148 -0
- switchboard/verilog/sim/sb_rx_sim.sv +55 -0
- switchboard/verilog/sim/sb_to_queue_sim.sv +196 -0
- switchboard/verilog/sim/sb_tx_sim.sv +55 -0
- switchboard/verilog/sim/switchboard_sim.py +49 -0
- switchboard/verilog/sim/umi_rx_sim.sv +61 -0
- switchboard/verilog/sim/umi_to_queue_sim.sv +66 -0
- switchboard/verilog/sim/umi_tx_sim.sv +61 -0
- switchboard/verilog/sim/xyce_intf.sv +67 -0
- switchboard/vpi/switchboard_vpi.cc +431 -0
- switchboard/vpi/xyce_vpi.cc +200 -0
- switchboard/warn.py +14 -0
- switchboard/xyce.py +27 -0
- switchboard_hw-0.3.0.dist-info/METADATA +303 -0
- switchboard_hw-0.3.0.dist-info/RECORD +99 -0
- switchboard_hw-0.3.0.dist-info/WHEEL +6 -0
- switchboard_hw-0.3.0.dist-info/entry_points.txt +6 -0
- switchboard_hw-0.3.0.dist-info/licenses/LICENSE +190 -0
- switchboard_hw-0.3.0.dist-info/top_level.txt +2 -0
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
// Copyright (c) 2024 Zero ASIC Corporation
|
|
2
|
+
// This code is licensed under Apache License 2.0 (see LICENSE for details)
|
|
3
|
+
|
|
4
|
+
`default_nettype none
|
|
5
|
+
|
|
6
|
+
module sb_axil_m #(
|
|
7
|
+
// AXI settings
|
|
8
|
+
parameter DATA_WIDTH = 32,
|
|
9
|
+
parameter ADDR_WIDTH = 16,
|
|
10
|
+
parameter STRB_WIDTH = (DATA_WIDTH/8),
|
|
11
|
+
|
|
12
|
+
// Switchboard settings
|
|
13
|
+
parameter integer VALID_MODE_DEFAULT=1,
|
|
14
|
+
parameter integer READY_MODE_DEFAULT=1,
|
|
15
|
+
parameter FILE=""
|
|
16
|
+
) (
|
|
17
|
+
input wire clk,
|
|
18
|
+
input wire reset,
|
|
19
|
+
|
|
20
|
+
// AXI lite master interface
|
|
21
|
+
// adapted from https://github.com/alexforencich/verilog-axi
|
|
22
|
+
output wire [ADDR_WIDTH-1:0] m_axil_awaddr,
|
|
23
|
+
output wire [2:0] m_axil_awprot,
|
|
24
|
+
output wire m_axil_awvalid,
|
|
25
|
+
input wire m_axil_awready,
|
|
26
|
+
output wire [DATA_WIDTH-1:0] m_axil_wdata,
|
|
27
|
+
output wire [STRB_WIDTH-1:0] m_axil_wstrb,
|
|
28
|
+
output wire m_axil_wvalid,
|
|
29
|
+
input wire m_axil_wready,
|
|
30
|
+
input wire [1:0] m_axil_bresp,
|
|
31
|
+
input wire m_axil_bvalid,
|
|
32
|
+
output wire m_axil_bready,
|
|
33
|
+
output wire [ADDR_WIDTH-1:0] m_axil_araddr,
|
|
34
|
+
output wire [2:0] m_axil_arprot,
|
|
35
|
+
output wire m_axil_arvalid,
|
|
36
|
+
input wire m_axil_arready,
|
|
37
|
+
input wire [DATA_WIDTH-1:0] m_axil_rdata,
|
|
38
|
+
input wire [1:0] m_axil_rresp,
|
|
39
|
+
input wire m_axil_rvalid,
|
|
40
|
+
output wire m_axil_rready
|
|
41
|
+
);
|
|
42
|
+
// AW channel
|
|
43
|
+
|
|
44
|
+
queue_to_sb_sim #(
|
|
45
|
+
.VALID_MODE_DEFAULT(VALID_MODE_DEFAULT),
|
|
46
|
+
.DW(ADDR_WIDTH + 3)
|
|
47
|
+
) aw_channel (
|
|
48
|
+
.clk(clk),
|
|
49
|
+
.reset(reset),
|
|
50
|
+
.data({m_axil_awprot, m_axil_awaddr}),
|
|
51
|
+
.dest(),
|
|
52
|
+
.last(),
|
|
53
|
+
.valid(m_axil_awvalid),
|
|
54
|
+
.ready(m_axil_awready)
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
// W channel
|
|
58
|
+
|
|
59
|
+
queue_to_sb_sim #(
|
|
60
|
+
.VALID_MODE_DEFAULT(VALID_MODE_DEFAULT),
|
|
61
|
+
.DW(DATA_WIDTH + STRB_WIDTH)
|
|
62
|
+
) w_channel (
|
|
63
|
+
.clk(clk),
|
|
64
|
+
.reset(reset),
|
|
65
|
+
.data({m_axil_wstrb, m_axil_wdata}),
|
|
66
|
+
.dest(),
|
|
67
|
+
.last(),
|
|
68
|
+
.valid(m_axil_wvalid),
|
|
69
|
+
.ready(m_axil_wready)
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
// B channel
|
|
73
|
+
|
|
74
|
+
sb_to_queue_sim #(
|
|
75
|
+
.READY_MODE_DEFAULT(READY_MODE_DEFAULT),
|
|
76
|
+
.DW(2)
|
|
77
|
+
) b_channel (
|
|
78
|
+
.clk(clk),
|
|
79
|
+
.reset(reset),
|
|
80
|
+
.data(m_axil_bresp),
|
|
81
|
+
.dest(),
|
|
82
|
+
.last(),
|
|
83
|
+
.valid(m_axil_bvalid),
|
|
84
|
+
.ready(m_axil_bready)
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
// AR channel
|
|
88
|
+
|
|
89
|
+
queue_to_sb_sim #(
|
|
90
|
+
.VALID_MODE_DEFAULT(VALID_MODE_DEFAULT),
|
|
91
|
+
.DW(ADDR_WIDTH + 3)
|
|
92
|
+
) ar_channel (
|
|
93
|
+
.clk(clk),
|
|
94
|
+
.reset(reset),
|
|
95
|
+
.data({m_axil_arprot, m_axil_araddr}),
|
|
96
|
+
.dest(),
|
|
97
|
+
.last(),
|
|
98
|
+
.valid(m_axil_arvalid),
|
|
99
|
+
.ready(m_axil_arready)
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
// R channel
|
|
103
|
+
|
|
104
|
+
sb_to_queue_sim #(
|
|
105
|
+
.READY_MODE_DEFAULT(READY_MODE_DEFAULT),
|
|
106
|
+
.DW(DATA_WIDTH + 2)
|
|
107
|
+
) r_channel (
|
|
108
|
+
.clk(clk),
|
|
109
|
+
.reset(reset),
|
|
110
|
+
.data({m_axil_rresp, m_axil_rdata}),
|
|
111
|
+
.dest(),
|
|
112
|
+
.last(),
|
|
113
|
+
.valid(m_axil_rvalid),
|
|
114
|
+
.ready(m_axil_rready)
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
// handle differences between simulators
|
|
118
|
+
|
|
119
|
+
`ifdef __ICARUS__
|
|
120
|
+
`define SB_START_FUNC task
|
|
121
|
+
`define SB_END_FUNC endtask
|
|
122
|
+
`else
|
|
123
|
+
`define SB_START_FUNC function void
|
|
124
|
+
`define SB_END_FUNC endfunction
|
|
125
|
+
`endif
|
|
126
|
+
|
|
127
|
+
`SB_START_FUNC init(input string uri);
|
|
128
|
+
string s;
|
|
129
|
+
|
|
130
|
+
/* verilator lint_off IGNOREDRETURN */
|
|
131
|
+
$sformat(s, "%0s-aw.q", uri);
|
|
132
|
+
aw_channel.init(s);
|
|
133
|
+
|
|
134
|
+
$sformat(s, "%0s-w.q", uri);
|
|
135
|
+
w_channel.init(s);
|
|
136
|
+
|
|
137
|
+
$sformat(s, "%0s-b.q", uri);
|
|
138
|
+
b_channel.init(s);
|
|
139
|
+
|
|
140
|
+
$sformat(s, "%0s-ar.q", uri);
|
|
141
|
+
ar_channel.init(s);
|
|
142
|
+
|
|
143
|
+
$sformat(s, "%0s-r.q", uri);
|
|
144
|
+
r_channel.init(s);
|
|
145
|
+
/* verilator lint_on IGNOREDRETURN */
|
|
146
|
+
`SB_END_FUNC
|
|
147
|
+
|
|
148
|
+
`SB_START_FUNC set_valid_mode(input integer value);
|
|
149
|
+
/* verilator lint_off IGNOREDRETURN */
|
|
150
|
+
aw_channel.set_valid_mode(value);
|
|
151
|
+
w_channel.set_valid_mode(value);
|
|
152
|
+
ar_channel.set_valid_mode(value);
|
|
153
|
+
/* verilator lint_on IGNOREDRETURN */
|
|
154
|
+
`SB_END_FUNC
|
|
155
|
+
|
|
156
|
+
`SB_START_FUNC set_ready_mode(input integer value);
|
|
157
|
+
/* verilator lint_off IGNOREDRETURN */
|
|
158
|
+
b_channel.set_ready_mode(value);
|
|
159
|
+
r_channel.set_ready_mode(value);
|
|
160
|
+
/* verilator lint_on IGNOREDRETURN */
|
|
161
|
+
`SB_END_FUNC
|
|
162
|
+
|
|
163
|
+
// initialize
|
|
164
|
+
|
|
165
|
+
initial begin
|
|
166
|
+
if (FILE != "") begin
|
|
167
|
+
/* verilator lint_off IGNOREDRETURN */
|
|
168
|
+
init(FILE);
|
|
169
|
+
/* verilator lint_on IGNOREDRETURN */
|
|
170
|
+
end
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
// clean up macros
|
|
174
|
+
|
|
175
|
+
`undef SB_START_FUNC
|
|
176
|
+
`undef SB_END_FUNC
|
|
177
|
+
|
|
178
|
+
endmodule
|
|
179
|
+
|
|
180
|
+
`default_nettype wire
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
// Copyright (c) 2024 Zero ASIC Corporation
|
|
2
|
+
// This code is licensed under Apache License 2.0 (see LICENSE for details)
|
|
3
|
+
|
|
4
|
+
`default_nettype none
|
|
5
|
+
|
|
6
|
+
module sb_axil_s #(
|
|
7
|
+
// AXI settings
|
|
8
|
+
parameter DATA_WIDTH = 32,
|
|
9
|
+
parameter ADDR_WIDTH = 16,
|
|
10
|
+
parameter STRB_WIDTH = (DATA_WIDTH/8),
|
|
11
|
+
|
|
12
|
+
// Switchboard settings
|
|
13
|
+
parameter integer VALID_MODE_DEFAULT=1,
|
|
14
|
+
parameter integer READY_MODE_DEFAULT=1,
|
|
15
|
+
parameter FILE=""
|
|
16
|
+
) (
|
|
17
|
+
input wire clk,
|
|
18
|
+
input wire reset,
|
|
19
|
+
|
|
20
|
+
// AXI lite master interface
|
|
21
|
+
// adapted from https://github.com/alexforencich/verilog-axi
|
|
22
|
+
input wire [ADDR_WIDTH-1:0] s_axil_awaddr,
|
|
23
|
+
input wire [2:0] s_axil_awprot,
|
|
24
|
+
input wire s_axil_awvalid,
|
|
25
|
+
output wire s_axil_awready,
|
|
26
|
+
input wire [DATA_WIDTH-1:0] s_axil_wdata,
|
|
27
|
+
input wire [STRB_WIDTH-1:0] s_axil_wstrb,
|
|
28
|
+
input wire s_axil_wvalid,
|
|
29
|
+
output wire s_axil_wready,
|
|
30
|
+
output wire [1:0] s_axil_bresp,
|
|
31
|
+
output wire s_axil_bvalid,
|
|
32
|
+
input wire s_axil_bready,
|
|
33
|
+
input wire [ADDR_WIDTH-1:0] s_axil_araddr,
|
|
34
|
+
input wire [2:0] s_axil_arprot,
|
|
35
|
+
input wire s_axil_arvalid,
|
|
36
|
+
output wire s_axil_arready,
|
|
37
|
+
output wire [DATA_WIDTH-1:0] s_axil_rdata,
|
|
38
|
+
output wire [1:0] s_axil_rresp,
|
|
39
|
+
output wire s_axil_rvalid,
|
|
40
|
+
input wire s_axil_rready
|
|
41
|
+
);
|
|
42
|
+
// AW channel
|
|
43
|
+
|
|
44
|
+
sb_to_queue_sim #(
|
|
45
|
+
.READY_MODE_DEFAULT(READY_MODE_DEFAULT),
|
|
46
|
+
.DW(ADDR_WIDTH + 3)
|
|
47
|
+
) aw_channel (
|
|
48
|
+
.clk(clk),
|
|
49
|
+
.reset(reset),
|
|
50
|
+
.data({s_axil_awprot, s_axil_awaddr}),
|
|
51
|
+
.dest(),
|
|
52
|
+
.last(),
|
|
53
|
+
.valid(s_axil_awvalid),
|
|
54
|
+
.ready(s_axil_awready)
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
// W channel
|
|
58
|
+
|
|
59
|
+
sb_to_queue_sim #(
|
|
60
|
+
.READY_MODE_DEFAULT(READY_MODE_DEFAULT),
|
|
61
|
+
.DW(DATA_WIDTH + STRB_WIDTH)
|
|
62
|
+
) w_channel (
|
|
63
|
+
.clk(clk),
|
|
64
|
+
.reset(reset),
|
|
65
|
+
.data({s_axil_wstrb, s_axil_wdata}),
|
|
66
|
+
.dest(),
|
|
67
|
+
.last(),
|
|
68
|
+
.valid(s_axil_wvalid),
|
|
69
|
+
.ready(s_axil_wready)
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
// B channel
|
|
73
|
+
|
|
74
|
+
queue_to_sb_sim #(
|
|
75
|
+
.VALID_MODE_DEFAULT(VALID_MODE_DEFAULT),
|
|
76
|
+
.DW(2)
|
|
77
|
+
) b_channel (
|
|
78
|
+
.clk(clk),
|
|
79
|
+
.reset(reset),
|
|
80
|
+
.data(s_axil_bresp),
|
|
81
|
+
.dest(),
|
|
82
|
+
.last(),
|
|
83
|
+
.valid(s_axil_bvalid),
|
|
84
|
+
.ready(s_axil_bready)
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
// AR channel
|
|
88
|
+
|
|
89
|
+
sb_to_queue_sim #(
|
|
90
|
+
.READY_MODE_DEFAULT(READY_MODE_DEFAULT),
|
|
91
|
+
.DW(ADDR_WIDTH + 3)
|
|
92
|
+
) ar_channel (
|
|
93
|
+
.clk(clk),
|
|
94
|
+
.reset(reset),
|
|
95
|
+
.data({s_axil_arprot, s_axil_araddr}),
|
|
96
|
+
.dest(),
|
|
97
|
+
.last(),
|
|
98
|
+
.valid(s_axil_arvalid),
|
|
99
|
+
.ready(s_axil_arready)
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
// R channel
|
|
103
|
+
|
|
104
|
+
queue_to_sb_sim #(
|
|
105
|
+
.VALID_MODE_DEFAULT(VALID_MODE_DEFAULT),
|
|
106
|
+
.DW(DATA_WIDTH + 2)
|
|
107
|
+
) r_channel (
|
|
108
|
+
.clk(clk),
|
|
109
|
+
.reset(reset),
|
|
110
|
+
.data({s_axil_rresp, s_axil_rdata}),
|
|
111
|
+
.dest(),
|
|
112
|
+
.last(),
|
|
113
|
+
.valid(s_axil_rvalid),
|
|
114
|
+
.ready(s_axil_rready)
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
// handle differences between simulators
|
|
118
|
+
|
|
119
|
+
`ifdef __ICARUS__
|
|
120
|
+
`define SB_START_FUNC task
|
|
121
|
+
`define SB_END_FUNC endtask
|
|
122
|
+
`else
|
|
123
|
+
`define SB_START_FUNC function void
|
|
124
|
+
`define SB_END_FUNC endfunction
|
|
125
|
+
`endif
|
|
126
|
+
|
|
127
|
+
`SB_START_FUNC init(input string uri);
|
|
128
|
+
string s;
|
|
129
|
+
|
|
130
|
+
/* verilator lint_off IGNOREDRETURN */
|
|
131
|
+
$sformat(s, "%0s-aw.q", uri);
|
|
132
|
+
aw_channel.init(s);
|
|
133
|
+
|
|
134
|
+
$sformat(s, "%0s-w.q", uri);
|
|
135
|
+
w_channel.init(s);
|
|
136
|
+
|
|
137
|
+
$sformat(s, "%0s-b.q", uri);
|
|
138
|
+
b_channel.init(s);
|
|
139
|
+
|
|
140
|
+
$sformat(s, "%0s-ar.q", uri);
|
|
141
|
+
ar_channel.init(s);
|
|
142
|
+
|
|
143
|
+
$sformat(s, "%0s-r.q", uri);
|
|
144
|
+
r_channel.init(s);
|
|
145
|
+
/* verilator lint_on IGNOREDRETURN */
|
|
146
|
+
`SB_END_FUNC
|
|
147
|
+
|
|
148
|
+
`SB_START_FUNC set_valid_mode(input integer value);
|
|
149
|
+
/* verilator lint_off IGNOREDRETURN */
|
|
150
|
+
b_channel.set_valid_mode(value);
|
|
151
|
+
r_channel.set_valid_mode(value);
|
|
152
|
+
/* verilator lint_on IGNOREDRETURN */
|
|
153
|
+
`SB_END_FUNC
|
|
154
|
+
|
|
155
|
+
`SB_START_FUNC set_ready_mode(input integer value);
|
|
156
|
+
/* verilator lint_off IGNOREDRETURN */
|
|
157
|
+
aw_channel.set_ready_mode(value);
|
|
158
|
+
w_channel.set_ready_mode(value);
|
|
159
|
+
ar_channel.set_ready_mode(value);
|
|
160
|
+
/* verilator lint_on IGNOREDRETURN */
|
|
161
|
+
`SB_END_FUNC
|
|
162
|
+
|
|
163
|
+
// initialize
|
|
164
|
+
|
|
165
|
+
initial begin
|
|
166
|
+
if (FILE != "") begin
|
|
167
|
+
/* verilator lint_off IGNOREDRETURN */
|
|
168
|
+
init(FILE);
|
|
169
|
+
/* verilator lint_on IGNOREDRETURN */
|
|
170
|
+
end
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
// clean up macros
|
|
174
|
+
|
|
175
|
+
`undef SB_START_FUNC
|
|
176
|
+
`undef SB_END_FUNC
|
|
177
|
+
|
|
178
|
+
endmodule
|
|
179
|
+
|
|
180
|
+
`default_nettype wire
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// Module for generating a simulation clock, needed for non-Verilator simulations
|
|
2
|
+
|
|
3
|
+
// Copyright (c) 2024 Zero ASIC Corporation
|
|
4
|
+
// This code is licensed under Apache License 2.0 (see LICENSE for details)
|
|
5
|
+
|
|
6
|
+
module sb_clk_gen #(
|
|
7
|
+
parameter real DEFAULT_PERIOD = 10e-9,
|
|
8
|
+
parameter real DEFAULT_DUTY_CYCLE = 0.5,
|
|
9
|
+
parameter real DEFAULT_MAX_RATE = -1,
|
|
10
|
+
parameter real DEFAULT_START_DELAY = -1
|
|
11
|
+
) (
|
|
12
|
+
output wire clk
|
|
13
|
+
);
|
|
14
|
+
// configure timing
|
|
15
|
+
|
|
16
|
+
`ifdef SB_XYCE
|
|
17
|
+
timeunit 1s;
|
|
18
|
+
timeprecision 1fs;
|
|
19
|
+
`define SB_DELAY(t) #(t)
|
|
20
|
+
`else
|
|
21
|
+
timeunit 1ns;
|
|
22
|
+
timeprecision 1ns;
|
|
23
|
+
`define SB_DELAY(t) #((t)*1e9)
|
|
24
|
+
`endif
|
|
25
|
+
|
|
26
|
+
// import external functions
|
|
27
|
+
|
|
28
|
+
`ifdef __ICARUS__
|
|
29
|
+
`define SB_EXT_FUNC(x) $``x``
|
|
30
|
+
`else
|
|
31
|
+
`define SB_EXT_FUNC(x) x
|
|
32
|
+
|
|
33
|
+
import "DPI-C" function void pi_start_delay (
|
|
34
|
+
input real value
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
import "DPI-C" function void pi_max_rate_tick (
|
|
38
|
+
inout signed [63:0] t_us,
|
|
39
|
+
input signed [63:0] min_period_us
|
|
40
|
+
);
|
|
41
|
+
`endif
|
|
42
|
+
|
|
43
|
+
// read in command-line arguments
|
|
44
|
+
|
|
45
|
+
real period = DEFAULT_PERIOD;
|
|
46
|
+
real duty_cycle = DEFAULT_DUTY_CYCLE;
|
|
47
|
+
real max_rate = DEFAULT_MAX_RATE;
|
|
48
|
+
real start_delay = DEFAULT_START_DELAY;
|
|
49
|
+
|
|
50
|
+
reg signed [63:0] t_us = -(64'sd1);
|
|
51
|
+
reg signed [63:0] min_period_us = -(64'sd1);
|
|
52
|
+
|
|
53
|
+
initial begin
|
|
54
|
+
void'($value$plusargs("period=%f", period));
|
|
55
|
+
void'($value$plusargs("duty-cycle=%f", duty_cycle));
|
|
56
|
+
void'($value$plusargs("start-delay=%f", start_delay));
|
|
57
|
+
|
|
58
|
+
void'($value$plusargs("max-rate=%f", max_rate));
|
|
59
|
+
|
|
60
|
+
if (max_rate > 0) begin
|
|
61
|
+
min_period_us = 1.0e6 / max_rate; // rounds according to LRM
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
// main clock generation code
|
|
66
|
+
|
|
67
|
+
reg clk_r;
|
|
68
|
+
assign clk = clk_r;
|
|
69
|
+
|
|
70
|
+
initial begin
|
|
71
|
+
`SB_EXT_FUNC(pi_start_delay)(start_delay);
|
|
72
|
+
|
|
73
|
+
forever begin
|
|
74
|
+
`SB_EXT_FUNC(pi_max_rate_tick)(t_us, min_period_us);
|
|
75
|
+
|
|
76
|
+
clk_r = 1'b0;
|
|
77
|
+
`SB_DELAY((1.0 - duty_cycle) * period);
|
|
78
|
+
|
|
79
|
+
clk_r = 1'b1;
|
|
80
|
+
`SB_DELAY(duty_cycle * period);
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
// clean up macros
|
|
85
|
+
|
|
86
|
+
`undef SB_EXT_FUNC
|
|
87
|
+
`undef SB_DELAY
|
|
88
|
+
|
|
89
|
+
endmodule
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
// Copyright (c) 2024 Zero ASIC Corporation
|
|
2
|
+
// This code is licensed under Apache License 2.0 (see LICENSE for details)
|
|
3
|
+
|
|
4
|
+
`default_nettype none
|
|
5
|
+
|
|
6
|
+
module sb_jtag_rbb_sim (
|
|
7
|
+
input clk,
|
|
8
|
+
input rst,
|
|
9
|
+
output tck,
|
|
10
|
+
output tms,
|
|
11
|
+
output tdi,
|
|
12
|
+
input tdo,
|
|
13
|
+
output trst,
|
|
14
|
+
output srst,
|
|
15
|
+
output reg led=1'b0
|
|
16
|
+
);
|
|
17
|
+
`ifdef __ICARUS__
|
|
18
|
+
`define SB_EXT_FUNC(x) $``x``
|
|
19
|
+
`define SB_START_FUNC task
|
|
20
|
+
`define SB_END_FUNC endtask
|
|
21
|
+
`define SB_VAR_BIT reg
|
|
22
|
+
`else
|
|
23
|
+
`define SB_EXT_FUNC(x) x
|
|
24
|
+
`define SB_START_FUNC function void
|
|
25
|
+
`define SB_END_FUNC endfunction
|
|
26
|
+
`define SB_VAR_BIT var bit
|
|
27
|
+
|
|
28
|
+
import "DPI-C" function void pi_sb_rx_init(output int id, input string uri);
|
|
29
|
+
import "DPI-C" function void pi_sb_recv(input int id, output bit [255:0] rdata,
|
|
30
|
+
output bit [31:0] rdest, output bit rlast, output int success);
|
|
31
|
+
|
|
32
|
+
import "DPI-C" function void pi_sb_tx_init (output int id, input string uri);
|
|
33
|
+
import "DPI-C" function void pi_sb_send (input int id, input bit [255:0] sdata,
|
|
34
|
+
input bit [31:0] sdest, input bit slast, output int success);
|
|
35
|
+
`endif
|
|
36
|
+
|
|
37
|
+
// SB DPI/VPI interface
|
|
38
|
+
|
|
39
|
+
integer rxid=-1;
|
|
40
|
+
integer txid=-1;
|
|
41
|
+
|
|
42
|
+
`SB_START_FUNC init(input string rxuri, input string txuri);
|
|
43
|
+
/* verilator lint_off IGNOREDRETURN */
|
|
44
|
+
`SB_EXT_FUNC(pi_sb_rx_init)(rxid, rxuri);
|
|
45
|
+
`SB_EXT_FUNC(pi_sb_tx_init)(txid, txuri);
|
|
46
|
+
/* verilator lint_on IGNOREDRETURN */
|
|
47
|
+
`SB_END_FUNC
|
|
48
|
+
|
|
49
|
+
`SB_VAR_BIT [255:0] sdata;
|
|
50
|
+
`SB_VAR_BIT [31:0] sdest;
|
|
51
|
+
`SB_VAR_BIT slast;
|
|
52
|
+
|
|
53
|
+
`SB_VAR_BIT [255:0] rdata;
|
|
54
|
+
`SB_VAR_BIT [31:0] rdest;
|
|
55
|
+
`SB_VAR_BIT rlast;
|
|
56
|
+
|
|
57
|
+
// initialize
|
|
58
|
+
|
|
59
|
+
integer r_success = 0;
|
|
60
|
+
integer s_success = 0;
|
|
61
|
+
|
|
62
|
+
initial begin
|
|
63
|
+
sdata = 256'd0;
|
|
64
|
+
sdest = 32'd0;
|
|
65
|
+
slast = 1'b1;
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
// main logic
|
|
69
|
+
|
|
70
|
+
reg [31:0] read_count = 32'd0;
|
|
71
|
+
|
|
72
|
+
// convenient to group these together,
|
|
73
|
+
// so that the output value can be computed
|
|
74
|
+
// from the incoming ASCII command
|
|
75
|
+
|
|
76
|
+
reg [2:0] tck_tms_tdi = 3'b011;
|
|
77
|
+
assign tck = tck_tms_tdi[2];
|
|
78
|
+
assign tms = tck_tms_tdi[1];
|
|
79
|
+
assign tdi = tck_tms_tdi[0];
|
|
80
|
+
|
|
81
|
+
reg [1:0] trst_srst = 2'b11;
|
|
82
|
+
assign trst = trst_srst[1];
|
|
83
|
+
assign srst = trst_srst[0];
|
|
84
|
+
|
|
85
|
+
always @(posedge clk) begin
|
|
86
|
+
if (rst) begin
|
|
87
|
+
// external pins
|
|
88
|
+
tck_tms_tdi <= 3'b011;
|
|
89
|
+
trst_srst <= 2'b11;
|
|
90
|
+
led <= 1'b0;
|
|
91
|
+
|
|
92
|
+
// internal state
|
|
93
|
+
read_count <= 32'd0;
|
|
94
|
+
end else begin
|
|
95
|
+
// write output value
|
|
96
|
+
if (read_count > 0) begin
|
|
97
|
+
sdata[7:0] = tdo ? "1" : "0"; // intended to be blocking
|
|
98
|
+
if (txid != -1) begin
|
|
99
|
+
`SB_EXT_FUNC(pi_sb_send)(txid, sdata, sdest, slast, s_success);
|
|
100
|
+
end else begin
|
|
101
|
+
s_success = 32'd0;
|
|
102
|
+
end
|
|
103
|
+
if (s_success == 32'd1) begin
|
|
104
|
+
read_count <= read_count - 1;
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
// get next command as long as long as it
|
|
109
|
+
// couldn't overflow the read counter
|
|
110
|
+
if (read_count < 32'h7fffffff) begin
|
|
111
|
+
if (rxid != -1) begin
|
|
112
|
+
`SB_EXT_FUNC(pi_sb_recv)(rxid, rdata, rdest, rlast, r_success);
|
|
113
|
+
end else begin
|
|
114
|
+
r_success = 32'd0;
|
|
115
|
+
end
|
|
116
|
+
if (r_success == 32'd1) begin
|
|
117
|
+
if (rdata[7:0] == "B") begin
|
|
118
|
+
led <= 1'b1;
|
|
119
|
+
end else if (rdata[7:0] == "b") begin
|
|
120
|
+
led <= 1'b0;
|
|
121
|
+
end else if (rdata[7:0] == "R") begin
|
|
122
|
+
read_count <= read_count + 32'd1;
|
|
123
|
+
end else if (rdata[7:0] == "Q") begin
|
|
124
|
+
// TODO: quit
|
|
125
|
+
end else if (("0" <= rdata[7:0]) && (rdata[7:0] <= "7")) begin
|
|
126
|
+
/* verilator lint_off WIDTH */
|
|
127
|
+
tck_tms_tdi <= {rdata[7:0] - "0"};
|
|
128
|
+
/* verilator lint_on WIDTH */
|
|
129
|
+
end else if (("r" <= rdata[7:0]) && (rdata[7:0] <= "u")) begin
|
|
130
|
+
/* verilator lint_off WIDTH */
|
|
131
|
+
trst_srst <= {rdata[7:0] - "r"};
|
|
132
|
+
/* verilator lint_on WIDTH */
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
// clean up macros
|
|
140
|
+
|
|
141
|
+
`undef SB_EXT_FUNC
|
|
142
|
+
`undef SB_START_FUNC
|
|
143
|
+
`undef SB_END_FUNC
|
|
144
|
+
`undef SB_VAR_BIT
|
|
145
|
+
|
|
146
|
+
endmodule
|
|
147
|
+
|
|
148
|
+
`default_nettype wire
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// Wrapper module for backwards compatibility (will eventually be removed)
|
|
2
|
+
|
|
3
|
+
// Copyright (c) 2024 Zero ASIC Corporation
|
|
4
|
+
// This code is licensed under Apache License 2.0 (see LICENSE for details)
|
|
5
|
+
|
|
6
|
+
`default_nettype none
|
|
7
|
+
|
|
8
|
+
module sb_rx_sim #(
|
|
9
|
+
parameter integer VALID_MODE_DEFAULT=0,
|
|
10
|
+
parameter integer DW=416,
|
|
11
|
+
parameter FILE=""
|
|
12
|
+
) (
|
|
13
|
+
input clk,
|
|
14
|
+
output [DW-1:0] data,
|
|
15
|
+
output [31:0] dest,
|
|
16
|
+
output last,
|
|
17
|
+
input ready,
|
|
18
|
+
output valid
|
|
19
|
+
);
|
|
20
|
+
`ifdef __ICARUS__
|
|
21
|
+
`define SB_START_FUNC task
|
|
22
|
+
`define SB_END_FUNC endtask
|
|
23
|
+
`else
|
|
24
|
+
`define SB_START_FUNC function void
|
|
25
|
+
`define SB_END_FUNC endfunction
|
|
26
|
+
`endif
|
|
27
|
+
|
|
28
|
+
queue_to_sb_sim #(
|
|
29
|
+
.VALID_MODE_DEFAULT(VALID_MODE_DEFAULT),
|
|
30
|
+
.DW(DW),
|
|
31
|
+
.FILE(FILE)
|
|
32
|
+
) rx_i (
|
|
33
|
+
.*
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
`SB_START_FUNC init(input string uri);
|
|
37
|
+
/* verilator lint_off IGNOREDRETURN */
|
|
38
|
+
rx_i.init(uri);
|
|
39
|
+
/* verilator lint_on IGNOREDRETURN */
|
|
40
|
+
`SB_END_FUNC
|
|
41
|
+
|
|
42
|
+
`SB_START_FUNC set_valid_mode(input integer value);
|
|
43
|
+
/* verilator lint_off IGNOREDRETURN */
|
|
44
|
+
rx_i.set_valid_mode(value);
|
|
45
|
+
/* verilator lint_on IGNOREDRETURN */
|
|
46
|
+
`SB_END_FUNC
|
|
47
|
+
|
|
48
|
+
// clean up macros
|
|
49
|
+
|
|
50
|
+
`undef SB_START_FUNC
|
|
51
|
+
`undef SB_END_FUNC
|
|
52
|
+
|
|
53
|
+
endmodule
|
|
54
|
+
|
|
55
|
+
`default_nettype wire
|