Fix MC68020 and A1200 chip-bus timing#263
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refines Copperline’s MC68020 + A1200 (AGA/Alice) timing model to better match real hardware by switching from a flat cycle-scaling approximation to datasheet/manual-derived timing tables and by modeling the A1200 chip-bus read data-return phase.
Changes:
- Replaced the prior “scaled-from-68000” 68020 timing approximation with MC68020UM section 8.2 integer timing tables (cache-case vs worst-case selection).
- Added per-instruction “all instruction-stream fetches hit” tracking so 68020 cache-case timing is only selected when opcode + extension + immediate words are resident.
- Updated A1200/Alice chip-bus timing to include an extra data-return phase for reads (chip RAM, cache fills, custom-register reads) while keeping writes posted, and documented the updated model.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/cpu.rs | Tracks per-instruction instruction-cache residency across opcode/extension/immediate fetches; adds targeted tests. |
| src/bus.rs | Adjusts A1200 (AGA/Alice) chip-bus timing to bill a read data-return phase; updates custom read behavior accordingly. |
| src/bus/tests.rs | Updates/renames AGA 68020 bus timing test expectations for read-vs-write behavior and fetch latch behavior. |
| README.md | Notes that 68020 integer timing is now selected from MC68020UM per-instruction totals. |
| docs/internals/timing.md | Documents the A1200 Alice data-return phase and the posted-write vs read-wait asymmetry. |
| docs/internals/cpu.md | Replaces the old 68020+ scaling narrative with the new MC68020UM table-driven timing model and its limitations. |
| crates/m68k/src/core/timing_060.rs | Extends finalize-cycle dispatch to route 68020/68EC020 through the new 68020 timing model. |
| crates/m68k/src/core/timing_020.rs | New module implementing MC68020UM section 8.2 integer timing tables plus unit tests. |
| crates/m68k/src/core/mod.rs | Exposes the new timing_020 module. |
| crates/m68k/src/core/memory.rs | Extends AddressBus with per-instruction fetch tracking hooks used by 68020 timing selection. |
| crates/m68k/src/core/execute.rs | Resets per-instruction fetch tracking each instruction and selects 68020 cache-case only when the full stream hit. |
| crates/m68k/src/core/cpu.rs | Adds per-instruction exception vector tracking to support exception timing selection in the 68020 model; updates comments and default init. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Summary
Benchmark results
Classic SysInfo 4.4 on the A1200 profile:
xSysInfo improves from 1.34x to 1.19x A1200. Its detected CPU clock is 13.76 MHz, so no workload-specific multiplier was added to chase the remaining difference.
Verification
cargo test --locked(1,754 passed, 5 ignored)cargo test --manifest-path crates/m68k/Cargo.toml --lib --locked(93 passed)cargo clippy --all-targets --all-features --locked -- -D warningscargo fmt --checkgit diff --checkcargo build --release --lockedThe optional broad m68k integration target expects Musashi fixture binaries that are not present in this checkout; the applicable self-contained library suite passes.