Skip to content

Commit

Permalink
Fix L0 testbench
Browse files Browse the repository at this point in the history
  • Loading branch information
micprog committed Jun 28, 2024
1 parent 0e1fb67 commit 456f680
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
2 changes: 2 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.


## Unreleased
### Fixed
- Fix L0 testbench.

## 0.1.1 - 28.06.2024
### Added
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ compile.tcl: .bender
$(BENDER) script vsim -t test \
--vlog-arg="$(VLOG_FLAGS)" \
> compile.tcl
echo "return 0" >> compile.tcl

.PHONY: build test_l0 test_ro test_l0_nogui test_ro_nogui

build: compile.tcl
$(VSIM) -c -do 'source compile.tcl; quit'
$(VSIM) -c -do 'quit -code [source compile.tcl]'

test_l0: build
$(VSIM) snitch_icache_l0_tb -coverage -voptargs='+acc +cover=sbecft' -do "log -r /*; run -all"
Expand Down
31 changes: 22 additions & 9 deletions test/snitch_icache_l0_tb.sv
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,7 @@ module snitch_icache_l0_tb #(
PENDING_IW: $clog2(2)
};

localparam int unsigned IdWidthReq = $clog2(NR_FETCH_PORTS) + 1;
localparam int unsigned IdWidthResp = 2*NR_FETCH_PORTS;
localparam int unsigned IdWidth = 2*NR_FETCH_PORTS;

logic clk, rst;
logic dut_flush_valid;
Expand All @@ -119,12 +118,12 @@ module snitch_icache_l0_tb #(
typedef struct packed {
logic [LINE_WIDTH-1:0] data;
logic error;
logic [IdWidthResp-1:0] id;
logic [IdWidth-1:0] id;
} dut_in_t;

typedef struct packed {
addr_t addr;
logic [IdWidthReq-1:0] id;
logic [IdWidth-1:0] id;
} dut_out_t;

typedef stream_test::stream_driver #(
Expand Down Expand Up @@ -283,22 +282,36 @@ module snitch_icache_l0_tb #(
`ASSERT(RequestProgress, dut_valid |-> ##[0:RequestTimeout] dut_ready, clk, rst)

// Response Drivers
mailbox #(dut_out_t) addr_mbx [2];
mailbox #(dut_out_t) addr_mbx [IdWidth];
semaphore response_lock = new (1);

function automatic logic [$clog2(IdWidth)-1:0] onehot2bin (input logic [IdWidth-1:0] onehot);
logic [$clog2(IdWidth)-1:0] bin;
for (int i = 0; i < IdWidth; i++) begin
logic [IdWidth-1:0] tmp_mask;
for (int j = 0; j < IdWidth; j++) begin
logic [IdWidth-1:0] tmp_i;
tmp_i = j;
tmp_mask[j] = tmp_i[i];
end
bin[i] = |(tmp_mask & onehot);
end
return bin;
endfunction

initial begin
automatic int unsigned stall_cycles;
automatic dut_out_t dut_out;
for (int i = 0; i < 2**IdWidthReq; i++)
automatic dut_out_t dut_out_loc;
for (int i = 0; i < IdWidth; i++)
addr_mbx [i] = new();
out_driver.reset_out();
@(negedge rst);
repeat (5) @(posedge clk);
forever begin
stall_cycles = $urandom_range(0, 5);
repeat (stall_cycles) @(posedge clk);
out_driver.recv(dut_out);
addr_mbx[dut_out.id].put(dut_out);
out_driver.recv(dut_out_loc);
addr_mbx[onehot2bin(dut_out_loc.id)].put(dut_out_loc);
// $info("Requesting from Address: %h, ID: %d", dut_out.addr, dut_out.id);
end
end
Expand Down

0 comments on commit 456f680

Please sign in to comment.