Skip to content

Commit 5b4a669

Browse files
Fix for issue openhwgroup#341.
Removed sticky debug request (debug_req_q) Updated assertion a_fencei_hndshk_req_when_fencei_wb to accomodate changes. Signed-off-by: Oystein Knauserud <[email protected]>
1 parent d0e123f commit 5b4a669

File tree

2 files changed

+8
-18
lines changed

2 files changed

+8
-18
lines changed

rtl/cv32e40x_controller_fsm.sv

+6-17
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,6 @@ module cv32e40x_controller_fsm import cv32e40x_pkg::*;
137137
// Debug state
138138
debug_state_e debug_fsm_cs, debug_fsm_ns;
139139

140-
// Sticky version of debug_req_i
141-
logic debug_req_q;
142-
143140
// Sticky version of lsu_err_wb_i
144141
logic nmi_pending_q;
145142
logic nmi_is_store_q; // 1 for store, 0 for load
@@ -482,8 +479,12 @@ module cv32e40x_controller_fsm import cv32e40x_pkg::*;
482479
(ebreak_in_wb && dcsr_i.ebreakm && !debug_mode_q) || // Ebreak with dcsr.ebreakm==1
483480
(ebreak_in_wb && debug_mode_q); // Ebreak during debug_mode restarts execution from dm_halt_addr, as a regular debug entry without CSR updates.
484481

485-
// Debug pending for external debug request
486-
assign pending_async_debug = ((debug_req_i || debug_req_q) && !debug_mode_q);
482+
// Debug pending for external debug request, only if not already in debug mode
483+
// Ideally the !debug_mode_q below should be factored into async_debug_allowed, but
484+
// that can currently cause a deadlock if debug_req_i gets asserted while in debug mode, as
485+
// a pending but not allowed async debug will cause the ID stage to halt forever while trying
486+
// to get to an interruptible state.
487+
assign pending_async_debug = debug_req_i && !debug_mode_q;
487488

488489
// Determine cause of debug. Set for all causes of debug entry.
489490
// In case of ebreak during debug mode, the entry code in DEBUG_TAKEN will
@@ -1129,18 +1130,6 @@ module cv32e40x_controller_fsm import cv32e40x_pkg::*;
11291130
assign ctrl_fsm_o.debug_mode_if = debug_mode_n;
11301131
assign ctrl_fsm_o.debug_mode = debug_mode_q;
11311132

1132-
// sticky version of debug_req (must be on clk_ungated_i such that incoming pulse before core is enabled is not missed)
1133-
always_ff @(posedge clk_ungated_i, negedge rst_n) begin
1134-
if (rst_n == 1'b0) begin
1135-
debug_req_q <= 1'b0;
1136-
end else begin
1137-
if (debug_req_i) begin
1138-
debug_req_q <= 1'b1;
1139-
end else if (debug_mode_q) begin
1140-
debug_req_q <= 1'b0;
1141-
end
1142-
end
1143-
end
11441133

11451134
// Sticky version of lsu_err_wb_i
11461135
always_ff @(posedge clk, negedge rst_n) begin

sva/cv32e40x_controller_fsm_sva.sv

+2-1
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,10 @@ module cv32e40x_controller_fsm_sva
244244
else `uvm_error("controller", "Fencei request when no fencei in writeback")
245245

246246
// Assert that the fencei request is set the cycle after fencei instruction enters WB (if fencei_ready=1 and there are no higher priority events)
247+
// Only check when no higher priority event is pending (nmi, async debug or interrupts) and WB stage is not killed
247248
a_fencei_hndshk_req_when_fencei_wb :
248249
assert property (@(posedge clk) disable iff (!rst_n)
249-
$rose(fencei_in_wb && fencei_ready) && !(pending_nmi || (pending_async_debug && async_debug_allowed) || (pending_interrupt && interrupt_allowed))
250+
$rose(fencei_in_wb && fencei_ready) && !ctrl_fsm_o.kill_wb && !(pending_nmi || (pending_async_debug && async_debug_allowed) || (pending_interrupt && interrupt_allowed))
250251
|=> $rose(fencei_flush_req_o))
251252
else `uvm_error("controller", "Fencei in WB did not result in fencei_flush_req_o")
252253

0 commit comments

Comments
 (0)