Skip to content

Commit 3bc1261

Browse files
authored
Fix remaining sec inconsistency regarding the X-IF addition (#291)
* Changes to make the X_if addition compatible with the golden version of the core, minus the rf_we line * [rt][sec][xif] Made the length of the cve2_id_stage's rf_wdata_sel dependent on the whether the X-IF is present * [rtl][sec][xif] Made the length of the cve2_id_stage's rf_wdata_sel dependent on the whether the X-IF is present
1 parent e8e7967 commit 3bc1261

File tree

3 files changed

+26
-26
lines changed

3 files changed

+26
-26
lines changed

rtl/cve2_decoder.sv

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ module cve2_decoder #(
5151
output logic [31:0] zimm_rs1_type_o,
5252

5353
// register file
54-
output cve2_pkg::rf_wd_sel_e rf_wdata_sel_o, // RF write data selection
54+
output logic [XInterface:0] rf_wdata_sel_o, // RF write data selection
5555
output logic rf_we_o, // write enable for regfile
5656
output logic [4:0] rf_raddr_a_o,
5757
output logic [4:0] rf_raddr_b_o,
@@ -660,7 +660,7 @@ module cve2_decoder #(
660660
// insufficient privileges), or when accessing non-available registers in RV32E,
661661
// these cases are not handled here
662662
if (illegal_insn) begin
663-
// rf_we = 1'b0;
663+
rf_we &= XInterface;
664664
data_req_o = 1'b0;
665665
data_we_o = 1'b0;
666666
jump_in_dec_o = 1'b0;

rtl/cve2_id_stage.sv

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,10 @@ module cve2_id_stage #(
216216

217217
// Register file interface
218218

219-
rf_wd_sel_e rf_wdata_sel;
220-
logic rf_we_dec, rf_we_raw;
221-
logic rf_ren_a, rf_ren_b;
222-
logic rf_ren_a_dec, rf_ren_b_dec;
219+
logic [XInterface:0] rf_wdata_sel;
220+
logic rf_we_dec, rf_we_raw;
221+
logic rf_ren_a, rf_ren_b;
222+
logic rf_ren_a_dec, rf_ren_b_dec;
223223

224224
// Read enables should only be asserted for valid and legal instructions
225225
assign rf_ren_a = instr_valid_i & ~instr_fetch_err_i & ~illegal_insn_o & rf_ren_a_dec;
@@ -418,19 +418,12 @@ module cve2_id_stage #(
418418

419419
// Register file write data mux
420420
always_comb begin : rf_wdata_id_mux
421-
if (XInterface)
422-
unique case (rf_wdata_sel)
423-
RF_WD_EX: rf_wdata_id_o = result_ex_i;
424-
RF_WD_CSR: rf_wdata_id_o = csr_rdata_i;
425-
RF_WD_COPROC: rf_wdata_id_o = x_result_i.data;
426-
default: rf_wdata_id_o = result_ex_i;
427-
endcase
428-
else
429-
unique case (rf_wdata_sel)
430-
RF_WD_EX: rf_wdata_id_o = result_ex_i;
431-
RF_WD_CSR: rf_wdata_id_o = csr_rdata_i;
432-
default: rf_wdata_id_o = result_ex_i;
433-
endcase
421+
unique case (rf_wdata_sel)
422+
RF_WD_EX: rf_wdata_id_o = result_ex_i;
423+
RF_WD_CSR: rf_wdata_id_o = csr_rdata_i;
424+
RF_WD_COPROC: rf_wdata_id_o = XInterface? x_result_i.data : result_ex_i;
425+
default: rf_wdata_id_o = result_ex_i;
426+
endcase
434427
end
435428

436429
/////////////
@@ -826,7 +819,7 @@ module cve2_id_stage #(
826819
// Stall ID/EX stage for reason that relates to instruction in ID/EX, update assertion below if
827820
// modifying this.
828821
assign stall_id = stall_mem | stall_multdiv | stall_jump | stall_branch |
829-
stall_alu | stall_coproc;
822+
stall_alu | (XInterface & stall_coproc);
830823

831824
// Generally illegal instructions have no reason to stall, however they must still stall waiting
832825
// for outstanding memory requests so exceptions related to them take priority over the illegal
@@ -902,10 +895,17 @@ module cve2_id_stage #(
902895
OP_A_FWD,
903896
OP_A_CURRPC,
904897
OP_A_IMM})
905-
`ASSERT(IbexRegfileWdataSelValid, instr_valid_i |-> rf_wdata_sel inside {
906-
RF_WD_EX,
907-
RF_WD_CSR,
908-
RF_WD_COPROC})
898+
if (XInterface) begin: gen_asserts_xif
899+
`ASSERT(IbexRegfileWdataSelValid, instr_valid_i |-> rf_wdata_sel inside {
900+
RF_WD_EX,
901+
RF_WD_CSR,
902+
RF_WD_COPROC})
903+
end
904+
else begin : no_gen_asserts_xif
905+
`ASSERT(IbexRegfileWdataSelValid, instr_valid_i |-> rf_wdata_sel inside {
906+
RF_WD_EX,
907+
RF_WD_CSR})
908+
end
909909
`ASSERT_KNOWN(IbexWbStateKnown, id_fsm_q)
910910

911911
// Branch decision must be valid when jumping.

rtl/cve2_pkg.sv

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,10 +260,10 @@ package cve2_pkg;
260260
} imm_b_sel_e;
261261

262262
// Regfile write data selection
263-
typedef enum logic[1:0] {
263+
typedef enum {
264264
RF_WD_EX,
265265
RF_WD_CSR,
266-
RF_WD_COPROC
266+
RF_WD_COPROC // Only used when XInterface = 1
267267
} rf_wd_sel_e;
268268

269269
//////////////

0 commit comments

Comments
 (0)