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,176 @@
|
|
|
1
|
+
// queue_to_sb_sim
|
|
2
|
+
|
|
3
|
+
// valid_mode settings (in all cases, valid remains low if there is no incoming data)
|
|
4
|
+
// valid_mode=0: valid alternates between "0" and "1" if there is a continuous stream of incoming data
|
|
5
|
+
// valid_mode=1: valid remains at "1" if there is a continuous stream of incoming data
|
|
6
|
+
// valid_mode=2: valid toggles randomly if there is a continuous stream of incoming data
|
|
7
|
+
|
|
8
|
+
// Copyright (c) 2024 Zero ASIC Corporation
|
|
9
|
+
// This code is licensed under Apache License 2.0 (see LICENSE for details)
|
|
10
|
+
|
|
11
|
+
`default_nettype none
|
|
12
|
+
|
|
13
|
+
module queue_to_sb_sim #(
|
|
14
|
+
parameter integer VALID_MODE_DEFAULT=0,
|
|
15
|
+
parameter integer DW=416,
|
|
16
|
+
parameter FILE=""
|
|
17
|
+
) (
|
|
18
|
+
input clk,
|
|
19
|
+
input reset,
|
|
20
|
+
output [DW-1:0] data,
|
|
21
|
+
output reg [31:0] dest=32'b0,
|
|
22
|
+
output reg last=1'b0,
|
|
23
|
+
input ready,
|
|
24
|
+
output reg valid=1'b0
|
|
25
|
+
);
|
|
26
|
+
// SBDW value corresponds to UMI DW=256
|
|
27
|
+
// 32b (cmd) + 64b (srcaddr) + 64b (dstaddr) + 256b = 416b
|
|
28
|
+
|
|
29
|
+
// SBDW must be a multiple of 32 (constrained by VPI driver,
|
|
30
|
+
// which transfers data in 32-bit chunks)
|
|
31
|
+
localparam SBDW = 416;
|
|
32
|
+
|
|
33
|
+
`ifdef __ICARUS__
|
|
34
|
+
`define SB_EXT_FUNC(x) $``x``
|
|
35
|
+
`define SB_START_FUNC task
|
|
36
|
+
`define SB_END_FUNC endtask
|
|
37
|
+
`define SB_VAR_BIT reg
|
|
38
|
+
`else
|
|
39
|
+
`define SB_EXT_FUNC(x) x
|
|
40
|
+
`define SB_START_FUNC function void
|
|
41
|
+
`define SB_END_FUNC endfunction
|
|
42
|
+
`define SB_VAR_BIT var bit
|
|
43
|
+
|
|
44
|
+
import "DPI-C" function void pi_sb_rx_init(output int id,
|
|
45
|
+
input string uri, input int width);
|
|
46
|
+
import "DPI-C" function void pi_sb_recv(input int id, output bit [SBDW-1:0] rdata,
|
|
47
|
+
output bit [31:0] rdest, output bit rlast, output int success);
|
|
48
|
+
`endif
|
|
49
|
+
|
|
50
|
+
// internal signals
|
|
51
|
+
|
|
52
|
+
integer id = -1;
|
|
53
|
+
|
|
54
|
+
`SB_START_FUNC init(input string uri);
|
|
55
|
+
/* verilator lint_off IGNOREDRETURN */
|
|
56
|
+
`SB_EXT_FUNC(pi_sb_rx_init)(id, uri, (DW + 7)/8);
|
|
57
|
+
/* verilator lint_on IGNOREDRETURN */
|
|
58
|
+
`SB_END_FUNC
|
|
59
|
+
|
|
60
|
+
integer success = 0;
|
|
61
|
+
|
|
62
|
+
`SB_VAR_BIT [SBDW-1:0] rdata;
|
|
63
|
+
`SB_VAR_BIT [31:0] rdest;
|
|
64
|
+
`SB_VAR_BIT rlast;
|
|
65
|
+
|
|
66
|
+
`SB_VAR_BIT [SBDW-1:0] data_padded = 'b0;
|
|
67
|
+
assign data = data_padded[DW-1:0];
|
|
68
|
+
|
|
69
|
+
initial begin
|
|
70
|
+
rdata = 'b0;
|
|
71
|
+
rdest = 32'b0;
|
|
72
|
+
rlast = 1'b0;
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
// valid mode
|
|
76
|
+
|
|
77
|
+
integer valid_mode = VALID_MODE_DEFAULT;
|
|
78
|
+
|
|
79
|
+
`SB_START_FUNC set_valid_mode(input integer value);
|
|
80
|
+
/* verilator lint_off IGNOREDRETURN */
|
|
81
|
+
valid_mode = value;
|
|
82
|
+
/* verilator lint_on IGNOREDRETURN */
|
|
83
|
+
`SB_END_FUNC
|
|
84
|
+
|
|
85
|
+
// main logic
|
|
86
|
+
|
|
87
|
+
always @(posedge clk or posedge reset) begin
|
|
88
|
+
if (reset) begin
|
|
89
|
+
valid <= 1'b0;
|
|
90
|
+
last <= 1'b0;
|
|
91
|
+
end else begin
|
|
92
|
+
if (ready && valid) begin
|
|
93
|
+
// the transaction has completed, so we can try to get another
|
|
94
|
+
// packet if we want to. whether we try to do this or not depends
|
|
95
|
+
// on the valid_mode setting.
|
|
96
|
+
|
|
97
|
+
if ((valid_mode == 32'd1) ||
|
|
98
|
+
((valid_mode == 32'd2) && ($random % 2 == 32'd1))) begin
|
|
99
|
+
// try to receive a packet
|
|
100
|
+
if (id != -1) begin
|
|
101
|
+
/* verilator lint_off IGNOREDRETURN */
|
|
102
|
+
`SB_EXT_FUNC(pi_sb_recv)(id, rdata, rdest, rlast, success);
|
|
103
|
+
/* verilator lint_on IGNOREDRETURN */
|
|
104
|
+
end else begin
|
|
105
|
+
/* verilator lint_off BLKSEQ */
|
|
106
|
+
success = 32'd0;
|
|
107
|
+
/* verilator lint_on BLKSEQ */
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
// if a packet was received, mark the output as valid
|
|
111
|
+
if (success == 32'd0) begin
|
|
112
|
+
valid <= 1'b0;
|
|
113
|
+
end else begin
|
|
114
|
+
valid <= 1'b1;
|
|
115
|
+
data_padded <= rdata;
|
|
116
|
+
dest <= rdest;
|
|
117
|
+
last <= rlast;
|
|
118
|
+
end
|
|
119
|
+
end else begin
|
|
120
|
+
valid <= 1'b0;
|
|
121
|
+
end
|
|
122
|
+
end else if (!valid) begin
|
|
123
|
+
// if there isn't a packet being presented, we can try to get one
|
|
124
|
+
// to present. whether we do or not depends on valid_mode: if
|
|
125
|
+
// valid_mode=2, then flip a coin to decide if a new packet is read.
|
|
126
|
+
// in any other case, try to read a packet.
|
|
127
|
+
|
|
128
|
+
if ((valid_mode == 32'd0) || (valid_mode == 32'd1) ||
|
|
129
|
+
((valid_mode == 32'd2) && ($random % 2 == 32'd1))) begin
|
|
130
|
+
// try to receive a packet
|
|
131
|
+
if (id != -1) begin
|
|
132
|
+
/* verilator lint_off IGNOREDRETURN */
|
|
133
|
+
`SB_EXT_FUNC(pi_sb_recv)(id, rdata, rdest, rlast, success);
|
|
134
|
+
/* verilator lint_on IGNOREDRETURN */
|
|
135
|
+
end else begin
|
|
136
|
+
/* verilator lint_off BLKSEQ */
|
|
137
|
+
success = 32'd0;
|
|
138
|
+
/* verilator lint_on BLKSEQ */
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
// if a packet was received, mark the output as valid
|
|
142
|
+
if (success == 32'd0) begin
|
|
143
|
+
valid <= 1'b0;
|
|
144
|
+
end else begin
|
|
145
|
+
valid <= 1'b1;
|
|
146
|
+
data_padded <= rdata;
|
|
147
|
+
dest <= rdest;
|
|
148
|
+
last <= rlast;
|
|
149
|
+
end
|
|
150
|
+
end else begin
|
|
151
|
+
valid <= 1'b0;
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
// initialize
|
|
158
|
+
|
|
159
|
+
initial begin
|
|
160
|
+
if (FILE != "") begin
|
|
161
|
+
/* verilator lint_off IGNOREDRETURN */
|
|
162
|
+
init(FILE);
|
|
163
|
+
/* verilator lint_on IGNOREDRETURN */
|
|
164
|
+
end
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
// clean up macros
|
|
168
|
+
|
|
169
|
+
`undef SB_EXT_FUNC
|
|
170
|
+
`undef SB_START_FUNC
|
|
171
|
+
`undef SB_END_FUNC
|
|
172
|
+
`undef SB_VAR_BIT
|
|
173
|
+
|
|
174
|
+
endmodule
|
|
175
|
+
|
|
176
|
+
`default_nettype wire
|
|
@@ -0,0 +1,66 @@
|
|
|
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 queue_to_umi_sim #(
|
|
7
|
+
parameter integer VALID_MODE_DEFAULT=0,
|
|
8
|
+
parameter integer DW=256,
|
|
9
|
+
parameter integer AW=64,
|
|
10
|
+
parameter integer CW=32,
|
|
11
|
+
parameter FILE=""
|
|
12
|
+
) (
|
|
13
|
+
input clk,
|
|
14
|
+
input reset,
|
|
15
|
+
output [DW-1:0] data,
|
|
16
|
+
output [AW-1:0] srcaddr,
|
|
17
|
+
output [AW-1:0] dstaddr,
|
|
18
|
+
output [CW-1:0] cmd,
|
|
19
|
+
input ready,
|
|
20
|
+
output valid
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
queue_to_sb_sim #(
|
|
24
|
+
.VALID_MODE_DEFAULT(VALID_MODE_DEFAULT),
|
|
25
|
+
.DW(DW+AW+AW+CW),
|
|
26
|
+
.FILE(FILE)
|
|
27
|
+
) rx_i (
|
|
28
|
+
.clk(clk),
|
|
29
|
+
.reset(reset),
|
|
30
|
+
.data({data, srcaddr, dstaddr, cmd}),
|
|
31
|
+
.dest(),
|
|
32
|
+
.last(),
|
|
33
|
+
.ready(ready),
|
|
34
|
+
.valid(valid)
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
// handle differences between simulators
|
|
38
|
+
|
|
39
|
+
`ifdef __ICARUS__
|
|
40
|
+
`define SB_START_FUNC task
|
|
41
|
+
`define SB_END_FUNC endtask
|
|
42
|
+
`else
|
|
43
|
+
`define SB_START_FUNC function void
|
|
44
|
+
`define SB_END_FUNC endfunction
|
|
45
|
+
`endif
|
|
46
|
+
|
|
47
|
+
`SB_START_FUNC init(input string uri);
|
|
48
|
+
/* verilator lint_off IGNOREDRETURN */
|
|
49
|
+
rx_i.init(uri);
|
|
50
|
+
/* verilator lint_on IGNOREDRETURN */
|
|
51
|
+
`SB_END_FUNC
|
|
52
|
+
|
|
53
|
+
`SB_START_FUNC set_valid_mode(input integer value);
|
|
54
|
+
/* verilator lint_off IGNOREDRETURN */
|
|
55
|
+
rx_i.set_valid_mode(value);
|
|
56
|
+
/* verilator lint_on IGNOREDRETURN */
|
|
57
|
+
`SB_END_FUNC
|
|
58
|
+
|
|
59
|
+
// clean up macros
|
|
60
|
+
|
|
61
|
+
`undef SB_START_FUNC
|
|
62
|
+
`undef SB_END_FUNC
|
|
63
|
+
|
|
64
|
+
endmodule
|
|
65
|
+
|
|
66
|
+
`default_nettype wire
|
|
@@ -0,0 +1,146 @@
|
|
|
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_apb_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 FILE=""
|
|
15
|
+
) (
|
|
16
|
+
input wire clk,
|
|
17
|
+
input wire reset,
|
|
18
|
+
|
|
19
|
+
// APB master interface
|
|
20
|
+
output wire m_apb_psel,
|
|
21
|
+
output wire m_apb_penable,
|
|
22
|
+
output wire m_apb_pwrite,
|
|
23
|
+
output wire [2:0] m_apb_pprot,
|
|
24
|
+
output wire [ADDR_WIDTH-1:0] m_apb_paddr,
|
|
25
|
+
output wire [STRB_WIDTH-1:0] m_apb_pstrb,
|
|
26
|
+
output wire [DATA_WIDTH-1:0] m_apb_pwdata,
|
|
27
|
+
input wire [DATA_WIDTH-1:0] m_apb_prdata,
|
|
28
|
+
input wire m_apb_pready,
|
|
29
|
+
input wire m_apb_pslverr
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
// APB FSM state register type
|
|
33
|
+
typedef enum logic [1:0] {
|
|
34
|
+
APB_IDLE,
|
|
35
|
+
APB_SETUP,
|
|
36
|
+
APB_ACCESS
|
|
37
|
+
} apb_state_t;
|
|
38
|
+
|
|
39
|
+
// Wires
|
|
40
|
+
wire apb_trans_avail;
|
|
41
|
+
wire apb_fire;
|
|
42
|
+
|
|
43
|
+
// APB FSM state register
|
|
44
|
+
apb_state_t apb_state;
|
|
45
|
+
|
|
46
|
+
// APB request channel
|
|
47
|
+
queue_to_sb_sim #(
|
|
48
|
+
.VALID_MODE_DEFAULT(VALID_MODE_DEFAULT),
|
|
49
|
+
.DW(1 + 3 + STRB_WIDTH + ADDR_WIDTH + DATA_WIDTH)
|
|
50
|
+
) apb_req_channel (
|
|
51
|
+
.clk(clk),
|
|
52
|
+
.reset(reset),
|
|
53
|
+
.data({m_apb_pwrite, m_apb_pprot, m_apb_pstrb, m_apb_paddr, m_apb_pwdata}),
|
|
54
|
+
.dest(),
|
|
55
|
+
.last(),
|
|
56
|
+
.valid(apb_trans_avail),
|
|
57
|
+
.ready(apb_fire)
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
// APB response channel
|
|
61
|
+
sb_to_queue_sim #(
|
|
62
|
+
// Queue should always be ready to receive responses
|
|
63
|
+
.READY_MODE_DEFAULT(1),
|
|
64
|
+
.DW(DATA_WIDTH + 1)
|
|
65
|
+
) apb_resp_channel (
|
|
66
|
+
.clk(clk),
|
|
67
|
+
.reset(reset),
|
|
68
|
+
.data({m_apb_pslverr, m_apb_prdata}),
|
|
69
|
+
.dest(),
|
|
70
|
+
.last(),
|
|
71
|
+
.valid(apb_fire),
|
|
72
|
+
.ready()
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
// APB master state machine
|
|
76
|
+
always_ff @(posedge clk or posedge reset)
|
|
77
|
+
if (reset)
|
|
78
|
+
apb_state <= APB_IDLE;
|
|
79
|
+
else
|
|
80
|
+
case (apb_state)
|
|
81
|
+
APB_IDLE:
|
|
82
|
+
if (apb_trans_avail) apb_state <= APB_SETUP;
|
|
83
|
+
APB_SETUP:
|
|
84
|
+
apb_state <= APB_ACCESS;
|
|
85
|
+
APB_ACCESS:
|
|
86
|
+
if (m_apb_pready) apb_state <= APB_IDLE;
|
|
87
|
+
default:
|
|
88
|
+
apb_state <= APB_IDLE;
|
|
89
|
+
endcase
|
|
90
|
+
|
|
91
|
+
assign m_apb_psel = (apb_state == APB_SETUP || apb_state == APB_ACCESS);
|
|
92
|
+
assign m_apb_penable = (apb_state == APB_ACCESS);
|
|
93
|
+
assign apb_fire = m_apb_psel & m_apb_penable & m_apb_pready;
|
|
94
|
+
|
|
95
|
+
// handle differences between simulators
|
|
96
|
+
|
|
97
|
+
`ifdef __ICARUS__
|
|
98
|
+
`define SB_START_FUNC task
|
|
99
|
+
`define SB_END_FUNC endtask
|
|
100
|
+
`else
|
|
101
|
+
`define SB_START_FUNC function void
|
|
102
|
+
`define SB_END_FUNC endfunction
|
|
103
|
+
`endif
|
|
104
|
+
|
|
105
|
+
`SB_START_FUNC init(input string uri);
|
|
106
|
+
string s;
|
|
107
|
+
|
|
108
|
+
/* verilator lint_off IGNOREDRETURN */
|
|
109
|
+
$sformat(s, "%0s_apb_req.q", uri);
|
|
110
|
+
apb_req_channel.init(s);
|
|
111
|
+
|
|
112
|
+
$sformat(s, "%0s_apb_resp.q", uri);
|
|
113
|
+
apb_resp_channel.init(s);
|
|
114
|
+
/* verilator lint_on IGNOREDRETURN */
|
|
115
|
+
`SB_END_FUNC
|
|
116
|
+
|
|
117
|
+
`SB_START_FUNC set_valid_mode(input integer value);
|
|
118
|
+
/* verilator lint_off IGNOREDRETURN */
|
|
119
|
+
apb_req_channel.set_valid_mode(value);
|
|
120
|
+
/* verilator lint_on IGNOREDRETURN */
|
|
121
|
+
`SB_END_FUNC
|
|
122
|
+
|
|
123
|
+
`SB_START_FUNC set_ready_mode(input integer value);
|
|
124
|
+
/* verilator lint_off IGNOREDRETURN */
|
|
125
|
+
apb_resp_channel.set_ready_mode(value);
|
|
126
|
+
/* verilator lint_on IGNOREDRETURN */
|
|
127
|
+
`SB_END_FUNC
|
|
128
|
+
|
|
129
|
+
// initialize
|
|
130
|
+
|
|
131
|
+
initial begin
|
|
132
|
+
if (FILE != "") begin
|
|
133
|
+
/* verilator lint_off IGNOREDRETURN */
|
|
134
|
+
init(FILE);
|
|
135
|
+
/* verilator lint_on IGNOREDRETURN */
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
// clean up macros
|
|
140
|
+
|
|
141
|
+
`undef SB_START_FUNC
|
|
142
|
+
`undef SB_END_FUNC
|
|
143
|
+
|
|
144
|
+
endmodule
|
|
145
|
+
|
|
146
|
+
`default_nettype wire
|
|
@@ -0,0 +1,199 @@
|
|
|
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_axi_m #(
|
|
7
|
+
// AXI settings
|
|
8
|
+
parameter DATA_WIDTH = 32,
|
|
9
|
+
parameter ADDR_WIDTH = 16,
|
|
10
|
+
parameter STRB_WIDTH = (DATA_WIDTH/8),
|
|
11
|
+
parameter ID_WIDTH = 8,
|
|
12
|
+
|
|
13
|
+
// Switchboard settings
|
|
14
|
+
parameter integer VALID_MODE_DEFAULT=1,
|
|
15
|
+
parameter integer READY_MODE_DEFAULT=1,
|
|
16
|
+
parameter FILE=""
|
|
17
|
+
) (
|
|
18
|
+
input wire clk,
|
|
19
|
+
input wire reset,
|
|
20
|
+
|
|
21
|
+
// AXI master interface
|
|
22
|
+
// adapted from https://github.com/alexforencich/verilog-axi
|
|
23
|
+
output wire [ID_WIDTH-1:0] m_axi_awid,
|
|
24
|
+
output wire [ADDR_WIDTH-1:0] m_axi_awaddr,
|
|
25
|
+
output wire [7:0] m_axi_awlen,
|
|
26
|
+
output wire [2:0] m_axi_awsize,
|
|
27
|
+
output wire [1:0] m_axi_awburst,
|
|
28
|
+
output wire m_axi_awlock,
|
|
29
|
+
output wire [3:0] m_axi_awcache,
|
|
30
|
+
output wire [2:0] m_axi_awprot,
|
|
31
|
+
output wire m_axi_awvalid,
|
|
32
|
+
input wire m_axi_awready,
|
|
33
|
+
output wire [DATA_WIDTH-1:0] m_axi_wdata,
|
|
34
|
+
output wire [STRB_WIDTH-1:0] m_axi_wstrb,
|
|
35
|
+
output wire m_axi_wlast,
|
|
36
|
+
output wire m_axi_wvalid,
|
|
37
|
+
input wire m_axi_wready,
|
|
38
|
+
input wire [ID_WIDTH-1:0] m_axi_bid,
|
|
39
|
+
input wire [1:0] m_axi_bresp,
|
|
40
|
+
input wire m_axi_bvalid,
|
|
41
|
+
output wire m_axi_bready,
|
|
42
|
+
output wire [ID_WIDTH-1:0] m_axi_arid,
|
|
43
|
+
output wire [ADDR_WIDTH-1:0] m_axi_araddr,
|
|
44
|
+
output wire [7:0] m_axi_arlen,
|
|
45
|
+
output wire [2:0] m_axi_arsize,
|
|
46
|
+
output wire [1:0] m_axi_arburst,
|
|
47
|
+
output wire m_axi_arlock,
|
|
48
|
+
output wire [3:0] m_axi_arcache,
|
|
49
|
+
output wire [2:0] m_axi_arprot,
|
|
50
|
+
output wire m_axi_arvalid,
|
|
51
|
+
input wire m_axi_arready,
|
|
52
|
+
input wire [ID_WIDTH-1:0] m_axi_rid,
|
|
53
|
+
input wire [DATA_WIDTH-1:0] m_axi_rdata,
|
|
54
|
+
input wire [1:0] m_axi_rresp,
|
|
55
|
+
input wire m_axi_rlast,
|
|
56
|
+
input wire m_axi_rvalid,
|
|
57
|
+
output wire m_axi_rready
|
|
58
|
+
);
|
|
59
|
+
// AW channel
|
|
60
|
+
|
|
61
|
+
queue_to_sb_sim #(
|
|
62
|
+
.VALID_MODE_DEFAULT(VALID_MODE_DEFAULT),
|
|
63
|
+
.DW(ADDR_WIDTH + 3 + ID_WIDTH + 8 + 3 + 2 + 1 + 4)
|
|
64
|
+
) aw_channel (
|
|
65
|
+
.clk(clk),
|
|
66
|
+
.reset(reset),
|
|
67
|
+
.data({m_axi_awcache, m_axi_awlock, m_axi_awburst, m_axi_awsize,
|
|
68
|
+
m_axi_awlen, m_axi_awid, m_axi_awprot, m_axi_awaddr}),
|
|
69
|
+
.dest(),
|
|
70
|
+
.last(),
|
|
71
|
+
.valid(m_axi_awvalid),
|
|
72
|
+
.ready(m_axi_awready)
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
// W channel
|
|
76
|
+
|
|
77
|
+
queue_to_sb_sim #(
|
|
78
|
+
.VALID_MODE_DEFAULT(VALID_MODE_DEFAULT),
|
|
79
|
+
.DW(DATA_WIDTH + STRB_WIDTH + 1)
|
|
80
|
+
) w_channel (
|
|
81
|
+
.clk(clk),
|
|
82
|
+
.reset(reset),
|
|
83
|
+
.data({m_axi_wlast, m_axi_wstrb, m_axi_wdata}),
|
|
84
|
+
.dest(),
|
|
85
|
+
.last(),
|
|
86
|
+
.valid(m_axi_wvalid),
|
|
87
|
+
.ready(m_axi_wready)
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
// B channel
|
|
91
|
+
|
|
92
|
+
sb_to_queue_sim #(
|
|
93
|
+
.READY_MODE_DEFAULT(READY_MODE_DEFAULT),
|
|
94
|
+
.DW(2 + ID_WIDTH)
|
|
95
|
+
) b_channel (
|
|
96
|
+
.clk(clk),
|
|
97
|
+
.reset(reset),
|
|
98
|
+
.data({m_axi_bid, m_axi_bresp}),
|
|
99
|
+
.dest(),
|
|
100
|
+
.last(),
|
|
101
|
+
.valid(m_axi_bvalid),
|
|
102
|
+
.ready(m_axi_bready)
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
// AR channel
|
|
106
|
+
|
|
107
|
+
queue_to_sb_sim #(
|
|
108
|
+
.VALID_MODE_DEFAULT(VALID_MODE_DEFAULT),
|
|
109
|
+
.DW(ADDR_WIDTH + 3 + ID_WIDTH + 8 + 3 + 2 + 1 + 4)
|
|
110
|
+
) ar_channel (
|
|
111
|
+
.clk(clk),
|
|
112
|
+
.reset(reset),
|
|
113
|
+
.data({m_axi_arcache, m_axi_arlock, m_axi_arburst, m_axi_arsize,
|
|
114
|
+
m_axi_arlen, m_axi_arid, m_axi_arprot, m_axi_araddr}),
|
|
115
|
+
.dest(),
|
|
116
|
+
.last(),
|
|
117
|
+
.valid(m_axi_arvalid),
|
|
118
|
+
.ready(m_axi_arready)
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
// R channel
|
|
122
|
+
|
|
123
|
+
sb_to_queue_sim #(
|
|
124
|
+
.READY_MODE_DEFAULT(READY_MODE_DEFAULT),
|
|
125
|
+
.DW(DATA_WIDTH + 2 + ID_WIDTH + 1)
|
|
126
|
+
) r_channel (
|
|
127
|
+
.clk(clk),
|
|
128
|
+
.reset(reset),
|
|
129
|
+
.data({m_axi_rlast, m_axi_rid, m_axi_rresp, m_axi_rdata}),
|
|
130
|
+
.dest(),
|
|
131
|
+
.last(),
|
|
132
|
+
.valid(m_axi_rvalid),
|
|
133
|
+
.ready(m_axi_rready)
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
// handle differences between simulators
|
|
137
|
+
|
|
138
|
+
`ifdef __ICARUS__
|
|
139
|
+
`define SB_START_FUNC task
|
|
140
|
+
`define SB_END_FUNC endtask
|
|
141
|
+
`else
|
|
142
|
+
`define SB_START_FUNC function void
|
|
143
|
+
`define SB_END_FUNC endfunction
|
|
144
|
+
`endif
|
|
145
|
+
|
|
146
|
+
`SB_START_FUNC init(input string uri);
|
|
147
|
+
string s;
|
|
148
|
+
|
|
149
|
+
/* verilator lint_off IGNOREDRETURN */
|
|
150
|
+
$sformat(s, "%0s-aw.q", uri);
|
|
151
|
+
aw_channel.init(s);
|
|
152
|
+
|
|
153
|
+
$sformat(s, "%0s-w.q", uri);
|
|
154
|
+
w_channel.init(s);
|
|
155
|
+
|
|
156
|
+
$sformat(s, "%0s-b.q", uri);
|
|
157
|
+
b_channel.init(s);
|
|
158
|
+
|
|
159
|
+
$sformat(s, "%0s-ar.q", uri);
|
|
160
|
+
ar_channel.init(s);
|
|
161
|
+
|
|
162
|
+
$sformat(s, "%0s-r.q", uri);
|
|
163
|
+
r_channel.init(s);
|
|
164
|
+
/* verilator lint_on IGNOREDRETURN */
|
|
165
|
+
`SB_END_FUNC
|
|
166
|
+
|
|
167
|
+
`SB_START_FUNC set_valid_mode(input integer value);
|
|
168
|
+
/* verilator lint_off IGNOREDRETURN */
|
|
169
|
+
aw_channel.set_valid_mode(value);
|
|
170
|
+
w_channel.set_valid_mode(value);
|
|
171
|
+
ar_channel.set_valid_mode(value);
|
|
172
|
+
/* verilator lint_on IGNOREDRETURN */
|
|
173
|
+
`SB_END_FUNC
|
|
174
|
+
|
|
175
|
+
`SB_START_FUNC set_ready_mode(input integer value);
|
|
176
|
+
/* verilator lint_off IGNOREDRETURN */
|
|
177
|
+
b_channel.set_ready_mode(value);
|
|
178
|
+
r_channel.set_ready_mode(value);
|
|
179
|
+
/* verilator lint_on IGNOREDRETURN */
|
|
180
|
+
`SB_END_FUNC
|
|
181
|
+
|
|
182
|
+
// initialize
|
|
183
|
+
|
|
184
|
+
initial begin
|
|
185
|
+
if (FILE != "") begin
|
|
186
|
+
/* verilator lint_off IGNOREDRETURN */
|
|
187
|
+
init(FILE);
|
|
188
|
+
/* verilator lint_on IGNOREDRETURN */
|
|
189
|
+
end
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
// clean up macros
|
|
193
|
+
|
|
194
|
+
`undef SB_START_FUNC
|
|
195
|
+
`undef SB_END_FUNC
|
|
196
|
+
|
|
197
|
+
endmodule
|
|
198
|
+
|
|
199
|
+
`default_nettype wire
|