# Validation: every oracle, its tier, and the plan ## Oracle tiers The family's rule (z80-python, spc700-python, huc6280-python): rank an oracle by **where its expected values came from**; a lower tier detects, the highest tier that covers a claim decides it. Order of authority for a disputed point: **a console result > documents agreeing > two independent emulators agreeing > MAME**. For this chip "two emulators agreeing" is rarer than it looks: ares and MAME carry one core (byuu's, also bsnes's; MAME's file says "Original by byuu in the public domain"), so only **Mesen2** is independent of them. **Sources marked †** (2026-11-19): Mesen2 (GPL-3), snes9x and bsnes's HLE code were read from source under the old rule (before 2026-11-19). They are closed boxes from now on: their source is not opened again, and no default rests on them. byuu's model is cited through ares (ISC, NOTICE) and MAME's `upd7725.cpp` (BSD-3-Clause), at the pinned revisions; bsnes (GPL-3) is a closed box. | Tier | Meaning here | What exists | | --- | --- | --- | | **hardware-captured** | values recorded from a real uPD7725/uPD96050 | **none** (searched 2026-11-05: no per-instruction capture, no logic-analyser trace, no recorded command input/output pairs; snes-python U7) | | **hardware-designed self-test** | a check written by the chip's programmers to pass on production hardware | the programs' **built-in test commands**: DSP-1 `0Fh` memory test, `1Fh` data ROM transfer, `2Fh` ROM version (`0100h` DSP-1/1A, `0101h` DSP-1B); DSP-3 the same three (`0300h`); DSP-4 `13h`/`14h` (`0400h`); ST011 `F1h`/`F2h` self-tests (fullsnes "BIOS Functions") | | **manufacturer** | NEC's documents | the 1997 data sheet (DS) and the 1992 data book's data sheet (DB); **uPD7725 only**: NEC published nothing on the uPD96050 and refused to (byuu 2012) | | **program** | what the shipped programs need to make sense | the seven programs (survey: C3, C4, U13) | | **research** | community documents from hardware study | fullsnes; byuu's notes; the HLE DSP code's comments (Overload, The Dumper, Neviksti, Andreas Naive, 2006) | | **die** | a netlist or die model | **none**: the DSP dies were decapped (Dr. Decapitator, 2010-2012) only to read the mask ROMs optically, not traced | | **emulator** | values an emulator produced | MAME 0.285 (runs here: traces, disassembly; `upd7725.cpp` is BSD-3 and readable), ares (ISC, readable, not built), Mesen2 † (LLE, not built; closed box), snes9x † and bsnes HLE † (command level; closed boxes) | ### What does not exist (searched 2026-11-05) - **No SingleStepTests-style corpus** for the uPD7725 or uPD96050 (the SingleStepTests organisation covers the 65x02, 68000, 8088, V20, Z80, SM83, SPC700, HuC6280, ARM7TDMI and others; none of these). - **No test ROM** for the DSPs: no gilyon, krom or blargg program exercises them; opensnes' `dsp1Present` probe (v0.37.0) was characterised on an emulator ("luna"), not hardware. - **No hardware measurement of DSP timing** was published: the 2019 NESdev thread (`t19107`) asked and got no numbers. - **No console route here**: Aubrey's Super EverDrive X5 has no DSP, a real DSP cartridge runs only its own game, and an FXPak's DSP is an FPGA model (emulator tier). So the instruction set has a manufacturer tier (the uPD7725 part), and the results of whole computations have the programs' own self-tests and the games. **The uPD96050's additions have research and emulator tiers only.** ## The oracles ### NEC data sheets: manufacturer - **DS**: *uPD77C25, 77P25 Data Sheet*, U12675EJ7V0DS00 (7th edition, PDF made 1997-06-05), 56 pages, text layer (`pdftotext -layout` reads it cleanly). Pin: `optixx/quickdev16@a1e3ef36` `files/docs/snes/U12675EJ7V0DS00.pdf`, SHA-256 `fb73bee3…` (the trac.godzil.net copy answered 502). - **DB**: the uPD77C25/77P25 data sheet in NEC's *1992 DSP and Speech Processor Products* data book, PDF pages 94-128 (printed 1-35), a scan; bitsavers via `ftp.mirrorservice.org`, SHA-256 `cb912846…`, 27 MB (`fetch_references.py --all`). Its text keeps two sentences the DS lost: the ALU-NOP rule (C3) and "The EI bit of the status register automatically resets to 0" (C7). - Not found: NEC's *uPD77C25 User's Manual* (the DB refers to it for the handshake protocol), any uPD96050 document. - Use: rung 1's expected values (ALU results and flags, field semantics, the host port), U1-U15, the register widths. ### The programs' built-in tests: hardware-designed self-test The DSP-1, DSP-3, DSP-4 and ST011 programs answer test commands (fullsnes "BIOS Functions"). The data ROM transfer (`1Fh`, DSP-4 `13h`) must reproduce the data ROM image word for word, the version command returns a known constant, and the memory test exercises all of data RAM. They need only the core and a scripted host: **a board-free judge of RAM, ROM, RP/DP stepping, the multiplier path the test uses and the DR/RQM handshake**. Expected results: the image itself for the ROM transfer, fullsnes for the version words; the memory test's pass value must be read from the program (disassembly) by the build session and confirmed by MAME and the HLE. ### fullsnes: research - Pin: `problemkaputt.de/fullsnes.txt` as served 2026-10-21, SHA-256 `d79dbec9…` (spc700-python's copy, satisfied in place). - "SNES Cart DSP-n/ST010/ST011" (lines 8771-9310): mapping per PCB, the registers of both chips, flag meanings and the S1/OV1 description, ROM image formats with the `JRQM $` detection rule, the opcode tables, reset (RP = 3FFh), interrupts, the games, the BIOS command lists; "External Oscillators (in Cartridges)" (line 22768). - Use: the uPD96050 differences (U9-U11), the clocks (C10), C2's alternative rule, the board's mapping. ### MAME 0.285 `upd7725`: emulator, the lockstep detector - `mame` 0.285 (installed), source at tag `mame0285` (`f379cd06`) in snes-python's tree. The DSP programs come from MAME's device sets read in place (`sns_dsp1leg.zip` ... `sns_seta11leg.zip` on `MAME_ROMPATH`); all seven images match the SHA-1 MAME's `upd.cpp` names (`survey_programs.py`). - `scripts/mame_dsp_trace.py` records one line per DSP instruction (PC A B K L TR TRB DP RP SP DR and the cycle) and every host access to DR, SR and the ST01x RAM stamped in DSP cycles, from power-on; [mame-oracle.md](mame-oracle.md) is the recipe and its traps. `--dasm` writes MAME's disassembly of a whole program (rung 0). - Known differences from the documents, each a C-entry: carry (C1), bit-reversed `@SOL`/`SIL` (C4), 16-level stack (C5), reset values (C6), interrupt slot (C7), unmasked DP/RP (C9), 8/10/15 MHz (C10). MAME has no SR or flag symbols for the debugger, so the trace cannot show flags directly; they show through branches, ALU results and SGN. - Measured: see timing.md "Measured on MAME 0.285" (seven games; a 30-frame Pilotwings window executes 71 % of the DSP-1 program, including the contested instructions). ### ares, Mesen2 † (LLE): emulator ares (ISC) is read at the pinned revision, not built: byuu's model, the same core as bsnes but for C1 (the wave-1 audit's count-only comparison, 2026-11-13; bsnes is not opened). Mesen2 † was read under the old rule and differs from ares in C5, C9, C10 and C12, and adds an exact skip of `JRQM $` loops. A per-instruction replay against Mesen2 needs a harness that builds and drives it as a closed box (its source is not opened): rung 5, a follow-up. ### The HLE implementations †: research-derived emulator, command level snes9x's DSP-1..4, ST010 and ST011 HLE and bsnes's DSP-1/2/4 and ST010 HLE (based, by their authors' account, on research by Overload, The Dumper, Neviksti and Andreas Naive, 2006). Read under the old rule; closed boxes from now on: a comparison runs them, never reads them. They compute each command's outputs from its inputs with no instruction model, so they are **independent of byuu's LLE lineage** and were written against real chips by probing. A detector for whole-command results, especially where the LLE emulators share one model (C2, C14). ### The games: the end judge, board level The board's milestone 5 acceptance (snes-python handoff-brief): DSP-1 games' frames against Mesen2. Two observable hardware facts are documented: the **DSP-1 command `28h` bug** visible in Pilotwings' plane demo, fixed in the DSP-1B (fullsnes), and the version words. A core running the DSP-1 image must show the glitch and the DSP-1B image must not. ## Rung plan | Rung | What | Judge (tier) | Runs where | | --- | --- | --- | --- | | 0 | **Decode**: the field tables against the DS; the disassembler against MAME's `dasm` for every word of all seven programs (syntax mapped: MAME prints `mov src,dst`, NEC `MOV @dst,src`; MAME omits the uPD96050's NA bank bits and PC bit 13) | DS (manufacturer); MAME (detector) | here, seconds | | 1 | **Directed per-instruction tests** from the DS: every ALU op with both accumulators and the other carry, every P-SELECT, SRC, DST, DPL, DPHM, RPDCR, every BRCH, LD, RT, the multiplier, SGN, @KLR/@KLM, SR's write mask, the host port's 8/16-bit sequences, reset. Each test cites its DS page. Where the DS is silent the test names its U/C entry | DS (manufacturer); fullsnes for the uPD96050 (research) | here | | 2 | **The built-in self-tests** in a minimal harness (core + scripted host, no board): DSP-1/1B/3 `0Fh`, `1Fh`, `2Fh`; DSP-4 `13h`, `14h`; ST011 `F1h`, `F2h` | the programs (hardware-designed self-test) | here, BYOR images | | 3 | **Command streams through the harness against the HLE**: random and recorded DSP-1 commands, outputs compared with the snes9x/bsnes HLE results (run as closed boxes) | HLE (research-derived emulator, detector) | needs an HLE build: follow-up, optional | | 4 | **MAME replay**: start the core at MAME's power-on state, feed the host accesses at their DSP-cycle stamps, compare every traced instruction's registers and every host read's value; windows from Pilotwings, Super Mario Kart (DSP-1), SD Gundam GX (DSP-3), Exhaust Heat II (ST010), and, once the trace script can press buttons, Dungeon Master (DSP-2), Top Gear 3000 (DSP-4), Morita Shougi (ST011). Divergences are classified by C-entry (C1, C4, C5, C6, C9); any other is a finding | MAME (detector) | here: ~2 min of MAME per window, gzipped traces in `tests/mame_traces/` (gitignored) | | 5 | **Mesen2 replay**, per instruction, on the same host streams | Mesen2 (independent emulator, detector) | follow-up: a harness driving a Mesen2 build as a closed box | | 6 | **Through snes-python milestone 5**: DSP-1 games' frames vs Mesen2; the Pilotwings DSP-1/DSP-1B demo difference; command-level timing as the board schedules it | games (end judge) | the board | ### What no judge decides (do not pretend) - C2 (S1/OV1) beyond the HLE's command results; C3 (the ALU-NOP flags) beyond the DSP-4's code; C7 (interrupt) entirely; C14 beyond the HLE; U10 (stack overflow); U17 (P0/P1 wiring); U18 (power-on values); U19/C13 (the RQM latency) at instruction level: the board can only choose a model. - Every uPD96050-only behaviour (U9-U11 for that chip, U21): research and emulator tiers, with the ST011 program as the strongest evidence. ## The minimal harness (rungs 2-4) A host that is not a SNES: the core, a scripted host that writes command bytes and reads results through `write_dr`/`read_dr`/`read_sr` with RQM polling, the ST01x RAM as words, and a stop rule (a cycle budget, or "back in the command loop's `JRQM $`"). The same harness replays a MAME trace: it applies each `R`/`W` line after the instruction with the same stamp and checks the value a host read returns. No S-CPU, no cartridge decode, no clock ratio: those are the board's. ## Results (build session, 2026-11-05) 146 tests: 139 in the quick loop (`pytest -m "not slow"`, 3 s on CPython, 13 s on PyPy), 7 MAME replays marked `slow` (5 min on PyPy, niced), plus one that skips without traces. ### Rung 0: decode (passed) `tests/test_fields.py` checks the field positions and tables against DS p.18-24. `tests/test_disasm_vs_mame.py` runs MAME 0.285's `unidasm -arch upd7725` (the debugger's own `necdsp_disassembler`) over each program image: **all 43,008 words of the seven programs** (5 x 2,048 + 2 x 16,384) match MAME's text rebuilt from this core's field extraction, and `disasm.py`'s NEC text matches MAME's mapped to NEC syntax (`mov src,dst` -> `MOV @DST,SRC`; MAME drops a move whose DST is 0, which NEC syntax keeps when SRC is not, since `DR` there sets RQM). No word has an unknown BRCH code. ### Rung 1: directed tests from the DS (passed) One file per family, each test citing its DS page or U/C entry: `test_alu.py` (42: all sixteen operations on both accumulators, the flag table, U12, U14, C1 both ways, C2 both ways, OV0 against the sign formula in 16,928 cases), `test_op.py` (24: every SRC, every DST, P-SELECT, @KLR/@KLM, SGN, DPL/DPHM, RPDEC, U2, U8, C3, C4, C14, C15, C16, the multiplier including -8000h x -8000h, RT, LD), `test_jump.py` (24: every BRCH in both senses, unknown codes, CALL/RT, stack depth and wrap, the uPD96050's bank bits, HJMP, HCALL, JMPSO, PC bit 13), `test_host.py` (9: both DR modes, C11, U20, the JRQM loop, the three image formats), `test_reset.py` (7: DS (25), C6, state capture). ### Rung 2: the built-in self-tests (passed) `tests/test_selftests.py`, the minimal harness with a host that waits for RQM and leaves 16 instructions between accesses (`DEFAULT_HOST_DELAY`; a zero-latency host writes the DSP-1's first parameter byte before the program has switched DR to 16 bits): | Program | Version | Memory test | Data ROM transfer | | --- | --- | --- | --- | | DSP-1 | `2Fh` -> 0100h | `0Fh` -> 0000h | `1Fh`: 1,024 words = the image | | DSP-1B | 0101h | 0000h | equal | | DSP-3 | 0300h | 0000h | equal | | DSP-4 | `14h` -> 0400h | (none) | `13h`: equal | | ST011 | | `F1h` -> 00h, `F2h` -> 00h | (`F3h` is the known broken dump) | The pass values are the programs': DSP-1 `0Fh` ends `LDI @DR,0000h` at 4DCh and its failure path (4DEh) returns a nonzero code built from DP; the ST011 parks at 086h (F1h) or 0ABh (F2h) with DR = 00h and on failure loads 00FFh, 01h or 02h and the address. Negative controls fail as they must: F2h on a cleared RAM returns 01h (address 1), and `0Fh` on a core with RAM word 37h's bit 0 stuck returns nonzero. Each command takes one (ignored) parameter word on the DSP-1/3, none on the DSP-4. ### Rung 4: MAME replay (passed) `tests/mame_traces//` (gitignored), made with `scripts/mame_dsp_trace.py`; every window replays from power-on. "Default-core differences" are the documented defaults against MAME's choices, each named by the switch that explains it (undocumented-behavior.md "What the build session measured"): | Window | Chip / program | Replayed | Traced and equal | Host reads equal | Distinct PCs | Default-core differences | | --- | --- | ---: | ---: | ---: | ---: | --- | | Pilotwings frames 1,800-1,829 | DSP-1 (LoROM, A14) | 243,733,302 | 3,993,445 | 140,362 | 904 | C1 x 168 | | Super Mario Kart 83-104 | DSP-1 (HiROM, A12) | 14,110,173 | 2,928,526 | 231,374 | 393 | none | | SD Gundam GX 13-29 | DSP-3 | 4,126,559 | 2,262,952 | 79,302 | 176 | none | | Dungeon Master 1,252-1,257 | DSP-2 | 167,591,604 | 798,689 | 15,293 | 191 | none | | Top Gear 3000 6,000-6,005 | DSP-4 | 799,620,947 | 798,689 | 151,766 | 660 | C1 x 1 | | Exhaust Heat II 1,004-1,015 | ST010 (RAM) | 169,222,261 | 1,996,723 | 76,807 | 398 | C1 x 122; C9 RP width x 49,597 | | Morita Shougi 646-651 | ST011 | 162,982,502 | 1,497,542 | 14,856 | 119 | C4 x 4; U10 x 2; C9 PC/DP width | Host-only logs (no `D` lines; every host read checked) also pass: Super Mario Kart 1,200 frames (231,374 reads), SD Gundam GX 1,200 (105,472), Exhaust Heat II 1,200 (1,007,675; C1 x 795), Dungeon Master 3,000 with presses (2,765,726), Top Gear 3000 attract 7,200 (1,191,882; C1 x 1,259). Not a single host-visible byte or traced register of the MAME-switched core differed from MAME; no finding against the core. Remake the windows (MAME niced, one at a time; carts from the play set): ```sh python -I scripts/mame_dsp_trace.py "Pilotwings (USA).7z" --start-frame 1800 --frames 30 python -I scripts/mame_dsp_trace.py "Super Mario Kart (USA).7z" --start-frame 83 --frames 22 python -I scripts/mame_dsp_trace.py "SD Gundam GX (Japan).zip" --start-frame 13 --frames 17 python -I scripts/mame_dsp_trace.py "Exhaust Heat II - F1 Driver e no Michi (Japan).zip" --start-frame 1004 --frames 12 python -I scripts/mame_dsp_trace.py "Top Gear 3000 (USA).7z" --start-frame 6000 --frames 6 P=(); for f in $(seq 300 120 3000); do P+=(--press "$f:P1 Start:20" --press "$((f+60)):P1 A:20"); done python -I scripts/mame_dsp_trace.py "Dungeon Master (USA).7z" --start-frame 1252 --frames 6 "${P[@]}" python -I scripts/mame_dsp_trace.py "Hayazashi Nidan Morita Shougi (Japan).zip" --start-frame 646 --frames 6 "${P[@]}" ``` Rungs 3 (HLE command comparison) and 5 (Mesen2 replay) are the follow-up session's (decision 11); rung 6 is snes-python milestone 5's.