diff --git a/src/cache_subsystem/std_icache.sv b/src/cache_subsystem/std_icache.sv index 7818c1d97..a6dcc2def 100644 --- a/src/cache_subsystem/std_icache.sv +++ b/src/cache_subsystem/std_icache.sv @@ -50,13 +50,14 @@ module std_icache #( logic flushing_d, flushing_q; // signals - logic [ICACHE_SET_ASSOC-1:0] req; // request to memory array - logic [(ICACHE_LINE_WIDTH+7)/8-1:0] data_be; // byte enable for data array + logic [ICACHE_SET_ASSOC-1:0] req; // request to data memory + logic [ICACHE_SET_ASSOC-1:0] vld_req; // request to valid/tag memory + logic [(ICACHE_LINE_WIDTH+7)/8-1:0] data_be; // byte enable for data memory logic [(2**NR_AXI_REFILLS-1):0][7:0] be; // byte enable logic [$clog2(ICACHE_NUM_WORD)-1:0] addr; // this is a cache-line address, to memory array logic we; // write enable to memory array logic [ICACHE_SET_ASSOC-1:0] hit; // hit from tag compare - logic [ICACHE_BYTE_OFFSET-1:2] idx; // index in cache line + logic [$clog2(ICACHE_NUM_WORD)-1:0] idx; // index in cache line logic update_lfsr; // shift the LFSR logic [ICACHE_SET_ASSOC-1:0] random_way; // random way select from LFSR logic [ICACHE_SET_ASSOC-1:0] way_valid; // bit string which contains the zapped valid bits @@ -84,7 +85,7 @@ module std_icache #( ) tag_sram ( .clk_i ( clk_i ), .rst_ni ( rst_ni ), - .req_i ( req[i] ), + .req_i ( vld_req[i] ), .we_i ( we ), .addr_i ( addr ), .wdata_i ( tag_wdata ), @@ -108,45 +109,31 @@ module std_icache #( .rdata_o ( data_rdata[i] ) ); end + // -------------------- - // Tag Comparison + // Tag Comparison and way select // -------------------- - for (genvar i = 0; i < ICACHE_SET_ASSOC; i++) begin - assign hit[i] = (tag_rdata[i].tag == tag) ? tag_rdata[i].valid : 1'b0; - end - `ifndef SYNTHESIS - `ifndef VERILATOR - // assert that cache only hits on one way - assert property ( - @(posedge clk_i) $onehot0(hit)) else begin $error("[icache] Hit should be one-hot encoded"); $stop(); end - `endif - `endif - - // ------------------ - // Way Select - // ------------------ - assign idx = vaddr_q[ICACHE_BYTE_OFFSET-1:2]; // cacheline selected by hit - logic [ICACHE_LINE_WIDTH/FETCH_WIDTH-1:0][FETCH_WIDTH-1:0] selected_cl; - logic [ICACHE_LINE_WIDTH-1:0] selected_cl_flat; + logic [ICACHE_SET_ASSOC-1:0][FETCH_WIDTH-1:0] cl_sel; + + assign idx = vaddr_q[ICACHE_BYTE_OFFSET-1:2]; - for (genvar i = 0; i < ICACHE_LINE_WIDTH; i++) begin - logic [ICACHE_SET_ASSOC-1:0] hit_masked_cl; - - for (genvar j = 0; j < ICACHE_SET_ASSOC; j++) - assign hit_masked_cl[j] = data_rdata[j][i] & hit[j]; - - assign selected_cl_flat[i] = |hit_masked_cl; + generate + for (genvar i=0;i redo the request, REDO_REQ: begin - req = '1; - addr = vaddr_q[ICACHE_INDEX_WIDTH-1:ICACHE_BYTE_OFFSET]; - tag = tag_q; + req = '1; + vld_req = '1; + tag = tag_q; state_d = TAG_CMP_SAVED; // do tag comparison on the saved tag end // ~> we are coming here after reset or when a flush was requested FLUSH: begin - addr = cnt_q; cnt_d = cnt_q + 1; - req = '1; + vld_req = '1; we = 1; // we've finished flushing, go back to idle if (cnt_q == ICACHE_NUM_WORD - 1) begin @@ -441,9 +436,21 @@ module std_icache #( end end - `ifndef SYNTHESIS - initial begin - assert ($bits(axi.aw_addr) == 64) else $fatal(1, "Ariane needs a 64-bit bus"); - end - `endif +/////////////////////////////////////////////////////// +// assertions +/////////////////////////////////////////////////////// + +//pragma translate_off +`ifndef VERILATOR +initial begin + assert ($bits(axi.aw_addr) == 64) + else $fatal(1, "[icache] Ariane needs a 64-bit bus"); +end + +// assert that cache only hits on one way +onehot: assert property ( + @(posedge clk_i) disable iff (~rst_ni) $onehot0(hit)) + else $fatal(1, "[icache] Hit should be one-hot encoded"); +`endif +//pragma translate_on endmodule