Skip to content

Commit 3636496

Browse files
committed
[rvfi] Track expanded instruction in rvfi
Tracking also the original instruction, not only the micro-op, allows the DV to track whether and which instruction we are expanding
1 parent e4040da commit 3636496

File tree

5 files changed

+34
-1
lines changed

5 files changed

+34
-1
lines changed

rtl/ibex_core.sv

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ module ibex_core import ibex_pkg::*; #(
159159
output logic [31:0] rvfi_ext_mhpmcountersh [10],
160160
output logic rvfi_ext_ic_scr_key_valid,
161161
output logic rvfi_ext_irq_valid,
162+
output logic [15:0] rvfi_ext_expanded_insn,
162163
`endif
163164

164165
// CPU Control Signals
@@ -186,6 +187,7 @@ module ibex_core import ibex_pkg::*; #(
186187
logic [15:0] instr_rdata_c_id; // Compressed instruction sampled inside IF stage
187188
logic instr_is_compressed_id;
188189
instr_exp_e instr_gets_expanded_id;
190+
logic [15:0] instr_expanded_id;
189191
logic instr_perf_count_id;
190192
logic instr_bp_taken_id;
191193
logic instr_fetch_err; // Bus error on instr fetch
@@ -474,6 +476,7 @@ module ibex_core import ibex_pkg::*; #(
474476
.instr_rdata_c_id_o (instr_rdata_c_id),
475477
.instr_is_compressed_id_o(instr_is_compressed_id),
476478
.instr_gets_expanded_id_o(instr_gets_expanded_id),
479+
.instr_expanded_id_o (instr_expanded_id),
477480
.instr_bp_taken_o (instr_bp_taken_id),
478481
.instr_fetch_err_o (instr_fetch_err),
479482
.instr_fetch_err_plus2_o (instr_fetch_err_plus2),
@@ -1318,6 +1321,9 @@ module ibex_core import ibex_pkg::*; #(
13181321
logic [31:0] rvfi_ext_stage_mhpmcountersh [RVFI_STAGES][10];
13191322
logic rvfi_ext_stage_ic_scr_key_valid [RVFI_STAGES];
13201323
logic rvfi_ext_stage_irq_valid [RVFI_STAGES+1];
1324+
logic [15:0] rvfi_ext_stage_expanded_insn [RVFI_STAGES];
1325+
1326+
logic [15:0] rvfi_expanded_insn;
13211327

13221328

13231329
logic rvfi_stage_valid_d [RVFI_STAGES];
@@ -1379,6 +1385,7 @@ module ibex_core import ibex_pkg::*; #(
13791385
assign rvfi_ext_mhpmcountersh = rvfi_ext_stage_mhpmcountersh [RVFI_STAGES-1];
13801386
assign rvfi_ext_ic_scr_key_valid = rvfi_ext_stage_ic_scr_key_valid [RVFI_STAGES-1];
13811387
assign rvfi_ext_irq_valid = rvfi_ext_stage_irq_valid [RVFI_STAGES];
1388+
assign rvfi_ext_expanded_insn = rvfi_ext_stage_expanded_insn [RVFI_STAGES-1];
13821389

13831390
// When an instruction takes a trap the `rvfi_trap` signal will be set. Instructions that take
13841391
// traps flush the pipeline so ordinarily wouldn't be seen to be retire. The RVFI tracking
@@ -1596,6 +1603,7 @@ module ibex_core import ibex_pkg::*; #(
15961603
rvfi_ext_stage_debug_mode[i] <= '0;
15971604
rvfi_ext_stage_mcycle[i] <= '0;
15981605
rvfi_ext_stage_ic_scr_key_valid[i] <= '0;
1606+
rvfi_ext_stage_expanded_insn[i] <= '0;
15991607
// DSim does not properly support array assignment in for loop, so unroll
16001608
rvfi_ext_stage_mhpmcounters[i][0] <= '0;
16011609
rvfi_ext_stage_mhpmcountersh[i][0] <= '0;
@@ -1647,6 +1655,7 @@ module ibex_core import ibex_pkg::*; #(
16471655
rvfi_ext_stage_debug_mode[i] <= debug_mode;
16481656
rvfi_ext_stage_mcycle[i] <= cs_registers_i.mcycle_counter_i.counter_val_o;
16491657
rvfi_ext_stage_ic_scr_key_valid[i] <= cs_registers_i.cpuctrlsts_ic_scr_key_valid_q;
1658+
rvfi_ext_stage_expanded_insn[i] <= rvfi_expanded_insn;
16501659
// DSim does not properly support array assignment in for loop, so unroll
16511660
rvfi_ext_stage_mhpmcounters[i][0] <= cs_registers_i.mhpmcounter[3][31:0];
16521661
rvfi_ext_stage_mhpmcountersh[i][0] <= cs_registers_i.mhpmcounter[3][63:32];
@@ -1716,6 +1725,7 @@ module ibex_core import ibex_pkg::*; #(
17161725
rvfi_ext_stage_ic_scr_key_valid[i] <= rvfi_ext_stage_ic_scr_key_valid[i-1];
17171726
rvfi_ext_stage_mhpmcounters[i] <= rvfi_ext_stage_mhpmcounters[i-1];
17181727
rvfi_ext_stage_mhpmcountersh[i] <= rvfi_ext_stage_mhpmcountersh[i-1];
1728+
rvfi_ext_stage_expanded_insn[i] <= rvfi_ext_stage_expanded_insn[i-1];
17191729
end
17201730

17211731
// Some of the rvfi_ext_* signals are used to provide an interrupt notification (signalled
@@ -1784,6 +1794,14 @@ module ibex_core import ibex_pkg::*; #(
17841794
end
17851795
end
17861796

1797+
always_comb begin
1798+
if (instr_gets_expanded_id == INSTR_NOT_EXPANDED) begin
1799+
rvfi_expanded_insn = '0;
1800+
end else begin
1801+
rvfi_expanded_insn = instr_expanded_id;
1802+
end
1803+
end
1804+
17871805
// Source registers 1 and 2 are read in the first instruction cycle
17881806
// Source register 3 is read in the second instruction cycle.
17891807
always_comb begin

rtl/ibex_if_stage.sv

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,11 @@ module ibex_if_stage import ibex_pkg::*; #(
7171
// instr_is_compressed_id_o = 1'b1
7272
output logic instr_is_compressed_id_o, // compressed decoder thinks this
7373
// is a compressed instr
74-
output instr_exp_e instr_gets_expanded_id_o,
74+
output instr_exp_e instr_gets_expanded_id_o, // this instruction comes from one
75+
// that gets expanded by the
76+
// compressed decoder
77+
output logic [15:0] instr_expanded_id_o, // the instruction that is currently
78+
// getting expanded
7579
output logic instr_bp_taken_o, // instruction was predicted to be
7680
// a taken branch
7781
output logic instr_fetch_err_o, // bus error on fetch
@@ -514,6 +518,8 @@ module ibex_if_stage import ibex_pkg::*; #(
514518
instr_fetch_err_plus2_o <= '0;
515519
instr_rdata_c_id_o <= '0;
516520
instr_is_compressed_id_o <= '0;
521+
instr_gets_expanded_id_o <= INSTR_NOT_EXPANDED;
522+
instr_expanded_id_o <= '0;
517523
illegal_c_insn_id_o <= '0;
518524
pc_id_o <= '0;
519525
end else if (if_id_pipe_reg_we) begin
@@ -525,6 +531,7 @@ module ibex_if_stage import ibex_pkg::*; #(
525531
instr_rdata_c_id_o <= if_instr_rdata[15:0];
526532
instr_is_compressed_id_o <= instr_is_compressed_out;
527533
instr_gets_expanded_id_o <= instr_gets_expanded_out;
534+
instr_expanded_id_o <= if_instr_rdata[15:0];
528535
illegal_c_insn_id_o <= illegal_c_instr_out;
529536
pc_id_o <= pc_if_o;
530537
end
@@ -540,6 +547,7 @@ module ibex_if_stage import ibex_pkg::*; #(
540547
instr_rdata_c_id_o <= if_instr_rdata[15:0];
541548
instr_is_compressed_id_o <= instr_is_compressed_out;
542549
instr_gets_expanded_id_o <= instr_gets_expanded_out;
550+
instr_expanded_id_o <= if_instr_rdata[15:0];
543551
illegal_c_insn_id_o <= illegal_c_instr_out;
544552
pc_id_o <= pc_if_o;
545553
end

rtl/ibex_lockstep.sv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,7 @@ module ibex_lockstep import ibex_pkg::*; #(
481481
.rvfi_ext_mhpmcountersh (),
482482
.rvfi_ext_ic_scr_key_valid (),
483483
.rvfi_ext_irq_valid (),
484+
.rvfi_ext_expanded_insn (),
484485
`endif
485486

486487
.fetch_enable_i (shadow_inputs_q[0].fetch_enable),

rtl/ibex_top.sv

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ module ibex_top import ibex_pkg::*; #(
144144
output logic [31:0] rvfi_ext_mhpmcountersh [10],
145145
output logic rvfi_ext_ic_scr_key_valid,
146146
output logic rvfi_ext_irq_valid,
147+
output logic [15:0] rvfi_ext_expanded_insn,
147148
`endif
148149

149150
// CPU Control Signals
@@ -426,6 +427,7 @@ module ibex_top import ibex_pkg::*; #(
426427
.rvfi_ext_mhpmcountersh,
427428
.rvfi_ext_ic_scr_key_valid,
428429
.rvfi_ext_irq_valid,
430+
.rvfi_ext_expanded_insn,
429431
`endif
430432

431433
.fetch_enable_i (fetch_enable_buf),

rtl/ibex_top_tracing.sv

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ module ibex_top_tracing import ibex_pkg::*; #(
135135
logic [31:0] rvfi_ext_mhpmcountersh [10];
136136
logic rvfi_ext_ic_scr_key_valid;
137137
logic rvfi_ext_irq_valid;
138+
logic [15:0] rvfi_ext_expanded_insn;
138139

139140
logic [31:0] unused_perf_regs [10];
140141
logic [31:0] unused_perf_regsh [10];
@@ -150,6 +151,7 @@ module ibex_top_tracing import ibex_pkg::*; #(
150151
logic [63:0] unused_rvfi_ext_mcycle;
151152
logic unused_rvfi_ext_ic_scr_key_valid;
152153
logic unused_rvfi_ext_irq_valid;
154+
logic [15:0] unused_rvfi_ext_expanded_insn;
153155

154156
// Tracer doesn't use these signals, though other modules may probe down into tracer to observe
155157
// them.
@@ -165,6 +167,7 @@ module ibex_top_tracing import ibex_pkg::*; #(
165167
assign unused_perf_regsh = rvfi_ext_mhpmcountersh;
166168
assign unused_rvfi_ext_ic_scr_key_valid = rvfi_ext_ic_scr_key_valid;
167169
assign unused_rvfi_ext_irq_valid = rvfi_ext_irq_valid;
170+
assign unused_rvfi_ext_expanded_insn = rvfi_ext_expanded_insn;
168171

169172
ibex_top #(
170173
.PMPEnable ( PMPEnable ),
@@ -273,6 +276,7 @@ module ibex_top_tracing import ibex_pkg::*; #(
273276
.rvfi_ext_mhpmcountersh,
274277
.rvfi_ext_ic_scr_key_valid,
275278
.rvfi_ext_irq_valid,
279+
.rvfi_ext_expanded_insn,
276280

277281
.fetch_enable_i,
278282
.alert_minor_o,

0 commit comments

Comments
 (0)