# Start here: the SH-4 as the Dreamcast uses it Phase 0, 2026-11-26. Citations: "HM n.n" is Renesas's *SH7750, SH7750S, SH7750R Group User's Manual: Hardware*, R01UH0456EJ0702 Rev. 7.02 (2013); "SM n.n" is the *SH-4 Software Manual*, REJ09B0318-0600 Rev. 6.00 (2006), Renesas's reissue of Hitachi's SH-4 programming manual. Both are tier 2 (manufacturer), pinned in `scripts/pinned_files.json`, fetched by `scripts/fetch_references.py` with text versions under `reference/text/`. "Comstedt" is Marcus Comstedt's *Dreamcast Programming* pages, pinned by [dreamcast-python](../../dreamcast-python) (tier 3). ## Which chip - The Dreamcast's CPU is the **SH7091** (MAME 0.285's device list for `dc`: "Hitachi SH7091 @ 200.00 MHz"; OBSERVED). No public Hitachi document for the SH7091 was found. It is treated as an **SH7750-class** part, read through the SH7750 manual: the SH7750's 8 KB I-cache and 16 KB O-cache, not the SH7750R's doubled, 2-way "cache enhanced mode" (HM 4.3.10, SH7750R only). HYPOTHESIS (handoff U1): the SH7091 is the SH7750 core with the Dreamcast's pin-out; nothing we hold says which SH7750 revision its core matches. Every place the HM says "SH7750R only" or "SH7750S or SH7750R" is out of scope until U1 is settled. - Comstedt's CPU page: "200 MHz/360 MIPS", from Hitachi's product material (DOC, tier 3 quoting tier 2; the figure is not in the pinned HM). 360 MIPS at 200 MHz is 1.8 instructions a cycle: a peak with both pipes issuing, not a measured game rate. ## What is new against the SH-2 The SH-4 is "upward-compatible with SH-1, SH-2, and SH-3" (SM 1.1, table 1.1). What the family's [sh2-python](../../sh2-python) does not have: | Feature | SH-4 | Source | | --- | --- | --- | | Issue | two instructions a cycle, six issue groups (MT, EX, BR, LS, FE, CO) and a pairing table | SM 8.2, tables 8.1, 8.2 | | Pipeline | five stages (I, D, EX/SX/F1, NA/MA/F2, S/FS), latencies and lock stages per instruction | SM 8.1, 8.3, table 8.3 | | Registers | R0-R7 banked (BANK0/BANK1 selected by SR.RB in privileged mode); SSR, SPC, SGR, DBR; SR gains MD, RB, BL, FD | SM 2 | | Modes | privileged and user (SR.MD); privileged-only instructions raise a general illegal instruction in user mode | SM 2, 5 | | FPU | single and double precision, 2 banks of 16 registers (FPSCR.FR), FPUL, pair moves (FPSCR.SZ), FIPR and FTRV | SM 6, HM 6; [fpu.md](fpu.md) | | MMU | 4-entry ITLB, 64-entry UTLB, 1 K/4 K/64 K/1 M pages, 8-bit ASIDs, single and multiple virtual modes | HM 3; [mmu-caches-sq.md](mmu-caches-sq.md) | | Caches | 8 KB direct-mapped I-cache, 16 KB direct-mapped O-cache (copy-back or write-through), 32-byte lines, index modes, 8 KB O-cache RAM mode | HM 4 | | Store queues | two 32-byte queues written at E0000000-E3FFFFFF, flushed by PREF | HM 4.7 | | Exceptions | the SH-3 model: EXPEVT/INTEVT codes, vectors VBR+100h (general), +400h (TLB miss), +600h (interrupts), reset at A0000000; an exception while SR.BL=1 resets the chip | HM 5.3, table 5.2; SM 2 | | Decode | depends on FPSCR.PR and FPSCR.SZ as well as the 16 opcode bits | SM 7; [isa.md](isa.md) | | On-chip modules | BSC (SDRAM), DMAC (4 channels), TMU (3 channels), RTC, SCI, SCIF, INTC (IRL, priorities), CPG, WDT, UBC, H-UDI | HM 9-21 | ## Clocks (HM 10; SM 8.3) Three clocks: I (CPU, FPU, MMU, caches), B (external bus), P (peripherals), ratios set by FRQCR. On the Dreamcast I = 200 MHz (MAME's device clock). The B and P clocks the boot ROM selects (FRQCR's value) are not yet read: the MAME trace's first register writes give them (handoff U2). The core counts I-clock cycles; the board converts. ## What the core owns, and what the board owns As sh2-python is the whole SH7604, `sh4_python` is the whole SH7750-class chip: anything inside the package is in the core. | Core (`sh4_python`) | Board (`dreamcast_python`) | | --- | --- | | CPU, FPU, registers, both banks, the decode and every instruction | the physical memory map (areas 0-7 as the Dreamcast wires them) | | the issue model (pairing, latencies, stalls) and its cycle cost | Holly's registers, the TA FIFO, the G1/G2 buses and their DMA | | MMU: ITLB, UTLB, MMUCR, PTEH/PTEL/PTEA/TTB/TEA, the TLB arrays in P4 | what the B-clock costs on each area (SDRAM, VRAM, G2 waits) beyond the BSC's own settings | | I-cache, O-cache, their P4 arrays, OC RAM mode, the write-back and write-through buffers | the IRL lines (Holly's interrupt controller drives IRL3-0) | | the store queues and their burst to the bus | the AICA, GD-ROM, Maple, flash, modem | | exceptions, interrupts (NMI, IRL decode, on-chip sources), SR.BL | the DREQ/DACK wiring of the DMAC's channel 2 (Holly's channel-2 DMA to the TA) | | BSC registers (and SDRAM refresh timing), DMAC, TMU, RTC, SCI, SCIF, INTC, CPG, WDT, UBC (registers at least) | the reset and NMI sources | The boundary is **one bus interface** carrying the BSC's transactions (physical address, size, kind: instruction fetch, data, cache line fill/write-back, SQ burst, DMAC) with the B-clock time each took, plus IRL3-0, NMI, the DMAC's DREQ/DACK pins and reset. The core never knows what is at an address. ## Address spaces (HM 3.3; Comstedt "memory") 32-bit effective addresses, 29-bit physical. U0/P0 00000000-7FFFFFFF (translated when MMUCR.AT=1, user and privileged); P1 80000000-9FFFFFFF (privileged, cacheable, untranslated); P2 A0000000-BFFFFFFF (privileged, uncached, untranslated); P3 C0000000-DFFFFFFF (privileged, cacheable, translated); P4 E0000000-FFFFFFFF (privileged, on-chip registers and arrays; the store-queue window E0000000-E3FFFFFF is reachable from user mode when MMUCR.SQMD=0, HM 4.7.4). Area 7 (1C000000-1FFFFFFF) mirrors P4's register space and also needs privileged mode (Comstedt "memory"). The Dreamcast boots with the MMU off (Comstedt: "the normal mode of operation in the Dreamcast is to have the MMU disabled"), but Windows CE titles turn it on (141 of the 1,509 Redump discs carry the Windows CE bit: dreamcast-python docs/census.md). ## Read next 1. [isa.md](isa.md): the instruction set, the mode-dependent decode, the overlap with sh2-python. 2. [fpu.md](fpu.md): the FPU, FIPR and FTRV. 3. [mmu-caches-sq.md](mmu-caches-sq.md): MMU, caches, store queues. 4. [timing.md](timing.md): the dual-issue pipeline and the modelling level. 5. [reuse-sh2.md](reuse-sh2.md): what to take from sh2-python and how. 6. [validation.md](validation.md), [mame-oracle.md](mame-oracle.md). 7. [handoff-brief.md](handoff-brief.md).