# Start here `ym2151-python` will be a pure-Python, MIT-licensed, cycle-level reference core of the Yamaha YM2151 (OPM), with the YM2164 (OPP) as a variant. Today it is Phase 0: a specification, the closed-box referee harness and measurement scripts. No core yet. ## Reading order 1. [restart.md](restart.md): why this repository restarted on 2026-11-19 and the rules that follow from it (what may never be read). 2. [decisions.md](decisions.md): the owner's decisions. 3. [handoff-brief.md](handoff-brief.md): scope, names, board contract, unknowns, contradictions, the ladder. 4. The specification: [registers.md](registers.md), [phase-generator.md](phase-generator.md), [operators.md](operators.md), [envelope.md](envelope.md), [lfo-noise.md](lfo-noise.md), [timers-and-bus.md](timers-and-bus.md), [output.md](output.md), [ym2164.md](ym2164.md). 5. [validation.md](validation.md): the oracles and every result; [provenance.md](provenance.md). ## Evidence tags Every rule names its source (family methodology, emulator-lineage's docs/methodology.md): | Tag | Here it means | Citation form | | --- | --- | --- | | MEASURED | a hardware capture; none exist for this chip yet | - | | DIE | IKAOPM, the die-derived Verilog with a traced schematic (BSD-2) | `DIE (IKAOPM 08a5b40, file:line)` | | TEST ROM | a hardware test program with real-unit results; none yet | - | | DOC | Yamaha's documents | `DOC (AM p.N)`: application manual, page N of the PDF scan; `DOC (DS p.N)`: the 1991 catalogue, printed page N | | OBSERVED | a model or emulator run as a closed box, or a statement in permissive emulator source | `OBSERVED (Nuked-OPM f209e6e, script or output file)`; ymfm as `ymfm 81aec25, file:line` | | FITTED | a value chosen to make named tests pass; none yet | - | | HYPOTHESIS | a reasoned guess, with the experiment that would settle it | - | Unknowns are `U1`... and contradictions between sources `C1`..., both listed in [handoff-brief.md](handoff-brief.md) and described where the behaviour is. ## Units used throughout - Input clock fM (3.0-4.0 MHz; 3.579545 MHz in the manual's examples). - Internal cycle = 2 input clocks; sample = 32 cycles = 64 input clocks. - Phase step: 2^-20 turn per sample (0.05334 Hz at 3.579545 MHz). - Attenuation: 10 bits, 0.09375 dB per unit; TL step 8 units. ## Tools | Command | What it does | | --- | --- | | `python -I scripts/fetch_references.py` | fetches the pinned references into `reference/` (git-ignored) | | `sh validation/build_referee.sh` | checks that the closed-box referee is built at `$EMU_TOOLS_GPL/tools/nuked/build/opm-events` (emu-tools-gpl's `tools/nuked/build.sh` builds it); exit 3 when `EMU_TOOLS_GPL` is unset or it is not built | | `python -I scripts/referee_probe.py` | bus, timer, CT and frame probes | | `python -I scripts/referee_measure.py` | noise, LFO and envelope measurements | | `nice python -I scripts/referee_freq.py` | every KC/KF step and DT1 size, compared with IKAOPM, ymfm and the manual (about 5 min) | | `python -I scripts/ikaopm_tables.py [--dump]` | IKAOPM's sine and exponent ROMs expanded and compared | | `nice python -I scripts/referee_survey.py [csm\|ym2164\|so]` | slow LFO rates, CSM at start, YM2164 against YM2151, SO words | | `sh scripts/mame_tap.sh`, `python -I scripts/replay_tap.py` | MAME tap logs and their replay ([mame-oracle.md](mame-oracle.md)) | | `python -I scripts/mame_census.py` | who uses the chip in MAME 0.285 ([users.md](users.md)) | ## House rules Never open forbidden sources (restart.md). No `rm -rf`, `sed -i`, `ln -sfn`; move aside to `trash/` (git-ignored). `nice` for long runs. ROM sets only through `MAME_ROMPATH`, never a machine path in the repository. Commit locally; push, tag and publish only on Aubrey's word.