Skip to content

fix unclock functionality (io / cp0) and tests for MIPS components - #117

Merged
Spooky-Firefox merged 1 commit into
masterfrom
p0_unclock_fix
Sep 30, 2026
Merged

Spooky-Firefox merged 1 commit into
masterfrom
p0_unclock_fix

Conversation

@Spooky-Firefox

Copy link
Copy Markdown
Collaborator

This pull request introduces improvements and corrections to the interrupt handling and simulation replay mechanisms in the MIPS CPU and IO components. The main focus is on making the simulation of interrupts and their rollback (unclock) behavior more robust and testable, especially for the IO device. The changes include bug fixes, new and improved tests, and a refactor of the IO state management to ensure correct undo/redo of simulation steps.

Key changes include:

Interrupt and Simulation Replay Robustness:

  • Refactored MipsIOData to track all state changes relevant to simulation replay, replacing ad-hoc tracking with a dedicated IOState struct and a history stack for robust unclock (rollback) support. This ensures IO state can be precisely restored when stepping backwards in the simulation. [1] [2] [3]
  • Updated the un_clock method in both CP0 and MipsIO to correctly restore previous state based on simulation cycle, fixing off-by-one errors and ensuring that only actual state changes are reverted. [1] [2]
  • Improved error handling in MipsIO for invalid addresses and data, replacing todo! placeholders with proper error and warning conditions.

Testing Improvements:

  • Added comprehensive tests for interrupt handling and simulation replay for both timer and IO interrupts, including new test cases for the CP0 component and a new interrupt_test.rs file for integration-style interrupt tests. [1] [2]

Bug Fixes and Cleanups:

  • Fixed address constants in CP0 register writes to use hexadecimal notation, ensuring correct register selection.
  • Removed unused and unnecessary fields (read_eq_end_cause, BitVec) and constants from MipsIOData, simplifying the codebase. [1] [2]
  • Fixed a bug where the IO read enable input was incorrectly wired to the write enable input, ensuring correct IO behavior.

These changes collectively make the simulation of interrupts and their rollback more reliable and maintainable, and add thorough tests to prevent regressions.

References:

@Spooky-Firefox
Spooky-Firefox merged commit f383e93 into master Sep 30, 2026
4 checks passed
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