# Pipeline, dual issue and timing Sources: ECUM §1.2-1.3, §2.12, ch. 6-7 (Sony, DOC); TX79 ch. 2 (Toshiba, DOC); the judges are ps2autotests `cpu/ee/*delay*`, `cpu/ee_cop0/performance` (TEST ROM) and, for timing, nothing captured beyond them (see "What can judge timing"). ## The machine - Six pipeline stages, I Q R A D W, each in two phases (ECUM §1.3.2). Two logical pipes, Pipe 0 and Pipe 1, feed six physical pipes: I0, I1 (each a 64-bit ALU, shifter and multiply-accumulate unit; I0 holds SA, I1 the leading-zero counter; together they form the 128-bit "wide" pipe for MMI), LS (loads, stores, prefetch, CACHE), BR, C1 (COP1, 8 stages, with I0) and C2 (COP2 = VU0 macro mode, with I1) (ECUM §1.2.6, §1.3.3-1.3.4). - **Issue**: two instructions fetched per cycle; if both cannot issue, one waits in a pair of staging registers and is issued first next cycle with a newly fetched one (ECUM §1.3.6). Which categories go to which logical pipe is ECUM Table 1-2; which pairs can issue together, which cannot (X) and which issue but stall one cycle in A (Y) is Table 1-3. Those two tables are the specification's pairing data, transcribed as facts into a table (decision E2). - **Interlocks**: any read of a register (GPR, HI/LO, SA, PC, coprocessor) that a preceding instruction is still writing stalls the pipeline (ECUM §1.3.1). - **Latencies** (ECUM §2.12, cycles, latency/throughput): ALU, shifts, LUI, branches, conditional moves, HI/LO moves 1/1; MULT, MULT1, MADD, MADD1 4/2; DIV, DIV1 37/37; loads 1/1 on a hit; MMI multiply 4/2, MMI divide 37/37; FPU as in docs/fpu.md. - **Branch prediction**: a 64-entry BTAC and two bits of history (BHT) per branch held in the I-cache (ECUM §1.2.1, §1.2.3). Both are readable and writable by CACHE operations (BXLBT, BXSBT, IXLDT reads the BHT into TagHi[5:4]; ECUM ch. 6 CACHE table), so they are visible state, not only timing. The update rule and the misprediction penalty are not in the manuals we hold (**U13**); the performance counters count "branch mispredicted" and "BTAC miss" events (ECUM §7.2.3), which is how a probe would measure them. - **Memory timing**: a cache refill is a 4-qword burst, 4 bus cycles = 8 CPU cycles at best, "more due to bus arbitration" (ECUM §6.3.3); the data cache restarts on the first qword, the I-cache after the last. Main-memory latency (RDRAM through the DRAMC and the EE's main bus, shared with the DMAC) is the board's (ps2-python docs/memory-map.md) and undocumented in cycles (**U14**). ## The modelling level (decision E1) **Instruction level with issue pairing, interlocks and bus transactions; no per-stage model.** Per instruction the specification knows its pipe class (Table 1-1), its pairing class (Tables 1-2, 1-3), its result latency and throughput (§2.12), and the registers it reads and writes. A small scoreboard (result-ready cycle per register, the busy-until of each MAC, the FDIV-like units of C1) and the pairing rule give each instruction's issue cycle. Cache misses, uncached accesses and WBB/UCAB traffic are bus transactions whose durations the board returns. That is the shape vr4300-python and r3000a-python chose (their decisions 2 and 4), and it is what the evidence can judge: - the structure (stages, pipes, pairing, latencies) is DOC; - the constants that the manuals leave open (miss penalties, misprediction, the WBB's drain rate) are FITTED, against performance-counter readings when a console is available, and until then marked HYPOTHESIS; - no manual describes per-phase behaviour finely enough to judge a per-stage model, so building one would claim more than we can check. ## What can judge timing - `cpu/ee_cop0/performance` (ps2autotests): it reads PCCR/PCR0/PCR1 around code sequences; its `.expected` holds counts from a real PS2 (TEST ROM). The first and only hardware-captured timing judge we have for the core. How many events it covers is to be listed when rung 3 runs. - COP0.Count, which counts every EE cycle (ps2tek tier 3), read by test code around a sequence: a probe to write (queued as a hardware probe for Aubrey: probe-batching rule). - MAME is no judge here: its R5900 charged about 0.875 instructions per cycle in a BIOS delay loop (docs/mame-oracle.md: 8,601,780 instructions in 1/30 s = 258 M/s at 294.912 MHz), with no pairing or cache model we can see (OBSERVED; its source is closed). ## Why timing matters on this machine EE timing is mostly visible through other domains: when a store reaches the VIF or GIF, when a DMA started by the core completes relative to the core's polling, Count/Compare, the timers. The PS2's software is mostly tolerant of the EE running somewhat fast or slow (PCSX2 exposes "EE Cycle Rate" from 50 % to 300 % and "EE Cycle Skip" as user settings, pcsx2.net docs "Performance Issues" and the libretro core options page, found by search 2026-11-26, OBSERVED; which games each setting breaks is not recorded by us). That tolerance is exactly why timing **is a candidate for a named concession on weak targets** (ps2-python docs/execution-architecture.md): the specification keeps the exact model; turbo may offer "fixed cost per instruction" as a concession with its measured cost. ## Unknowns U13 BHT update rule and misprediction penalty; U14 main-memory latency per access kind; U15 the "Y" stall's exact cycle (ECUM Table 1-3: one cycle in A); U16 what happens when a non-blocking load's destination is overwritten by a younger instruction before the load returns (ECUM §6.3.2 lists when the pipeline stalls, not this case; the `lsudelay` test may show it).