Skip to content

Commit

Permalink
Optimize some parts of the code for Verilator
Browse files Browse the repository at this point in the history
  • Loading branch information
cfuguet committed Dec 11, 2024
1 parent ecfcdd7 commit 4699e14
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 39 deletions.
21 changes: 16 additions & 5 deletions rtl/src/hpdcache_cmo.sv
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ import hpdcache_pkg::*;
hpdcache_nline_t cmoh_nline;
hpdcache_set_t cmoh_set;
hpdcache_tag_t cmoh_tag;
logic cmoh_flush_req_w, cmoh_flush_req_wok;
logic cmoh_flush_req_w;
logic cmoh_flush_req_wok;
hpdcache_set_t cmoh_flush_req_set;
hpdcache_tag_t cmoh_flush_req_tag;
hpdcache_way_vector_t cmoh_flush_req_way;
Expand Down Expand Up @@ -185,7 +186,6 @@ import hpdcache_pkg::*;

wbuf_flush_all_o = 1'b0;

cmoh_flush_req_w = 1'b0;
cmoh_flush_req_set = '0;
cmoh_flush_req_way = '0;
cmoh_flush_req_tag = '0;
Expand Down Expand Up @@ -323,7 +323,6 @@ import hpdcache_pkg::*;
dir_inval_o = cmoh_flush_req_inval_q;
dir_inval_set_o = cmoh_flush_req_set_q;
dir_inval_way_o = cmoh_flush_req_way_q;
cmoh_flush_req_w = dir_check_entry_valid_i & dir_check_entry_dirty_i;
cmoh_flush_req_set = cmoh_flush_req_set_q;
cmoh_flush_req_way = cmoh_flush_req_way_q;
cmoh_flush_req_tag = dir_check_entry_tag_i;
Expand Down Expand Up @@ -354,7 +353,6 @@ import hpdcache_pkg::*;
dir_inval_o = cmoh_flush_req_inval_q;
dir_inval_set_o = cmoh_flush_req_set_q;
dir_inval_way_o = cmoh_flush_req_way_q;
cmoh_flush_req_w = dir_check_entry_valid_i & dir_check_entry_dirty_i;
cmoh_flush_req_set = cmoh_flush_req_set_q;
cmoh_flush_req_way = cmoh_flush_req_way_q;
cmoh_flush_req_tag = dir_check_entry_tag_i;
Expand Down Expand Up @@ -386,7 +384,6 @@ import hpdcache_pkg::*;
dir_inval_o = cmoh_flush_req_inval_q & cmoh_dir_check_nline_hit;
dir_inval_set_o = cmoh_set;
dir_inval_way_o = dir_check_nline_hit_way_i;
cmoh_flush_req_w = cmoh_dir_check_nline_hit & dir_check_nline_dirty_i;
cmoh_flush_req_set = cmoh_set;
cmoh_flush_req_tag = cmoh_tag;
cmoh_flush_req_way = dir_check_nline_hit_way_i;
Expand Down Expand Up @@ -460,6 +457,19 @@ import hpdcache_pkg::*;
if (HPDcacheCfg.u.wbEn) begin : gen_cmo_flush_fifo
cmoh_flush_req_t cmoh_flush_req_wdata, cmoh_flush_req_rdata;

always_comb
begin : cmoh_flush_req_w_comb
cmoh_flush_req_w = 1'b0;
if (cmoh_flush_req_valid_q) begin
unique case (cmoh_fsm_q)
CMOH_FLUSH_ALL_NEXT, CMOH_FLUSH_ALL_LAST:
cmoh_flush_req_w = dir_check_entry_valid_i & dir_check_entry_dirty_i;
CMOH_FLUSH_NLINE_NEXT:
cmoh_flush_req_w = cmoh_dir_check_nline_hit & dir_check_nline_dirty_i;
endcase
end
end

assign cmoh_flush_req_wdata = '{
nline: {cmoh_flush_req_tag, cmoh_flush_req_set},
way : cmoh_flush_req_way
Expand All @@ -483,6 +493,7 @@ import hpdcache_pkg::*;
assign flush_alloc_nline_o = cmoh_flush_req_rdata.nline;
assign flush_alloc_way_o = cmoh_flush_req_rdata.way;
end else begin : gen_cmo_no_flush_fifo
assign cmoh_flush_req_w = 1'b0;
assign cmoh_flush_req_wok = 1'b1;
assign flush_alloc_o = 1'b0;
assign flush_alloc_nline_o = '0;
Expand Down
71 changes: 37 additions & 34 deletions rtl/src/hpdcache_rtab.sv
Original file line number Diff line number Diff line change
Expand Up @@ -373,40 +373,43 @@ import hpdcache_pkg::*;
);
// }}}

for (gen_i = 0; gen_i < N; gen_i++) begin : gen_deps_rst
// reset write buffer dependency bits with the output from the write buffer
// {{{
assign deps_rst[gen_i].wbuf_hit = wbuf_sel[gen_i] & ~(wbuf_hit_open_i |
wbuf_hit_pend_i |
wbuf_hit_sent_i);
assign deps_rst[gen_i].wbuf_not_ready = wbuf_sel[gen_i] & ~wbuf_not_ready_i;
// }}}

// Update miss handler dependency
// {{{
assign deps_rst[gen_i].mshr_ready = miss_ready_i;
// }}}

// Update refill dependencies
// {{{
assign deps_rst[gen_i].mshr_full = refill_i & match_refill_mshr_set[gen_i];
assign deps_rst[gen_i].mshr_hit = refill_i & match_refill_nline[gen_i];
assign deps_rst[gen_i].write_miss = deps_rst[gen_i].mshr_hit;
// }}}

// Update cache directory dependencies
// {{{
assign deps_rst[gen_i].dir_unavailable = refill_i & match_refill_set[gen_i];
assign deps_rst[gen_i].dir_fetch = refill_i & match_refill_set[gen_i] &
match_refill_way[gen_i];
// }}}

// Update flush dependencies
// {{{
assign deps_rst[gen_i].flush_hit = flush_ack_i & match_flush_nline[gen_i];
assign deps_rst[gen_i].flush_not_ready = flush_ready_i;
// }}}
end
always_comb
begin : deps_rst_comb
deps_rst = '0;

for (int i = 0; i < N; i++) begin

// reset write buffer dependency bits with the output from the write buffer
// {{{
if (wbuf_sel[i]) begin
deps_rst[i].wbuf_hit = ~(wbuf_hit_open_i | wbuf_hit_pend_i | wbuf_hit_sent_i);
deps_rst[i].wbuf_not_ready = ~wbuf_not_ready_i;
end
// }}}

// Update miss handler dependency
// {{{
deps_rst[i].mshr_ready = miss_ready_i;
// }}}

// Update refill dependencies
// {{{
if (refill_i) begin
deps_rst[i].mshr_full = match_refill_mshr_set[i];
deps_rst[i].mshr_hit = match_refill_nline[i];
deps_rst[i].write_miss = match_refill_nline[i];
deps_rst[i].dir_unavailable = match_refill_set[i];
deps_rst[i].dir_fetch = match_refill_set[i] & match_refill_way[i];
end
// }}}

// Update flush dependencies
// {{{
deps_rst[i].flush_hit = flush_ack_i & match_flush_nline[i];
deps_rst[i].flush_not_ready = flush_ready_i;
// }}}
end
end
// }}}

// Pop interface
Expand Down

0 comments on commit 4699e14

Please sign in to comment.