# The CPU: Philips SCC68070, and whether it is a variant of m68000-python Sources: the Philips SCC68070 product specifications of November 1990 and **April 1993** (`reference/docs/x-scc68070/`, scans OCR'd with `ocrmypdf --force-ocr --sidecar`; Philips's documents, facts only; ICDIA warns they contain "some inaccuracies"). Section numbers below are the April 1993 edition's. The full "User Manual 1991, Part 1 - Hardware" the data sheet refers to is not among the fetched documents (U1). ## What the chip is (DOC, data sheet 5.1-5.13) - A 68000-compatible CPU ("software compatible with the 68000 ... programs written for the 68000 will run on the SCC68070 unchanged", 5.1) with, on the same die: an MMU (chapter 7), a two-channel DMA controller (8), peripheral interrupt control (9), an I2C-bus interface (10), a UART (11) and a 16-bit timer with two match/count/capture channels (12). - 24 address lines outside (16 MB), 16-bit data bus. The on-chip peripherals sit in a CPU space above it: `80001001` LIR, `80002001-80002009` I2C, `80002011-8000201B` UART, `80002020-80002029` timer, `80002045`/`80002047` PICR1/PICR2, `80004000-8000406D` DMA, `80008000-8000807F` MMU (5.12, Table 7). So the core sees a 32-bit address for its own peripherals and puts 24 bits on the board's bus. - Clocks (5.13, Fig.18): the master oscillator divided by 2 clocks the CPU, MMU and DMA; by 4 the UART and I2C; by 192 the timer. In the CD-i, MAME lists the SCC68070 at 30,000,000 Hz (OBSERVED, `-listxml`), i.e. a **15 MHz CPU clock** and a timer tick of 6.40 us (Fig.18's row for a 30 MHz crystal). The internal clock ranges 4-17.5 MHz (5.3). - Bus (5.3-5.4): "a non-access machine cycle has 3 clock cycles"; an on-chip or external bus access "normally consists of 3 clock cycles plus 1 clock cycle", wait states added in pairs of states while DTACK is not asserted. Bus cycles are "similar to those of a 68000 running at a CKOUT frequency". ## How it differs from the 68000, point by point | Area | 68000 (m68000-python) | SCC68070 (DOC: data sheet) | What it costs a variant | | --- | --- | --- | --- | | **Instruction timing** | 4-clock bus cycles, 2-clock internal steps; per-instruction bus sequences from the corpus (m68000-python docs/timing.md) | "instruction execution timing is completely different" (5.1). Tables 11-23: `MOVE.W Dn,Dn` 7 clocks (68000: 4), `ADD ,Dn` 7+ea, EA (An) 4 / -(An) 7 / d(An) 11 / d(An,Xi) 14, `Bcc` 13 taken or not, `DBcc` 14 when cc true, `RTS` 15, `JSR (An)` 18, `MOVEM` 26+7n.., `MULU`/`MULS` a constant 76, `DIVU` 130 and `DIVS` at most 169, `RTE` 39 (short frame), `RESET` 154, `STOP` 17; exceptions: interrupt 65, trap 52, address error 158 (3 reads, 17 writes) | every handler's clock total replaced: a second timing table, not a patch | | Per-access placement | modelled (`step_clocks` inside an instruction) | not documented: the tables give totals and read/write counts only | the variant charges at **instruction level** with the documented access counts; where each access falls inside the instruction is U2 | | Prefetch | two-word queue (`ir`, `irc`) with its documented quirks | there is a prefetch: the long frame stores "IRC ... the prefetched instruction" (5.10.1); its depth and refill timing are not documented | the m68000 queue is kept as the semantic model (HYPOTHESIS: same observable PC/fetch order) until a hardware trace says otherwise (U3) | | **Exception frames** | 3 words (group 1/2), 7 words (group 0) | 68010-like: at least 4 words (SR, PC, format/vector word); a 17-word "68070 format" (format 1111) for bus and address errors with SSW, MM, TPF/TPD, DBIN, IR, IRC; any other format on RTE is a **format error** (5.10, Fig.14-16) | new frame writer, new RTE, vector 14 (format error) live | | Bus error recovery | the frame is written, the instruction is not restarted (m68000-python claims stop there) | "full bus-error recovery": RTE re-runs the faulty cycle unless SSW.RR is set (5.9, 5.10.2) | an instruction-continuation model (needed only with the MMU or a faulting device) | | **Interrupts** | IPL0-2 encoded levels; autovector or a vector from the device | decoded inputs IN2, IN4, IN5, NMI (levels 2, 4, 5, 7) each with its own IACK; two latched inputs INT1/INT2 with programmable levels (LIR at `80001001`) served by autovector from the "on-chip" vector entries; levels 1, 3, 6 exist only if programmed into INT1/INT2 or an on-chip peripheral; on-chip daisy chain IN/INT1/INT2/timer/UART RX/UART TX/I2C/DMA1/DMA2 at equal levels; the acknowledge cycle does not assert LDS (5.11) | an interrupt controller inside the core; the board drives pins, not a level | | On-chip peripherals | none | MMU, DMA, UART, timer, I2C, PICR1/2 at `8000xxxx` (5.12) | new device models inside the core | | **MMU** | none | segmented, 8 on-chip descriptors (fully associative), mode 1: 8 segments of up to 2 MB, mode 2: 128 segments of up to 128 KB, in 1 KB blocks; attributes S/E/R/W/ST; a miss or violation raises BERR with SSW.BM; adds 1 clock to every external CPU bus cycle when enabled; interrupt-acknowledge vector fetches untranslated (7.1-7.4) | a translation step on every core access; continuation (above) when it faults | | DMA | none (the host steals the bus) | 2 channels, "a subset of" the 68430/68440/68450, byte or word operands, cycle-steal or burst; channel 1 single-address only, channel 2 single or dual (memory to memory); channel 1 > channel 2 > external masters > CPU in the bus-grant daisy chain; latency "less than 1.7 us", at most 2.98 M transfers/s at a 35 MHz crystal (5.5, 8.1-8.5) | a bus master inside the core that the CDIC (and the DVC) drive with REQ/ACK | | Flags | per PRM, checked against the corpus | not restated in the data sheet; cdifan/cputest's README says no CD-i hardware **or** emulator passes all of MicroCoreLabs' opcode test, every failure in condition-code checks | U4: undefined-flag behaviour (DIV overflow, BCD V, CHK) unmeasured on a 68070 | ## The CD-i's use of it (OBSERVED, MAME closed box; DOC, CDi_MiSTer `doc/scc68070.md`) - Interrupt sources on a Mono-I (CDi_MiSTer's table of the CD-RTOS vectors): the CDIC, the DVC's FMV and FMA on IN4 (shared), the slave on IN2, the MCD212 on INT1, the timer on chip. The CD-RTOS clock tick comes from the on-chip timer (the trace's first vector is `$F8`, MAME interrupt level 6 in the trace header: mame-oracle.md). - The CDIC driver moves sectors with **DMA channel 1** in device-to-memory mode (word operands, REQ/ACK); the DVC drivers use it memory-to-device. MAME performs that DMA at a high level; the MiSTer core models it (its doc). The board needs the real DMA. - The UART is OS-9's `/t2` (the serial port on the back); the I2C bus reaches the front panel through the slave on Mono-I (slave.md). Whether CD-RTOS enables the MMU on any consumer player is not established (U5); the cdinotes and MAME traces show physical addresses in use (OBSERVED), so the MMU is a late rung. ## Reuse: options weighed | Option | For | Against | | --- | --- | --- | | **A. A variant class inside m68000-python** (`SCC68070CPU(M68000CPU)`) | one repository, the instruction semantics shared at once | widens a public, released core past its claims boundary (docs/claims.md: "Other processors" out of scope); the 68070's timing, frames, interrupts, MMU and five peripherals would be most of the new code, living in a repository whose evidence (the 68000 corpus, WinUAE, Nuked-MD) says nothing about them | | B. A new core written from scratch | independence | re-derives 68000 semantics the family already proved (reuse first: rejected) | | **C. A new core repository `scc68070-python` that pins m68000-python and subclasses it for the instruction semantics** | the chip rule (CPUs get their own core; the SCC68070 is a different chip with its own die, timing and peripherals); the semantics and their proof come from the pinned 68000 core unchanged; the 68070's own evidence (data sheet tables, CD-i test ROMs) lives where it is judged | m68000-python must offer a small subclassing contract (below); two pins to keep | **Recommendation: C** (open decision 1). `scc68070-python`, package `scc68070_python`, class `SCC68070`, owning: the timing tables (Tables 11-23, instruction level), the exception and RTE formats, the interrupt inputs and LIR, and the on-chip MMU, DMA, UART, timer and I2C as modules of the core (they are inside the chip, and software addresses them at `8000xxxx`). The CD-i board pins it. What m68000-python would need (raise them there as core corners; nothing is copied): 1. A **clock-charging hook**: today every bus access adds 4 and internal steps add idle clocks inline (`_core.py`). The variant needs the semantics without that accounting, then its own total per instruction (and the access count per instruction for the bus). 2. **Overridable exception entry and RTE** (frame writer, format word, format error). 3. The **decoded instruction class and EA modes** of each step, for the timing lookup (the dispatch table knows them; a step record already carries most of it). 4. An **interrupt-acknowledge hook** that takes a vector or "on-chip autovector" per level (the existing `acknowledge(level)` nearly does). 5. A 32-bit internal address path for `8000xxxx` before the 24-bit mask, or a pre-bus hook the variant uses to claim its peripheral window. If m68000-python's maintainer (the next agent there) finds (1) too invasive, the fallback is option A's class living in scc68070-python with a vendored-by-pin import of the 68000 ALU helpers, still not a copy. ## Modelling level Instruction level for timing (the only level the evidence supports: totals and access counts), with the bus accesses in the 68000 order and each external access charged its 3+1 clocks plus wait states from the board (DRAM slot waits from the MCD212, the CDIC's and slave's DTACK delays, ROM DTACK delay from CSR1W). A cycle-level 68070 needs a hardware trace (cdifan's `cpufull` run on a real player through CD-i Link would be the first one; U2). ## Oracles for the core | Oracle | Tier | Decides | | --- | --- | --- | | the SCC68070 data sheets (1990, 1993) | 2 | timing totals, frames, registers; inaccuracies noted by ICDIA (C2 if the two editions differ) | | m68000-python's proof (pinned) | the 68000's evidence | instruction semantics, through inheritance | | cdifan/cputest (`cputest`, `cpudiag`, `cpufull`) | 3 once a real-player result is recorded; today a detector | flags; a full instruction trace on hardware would be tier 1 | | CD-RTOS itself running (system ROM by SHA-1) | the software | that boot, interrupts and DMA work | | MAME 0.285 `scc68070` (closed box) | 5 | instruction streams and I/O order; its timing is MAME's own (the boot's module scan runs ~0.43 M instructions per emulated second in MAME, mame-oracle.md, against ~1.2 M the data sheet's totals give for that loop without wait states: a question, not a verdict) |