Refactor illegal instruction warning handling#328
Open
MikeOpenHWGroup wants to merge 1 commit into
Open
Conversation
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).
There was a problem hiding this comment.
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
$displaytime formatting.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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).