copper: model the WAIT/SKIP/COPJMP pipeline against the vAmiga copper trace#146
Merged
Conversation
Owner
Author
|
Merge-order note: this PR and #145 both bump savestate::STATE_VERSION to 25 - whichever merges second must renumber to 26 (one-line change). The small guard-family movements (CIA +2.8, Paula +1.3, Blitter +4.2) are the CPU-vs-copper phase boundary and should be re-validated once stacked on #145's blitter model. |
… trace Copper MOVE-after-WAIT register writes landed four colour clocks late (SPR0CTL at hpos $26 where the vAmigaTS spritedma/interfere real-A500 photos and vAmiga land it at $22). Two-sided landing probes isolated four pipeline differences, each modelled here: - The WAIT comparator's horizontal input runs two colour clocks ahead of the beam and wraps through zero over the last three clocks of a line (vAmiga runHorizontalComparator). A sleeping WAIT wakes at target-2, the match clock is the bus-free wake-up cycle, the next fetch lands on the masked target and its write two clocks later. - A WAIT/SKIP spends two Copper cycles after its second word fetch (Minimig WAITSKIP1/WAITSKIP2, vAmiga COP_WAIT1/COP_WAIT2): an immediately-true WAIT resumes fetching at fetch2+6. - The SKIP decision samples the comparator at the next instruction's first-word fetch (vAmiga evaluates the skip flag inside COP_FETCH), so a line-end SKIP pushed past the wrap by the bus lockout sees the next line's vertical phase (jumpbpu-style list switches). - A Copper MOVE to COPJMP1/2 spends two tail cycles (COP_JMP1/COP_JMP2) before the PC reloads; the first fetch from the new list lands three Copper cycles after the strobe (vAmiga trace: strobe write at $04, next list's write at $0C). Calibrations that had absorbed the old +4 landing move in lockstep: the copper bus lockout sits at $E0 on short lines ($E1 on long lines, vAmiga busIsFree), the vertical-blank restart fetches from hpos $02 (vAmiga trace: first frame-start MOVE write at $04), copper-sourced render events are recorded at their Denise-effective position (bus landing plus DENISE_WRITE_EFFECT_DELAY_CCK), and copper-raised interrupts take COPPER_IRQ_EXTRA_LATENCY_CCK on top of the calibrated recognition latency. The last two compensate the still-unmodelled CPU write-landing bias and carry a shared TODO. vAmigaTS Agnus/Copper family sum drops 1115.7 -> 1008.2 (copstrt1/2 28.3 -> 0.0, cross6 14.0 -> 0.0, Skip family 65.8 -> 2.4, mask 113.5 -> 86.2, Wait 10.5 -> 4.5, coptim 50.6 -> 45.4, oldJump 137.6 -> 131.9 with jumpbpu1-4 restored). Remaining regressions are the CPU-vs-copper colour race class (coprace, copcpu1) bounded by the CPU write-landing bias. Bumps savestate::STATE_VERSION to 25 (Copper gained skip_eval and the Jumping strobe-tail state).
Env-gated stderr trace of every Copper MOVE's landing colour clock (beam position, register, value), for cross-emulator write-landing comparison against vAmiga's VAMIGA_COP_PROBE trace (snapshot of that patch in vamigats-reports/vamiga-cop-probe.patch).
…nt models it The +4 recognition-latency offset for copper-raised interrupts was calibrated against the pre-#144 IPL pipe, which itself embedded the old +4-late copper landings. With the per-instruction IPL poll placement on main, copper INTREQ/INTENA writes recognize correctly from their bus-true landings: with the offset the vAmigaTS Copper/Irq family regressed 15.0 -> 42.3 and coprace 96.4 -> 167.1; without it they sit at the new-main baseline.
b765ec1 to
1d5ccc6
Compare
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.
Rebased onto main c4c7207 (#141-#145); all numbers below are re-measured against a fresh c4c7207 baseline.
savestate::STATE_VERSIONis now 26 (#145 took 25). The interrupt-latency compensation from the pre-rebase version was dropped: #144's IPL poll placement models the recognition, and with the offset the Copper/Irq family regressed 15.0 -> 42.3 (without it: 14.9).The class
Copper MOVE-after-WAIT register writes landed ~4 colour clocks late relative to vAmiga/real hardware (SPR0CTL at hpos $26 where the vAmigaTS spritedma/interfere real-A500 photos and vAmiga land it at $22). Three independent investigations converged on this class as the dominant Agnus/Copper residual.
Two-sided trace evidence
Both emulators instrumented with env-gated landing probes:
COPPERLINE_DIAG_COP_WRITES=1(new, this PR) andVAMIGA_COP_PROBE=1in the local vAmiga tree (snapshot:vamigats-reports/vamiga-cop-probe.patch). Denise/Sprites/spritedma/interfere2 (WAIT $4721/MOVE SPR0CTL/MOVE COLOR00/WAIT $47B1/MOVE COLOR00), per-frame steady state:The jumpbpu trace pinned two more pipeline differences: the frame-start stream (vAmiga's first line-0 MOVE write lands at h=$04; CL's landed at $08) and the post-COPJMP fetch (vAmiga strobe write at h=$04 fetches the new list's first MOVE at $0A, write at $0C; CL wrote at $08). Both are now cycle-exact against the vAmiga trace.
The pipeline model (all vAmiga-verified)
runHorizontalComparator). A sleeping WAIT wakes at target-2; the match clock is the bus-free wake-up cycle; the next fetch lands on the masked target, its write two clocks later.busIsFree<COPPER>), previously fixed $E1.One calibration that had absorbed the old +4 landing moves in lockstep, with a TODO naming the CPU write-landing class it still compensates: copper-sourced render events are recorded at their Denise-effective position (
DENISE_WRITE_EFFECT_DELAY_CCK, bus landing +4; CPU-sourced writes already carry that offset in their landing).vAmigaTS results on the rebased stack (tools/vamigats-compare.py, diff% family sums, baseline = main c4c7207)
Other gates (rebased stack)
cargo test --lib: 1329 passed.cargo clippy --all-targets --all-features --locked -- -D warningsandcargo fmt --checkclean.Rebase conflict resolutions
src/savestate.rs: blitter: model the micro-cycle protocol against the vAmiga slot oracle #145 took version 25; this PR's bump renumbered to 26 with both changelog lines kept.src/bus/tests.rs(copper_wait_with_bfd_clear_resumes_after_busy_blitter_finishes): blitter: model the micro-cycle protocol against the vAmiga slot oracle #145's blit end protocol finishes the polled blit one colour clock earlier (wakeup prediction Some(8)); with this PR's wake semantics the MOVE write lands at hpos 0x2E, recorded at its Denise-effective position 0x32. Verified by the suite.docs
COPPERLINE_DIAG_COP_WRITESrow.