# Timing: the GSU clock, what each access costs, and what the board must schedule > **Sources (wave 2, 2026-11-19).** byuu's model is cited to **ares** (ISC, > `ares/component/processor/gsu` and `ares/sfc/coprocessor/superfx` at `9408cb4`; notice > in [NOTICE](../NOTICE)), its readable form; bsnes is a closed box and is not cited. > MAME is cited from its BSD-3 files (`bus/snes/sfx.cpp`, `sfx_dasm.cpp`) and from runs > (OBSERVED, MAME 0.285: traces, krom's rows, the rung-4 replays); its GSU file > `cpu/superfx/superfx.cpp` is GPL and a closed box. A **†** marks a statement about > Mesen2, snes9x, the sd2snes GSU or MAME's `superfx.cpp` that was **read from source under > the old rule (before 2026-11-19)**: those are closed boxes from now on, and such a > statement is never the basis of a default. Results of running Mesen2 or MAME are > closed-box observations and carry no mark. Unlike the uPD7725, the GSU's instructions do not take one clock each: an instruction costs its **opcode fetches** (from the cache, ROM or RAM), plus **waits** on the ROM buffer, the RAM write buffer, the multiplier, the pixel caches and the bus grant (RON/RAN). The S-CPU sees all of it, because it polls SFR.GO or waits for the IRQ, and because games time their frame work against the GSU (Winter Gold's race start, below). This is where most of the core's risk is: the emulators agree on results and **disagree with each other and with Nintendo's manual on time** (C8, C10, C12-C15 in [undocumented-behavior.md](undocumented-behavior.md)). Short names as in [start-here.md](start-here.md). ## The clocks | Chip | Input clock (fullsnes "External Oscillators") | CLSR = 0 | CLSR = 1 | ares | Mesen2† | MAME 0.285 | snes9x† | | --- | --- | --- | --- | --- | --- | --- | --- | | MC1 | the SNES master clock, 21.47727 MHz (NTSC), 21.28137 (PAL) | input / 2 | input | `system.cpuFrequency()` (ares `sfc/cartridge/load.cpp` l.267) | master clock | `DERIVED_CLOCK(1,1)` = slot clock | master clock | | GSU-1, GSU-1A | own crystal "21.4MC/TDKT", 21.4 MHz | / 2 | x 1 | the board's `oscillator` (l.265) | master clock | master clock | master clock | | GSU-2, GSU-2-SP1 | own crystal "[M]21440C", 21.44 MHz | / 2 | x 1 | the board's `oscillator` | master clock | master clock | master clock | BK2 2-4-11: "CLSR Flag = 0, Super FX operates at 10.7 MHz; = 1, 21.4 MHz". BK2 2-1-1 calls 10.74 MHz "six times as fast as the Super NES CPU" (the 3.58 MHz FastROM figure). fullsnes: "MS0 be zero in 21MHz mode"; "XXX according to MotZilla, GSU1 supports 21MHz, too?"; CLSR "exists on all GSU variants (including Black Blob MC1) (however, there are rumours that the fast mode was 'bugged' on older MC1)". **Which games set CLSR = 1** is measured below. The emulators that clock GSU-1/GSU-2 from the master clock are off by the crystal ratio below, 0.17 % for a GSU-2 (C8). Every emulator counts GSU time in **input clocks** (21.4 MHz units) and makes CLSR = 0 cost twice as many: ares's costs are `regs.clsr ? 1 : 2` for a cache fetch and `regs.clsr ? 5 : 6` for a ROM/RAM access (ares `memory.cpp` l.50-68, `timing.cpp` l.32, l.46), Mesen2† the same (`Gsu.cpp` `ReadProgramByte`), snes9x†'s 2026 GSU cycle mode the same. In **GSU cycles** that is: cache fetch 1 cycle at either speed; ROM/RAM access **3 cycles at 10.7 MHz, 5 cycles at 21.4 MHz** (BK2 2-7-2: "Read timing for game pak ROM access ... 21.4 MHz: 5 cycles; 10.7 MHz: 3 cycles"). That BK2 sentence is about the ROM buffer's data read; whether an **opcode** fetch from ROM or RAM also takes 5 cycles at 21.4 MHz is open: fullsnes asks "ROM/RAM Opcode-byte-read: 3 cycles at both 21MHz and 10MHz?", and BK2 2-6-9 calls cache fetches "six times as fast" (C12). ### Against the master clock (NTSC 21.47727 MHz = 236.25 / 11 MHz) | | GSU cycles per master clock | per scanline (1,364) | per frame (357,368) | | --- | ---: | ---: | ---: | | MC1, CLSR = 0 | 1/2 | 682 | 178,684 | | MC1, CLSR = 1 | 1 | 1,364 | 357,368 | | GSU-1 at 21.4 MHz, CLSR = 0 | 4708/9450 = 0.498201 | 679.55 | 178,041 | | GSU-2 at 21.44 MHz, CLSR = 0 | 11792/23625 = 0.499132 | 680.82 | 178,373.9 | | GSU-2 at 21.44 MHz, CLSR = 1 | 23584/23625 = 0.998265 | 1,361.63 | 356,747.8 | The crystal fractions are exact only for the nominal frequencies; a real crystal is off by tens of ppm and drifts against the console's, as the S-SMP's does (snes-python U8). On MC1 boards the GSU is **locked** to the master clock. The board keeps the GSU as a clock domain with an exact fraction (snes-python already does this for the APU and the NEC DSPs, `necdsp.py` `advance`). ## What an instruction costs (BK2 chapter 9 "Machine Cycles"; chapter 7 examples) ### Opcode fetches Each opcode or operand byte comes through the pipeline (start-here.md): from the **cache** when R15 is in a valid line (1 cycle), else from ROM or RAM (BK2's tables: 3 cycles a byte). BK2's per-instruction tables give three columns, "ROM execution time", "RAM execution time", "Cache RAM execution time", and do not say at which CLSR; their fetch costs (3 a byte from ROM) are the 10.7 MHz figure, while some wait ranges (GETB "Cache 1-6") look like 21.4 MHz's 5-cycle ROM read (U5). A selection (OCR checked against the page images where it lost digits): | Instruction | Bytes | ROM | RAM | Cache | Notes | | --- | ---: | ---: | ---: | ---: | --- | | ADD Rn, INC, TO, NOP, STOP, LOOP, JMP, COLOR, MERGE ... | 1 | 3 | 3 | 1 | | | ADD #n, ADC, MOVE, IBT, CMODE, ROMB, RAMB, branches | 2 | 6 | 6 | 2 | branch: "the execution time ... of the pipeline byte is not included" | | IWT Rn,#xx | 3 | 9 | 9 | 3 | | | MULT Rn | 1 | 3 or 5 | 3 or 5 | 1 or 2 | MS0 = 1 / 0 | | MULT #n, UMULT Rn | 2 | 6 or 8 | 6 or 8 | 2 or 3 | | | FMULT | 1 | 11 or 7 | 11 or 7 | 8 or 4 | MS0 = 0 / 1 | | LMULT | 2 | 10 or 14 | 10 or 14 | 5 or 9 | MS0 = 1 / 0 | | GETB | 1 | 3-8 | 3-9 | 1-6 | waits for the ROM buffer | | GETBH, GETBL, GETBS | 2 | 6-10 | 6-9 | 2-6 | | | GETC | 1 | 3-10 | 3-9 | 1-6 | | | LDW (Rm) | 1 | 10 | 12 | 7 | a RAM word read in the instruction | | LDB (Rm) | 2 | 11 | 13 | 6 | | | LM Rn,(xx) | 4 | 20 | 21 | 11 | | | LMS Rn,(yy) | 3 | 17 | 17 | 10 | | | STW (Rm) | 1 | 3-8 | 7-11 | 1-6 | buffered; waits for the previous store | | STB (Rm) | 2 | 6-9 | 8-14 | 2-5 | | | SM (xx),Rn | 4 | 12-17 | 16-20 | 4-9 | | | SMS (yy),Rn | 3 | 9-14 | 13-17 | 3-8 | | | SBK | 1 | 3-8 | 7-11 | 1-6 | | | PLOT | 1 | 3-48 | 3-51 | 1-48 | waits on the secondary pixel cache | | RPIX | 2 | 24-80 | 24-78 | 20-74 | flushes both pixel caches, reads RAM | (BK2 2-9-3 .. 2-9-122; the table at 2-2-6 lists 98 instructions; chapter 9 stops after "9.90 UMULT Rn", so UMULT #n, WITH, XOR Rn, XOR #n have no entry: fullsnes "GSU Undoc opcodes".) ### The manual's worked examples: timing vectors (BK2 2-7-2 .. 2-7-5) All six are **in the cache at CLSR = 1** (BK2 7.1.1, 7.2.1), with the cycles printed per line (read from the page images, PDF pages 137-140): | Example | Program (cycles per instruction) | Total | ares / Mesen2† model | | --- | --- | ---: | --- | | 1 (ROM buffer) | `MOVE R14,R1` 2, `GETB` **5**, then `TO FROM ADD TO FROM ADD ADD` 1 each | **14** | 14: R14 written at the end of MOVE, the 5-clock read, GETB = 1 fetch + 4 wait | | 2 | `MOVE R14,R1` 2, six 1-cycle ops, `GETB` 1, `ADD R8` 1 | **10** | 10 | | 3 (RAM buffer) | `FROM R8` 1, `STW (R10)` 1, `STW (R11)` **10**, five 1-cycle ops | **17** | 22: a word store is two byte writes, so the first STW already waits 5 | | 4 | `FROM` 1, `STW` 1, `TO FROM ADD` 3, `STW` **7**, `FROM ADD` 2 | **14** | 19 | | 5 (bulk) | `LM R0,(1234h)` **14**, `INC` 1, `SM (1234h),R0` 4 | **19** | 4 + 1 + 9 = 14: RAM data reads cost nothing | | 6 | `LM` 14, `INC` 1, `SBK` 1 | **16** | 4 + 1 + 6 = 11 | The manual's figures fit one model: an opcode byte from the cache 1 cycle; a ROM or RAM byte 5 cycles at 21.4 MHz; **a RAM word read 10 cycles inside the instruction** (LM: 4 fetches + 10); **a word store buffered whole**, the buffer busy for 10 cycles, a store meeting a busy buffer waiting for it. ares, MAME's buffers† and Mesen2† do **not** charge RAM data reads (ares `timing.cpp` l.39-42: `readRAMBuffer` reads without `step`; Mesen2† likewise) and buffer **bytes**, so they miss examples 3-6 (C13). snes9x†'s cycle mode charges two memory accesses for an LDW. The sd2snes† FPGA holds a 16-bit write buffer (its own comment says it should be 8 bits) and a RAM latency on loads. These six examples are the strongest timing judge there is (manufacturer tier); [validation.md](validation.md) rung 3 makes them tests. ### The buffers (BK2 7.1, 7.2; ares `timing.cpp`) - **ROM buffer**: a write of R14 (by an instruction, at its end, or by the S-CPU, `io.cpp` l.68) starts a 5-cycle (21.4 MHz) / 3-cycle (10.7 MHz) read; GETxx waits for it; ROMB waits for it first (BK2 7.1.1). A program **running from ROM** cannot overlap: "The instruction following a change in register R14 will not begin execution until the ROM buffer is loaded" (BK2 7.1.2; ares `memory.cpp` l.60-64: `readOpcode` from ROM calls `syncROMBuffer`). - **RAM buffer**: a program running from RAM cannot overlap a store: "The instruction following a STB or similar instruction is executed after completion of the write operation" (BK2 7.2.2; ares `memory.cpp` l.65-69: `readOpcode` from RAM calls `syncRAMBuffer`). - **The CACHE hazard**: CACHE in the 7 cycles (21.4 MHz) / 4 (10.7 MHz) after an R14 change spoils the ROM buffer (BK2 7.1 CAUTIONS; fullsnes "will return garbage"). No emulator models it (U6). ### Multiply (BK2 8.2, chapter 9; CFGR.MS0) Extra cycles over the fetches, from BK2's table: MULT/UMULT +1 at standard speed, 0 at high speed; FMULT/LMULT +7 standard, +3 high speed. ares: `if(!regs.cfgr.ms0) step(regs.clsr ? 1 : 2)` (`instructions.cpp` l.228) and `step((regs.cfgr.ms0 ? 3 : 7) * (regs.clsr ? 1 : 2))` (l.304), which is BK2 in GSU cycles. Mesen2† charges MULT by MS0 alone, whatever CLSR (a cycle too many at high speed, and at 21.4 MHz); sd2snes†: FMULT 7 at 21.4 MHz whatever MS0, 7/14 at 10.7 MHz (its comment notes that Star Fox 2 uses the slow MS0). MS0 = 1 at 21.4 MHz is against BK2 2-4-11; MAME clears MS0 when CLSR is set (`superfx_update_speed`†). C14. ### Plot (BK2 8.1.3; chapter 9 PLOT/RPIX) A PLOT that fills or leaves the primary cache hands it to the secondary, which is written to RAM **while later instructions run**; only a second hand-over while the secondary is still busy waits (BK2 8.1.3.1). ares and Mesen2† write the secondary at once, charging 5/6 clocks per plane plus a read per plane when the row is partial (`flushPixelCache`: 2, 4 or 8 planes), stalling the PLOT instead (C15). RPIX: flush both caches, then read one byte per plane, 5/6 clocks each, at least "20" cycles in the cache (BK2). ### Waiting for the bus With RON = 0 (or RAN = 0) the GSU waits at its next ROM (RAM) access until the S-CPU sets the bit again (BK2 5.3). ares steps 6 clocks at a time while it waits (`memory.cpp` l.3-7, l.12-16, l.21-25, l.34-38); Mesen2† stops the GSU until the SCMR write (`WaitForRomAccess`). Code running from the cache does not wait (BK2 6.1.2). Measured: **Star Fox writes SCMR `39h` (RON = RAN = 1), `29h` (RAN only) and `21h` (neither) while the GSU runs**, 15,694 times in its first 1,800 frames, so it takes the ROM back from a running GSU every frame (below). A STOP releases the buses; GO = 0 by the S-CPU too. ## What the games set (measured on MAME 0.285, 2026-11-06) `scripts/mame_gsu_trace.py --host-only`, the first 1,800 frames (30 s) of the attract mode, no buttons; values are the S-CPU's writes (banks 00 and 80): | Game (dump) | GSU starts (`$301F` writes) | CLSR | CFGR | SCMR values | other | | --- | ---: | --- | --- | --- | --- | | Star Fox (USA) (Rev 2), MC1 | 6,008 | never written (0: 10.7 MHz) | never written (0: IRQ on, MS0 = 0) | `39h` x 7,608, `21h` x 7,046, `29h` x 1,040 | SCBR `0Bh`; PBR 1 and 6; 3.38 M SFR reads | | Super Mario World 2 - Yoshi's Island (USA) (Rev 1), GSU-2-SP1 | 12 | `01h` (21.4 MHz) | `80h` (IRQ masked) | `3Dh` (OBJ mode, 16 colours, RON+RAN), `00h` | BRAMR 1; SFR = 0 (GO = 0) before each start; SCBR `16h` | So both clock speeds and both IRQ settings are in use, and Star Fox drives the RON/RAN arbitration hard. A 3-frame trace of Star Fox from frame 600 (`--start-frame 600 --frames 3 --ram`) executed **225,133 GSU instructions** under MAME, 214 STOPs, 515 PLOTs, 31 RPIXs, 691 CACHEs, all from ROM bank 1 or 6 (`scripts/trace_coverage.py`); the instruction count is MAME's, not the chip's (MAME runs one instruction per input clock: mame-oracle.md). ## Game-level timing evidence - **Winter Gold (snes9x issue #533)**: at the race-start pose switch the game polls a value the GSU publishes; the report is that on hardware the course-load render keeps the GSU busy about one frame longer, so a board that gets the GSU's time wrong shows a garbled skier for one frame. A game-level timing check, at most a second-hand hardware report (middle rule; no capture). This paraphrase was first taken from a comment in snes9x's source (read under the old rule); the address and line count quoted with it were removed on 2026-11-19, and the wording is still to be checked against the issue itself. - **The MC1 STOP hang** (fullsnes): "On MC1 (maybe also GSU1), STOP hangs when executed after a RAM write (there must be at least 2 cycles after write ... the bug doesn't occur on GSU2)". Star Fox's code was written around it; no emulator models it (U24). - snes-python validation.md (2026-10-21): MAME's frames at 5 s match krom's pictures for **0 of the 58** `CHIP/GSU` ROMs (31 test screens and 27 plot demos), "pictures differ wholesale: MAME's GSU or timing". The 31 tests' PASS/FAIL rows all pass on MAME when read from the VRAM stream ([validation.md](validation.md)), so the picture difference is not results.