Skip to content

Commit 727c3b8

Browse files
MaxWipfliMoritz Scherer
authored andcommitted
treewide: Optimizations for faster Verilator simulation (pulp-platform#259)
* rr_arb_tree: Add Verilator pragmas to split tree node signals This enables Verilator optimizations as it now understands there are no combinatorial loops. For the Cheshire SoC, this can reduce simulation time by around 3%. * lzc: Add Verilator pragmas to split tree node signals This enables Verilator optimizations as it now understands there are no combinatorial loops. For the Cheshire SoC, this can reduce simulation time by around 2.5%. * lzc: Optimize reversing of input vector for Verilator speedup In case the vector is not flipped, using a direct assignment can lead to an approximately 2% decrease in total system simulation time (measured using the Cheshire SoC). * cb_filter: Logic simplification for Verilator speed-up This decreases total simulation time of the Cheshire SoC by around 1.8%.
1 parent 1bdb175 commit 727c3b8

File tree

3 files changed

+20
-15
lines changed

3 files changed

+20
-15
lines changed

src/cb_filter.sv

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,8 @@ module hash_block #(
230230
// output assignment
231231
always_comb begin : proc_hash_or
232232
indicator_o = '0;
233-
for (int unsigned i = 0; i < (2**HashWidth); i++) begin
234-
for (int unsigned j = 0; j < NoHashes; j++) begin
235-
indicator_o[i] = indicator_o[i] | hashes[j][i];
236-
end
233+
for (int unsigned j = 0; j < NoHashes; j++) begin
234+
indicator_o = indicator_o | hashes[j];
237235
end
238236
end
239237

src/lzc.sv

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,21 @@ module lzc #(
4646
`endif
4747

4848
logic [WIDTH-1:0][NumLevels-1:0] index_lut;
49-
logic [2**NumLevels-1:0] sel_nodes;
50-
logic [2**NumLevels-1:0][NumLevels-1:0] index_nodes;
49+
logic [2**NumLevels-1:0] sel_nodes /* verilator split_var */;
50+
logic [2**NumLevels-1:0][NumLevels-1:0] index_nodes /* verilator split_var */;
5151

5252
logic [WIDTH-1:0] in_tmp;
5353

54-
// reverse vector if required
55-
always_comb begin : flip_vector
56-
for (int unsigned i = 0; i < WIDTH; i++) begin
57-
in_tmp[i] = (MODE) ? in_i[WIDTH-1-i] : in_i[i];
54+
if (MODE) begin : g_flip
55+
// Mode 1 (leading zero): flip input vector
56+
always_comb begin : flip_vector
57+
for (int unsigned i = 0; i < WIDTH; i++) begin
58+
in_tmp[i] = in_i[WIDTH-1-i];
59+
end
5860
end
61+
end else begin
62+
// Mode 0 (trailing zero)
63+
assign in_tmp = in_i;
5964
end
6065

6166
for (genvar j = 0; unsigned'(j) < WIDTH; j++) begin : g_index_lut

src/rr_arb_tree.sv

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,13 @@ module rr_arb_tree #(
121121
end else begin : gen_arbiter
122122
localparam int unsigned NumLevels = unsigned'($clog2(NumIn));
123123

124-
/* verilator lint_off UNOPTFLAT */
125-
idx_t [2**NumLevels-2:0] index_nodes; // used to propagate the indices
126-
DataType [2**NumLevels-2:0] data_nodes; // used to propagate the data
127-
logic [2**NumLevels-2:0] gnt_nodes; // used to propagate the grant to masters
128-
logic [2**NumLevels-2:0] req_nodes; // used to propagate the requests to slave
124+
/* verilator lint_off SPLITVAR */ // disable warning that is issued if bitwidth is 1
125+
idx_t [2**NumLevels-2:0] index_nodes /* verilator split_var */; // used to propagate the indices
126+
DataType [2**NumLevels-2:0] data_nodes /* verilator split_var */; // used to propagate the data
127+
logic [2**NumLevels-2:0] gnt_nodes /* verilator split_var */; // used to propagate the grant to masters
128+
logic [2**NumLevels-2:0] req_nodes /* verilator split_var */; // used to propagate the requests to slave
129+
/* verilator lint_on SPLITVAR */
130+
129131
/* lint_off */
130132
idx_t rr_q;
131133
logic [NumIn-1:0] req_d;

0 commit comments

Comments
 (0)