# CPU and chip cores: reuse first ## Every chip against the family's existing cores | Chip | Family core today | What it needs for the ST | Proposal | | --- | --- | --- | --- | | **MC68000** | **m68000-python** (public, v0.1.0, `55d3d60`), m68000-rust, m68000-rust-fast | per-access timing (have), E-clock VPA data cycles (request 1), bus-error frames (request 2), vectored and autovectored acknowledge (have), RESET pulse (have), a bus the board can stall (have) | pin it; raise two requests (below) | | HD6301V1 (IKBD) | **m6800-python** (public, v0.2.0, `96302c2`): MC6800/02/08 and the MC6801/03 superset; its README lists "HD6301 / HD63701 / HD6303: Hitachi supersets ... out of scope, noted" | the Hitachi superset as a variant (new op-codes, faster cycle counts, traps), plus the on-chip ports, timer and SCI | **an HD6301 variant in m6800-python**, shared with namcos1-python's HD63701V0 (the same family: U07 covers both); the peripherals in one module there (open decision 3) | | YM2149 | **ay8910-python** (`76cace3`, published) | port A/B callbacks, 2 MHz clock | pin it; nothing new | | MK68901 MFP | none | | in the board as `Mfp68901`; **`mc68901-python`** when the X68000 board starts (open decision 4) | | MC6850 ACIA x 2 | none (bbcmicro-python Phase 0 keeps one in its board) | | **`mc6850-python`** on the second family board (open decision 5) | | WD1772 | none (bbcmicro-python: WD1770/1772; msx-python: WD2793; both in-board proposals) | | **`wd177x-python`** with the 179x/279x rows (open decision 6) | | GLUE, MMU, Shifter, DMA chip, GSTMCU, STE Shifter | none | | the board (ST-only chips) | | Blitter | none | | the board (Mega ST, STE, Mega STE only) | | LMC1992, Microwire | none | | the board (STE only) | | RP5C15, Z8530 (Mega rows) | none | | the board, rows 2 and 4 | No other family core (z80, mcs48, tms9918, ym2151, ym2413, sn76489, arm7tdmi, sh2, i8086, huc6280 ...) is used by these rows. ## What the ST needs from m68000-python Read against its README ("Minimal host", "Reference-core boundary") and docs/claims.md. 1. **Per-access timing inside an instruction (have).** The core runs one instruction per `step()`; inside each bus callable `cpu.step_clocks` says at which clock of the step the access ends, and the host adds its own stall clocks. The ST board aligns every RAM and Shifter access to GLUE/MMU's 4-clock slot ([bus-and-memory.md](bus-and-memory.md)): with a running stall total, each access's true time is start + `step_clocks` + stalls so far, rounded up to the next CPU slot. This is the same mechanism the Amiga Phase 0 uses for Agnus's slots. The strength of `step_clocks` is "Provisional" in claims.md: **the ST, like the Amiga, will be the first real test of where each access falls inside an instruction**; disagreements found here are raised on m68000-python, not patched in the board. 2. **E-clock VPA cycles for data (request 1, shared with amiga-python).** The ACIAs at FFFC00 are 6800-family peripherals: synchronous cycles whose length depends on the E phase. The core models the E-clock wait for the autovector acknowledge only (`_e_clock_wait`, MAME's rule restated, its provenance.md). The board could add the wait as a stall itself, but the rule should live in one place: an optional way for a host to mark an access as VPA and receive the same wait. 3. **Bus-error frames (request 2).** GLUE asserts BERR in normal operation: user-mode accesses below 800h and to I/O, writes to ROM, unanswered addresses (SVC "Glue"); TOS and programs use bus errors to probe hardware. claims.md already says "Bus errors matter to Amiga and Atari ST system software" and that the frame's stacked PC, IR and I/N bit are not claimed. On this board they become load-bearing: a program that inspects or resumes from the frame will diverge. Request: bring the bus-error frame inside the claim (WinUAE's CPU tester already checks "read and prefetch bus-error frames" at T2 in its referees table), before milestone 1's TOS probes are judged. 4. **Interrupts (have).** GLUE drives IPL with level 2 (HSYNC) and 4 (VSYNC) as autovectors, level 6 for the MFP with a vector from the MFP (HWSPEC 10; SVC): `acknowledge(level)` returning `AUTOVECTOR` or the MFP's vector covers it. The cost of the MFP's vectored acknowledge cycle is board timing (U11). 5. **RESET (have).** TOS executes RESET at boot (SVC "System Startup"); `reset_devices()` sees the pulse; which chips it resets (the MFP, the ACIAs, the FDC, the PSG, the DMA chip, the IKBD?) is U19. 6. **Bus arbitration (have, by stalling).** The DMA chip's transfers and the Blitter's 64-cycle turns take the bus; the board models them as stalls inside the CPU's next access, which `step_clocks` allows. The Blitter halting the CPU mid-instruction (between two bus cycles of one instruction) is exactly what per-access stalls express. 7. **TAS (have).** The ST's RAM performs TAS's read-modify-write normally (no Amiga or Mega Drive restriction known: HYPOTHESIS); `tas_write` exists. 8. **Speed (have).** About 33 M instructions a second on PyPy (its README): the ST's 68000 needs under 1 M ([domains-and-speed.md](domains-and-speed.md)). ## The HD6301 variant (shared with Namco System 1) The HD6301V1 (U07): MC6801 instruction set plus Hitachi's additions (AIM, OIM, EIM, TIM, XGDX, SLP), changed cycle counts, an address trap and an op-code trap; 4 KB mask ROM, 128 bytes RAM, ports 1-4, a 16-bit timer with output compare and input capture, an SCI. The namcos1-python Phase 0 (tonight) recommends adding this as a variant in m6800-python (option A in its cpu-cores.md) for its HD63701V0 (the EPROM member of the same HD6301V family, U07 1.1 and the HD63701V0 manual). **The ST agrees and is a second consumer of the same variant**, which by the chip rule also justifies putting the on-chip ports, timer and SCI in one reusable module beside it (the ST's SCI is the keyboard link; its ports scan the key matrix). The Namco parts' two extra op-codes ($12, $13) would be a further flag the ST does not need. One request, two boards: open decision 3. Oracles for the variant: U07 (tier 2) for semantics and cycle counts; MAME's `m6801.cpp` family (BSD-3-Clause by its license line, run only) traced on the IKBD ROM as a detector (this phase traced 337,571 HD6301 instructions in one emulated second of TOS boot, [mame-oracle.md](mame-oracle.md)); no hardware-captured HD6301 corpus is known.