-
Notifications
You must be signed in to change notification settings - Fork 34
Description
Bug Description
Description
The cve2 core fails to enter debug mode and locks up (or behaves unpredictably) when the debug_req_i signal is asserted for a short duration (1 or 2 clock cycles). This was observed in the cv32e20-dv environment but is caused by the core's handling of the debug request signal.
Root Cause
The cve2_controller FSM uses combinatorial logic to detect debug requests:
assign enter_debug_mode = enter_debug_mode_prio_d | (trigger_match_i & ~debug_mode_q);enter_debug_mode_prio_d is derived from debug_req_i. Use of grep confirms that enter_debug_mode_prio_q (the registered version) is assigned but never used in any state transition logic or output assignment. It effectively acts as dead code.
Because it is not used in the enter_debug_mode condition, the request is dropped immediately after the pulse ends if the core was not ready to accept it.
Steps to Reproduce
- Run a test case (e.g.,
debug_test.cthat pulsesdebug_req_ifor 1 or 2 cycles. - Ensure the core is busy (e.g., executing instructions) during the pulse.
- Observe that the core continues execution instead of entering debug mode, or enters an inconsistent state.
- Simulation assertion failure (if enabled):
IbexDontSkipExceptionReq.
Proposed Fix
Modify cv32e20/rtl/cve2_controller.sv to include the registered debug request signal (enter_debug_mode_prio_q) in the valid debug mode entry condition. This makes the request "sticky" for at least one extra cycle.
// old
// assign enter_debug_mode = enter_debug_mode_prio_d | (trigger_match_i & ~debug_mode_q);
// new
assign enter_debug_mode = enter_debug_mode_prio_d | enter_debug_mode_prio_q | (trigger_match_i & ~debug_mode_q);Verification
With the proposed fix, the core correctly detects 1-cycle and 2-cycle debug pulses and transitions to the debug ROM address as expected.