Skip to content

Refactor illegal instruction warning handling#328

Open
MikeOpenHWGroup wants to merge 1 commit into
openhwgroup:mainfrom
MikeOpenHWGroup:refactor_illegal_insn_warn
Open

Refactor illegal instruction warning handling#328
MikeOpenHWGroup wants to merge 1 commit into
openhwgroup:mainfrom
MikeOpenHWGroup:refactor_illegal_insn_warn

Conversation

@MikeOpenHWGroup

Copy link
Copy Markdown
Member

The controller has a bit of behavioural code that prints a warning if an illegal instruction is decoded. This PR will terminate the simulation if the PC does not advance (such circumstances will result in an infinite loop that spews "Illegal instruction..." messages every clock cycle).

The controller has a bit of behavioural code that prints a warning if an illegal instruction is decoded.  This PR will terminate the simulation if the PC does not advance (such circumstances will result in an infinite loop that spews "Illegal instruction..." messages every clock cycle).

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the simulation-only illegal-instruction warning logic in cve2_controller to detect when the core is repeatedly decoding an illegal instruction without making forward progress, and to terminate the simulation to avoid infinite warning spam.

Changes:

  • Adds a “last PC” tracker in the controller’s simulation-only block.
  • Attempts to terminate the simulation when the same illegal instruction is seen at an unchanged PC.
  • Minor formatting updates to $display time formatting.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread rtl/cve2_controller.sv
Comment on lines +160 to +164
logic [31:0] pc_last = 0;
always_ff @(negedge clk_i) begin
// print warning in case of decoding errors
// print warning in case of decoding errors (terminate if the PC doesn't advance).
if ((ctrl_fsm_cs == DECODE) && instr_valid_i && !instr_fetch_err_i && illegal_insn_d) begin
$display("%m @ %t: Illegal instruction (hart %0x) at PC 0x%h: 0x%h", $time, cve2_core.hart_id_i,
cve2_id_stage.pc_id_i, cve2_id_stage.instr_rdata_i);
$display("%m @ %0t: Illegal instruction (hart %0x) at PC 0x%h: 0x%h",
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants