# Memory map, buses, DMA and arbitration Sources and keys (all pinned in `scripts/pinned_files.json`): '641 = WO1994010641A1 ("Audio/video computer architecture", the whole system); '235 = US5572235A; '642 = WO1994010642A1; '876 = WO1995012876A1 (its appendix carries 1993 Portfolio source: `hardware.h`, `BuildSystemVDLs()`); SDK = the Portfolio 2.5 Developer's Documentation Set (`reference/src/3do-devkit/docs/3dosdk/`, paths relative to `ppgfldr/`); wiki = the 3dodev snapshots (`reference/wiki/`). Patents and SDK are DOC (tier 2: a patent describes a design, not necessarily the shipped silicon); the wiki is tier 3 and partly derived from FreeDO's code and decompiled firmware. **Every register address below is wiki-only unless a DOC source is named beside it.** The patents call MADAM the "address manipulator chip 106" and CLIO the "audio/video processor 140"; "spryte" is the cel, "SCoB" the CCB. ## The map (wiki opera_memory_mappings; shape confirmed by '641 sections II, IV, VII) | Base | End | Size | What | | --- | --- | --- | --- | | 0x0000_0000 | 0x001F_FFFF | 2 MiB | DRAM (retail) | | 0x0020_0000 | 0x002F_FFFF | 1 MiB | VRAM (retail) | | 0x0300_0000 | 0x030F_FFFF | 1 MiB | ROM (BIOS), on the 8-bit slow bus | | 0x0314_0000 | 0x0315_FFFF | 128 KiB window | NVRAM (battery SRAM, D7:0 only); mirror at 0x0316_0000 | | 0x031C_0000 | 0x031C_FFFF | | FMV module ("Woody"), when fitted | | 0x0320_0000 | 0x032F_FFFF? | | SPORT: VRAM special functions (page in address bits 9:2, '641 II) | | 0x0330_0000 | 0x0330_07FF | 2 KiB | MADAM | | 0x0340_0000 | 0x0340_FFFF | | CLIO (registers to 0x3FF; DSP memories from about 0x1800 in MAME's tap counts; PRNG at 0x17F0 per wiki) | - **Reset overlay:** MADAM maps the ROM at address 0, read-only, until the start-up code has copied what it needs and remaps ('641 VII, DOC). OBSERVED in MAME: the first instructions run at 0x0 and branch into 0x0300_0028. The remap control is undocumented (U4). - **SYSRAM:** a region from 0 of 0, 8, 16 or 32 KB, chosen by software, closed to user mode and to graphics/audio DMA ('641 II, DOC). - **Decode:** MADAM decodes A31:16; for a register it asserts a select and the device uses A15:2; memory uses A23:2 (a 22-bit word address, a 16 MB window) ('641 IV, VI, DOC). Slow-bus devices (ROM, NVRAM, front panel) use A16:2 plus an 8-bit data bus; each CPU word read from ROM is four byte reads assembled by MADAM ('641 IV.D, DOC). The slow bus is not reachable by DMA. - Everything sits below 0x0400_0000, so the machine fits a 26-bit space; MADAM's abort reason R26E "Out of 26bit address range" (wiki) suggests MADAM aborts any access above it (HYPOTHESIS). ## DRAM, VRAM, pages (DOC unless marked) - The data bus is 32 bits, big-endian: high half = left bank (D31:16), low half = right bank (D15:0); MADAM addresses the two banks separately (LA/RA, 11-bit multiplexed each) but one master at a time ('641 I, IV). - Sets: 1 or 2 VRAM sets of 1 MB (512 KB left + 512 KB right); 0, 1 or 2 DRAM sets of 1, 4 or 16 MB ('641 I). Retail: 2 MB DRAM + 1 MB VRAM; the OS supports up to 15 MB DRAM + 1 MB VRAM or 14 + 2 (SDK `pgsfldr/spg/05spg001`). Named VRAM parts: NEC uPD482234/482235 (256K x 8, 512 rows x 512 bytes, split serial register), Toshiba TC524256 ('641, '679). - A VRAM page across both banks is 512 words = 2 KB (SDK `ggsfldr/gpgfldr/3gpgf`: "VRAM page sizes are 2 kilobytes"; a 320x240x16 frame buffer is 75 pages). The OS's protection pages are another thing: always 64 per memory type (2 MB DRAM: 32 KB; 1 MB VRAM: 16 KB; SDK spg 05spg001). - Page mode: MADAM detects page breaks on random accesses and anticipates them on sequential ones; "a new page is always established for every new device which gains access"; DMA looping always breaks the page ('641 II, VI). - MSYSBits (MADAM 0x004, wiki): memory sizes, SYSRAM size, display mode, CLUT and player-bus transfer enables; two layouts (Brown vs Blue MADAM). The BIOS sizes DRAM from bits 6:0 (wiki opera_memory_configurations, from decompiled firmware: facts only). ## Frame buffer layout (SDK gpg 2gpgb, '642 I; DOC) Line pairs interleave: pixel (x, 2k) is the high halfword (left bank) and (x, 2k+1) the low halfword (right bank) of word k x width + x. One address fetches two vertically adjacent pixels, which is what the display path and the interpolator want (display.md). ## SPORT: VRAM special functions (SDK gpg 3gpgf, 4gpgh, gpr 01gpr002/005/068; '641 II) - Copy pages and clone a page to many: VRAM to VRAM, whole 2 KB pages, page-aligned, within one 1 MB bank, **only during vertical blank** (the serial port is busy during display; the call waits for VBL). FlashWrite (fill pages with a 32-bit value) runs at once, any time. A 32-bit write mask per bit (non-all-ones discouraged). Command numbers SPORTCMD_CLONE 4, SPORTCMD_COPY 5, FLASHWRITE_CMD 6 ('876 `graphics.h`). - Mechanism: an access to a memory-mapped function address with the VRAM page in address bits 9:2; D-bus data during a write transfer is the bit mask ('641 II). So a page copy is a read transfer and a write transfer, not 512 word moves (HYPOTHESIS from the VRAM parts' function set). Per-operation cost undocumented (U5). ## MADAM register map (wiki opera_madam, opera_memory_mappings; DOC confirmations noted) | Address | Name | Notes | | --- | --- | --- | | 0x000 | MADAMREV / debug | revisions Brown 0x0100_0000, Blue 0x0100_0100, Red 0x0101_0000, Green 0x0102_0000, Green+ 0x0102_1000, Preen 0x0102_2000 (Sanyo TRY); C1 | | 0x004 | MSYSBits | memory configuration | | 0x008 | MCTL: DMA enables (0x8000 player bus, 0x0010_0000 sprite control) | '876 code ORs CLUTXEN and VSCTXEN into MCTL (names DOC, values U6) | | 0x020 | abort reasons | ROMF, ROMW, CLIOT, HARDU, SYSRAMU, FENCEV, VPR, R26E, SPSC, BITE, BADDEC, ARPS, BWAAC | | 0x024 | DMA privilege violations | SYSRAM and VRAMSIZE checks for DMA, SPORT, REGIS | | 0x028 | cel status | SPRON 0x10, SPRPAU 0x20 (names DOC '235 table 1.8; bits wiki) | | 0x02C | priority encoder | write a value, read the index of its top set bit | | 0x040 | current horizontal pixel offset | | | 0x100-0x13C | cel engine | madam.md | | 0x200-0x2FF | "fence FIFO"; fences 0L/0R/1L/1R at 0x230-0x23C, 2L-3R at 0x270-0x27C | U7 | | 0x300-0x3FF | "MMU" | U7 | | 0x400-0x5FF | the DMA stack | below | | 0x600-0x7FF | matrix engine | madam.md | MAME's 600-frame run of the FZ-10 BIOS (mame-oracle.md) touches 0x000, 0x004, 0x008, 0x00C, 0x020, the fences 0x218/0x21C/0x238/0x23C (2,645 writes each), the whole 0x400-0x53C stack once at start-up, and the player-bus group 0x570-0x578 239 times. ## The D-bus arbiter ('641 IV.A, DOC) Priority, highest first: (1) the cel engine once it holds the bus; (2) mid-line video transfers; (3) slipstream capture, CLUT transfer, CLUT mid-line, start-video (never overlapping); (4) refresh, four rows a burst, once per line; (5) player bus; (6) all CLIO requests (audio, expansion bus, coprocessor: one level; CLIO arbitrates inside and sends the channel number serially on DMAREQ); (7) cel-engine FIFO input fetches; (8) the cel engine before it holds the bus; (9) the CPU. A requester keeps the bus for its burst; a running cel engine keeps requesting and must release within 7 ticks when anyone else asks or an interrupt arrives, then re-requests at low priority. '644 section 4 gives a simpler order (DMA stack > line filler > CPU, line filler sticky) (C2). **The CPU gets no bus cycles while the cel engine runs** ('235 table 1.8; SDK gpg 6gpgb: "When the cel engine is running, the CPU can't operate"); MADAM stretches MCLK to stall it ('641 IV). ## The DMA stack ('641 VI, VI.A, table I; DOC; table I read from the PDF page image) 128 dual-ported 22-bit registers in groups, each a fixed channel; addresses are word addresses; the CPU writes them as memory-mapped registers; writing a current address zeroes the next address one tick later, writing a length zeroes the next length; 0 is a flag value (no DMA to address 0, no length 0). Audio groups: current address, length, next address, next length; at length 0 a non-zero next address reloads (loop), else the channel stops; CCODE tells CLIO "will loop" or "done". | Grouping | Groups x regs | Loop | Interrupt | Channels | Max burst (words) | | --- | --- | --- | --- | --- | --- | | S-port read (CLUT and video) | 1 x 8 (7 used) | no | no | CLUT control, CLUT display path, CLUT mid-line, video, video mid-line | 4, 1, 1, 1, 1 | | S-port write (slipstream) | 2 x 4 | yes | no | frame grabber, command grabber | - | | Refresh | 1 x 1 | no | no | 1 | 4 | | Audio | 18 x 4 | yes | yes | RAM->DSP FIFO 13, DSP FIFO->RAM 4, RAM->DSP EI/N memory 1 | 3, 3, 4 | | Expansion bus | 2 x 4 | yes | yes | 2 | 4 | | Player bus | 1 x 3 | no | yes | 1 | 1 | | Cel ("spryte") engine | 1 x 8 | no | no | control (CCB), PLUT, source start, image data (2) | 7, 4, 1, 4 | | Coprocessor (decompression, other) | 4 x 4 | yes | yes | 2 + 2 | 4, 4 | Memory-mapped placement (wiki): RAM->DSP groups 0-12 at 0x400 + 0x10 n; XBUS DMA address 0x540, length 0x544; player bus write address 0x570, length 0x574, read address 0x578. The other groups' places in 0x400-0x5FF are unknown (U8). ## CPU access costs (wiki opera_arm, tier 3, origin unstated) Sequential RAM read or write 2 ticks; non-sequential 5; "short non-sequential" 3 (+ internal if the page changed); internal 2; CLIO registers >= 5 / >= 3; MADAM registers >= 5 / >= 2; ROM 35; SPORT read 7, write 6; slow bus 7 (short) or 13 (long). HYPOTHESIS: a tick is the ~25 MHz system clock, so a sequential access is one 12.5 MHz CPU cycle (U9). ## Clocks (DOC unless marked) - Master crystal 50.097896 MHz, "divided by one or two" ('462, '876, '389, '679). - System clock "approximately 25 MHz" ('641): MADAM, its registers and the DSP. 568 x 44,100 = 25.0488 MHz = 50.097896 / 2 within 1e-5, and the SDK and '641 both give 568 system ticks per audio sample: the system clock is 25.048948 MHz (HYPOTHESIS, strongly supported). - CPU 12.5 MHz (wiki, devnotes; MAME runs 12.50 MHz): HYPOTHESIS 50.097896 / 4 = 12.524 MHz. MCLK is generated and stretched by MADAM ('641 IV). - NTSC video: CV25M 24.5454 MHz (2 x 12.2727, the 640-pixel square-pixel rate; '679), from a separate crystal, replaced by the video input when genlocked ('641 I). VRAM serial clocks 6.136 MHz per bank, out of phase (12.2727 combined). PAL clock undocumented (U10). ## Unknowns and contradictions (this page) - U4 ROM-overlay remap control. U5 SPORT operation costs. U6 MCTL bit values. U7 fence and "MMU" register meaning (per-page write masks, HYPOTHESIS). U8 placement of the S-port, slipstream, cel, refresh, DSP->RAM, EI and coprocessor DMA groups. U9 the unit of the wiki's "ticks". U10 the PAL video clock. - C1 The wiki lists the MADAM revision values under 0x000 on one page and under 0x004 on another. C2 The two arbitration orders ('641 vs '644).