# The CPU cores: three 6809Es and the CUS64 MCU ## MC6809E x 3: [m6809-python](../../m6809-python) | | | | --- | --- | | Instances | `:maincpu`, `:subcpu`, `:audiocpu`, all MC6809E at 1.536 MHz (OBSERVED, `-listxml`; the traces count 3.09 M cycles in 2.01 s of emulated time for the main CPU) | | Core state | **Phase 0 only, no core code** (its README, HEAD `b35c084`). Its handoff brief is ready; it names Namco System 86 among its targets but not System 1 | | What System 1 needs from it | the plain MC6809E instruction set and cycle counts; `step()` returning E cycles; RESET, NMI, FIRQ, IRQ inputs the board drives; a reset line the board can hold (the CUS117 resets the sub, sound and MCU: [memory-map.md](memory-map.md)); no HD6309 mode (no System 1 set uses one) | | Note | m6809-python's README says "Python 3.12+"; the family floor is PyPy's 3.11. Its build session should take the floor from the family rule (reported, not changed here) | The two main CPUs see memory only through the CUS117; the board supplies each one's `read_byte`/`write_byte`, which translate through that CPU's bank registers. ## HD63701V0 = Namco CUS64 ("64A1") What it is: - Hitachi's **HD63701V0**: the EPROM member of the HD6301V family, an MC6801-compatible core with Hitachi's additions (`XGDX`, `SLP`, `AIM`/`OIM`/`EIM`/`TIM`, an op-code and address **trap**), 4 KB of EPROM at $F000-$FFFF, 128 bytes of RAM, ports, a 16-bit timer and an SCI. DOC: Hitachi, *HD6301/HD6303 Series Handbook* (1989, U07), "HD63701V0 User's Manual" 1.1 p. 251, and the EPROM notes ("Please use 4k bytes of EPROM address space located from $F000 through $FFFF"). MAME names the part `HD63701V0` at a 6.144 MHz input; the U07 says E is a quarter of the crystal (1.536 MHz), which matches the traced cycle count. - **Namco's part is not a stock HD63701.** jrok's pages (tier 3, logic-analyser work on real boards, credit jrok.com; [sources.md](sources.md)) say the CUS60, CUS63 and CUS64 are one semi-custom 6301 with two extra op-codes, **$12 and $13**, both of which "add the value at the top of the stack to the X register while preserving all other registers"; "examining the instructions on original hardware showed" an earlier ADX guess was wrong. The CUS64 is the System 1 member, "the same micro-controller as the 60 and 63 but with a different internal ROM". - jrok also saw, with a logic analyser, a write of $00 **appear on the bus as $A6** when a stock HD63701 replaced the CUS64 (the original part does not do this; self test fails otherwise). He did not find the cause. This is U3 in the brief: an observed difference between the custom and the stock part, unexplained. - Whether System 1's programs use $12/$13 at all is open: jrok says a 6803 runs the CUS64 board with a voice-ROM patch, "it doesn't even use custom instructions". OBSERVED: the 2 s Pac-Mania MCU trace (541,708 instructions) uses 45 mnemonics, none of them $12/$13 or an illegal op-code, but it **does use `OIM`** (a 6301-only instruction, Hitachi U07), so a plain MC6801 core cannot run the CUS64 firmware: the HD6301 variant is required. Where it could live, by the chip rule (CPUs get their own core): | Option | For | Against | | --- | --- | --- | | **A. An HD6301 variant in [m6800-python](../../m6800-python)** (recommended) | m6800-python already has the MC6801/6803 superset, its cycle tables and five games' MAME lockstep; its README lists "HD6301 / HD63701 / HD6303: Hitachi supersets ... out of scope, noted". The 6301 changes cycle counts (many instructions are faster) and adds a handful of opcodes and the trap: a variant table, as m6809-python plans the HD6309 as a mode. Namco's $12/$13 would be a further variant flag (`HD6301(namco_cus6x=True)`) | m6800-python is public and released (v0.2.0); the variant adds a new timing table to keep in its ladder | | B. A new core `hd6301-python` pinning m6800-python's decoder | a clean release line | duplicates most of a working core; the family rule is "never copy code between repos" | On-chip peripherals (ports, the 16-bit timer, the SCI, the trap): m6800-python's README says "the timer, SCI and ports belong to the host, not the core". The HD63701's are documented in the U07, so they belong in one reusable place; recommend a peripheral module beside the variant in m6800-python (its second consumer would be Namco System 86, Baraduke, Pac-Land, Sky Kid and Thunder Ceptor, all HD63701V0 in MAME, and Technos's HD63701Y0 boards), and until then in this board behind a pin-shaped class. Open decision 3. The firmware is Namco's (`cus64-64a1.mcu`, 4,096 bytes, SHA-1 `7a38c0cc2553c627f4ec507fb6e807cf7d537c02`, one image in all 40 sets): the player supplies it in the romset, never fetched or committed. ## Other users in the family and in MAME (OBSERVED, a full `-listxml` scan) | Chip | MAME drivers using it | Family boards that would need it | | --- | --- | --- | | MC6809E | 110 drivers, 464 parent machines | System 1, System 2 (sound), Vectrex, Williams, System 86 (none built) | | HD63701V0 | namcos1 (40), namcos86 (11), pacland (6), skykid (5), baraduke (4), tceptor (2) | System 1 only for now | | HD63701Y0 | ddragon (13), spdodgeb (3) | none |