Skip to content

[BUG] Core lockup with short debug pulses (1-2 cycles) #314

@Amit-Matth

Description

@Amit-Matth

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

  1. Run a test case (e.g., debug_test.c that pulses debug_req_i for 1 or 2 cycles.
  2. Ensure the core is busy (e.g., executing instructions) during the pulse.
  3. Observe that the core continues execution instead of entering debug mode, or enters an inconsistent state.
  4. 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.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions