Skip to content

Commit

Permalink
simplify macro usage
Browse files Browse the repository at this point in the history
  • Loading branch information
sgherbst committed Apr 17, 2024
1 parent c7d1a21 commit c48f581
Show file tree
Hide file tree
Showing 18 changed files with 122 additions and 89 deletions.
2 changes: 1 addition & 1 deletion examples/axi/testbench.sv
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ module testbench (

// Instantiate switchboard module

`SB_AXI_M(sb_axi_m_i, axi, clk, DATA_WIDTH, ADDR_WIDTH, ID_WIDTH, "axi");
`SB_AXI_M(axi, DATA_WIDTH, ADDR_WIDTH, ID_WIDTH);

// Initialize RAM to zeros for easy comparison against a behavioral model

Expand Down
2 changes: 1 addition & 1 deletion examples/axil/testbench.sv
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ module testbench (

// Instantiate switchboard module

`SB_AXIL_M(sb_axil_m_i, axil, clk, DATA_WIDTH, ADDR_WIDTH, "axil");
`SB_AXIL_M(axil, DATA_WIDTH, ADDR_WIDTH);

// Initialize RAM to zeros for easy comparison against a behavioral model

Expand Down
24 changes: 13 additions & 11 deletions examples/minimal/testbench.sv
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,31 @@ module testbench (
`SB_CREATE_CLOCK(clk)
`endif

localparam integer DW=256;

// SB RX port

`SB_WIRES(sb_rx, 256);
`QUEUE_TO_SB_SIM(rx_i, sb_rx, clk, 256, "to_rtl.q");
`SB_WIRES(to_rtl, DW);
`QUEUE_TO_SB_SIM(to_rtl, DW);

// SB TX port

`SB_WIRES(sb_tx, 256);
`SB_TO_QUEUE_SIM(tx_i, sb_tx, clk, 256, "from_rtl.q");
`SB_WIRES(from_rtl, DW);
`SB_TO_QUEUE_SIM(from_rtl, DW);

// custom modification of packet

genvar i;
generate
for (i=0; i<32; i=i+1) begin
assign sb_tx_data[(i*8) +: 8] = sb_rx_data[(i*8) +: 8] + 8'd1;
for (i=0; i<(DW/8); i=i+1) begin
assign from_rtl_data[(i*8) +: 8] = to_rtl_data[(i*8) +: 8] + 8'd1;
end
endgenerate

assign sb_tx_dest = sb_rx_dest;
assign sb_tx_last = sb_rx_last;
assign sb_tx_valid = sb_rx_valid;
assign sb_rx_ready = sb_tx_ready;
assign from_rtl_dest = to_rtl_dest;
assign from_rtl_last = to_rtl_last;
assign from_rtl_valid = to_rtl_valid;
assign to_rtl_ready = from_rtl_ready;

// Waveforms

Expand All @@ -43,7 +45,7 @@ module testbench (
// $finish

always @(posedge clk) begin
if (sb_rx_valid && ((&sb_rx_data) == 1'b1)) begin
if (to_rtl_valid && ((&to_rtl_data) == 1'b1)) begin
$finish;
end
end
Expand Down
24 changes: 13 additions & 11 deletions examples/python/testbench.sv
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,31 @@ module testbench (
`SB_CREATE_CLOCK(clk)
`endif

localparam DW=256;

// SB RX port

`SB_WIRES(sb_rx, 256);
`QUEUE_TO_SB_SIM(rx_i, sb_rx, clk, 256, "to_rtl.q");
`SB_WIRES(to_rtl, DW);
`QUEUE_TO_SB_SIM(to_rtl, DW);

// SB TX port

`SB_WIRES(sb_tx, 256);
`SB_TO_QUEUE_SIM(tx_i, sb_tx, clk, 256, "from_rtl.q");
`SB_WIRES(from_rtl, DW);
`SB_TO_QUEUE_SIM(from_rtl, DW);

// custom modification of packet

genvar i;
generate
for (i=0; i<32; i=i+1) begin
assign sb_tx_data[(i*8) +: 8] = sb_rx_data[(i*8) +: 8] + 8'd1;
for (i=0; i<(DW/8); i=i+1) begin
assign from_rtl_data[(i*8) +: 8] = to_rtl_data[(i*8) +: 8] + 8'd1;
end
endgenerate

assign sb_tx_dest = sb_rx_dest;
assign sb_tx_last = sb_rx_last;
assign sb_tx_valid = sb_rx_valid;
assign sb_rx_ready = sb_tx_ready;
assign from_rtl_dest = to_rtl_dest;
assign from_rtl_last = to_rtl_last;
assign from_rtl_valid = to_rtl_valid;
assign to_rtl_ready = from_rtl_ready;

// Waveforms

Expand All @@ -43,7 +45,7 @@ module testbench (
// $finish

always @(posedge clk) begin
if (sb_rx_valid && ((&sb_rx_data) == 1'b1)) begin
if (to_rtl_valid && ((&to_rtl_data) == 1'b1)) begin
$finish;
end
end
Expand Down
10 changes: 6 additions & 4 deletions examples/router/testbench.sv
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@ module testbench (
`SB_CREATE_CLOCK(clk)
`endif

localparam integer DW=256;

// SB RX port

`SB_WIRES(sb_rx, 256);
`QUEUE_TO_SB_SIM(rx_i, sb_rx, clk, 256, "queue-5557");
`SB_WIRES(sb_rx, DW);
`QUEUE_TO_SB_SIM(sb_rx, DW, "queue-5557");

// SB TX port

`SB_WIRES(sb_tx, 256);
`SB_TO_QUEUE_SIM(tx_i, sb_tx, clk, 256, "queue-5558");
`SB_WIRES(sb_tx, DW);
`SB_TO_QUEUE_SIM(sb_tx, DW, "queue-5558");

// custom modification of packet

Expand Down
10 changes: 6 additions & 4 deletions examples/stream/testbench.sv
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@ module testbench (
`SB_CREATE_CLOCK(clk)
`endif

localparam integer DW=256;

// SB RX port

`SB_WIRES(sb_rx, 256);
`QUEUE_TO_SB_SIM(rx_i, sb_rx, clk, 256, "client2rtl.q");
`SB_WIRES(sb_rx, DW);
`QUEUE_TO_SB_SIM(sb_rx, DW, "client2rtl.q");

// SB TX port

`SB_WIRES(sb_tx, 256);
`SB_TO_QUEUE_SIM(tx_i, sb_tx, clk, 256, "rtl2client.q");
`SB_WIRES(sb_tx, DW);
`SB_TO_QUEUE_SIM(sb_tx, DW, "rtl2client.q");

// custom modification of packet

Expand Down
4 changes: 2 additions & 2 deletions examples/umi_endpoint/testbench.sv
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ module testbench (
parameter integer AW=64;

`SB_UMI_WIRES(udev_req, DW, CW, AW);
`QUEUE_TO_UMI_SIM(rx_i, udev_req, clk, DW, CW, AW, "to_rtl.q");
`QUEUE_TO_UMI_SIM(udev_req, DW, CW, AW, "to_rtl.q");

`SB_UMI_WIRES(udev_resp, DW, CW, AW);
`UMI_TO_QUEUE_SIM(tx_i, udev_resp, clk, DW, CW, AW, "from_rtl.q");
`UMI_TO_QUEUE_SIM(udev_resp, DW, CW, AW, "from_rtl.q");

reg nreset = 1'b0;
wire [AW-1:0] loc_addr;
Expand Down
4 changes: 2 additions & 2 deletions examples/umi_fifo/testbench.sv
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ module testbench (
localparam integer CW=32;

`SB_UMI_WIRES(udev_req, DW, CW, AW);
`QUEUE_TO_UMI_SIM(rx_i, udev_req, clk, DW, CW, AW, "to_rtl.q");
`QUEUE_TO_UMI_SIM(udev_req, DW, CW, AW, "to_rtl.q");

`SB_UMI_WIRES(udev_resp, DW, CW, AW);
`UMI_TO_QUEUE_SIM(tx_i, udev_resp, clk, DW, CW, AW, "from_rtl.q");
`UMI_TO_QUEUE_SIM(udev_resp, DW, CW, AW, "from_rtl.q");

reg nreset = 1'b0;

Expand Down
4 changes: 2 additions & 2 deletions examples/umi_fifo_flex/testbench.sv
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ module testbench (
parameter integer CW=32;

`SB_UMI_WIRES(udev_req, IDW, CW, AW);
`QUEUE_TO_UMI_SIM(rx_i, udev_req, clk, IDW, CW, AW, "to_rtl.q");
`QUEUE_TO_UMI_SIM(udev_req, IDW, CW, AW, "to_rtl.q");

`SB_UMI_WIRES(udev_resp, ODW, CW, AW);
`UMI_TO_QUEUE_SIM(tx_i, udev_resp, clk, ODW, CW, AW, "from_rtl.q");
`UMI_TO_QUEUE_SIM(udev_resp, ODW, CW, AW, "from_rtl.q");

reg nreset = 1'b0;

Expand Down
4 changes: 2 additions & 2 deletions examples/umi_gpio/testbench.sv
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ module testbench (
localparam integer OWIDTH=128;

`SB_UMI_WIRES(udev_req, DW, CW, AW);
`QUEUE_TO_UMI_SIM(rx_i, udev_req, clk, DW, CW, AW, "to_rtl.q");
`QUEUE_TO_UMI_SIM(udev_req, DW, CW, AW, "to_rtl.q");

`SB_UMI_WIRES(udev_resp, DW, CW, AW);
`UMI_TO_QUEUE_SIM(tx_i, udev_resp, clk, DW, CW, AW, "from_rtl.q");
`UMI_TO_QUEUE_SIM(udev_resp, DW, CW, AW, "from_rtl.q");

reg nreset = 1'b0;
wire [(IWIDTH-1):0] gpio_in;
Expand Down
6 changes: 3 additions & 3 deletions examples/umi_splitter/testbench.sv
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ module testbench (
// UMI input

`SB_UMI_WIRES(umi_in, DW, CW, AW);
`QUEUE_TO_UMI_SIM(rx, umi_in, clk, DW, CW, AW, "in.q");
`QUEUE_TO_UMI_SIM(umi_in, DW, CW, AW, "in.q");

// UMI output (response)

`SB_UMI_WIRES(umi_resp_out, DW, CW, AW);
`UMI_TO_QUEUE_SIM(tx0, umi_resp_out, clk, DW, CW, AW, "out0.q");
`UMI_TO_QUEUE_SIM(umi_resp_out, DW, CW, AW, "out0.q");

// UMI output (request)

`SB_UMI_WIRES(umi_req_out, DW, CW, AW);
`UMI_TO_QUEUE_SIM(tx1, umi_req_out, clk, DW, CW, AW, "out1.q");
`UMI_TO_QUEUE_SIM(umi_req_out, DW, CW, AW, "out1.q");

// UMI splitter

Expand Down
4 changes: 2 additions & 2 deletions examples/umiram/testbench.sv
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ module testbench (
localparam integer CW=32;

`SB_UMI_WIRES(udev_req, DW, CW, AW);
`QUEUE_TO_UMI_SIM(rx_i, udev_req, clk, DW, CW, AW, "to_rtl.q");
`QUEUE_TO_UMI_SIM(udev_req, DW, CW, AW, "to_rtl.q");

`SB_UMI_WIRES(udev_resp, DW, CW, AW);
`UMI_TO_QUEUE_SIM(tx_i, udev_resp, clk, DW, CW, AW, "from_rtl.q");
`UMI_TO_QUEUE_SIM(udev_resp, DW, CW, AW, "from_rtl.q");

// instantiate module with UMI ports

Expand Down
Loading

0 comments on commit c48f581

Please sign in to comment.