# Validation: the oracles, their tiers, and what judges what Tiers, best first: (1) real-hardware measurements and die-level simulation, (2) manufacturer documents and schematics, (3) community hardware research with shown measurements, (4) FPGA cores written from the die or schematics, (5) other emulators. A tier-5 source is a detector, never a judge. Pins are in `scripts/pinned_files.json` and `scripts/pinned_repos.json` (URL + SHA-256, or repository + commit); everything lands in ignored `reference/`. ## What was found, in one table | Oracle | Tier | Pin | Licence | Use | | --- | --- | --- | --- | --- | | Die photographs of C012294 (Greg James, Visual 6502) | 1 | visual6502.org `images/C012294_Pokey/` (not fetched: 16 MB images, the site refuses scripts; Wayback has them) | site's terms | the source of the next row; nobody has published a transistor netlist from them | | ijor, *PokeyReSchem* 1.3: schematics redrawn from those photographs | 1 (die-level, as a drawing) | `reference/byo/PokeyReSchem-13.pdf`, **by hand, not obtained** | (c) ijor, no licence stated | **not used in the restart**: whether an unlicensed schematic counts as "source" under restart rule 1 is a question for the owner ([provenance.md](provenance.md)) | | Atari, *POKEY CHIP* CO12294 rev B: 41 sheets incl. the MOS logic | 2 | `reference/docs/pokey-datasheet.pdf` | Atari, via the Atari Historical Society | registers, pins, flow charts, mode chart | | Atari's seven schematic sheets | 2 | `reference/docs/atarimuseum-pokey.zip` | Atari; released by Curt Vendel 2016 | the logic as designed | | Atari, *400/800 Hardware Manual* CO16555 | 2 | `reference/docs/hardware-manual-CO16555.pdf` | Atari | theory of operation, the formulas | | Atari, 5200 "PAM" package | 2 | `reference/docs/pam_package.pdf` | Atari | how the 5200 wires the chip | | Avery Lee, *Altirra Hardware Reference Manual* ch. 5, 13 | 3, with tier-1 numbers in it | `reference/docs/altirra-hrm.pdf` (2026-01-02 edition) | free document | every cycle number in timing.md | | Acid800 1.2 (`pokey_*.s`, 15 tests; Acid5200; AcidSAP) | 3: programs whose expectations pass on real machines by the author's statement; no capture file accompanies them | `reference/docs/Acid800-1.2.7z` | MIT | executable hardware expectations | | phaeron and ijor, AtariAge "Pokey decap" 2021-2023 | 1/3 | `reference/forum/atariage-182670-*` (Wayback) | forum posts | STIMER/AUDF/IRQST numbers; errata of the schematics | | David Viens (Plogue), slow-clock recordings | 1 (patterns only; no audio files published) | `reference/forum/plogue-pokeys.html` | blog | the 4-bit pattern, the 5-bit through the toggle | | **Nick Mikstas, `atari_pokey` VHDL** | **4**: an FPGA core its author says he wrote from ijor's schematics ([RE] p2) | `reference/src/atari_pokey` @ 88a8e00 (only the VHDL source directory is checked out) | none stated: **closed box only** | **the stream judge** (below); built and driven through pins, never opened | | MAME 0.285 (the released binary) | 5 | the `mame` binary on PATH (or `$MAME`); BIOS from `$MAME_ROMPATH` | GPL-2.0+ overall | **detector, run as a closed box**: [mame-oracle.md](mame-oracle.md). Its source is not fetched or opened | | ivop, Pokey Explorer | test program | `reference/src/pokey-explorer` @ b12773e | 0BSD | a sweep generator; its recordings' origin is unknown (U11) | Removed in the restart (2026-11-14, restart.md rule 1; see [provenance.md](provenance.md)): Mark Watson's `pokey.vhdl` (non-commercial terms), the Altirra 4.40 source, Atari800, ASAP, MAME's `pokey.cpp`/`pokey.h`, the A7800 fork. They are no longer pinned or fetched, and nothing in this repository may rest on them. Not found, after looking: a transistor or gate netlist of POKEY (visual6502 has photographs only; siliconpr0n has nothing indexed under the part); a logic-analyser capture of the pins; published reference audio recorded from a named real machine with the register log that made it; any document for the quad part. Not fetchable: ijor's PDF (by hand), the "Pokeydocs" zip (U12). Source rule (restart.md, binding from 2026-11-14): no GPL, LGPL or unlicensed source is read, for any purpose. Mikstas's VHDL has no licence: it is built and driven through its pins only, and a value measured through it is tagged `OBSERVED` (closed box, commit 88a8e00). Phase 0 (before the restart) read the GPL sources for facts; every statement that rested on that reading is struck or re-sourced in [provenance.md](provenance.md). ## The judge There is no single chip-exact reference. The judgement is split: 1. **Absolute timing from a bus access** (which cycle a read first sees a change): the hardware numbers of [timing.md](timing.md), which come from the Altirra manual and Acid800. Tier 1 as measurements, reported at tier 3. 2. **Everything that is a long stream** (channel outputs per cycle, RANDOM, interrupt line, pot registers, key scan lines, serial pins): the schematic-derived VHDL under GHDL, tier 4, after a per-stream alignment that is itself checked against (1). On the questions asked of it in Phase 0 it gave the hardware's divider periods and three hardware RANDOM values exactly, and was 1 to 2 cycles off on three latencies (U1). 3. **Manufacturer documents** for register layout and anything neither of the above can be asked. 4. Emulators only to find differences. ### The recipe for chip-level traces (proved, small) python -I scripts/fetch_references.py # the closed box, among others python -I scripts/run_vhdl.py --oss DIR # DIR: an unpacked oss-cad-suite - GHDL 7.0.0-dev from the oss-cad-suite bundle of 2026-10-05 analyses the model's files unchanged (`--std=08`; the script globs `*.vhd` and passes the names to GHDL, it never reads them), 17 s to build at nice 19. - `validation/pokey_tb.vhd` (this repository's, pins only) reads a stimulus file (`W a d`, `R a`, `N n`, and `K`/`P`/`S` for the keyboard response, pot and serial input pins) and prints one line per cycle: bus, the 6-bit audio sum, /IRQ, SOD, OCLK, BCLK out, dump, K0-K5. - Speed: about 20,000 cycles/s (100,024 cycles in 5.0 s). One second of chip time is 90 s; a full slow pot scan (26,000 cycles) is 1.3 s; a 131,071-cycle poly period is 7 s. A hundred million cycles would be 83 minutes: affordable per rung, not per commit. **No long run was made in Phase 0.** - The model has no power-on reset: any register not written simulates as `U` (printed -1). Every stimulus starts by writing all fifteen write registers. What it still takes to judge a core with it: 1. Per-channel outputs. The model's audio pin is the 6-bit sum. Choose volumes 1, 2, 4, 8 on the four channels in synthetic streams so the sum decodes into the four output bits. (Reading internal signals would need their names, which only opening the model would give: not done.) 2. A sample on both clock edges, for U3. 3. Close U1, so that the alignment is a known constant per path and not a fit. 4. Treat the serial port, two-tone and the high-pass paths of the closed box with suspicion until they agree with the Altirra manual's figures and Acid800's expectations. (Phase 0 recorded that the model's author lists these as untested; that rests on the author's notes, not re-read in the restart.) 5. A stream generator in the family's style (sn76489-python's `scripts/referees.py`, ay8910-python's `scripts/streams.py`): seeded random register writes at random cycles, plus directed streams per rung. The stronger alternative, not attempted: transcribe ijor's PDF into a switch- or gate-level netlist ourselves (about 5,000 transistors, [RE] p2) and simulate the two-phase logic as drawn. That would be tier 1 and would close U1 by construction. It is weeks of careful work, needs the PDF, which only a person can download, and needs the owner's ruling on whether the restart's source rule admits it. ## Rungs Each rung: what is built, the judge and its tier, the measurable exit. Rung 0 is this Phase 0. | Rung | Scope | Judge (tier) | Exit | | --- | --- | --- | --- | | 1 | Register model: 16 addresses each way, strobes, `$FF` on unmapped reads, SKSTAT/IRQST polarity, IRQEN acknowledge, init mode's list of what it holds and what it leaves | [DS] sheets 17-23, 32 (2); [AHRM 5.1, 5.2, 5.7] (3); [ACID] `pokey_default.s`, `pokey_addrmirror.s` | a table test per register bit, each line citing its source; 0 failures | | 2 | Dividers, the two derived clocks, the three polynomial counters, RANDOM, STIMER, joins | hardware numbers of timing.md (1 via 3) for latency; VHDL (4) for streams | every row of the cycle table and of "The two derived clocks" as a test; RANDOM and the four divider pulses equal to the VHDL's for >= 10 million cycles over >= 200 seeded streams, 0 differences after the fixed alignment; U1 closed or its three rows listed as known deviations of the VHDL | | 3 | Output: distortions, poly-5 gating, noise delays per channel, high-pass, volume-only, the four codes per cycle; then the DAC table | VHDL (4) for the digital codes; [AHRM 5.3] (3) and [Plogue] (1) for patterns; the measured curve for `mix()` | the four channel codes equal to the VHDL's on the rung 2 streams with AUDC/AUDCTL randomised; the 4-bit and 5-bit patterns of start-here.md reproduced with channel 1 at the machine clock, AUDF1 = 0..4; C2 settled | | 4 | Interrupts and timers as software sees them | [AHRM 5.7] numbers (3); [ACID] `pokey_irqtiming.s`, `pokey_timerirq.s`, `pokey_timertiming.s`, `pokey_timergranularity.s`, `pokey_inittiming.s` run with a 6502 in the loop | /IRQ equal to the VHDL's on the streams; the five Acid tests pass in the AcidSAP harness (below) or, if that harness is not built, in a5200-python's Acid5200 run. (`pokey_timertiming.s` is not in AcidSAP's standalone set; its numbers are the B2.3 tests) | | 5 | Pot scan: slow, fast, ALLPOT, live-read AND values, 228/229, dump state, truncated and suspended scans | [AHRM 5.9] numbers (3); VHDL (4) with the pot pins driven | the fast-scan live-read sequence and the three end-of-scan cycle numbers as tests; POT0-7/ALLPOT/dump equal to the VHDL's over 100 scans with random pin crossings | | 6 | Keyboard: counter, the four-state machine, debounce on and off, KBCODE, Shift/Control/Break on /KR2, overrun, SKSTAT bits | [DS 11] flow chart (2); [AHRM 5.8] (3); VHDL (4) with /KR1, /KR2 driven per scan code | K0-K5, KBCODE, SKSTAT, IRQST equal to the VHDL's over 500 random key scripts in both debounce settings; the 5200 aliasing case (a key at four codes, debounce off, re-report every 32 ticks) as a test | | 7 | Serial port: both shifters, all eight clock modes, async receive holding timers 3+4, two-tone and its resync, force break, the three serial IRQs, frame and overrun | [AHRM 5.6] (3) with Table 10 and Figures 10-11; [ACID] `pokey_seroc.s`, `pokey_serclock.s`, `pokey_serdirect.s`, `pokey_sertiming.s`, `pokey_skstat.s`, `pokey_asyncrecv.s`, `pokey_twotone.s`; VHDL (4) only where it agrees with those first | SOD/OCLK/BCLK/SERIN/IRQST/SKSTAT as tests from the manual's figures; the seven Acid tests pass (four are in AcidSAP, three need the 8-bit computer's SIO loop: record which were run); two-tone firing at T+8, +14, +20 | | 8 | Music and real programs: register logs from the boards, replayed | VHDL (4) on excerpts; MAME (5) and the boards' other detectors to find differences | 0 differences against the VHDL on >= 20 excerpts of >= 1 s from at least a 5200 game, a 7800 POKEY cartridge and two 8-bit music players (one using two-tone or 1.79 MHz noise) | | 9 | Fault injection | the tests themselves | a seeded-fault list (sn76489-python's `scripts/mutation.py` shape): every fault caught by at least one test; target >= 40 faults, 100 % caught | | 10 | Conformance kit and adoption | | `validation/` examples a Rust port must reproduce; a5200-python and a7800-python pin a commit | **The AcidSAP harness** (rung 4, decision 6; built 2026-11-14): `tests/acidsap.py`, about 200 lines on 6502-python's public interface (`MOS6502(read, write)`, `step()`, the IRQ request calls, `note_stall()`; the `acid` extra pins 6502-python 741419a). It runs the ten POKEY tests of AcidSAP's standalone set, each deciding pass or fail by its own convention (the N flag on reaching `_sap_testEnd`). The machine: 114 cycles a line, 262 lines; refresh DMA halting the CPU at cycles 25, 29, ..., 57 [AHRM 4.14]; WSYNC releasing the next read at cycle 105, one more cycle running first, writes not stopped by RDY, a write at 104 or later waiting a line [AHRM 4.9]; VCOUNT with its cycle-111 early change and end-of-frame value [AHRM 4.10]; no NMIs; POKEY as a SAP player leaves it (SKCTL = 3); every bus cycle a callback that performs the access, then ticks POKEY (B0.1). The CPU sees in cycle c the /IRQ line after tick c-1 (the 2-cycle machine of AHRM 5.7) or after tick c-2 (the 3-cycle machine); every test runs on both, as the tests accept both. It lives in `tests/`, and a test checks that `src/` never imports it. The tests' cycle comments (the refresh cycles in `pokey_irqtiming.s`'s `pha:pla` table, the nine refresh cycles counted in `pokey_inittiming.s`) confirm the refresh model. ## What no judge decides - The analogue curve per maker (U6), power-on state (U7), revisions (U8). - Half-cycle pulses (U3) unless the VHDL is sampled on both edges. - Anything in the serial port that Acid800 does not test and where the VHDL's author reports no check. ## Closed-box differences Measured 2026-11-14 through the pins of atari_pokey @ 88a8e00 under GHDL 7.0.0-dev. Each is written down, not fixed (restart.md rule 6): the core follows the documents. The fixed alignment the referee applies is in `scripts/validation_constants.py` and `scripts/streams.py` (`box_commands`, `BoxAligned`); it is never fitted per stream. | # | What | Box | Core (and its source) | Alignment / handling | | --- | --- | --- | --- | --- | | D1 | STIMER to reload (U1 row 1) | IRQST at T+7+N; last AUDF write for the first period T+1 | T+8+N; T+2 (AHRM 5.3, Figure 8) | the box gets each STIMER one cycle later | | D2 | first derived-clock pulse after init (U1 rows 2-3) | IRQST +26/+84 (64 kHz / 15 kHz); toggles +28/+86 | +25/+84 (B2.1b, Acid800 `pokey_inittiming.s`; the manual's sentence says +24/+83: C10). Before rung 4 the core had +24/+83 and the box was 2 / 1 late. ijor's die schematic as drawn gives the box's 58-cycle gap (+26 with +84), by a half-phase race at the 15 kHz register's init input; the test's sled counts need 59; core kept (U1, "The die", 2026-11-19) | `BoxAligned` holds the core's 64 kHz counter 1 extra tick after its own release; 15 kHz agrees | | D3 | AUDCTL bit 7 switched while running (U2) | recurrence changes at tick T+2; one bit at T+2 on a 17-to-9 switch fits neither | changes at T+1 (B2.9, HYPOTHESIS) | the judge's streams keep bit 7 fixed per stream | | D4 | AUDCTL clock or join bits switched while running | occasional fires differ near the switch (counts in status.md) | B0.2 timing (HYPOTHESIS for this case) | counted separately (`--audctl-changes`) | | D5 | init mode re-entered while running | with holds under about 7 cycles the clocks are part reset, differently from B2.1a; with longer holds, occasional fire differences remain (counts in status.md) | B2.1a (HYPOTHESIS) | counted separately (default streams); the zero-difference judge uses `--no-init-toggles` | | D6 | 5-bit gate in init mode | poly-5-gated channels do not clock in init mode (scratch e1: no toggle in 60 cycles of init; after release the gate follows the manual's 5-bit pattern, 1 = pass) | the manual: the 5-bit generator is "a constant 1" in init mode [AHRM 5.5], so they clock (B3.2) | the referee keeps AUDC ungated during init mode | | D7 | STIMER and the 5-bit gate (B3.2) | the first STIMER after leaving init mode loads the gates in tick T+2 (89 cases, channels 1, 3, 4, both clock rates); a later STIMER loads nothing: on a 64 kHz channel, 66 two-STIMER cases fit "the gate the last fire or the first STIMER loaded" exactly and no load time near the second STIMER | every STIMER loads the gates in T+2 (`HYPOTHESIS`: a STIMER is a reload; no document says) | the zero-difference judge has STIMER only in the preamble; `--stimers` streams are counted separately (status.md) | | D8 | an AUDC write in the cycle a STIMER loads the gates (T+2) | the load sees the write when the channel's AUDF is below 128 and not when it is 128 or more (channel 1, AUDF 10-127 against 128-255, flips exactly at 128) | the load sees the write, whatever AUDF (B3.2, as a fire's load does) | the rung 3 streams write their random AUDC values from T+4 of the preamble's STIMER | | D9 | an IRQEN write that clears a pending bit (B4.1) | the bit and the pin stay up one more cycle: a disable at W is still read as pending at W+1; a disable in the latch tick F shows the interrupt for one cycle (sweep of the write across a timer 1 fire, F-4..F+3, 2026-11-14) | cleared at the end of tick W (B4.1). With the box's timing a disable at the manual's "cycle 14" for an IRQ handler at 16 would not block the IRQ on a 2-cycle machine (AHRM 5.7, B4.1's reading) | `BoxAligned` holds the cleared bits one tick (`--raw-irqen` counts it: 10 streams x 5,000 cycles, 349 pin and 123 IRQST differences) | | D10 | the /IRQ pin's IRQEN bit 3 term (B1.5) | the pin follows an IRQEN bit 3 write one cycle later than a timer latch | at the end of tick W, as every IRQEN write (B4.1): Acid800 `pokey_irqtiming.s`'s first half needs it (with the box's timing its odd case would read $02 on a 3-cycle machine; expected $01) | `BoxAligned` takes the bit 3 term from IRQEN as it was before the tick | **The pot scan cannot be judged by the closed box.** Measured 2026-11-14 through the pins: after POTGO, POT0-7 read undefined (-1) on every cycle of a 240-cycle fast scan and a 400-cycle slow scan, and ALLPOT is undefined once the scan should end; only ALLPOT's following of the P pins before that is defined. The model has no power-on state and nothing reachable through the pins defines its scan counter. Rung 5's exit "equal to the VHDL's over 100 scans" is therefore not met and cannot be; the judge is AHRM 5.9's numbers (tier 3) as tests (`tests/test_pots.py`). Rung 6 differences (keyboard), measured 2026-11-14 on the rung 6 streams: | # | What | Box | Core (and its source) | Alignment / handling | | --- | --- | --- | --- | --- | | D11 | K0-K5 after a carry | the pins ripple through 2-bit groups: $0F to $10 shows $0C, $00 for one row each before $10 | one step per tick (B6.1); the chip's own key check uses the settled code on both sides | rows matching a ripple of the step are counted as `k_ripple`, not compared | | D12 | which code reads /KR2 as Shift and as Break | Break at $10, Shift at $30 | Shift at $10, Break at $30 [AHRM 5.8, and its phantom-key cases: Control+V+L simulates Shift, Control+L+9 simulates Break] | `BoxAligned` swaps `SHIFT_CODE` and `BREAK_CODE` | | D13 | SKSTAT bits 3 (Shift) and 2 (key held) | a read in the 15 kHz step's own cycle already shows the step's result | a read sees the previous tick (B0.1), as for every other register | compared against the core after the read cycle's tick. The same one-cycle lead shows in the box's sampling of /KR1-/KR2: a pin change placed in the step's own cycle is seen by the core and missed by the box (2 of 501 judge streams, both with the change at cycle 6052, a step tick); counted, not aligned | | D14 | KBCODE | undefined on most reads; where defined it does not follow the registered code (e.g. 2 and 3 where the core has $3E and $3F) | B6.4 | not compared (counted as `kbcode_undefined`) | The keyboard judge drives /KR1 and /KR2 as static levels (the key answers at every code), so debounce-on streams register nothing and exercise the rejection paths; debounce-off streams register at every pair of codes. Its K pins are read as the scan code itself, not inverted: the box's K port shows $3F while the scan is held and then $00, $01, ..., which is the manual's upward count (the testbench comment "inverted scan code" inherited from Phase 0 is corrected in `scripts/referee.py`). The /IRQ pin is printed for the row's cycle: the core's `irq` after tick t is the box's row t+1 (`RUNG4_IRQ_OFFSET`); on the box a timer's IRQST bit and its pin change in the same row, as in the core. The model's `irq` port reads 1 while asserted. The output pin lags the core's fire by 3 rows (`RUNG2_FIRE_OFFSET`): a constant of the comparison, measured on an AUDCTL clock switch and on every slow-clock channel. The rung 3 comparison reads the core's `levels()` 2 rows earlier than the box's pin (`RUNG3_LEVEL_OFFSET`) and starts 8 cycles after the preamble's STIMER has defined the flip-flops; a box row whose pin is undefined (the model has no power-on state) is counted apart, never compared (none occurred in the judge's runs). The rung 3 streams enable the high-pass bits only after that STIMER: enabled from the start, the box's high-pass flip-flops copy undefined flip-flops and its pin stays undefined.