# The cores this board reuses, and what each needs The reuse-first survey. The Spectrum needs one CPU (Z80) and one sound chip (AY-3-8912) the family already has, one controller (uPD765A) the family has inside another board, and its own ULA/gate array, which stays in the board (chip rule: no other family machine uses it). | Chip | Family core | State | What the Spectrum needs from it | | --- | --- | --- | --- | | Z80A (NMOS; a few CMOS) | `../z80-python` (PUBLIC; local `main` 1302260, origin/main `b59c80b`) | instruction core, oracle-certified; access-timing table on origin/main; `read_m1` hook on branch `m1-fetch-hook-rebased` (`5434349`), unmerged | N1-N5 below | | AY-3-8912 | `../ay8910-python` (PUBLIC, `76cace3`) | built, judged against a die model, `AY8912` variant | nothing: input clock = CPU/2, port A as the core already offers | | uPD765A | inside `../sms-python` (`sf7000.py`, `UPD765`, `7066415`) | one drive, non-DMA, polled | extraction to `upd765-python` (chip rule, second user) plus two units, IPF/DSK-level discs, no-TC behaviour (fdc-upd765.md) | | ULA 5C/6C, 7K010; gate arrays 40056, 40077 | none (new, in this board) | - | - | | TMS9918, SN76489, etc. | not used | - | - | ## z80-python: the needs z80-python is an **instruction-level** core: `step()` executes one instruction through the host's `read_byte`/`write_byte`/`read_port`/`write_port` callables and returns its T-states; its README says plainly "It is **not** a claim of cycle-accurate bus-pin behavior". The Spectrum is the family's hardest Z80 host, because the ULA stops the Z80's clock in the middle of instructions, at T-states that depend on the address on the bus **including internal cycles with no memory request**. What the board needs, in order of importance: **N1. Where each access falls, and the internal cycles' addresses.** origin/main's `z80_python.timing.instruction_timing(bytes)` (commit `2f334ef`, merged as `b59c80b`) gives every MREQ/IORQ access's T-state offset, derived from SingleStepTests' per-T-state bus samples. With it the board can apply contention access by access: the k-th callback is the k-th access, its address is the callback's argument, its nominal offset is in the table, and each stall pushes everything after it later. Missing: the **internal T-states during which the Z80 holds an address on the bus without MREQ** (FAQ48's `pc+1:1 x 5`, `hl:1 x 4` entries, and the Wiki's `ir:1 x 2` for the T-states after a fetch, C13), which the Ferranti ULAs contend. SST's `cycles` arrays record the address on every T-state, so the same derivation can emit them as `("internal", t, source)` entries; FAQ48's breakdown (tier 3) and the 48K NEC Contention Test Suite and the timing-test suites (tier 3, hardware-verified) then judge the derivation, which is emulator-derived (SST comes from a port of Ares). **Proposal for z80-python** (raised there, not done here): extend `instruction_timing` with internal cycles and the address source of each (pc+n, hl, de, sp, ir, ii+n), and add interrupt acknowledge and the HALT cycle, which the table says it does not cover. **N2. Refresh: I:R on the bus in T3-T4 of each M1.** Snow needs the refresh address of each opcode fetch and the T-state it appears (floating-bus-and-snow.md). R after the fetch is in the CPU's state; the fetch's position is the table's `t == 1` plus 2. Nothing new is needed beyond N1 if the board reads R through the public state; `read_m1` (N4) would make it direct. **N3. Interrupt acknowledge timing.** The ULA's /INT lasts a fixed number of T-states (32 on the 48K by common report: HYPOTHESIS, U7) and the Z80 samples it at the end of each instruction; IM 2 reads the floating bus for the vector low byte (the IM0-2 test in the collection probes this). The board needs the acknowledge's length and access offsets (IM 1: 13 T; IM 2: 19 T; plus the HALT exit), which the timing table excludes. z80-python already models the acknowledge in `step()`; the request is to publish its access timing like N1's. **N4. The M1 hook (`read_m1`).** On `m1-fetch-hook-rebased` (`5434349`, rebased onto `b62891b`, full gate 6,303 passed on CPython and PyPy per the ColecoVision record). The Spectrum does not need a different byte for fetches, but the hook marks every M1 (fetch, HALT, acknowledge), which is where snow and the /RFSH-dependent late-timing rule (C2) live. Merging it is Aubrey's call (z80-python is public). **N5. NMOS versus CMOS.** Late +2A/+3s and some replacement boards carry CMOS Z80s; the collection's tests show different expected pictures for "Zilog NMOS" and "Zilog CMOS" (ULA 128 Timing Test, ULA 48 Simple Test). z80-python has a CMOS variant in progress (`../z80-python-cmos`, branch `cmos-out-c-zero`, `OUT (C),0` writes FF on CMOS). The board needs only a variant switch; NMOS first. **What is not needed:** a cycle-stepped rewrite of the Z80. The board can drive contention from (N1) table offsets plus callbacks: each instruction's stalls are computed as its accesses happen, because contention only delays, never reorders. The ladder (handoff brief) proves it: a per-T-state contention trace computed this way must equal the published breakdown on every instruction (FAQ48 and the Wiki, their differences C13/C14 settled by the tests), and the board must pass the hardware-verified timing suites. If that fails for a case the table cannot express, the fallback is a z80-python "bus-cycle" mode, which would be a larger change to raise there with a repro. ## The AY: no change `PSG(AY8912)`; `tick()` per input clock (one every two CPU T-states, so the board calls it on even T); `select()`, `write()`, reads through the core's read path; port A is a pin set the board wires to the RS-232/MIDI/keypad socket. Its claims (docs/claims.md there) list the YM2149 and DAC uncertainties; the Spectrum adds none.