# Requests to sh2-python (found by the transcription) Downstream never fixes behaviour (charter, "How change flows"). These go upstream; this crate keeps the reference's behaviour until a fix arrives by repin. **Status (2026-11-25):** R1 and R2 are fixed upstream in sh2-python `8824075` and carried down by the repin to it (docs/status.md): the reference's `ChipState` gained `internal` and `dma_address_error`, and its DMAC models HM's DMA address errors. The text below is the requests as sent, kept for the record. ## R1. A saved state does not continue identically in a fresh chip (cache on) **Resolved** in sh2-python `8824075` (its tests/test_state.py; here the `bench-*fresh*` scenarios of rung 3 and the `fresh-*` family of rung 5). `ChipState` holds CCR but not the cache's contents: its 4 KB of line data, the 256 tags and valid bits, the 64 LRU fields (`cache.py`; `Cache.state()` returns only `CCR`). Nor does it hold the BSC's SDRAM bank state (open rows, `_ready`, `_pre_ok`) or the chip's `_refresh_end`/`_bsc_due`. A state captured with the cache on and restored into a new `SH7604` on the same memory therefore misses where the original hits. The reference's own round-trip tests restore into the **same** chip, which keeps the cache, so they pass. The methodology's save-state gate ("saves half way, loads into a fresh console and must continue identically") cannot pass for a cached run. Repro (sh2-python at 0d61a66, PyPy): ```python import sys; sys.path[:0] = ["src", "benchmarks"] import harness_speed from sh2_python.harness import Harness def run(chip, n): out = [] for _ in range(n): if chip.pc == 0x11A: chip.pc = 0x100 out.append(chip.step()) return out h = Harness(harness_speed.program()); c = h.chip; c.reset() c._write(0xFFFFFFE8, 32, 0xA55A0000); c._write(0xFFFFFE92, 8, 0x11) # WCR = 0, cache on run(c, 1000) s = c.capture_state() h2 = Harness(harness_speed.program()); h2.high[:] = h.high; h2.low[:] = h.low h2.chip.restore_state(s) print(sum(run(c, 200)), sum(run(h2.chip, 200))) # 267 295: not identical ``` Suggested: the cache module's state carries its arrays (and the BSC its bank state), as the family's boards' save states do; a fresh-console round trip in the tests. This crate transcribes whatever lands, and its lockstep already has a `fresh_restore` operation (scripts/reference_trace.py) that compares the two cores' fresh-console restores with each other. ## R2. A DMA longword or word from the data array at an unaligned address raises **Resolved** in sh2-python `8824075`, modelled as HM 4.3, 9.2.7 and 9.3.8 say, with what the faulting access puts on the bus a HYPOTHESIS (its U15); here the `edge-dma-ae-*` scenarios and `edge-register-sweep-dma` of rung 5. The DMAC does not check its addresses' alignment (DMA address errors, vector 10, are not modelled: dmac.py's docstring), and `_dma_read` reads the data array with `cache.get(address & 0xFFF, width)`, which indexes past the 4 KB bytearray when a longword starts at H'FFD-H'FFF: `IndexError` out of `step()`. (A word at an address that is 3 mod 4 in an on-chip longword module raises too: `LongwordModule.read`'s negative shift.) This crate panics at the same places, faithfully. Repro (sh2-python at 0d61a66): ```python import sys; sys.path.insert(0, "src") from sh2_python import SH7604 chip = SH7604(lambda a, w, k: 0, lambda a, w, v, k: None) chip.pc = 0x06000000 chip._write(0xFFFFFF80, 32, 0xC0000FFE) # SAR0: the data array, not longword-aligned chip._write(0xFFFFFF84, 32, 0x06001000) # DAR0 chip._write(0xFFFFFF88, 32, 1) # TCR0 chip._write(0xFFFFFF8C, 32, 0x0A01) # CHCR0: longword, auto request, DE chip._write(0xFFFFFFB0, 32, 1) # DMAOR: DME chip.step() # IndexError: bytearray index out of range ``` Suggested: model the DMA address error (HM 9.3.x: DMAOR.AE set, the channels stop, vector 10), or at least wrap the data-array offset as the CPU's aligned accesses never need to. Found by this crate's register sweep (edge family), which now keeps DE clear. ## Notes (not requests) - A 16-byte DMA unit with a TCR that is not a multiple of 4 wraps past 0 and runs about 2^22 transfers in one `step()` (HM 9.2.3 says to set 4 × the count; the chip's behaviour otherwise is not documented). Both cores agree; the fuzz generator keeps to multiples of 4 so its scenarios finish.