Skip to content

Commit 727c573

Browse files
Merge pull request #694 from silabs-oysteink/silabs-oysteink_ptr-mcause-stall
CSR stall on CLIC pointers writing to mcause.minhv
2 parents 057c0cd + 011baa6 commit 727c573

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

bhv/cv32e40x_wrapper.sv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ module cv32e40x_wrapper
221221
.prefetch_valid_if_i (core_i.if_stage_i.prefetch_valid),
222222
.prefetch_is_tbljmp_ptr_if_i (core_i.if_stage_i.prefetch_is_tbljmp_ptr),
223223
.lsu_trans_valid_i (core_i.load_store_unit_i.trans_valid),
224+
.csr_en_id_i (core_i.id_stage_i.csr_en),
224225
.*);
225226
bind cv32e40x_cs_registers:
226227
core_i.cs_registers_i

rtl/cv32e40x_controller_bypass.sv

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,10 @@ module cv32e40x_controller_bypass import cv32e40x_pkg::*;
131131
// todo:low:Above loop reasoning only applies to halt_id; for other pipeline stages a local instr_valid signal can maybe be used.
132132

133133
// Detect when a CSR insn in in EX or WB
134-
// mret and dret implicitly writes to CSR. (dret is killing IF/ID/EX once it is in WB and can be disregarded here.
134+
// mret, dret and CLIC pointers implicitly writes to CSR. (dret is killing IF/ID/EX once it is in WB and can be disregarded here.
135135
assign csr_write_in_ex_wb = (
136-
(id_ex_pipe_i.instr_valid && (id_ex_pipe_i.csr_en || (id_ex_pipe_i.sys_en && id_ex_pipe_i.sys_mret_insn))) ||
137-
(ex_wb_pipe_i.instr_valid && (ex_wb_pipe_i.csr_en || (ex_wb_pipe_i.sys_en && ex_wb_pipe_i.sys_mret_insn)))
136+
(id_ex_pipe_i.instr_valid && (id_ex_pipe_i.csr_en || (id_ex_pipe_i.sys_en && id_ex_pipe_i.sys_mret_insn) || id_ex_pipe_i.instr_meta.clic_ptr)) ||
137+
(ex_wb_pipe_i.instr_valid && (ex_wb_pipe_i.csr_en || (ex_wb_pipe_i.sys_en && ex_wb_pipe_i.sys_mret_insn) || ex_wb_pipe_i.instr_meta.clic_ptr))
138138
);
139139

140140
// Stall ID when WFI or WFE is active in EX.

sva/cv32e40x_controller_fsm_sva.sv

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ module cv32e40x_controller_fsm_sva
9797
input logic wu_wfe_i,
9898
input logic sys_en_id_i,
9999
input logic sys_mret_id_i,
100-
input logic clic_ptr_in_wb
100+
input logic clic_ptr_in_wb,
101+
input logic csr_en_id_i
101102
);
102103

103104

@@ -794,5 +795,15 @@ end
794795
|->
795796
!ctrl_fsm_o.halt_wb)
796797
else `uvm_error("controller", "csr_restore_mret when WB is halted")
798+
799+
// CSR instructions should be stalled in ID if there is a CLIC pointer in EX or WB (RAW hazard)
800+
a_csr_stall_on_ptr:
801+
assert property (@(posedge clk) disable iff (!rst_n)
802+
(csr_en_id_i && if_id_pipe_i.instr_valid) &&
803+
((id_ex_pipe_i.instr_meta.clic_ptr && id_ex_pipe_i.instr_valid) ||
804+
(ex_wb_pipe_i.instr_meta.clic_ptr && ex_wb_pipe_i.instr_valid))
805+
|->
806+
!id_valid_i)
807+
else `uvm_error("controller", "CSR* not stalled in ID when CLIC pointer is in EX or WB")
797808
endmodule
798809

0 commit comments

Comments
 (0)