@@ -105,8 +105,7 @@ module snitch_icache_l0_tb #(
105105 PENDING_IW : $clog2(2 )
106106 } ;
107107
108- localparam int unsigned IdWidthReq = $clog2 (NR_FETCH_PORTS ) + 1 ;
109- localparam int unsigned IdWidthResp = 2 * NR_FETCH_PORTS ;
108+ localparam int unsigned IdWidth = 2 * NR_FETCH_PORTS ;
110109
111110 logic clk, rst;
112111 logic dut_flush_valid;
@@ -119,12 +118,12 @@ module snitch_icache_l0_tb #(
119118 typedef struct packed {
120119 logic [LINE_WIDTH - 1 : 0 ] data;
121120 logic error;
122- logic [IdWidthResp - 1 : 0 ] id;
121+ logic [IdWidth - 1 : 0 ] id;
123122 } dut_in_t ;
124123
125124 typedef struct packed {
126125 addr_t addr;
127- logic [IdWidthReq - 1 : 0 ] id;
126+ logic [IdWidth - 1 : 0 ] id;
128127 } dut_out_t ;
129128
130129 typedef stream_test :: stream_driver # (
@@ -283,22 +282,36 @@ module snitch_icache_l0_tb #(
283282 `ASSERT (RequestProgress, dut_valid | - > ## [0 : RequestTimeout] dut_ready, clk, rst)
284283
285284 // Response Drivers
286- mailbox # (dut_out_t) addr_mbx [2 ];
285+ mailbox # (dut_out_t) addr_mbx [IdWidth ];
287286 semaphore response_lock = new (1 );
288287
288+ function automatic logic [$clog2 (IdWidth)- 1 : 0 ] onehot2bin (input logic [IdWidth- 1 : 0 ] onehot);
289+ logic [$clog2 (IdWidth)- 1 : 0 ] bin;
290+ for (int i = 0 ; i < IdWidth; i++ ) begin
291+ logic [IdWidth- 1 : 0 ] tmp_mask;
292+ for (int j = 0 ; j < IdWidth; j++ ) begin
293+ logic [IdWidth- 1 : 0 ] tmp_i;
294+ tmp_i = j;
295+ tmp_mask[j] = tmp_i[i];
296+ end
297+ bin[i] = | (tmp_mask & onehot);
298+ end
299+ return bin;
300+ endfunction
301+
289302 initial begin
290303 automatic int unsigned stall_cycles;
291- automatic dut_out_t dut_out ;
292- for (int i = 0 ; i < 2 ** IdWidthReq ; i++ )
304+ automatic dut_out_t dut_out_loc ;
305+ for (int i = 0 ; i < IdWidth ; i++ )
293306 addr_mbx [i] = new ();
294307 out_driver.reset_out ();
295308 @ (negedge rst);
296309 repeat (5 ) @ (posedge clk);
297310 forever begin
298311 stall_cycles = $urandom_range (0 , 5 );
299312 repeat (stall_cycles) @ (posedge clk);
300- out_driver.recv (dut_out );
301- addr_mbx[dut_out .id].put (dut_out );
313+ out_driver.recv (dut_out_loc );
314+ addr_mbx[onehot2bin (dut_out_loc .id) ].put (dut_out_loc );
302315 // $info("Requesting from Address: %h, ID: %d", dut_out.addr, dut_out.id);
303316 end
304317 end
0 commit comments