# AICA: the sound block, its ARM7DI and its DSP Sources: ARM's ARM7DI Data Sheet DDI 0027D (tier 2, pinned); KOS `spu.h`, `spu.c`, `sound/*.h`, `rtc.c`, `g2bus.h`, `asic.h` (tier 3); MAME's `aica`, `aicadsp`, `arm7` devices run as closed boxes (tier 5). Sega's "AICA (FQ8005) Sound-block User's Manual" exists (Sega Retro hosts it) but was not used (sources.md). Yamaha's SCSP is the AICA's ancestor; saturn-python's scsp.md and Sega's SCSP manual are background, not evidence for the AICA. ## What it is - 64 channels of PCM (8- and 16-bit) and ADPCM playback from sound RAM, with envelope, LFO and pan per channel (Comstedt *hw*: "64 channel PCM"; KOS `aica_comm.h` channel commands; register blocks of 80h bytes per channel at 00700000: KOS `spu.c`). - An effects DSP (the SCSP's successor): its program, coefficient and address memories are register blocks in the AICA's space. Its instruction encoding is not in any document we hold (U11): the same gap saturn-python recorded for the SCSP (its U13). - An **ARM7DI** CPU that runs sound drivers from sound RAM. The SH-4 loads the driver into sound RAM over G2 and releases the ARM from reset through the register at 00702C00 (KOS `spu.c`). MAME 0.285: "ARM7 (little) @ 2.82 MHz" (OBSERVED). - 2 MB of sound RAM at 00800000 (KOS `spu.h`), shared by the ARM7 (at its own address 0), the channels, the DSP and the SH-4 (over G2). - The RTC: a 32-bit seconds counter read as two halves at 00710000/00710004 (KOS `rtc.c`); MAME's `aicartc` at 32.76 kHz. - An interrupt to the SH-4 through Holly (event 0101h, "SPU interrupt") and an interrupt controller of its own for the ARM7 (timers, MIDI, DMA: names from MAME's log lines and KOS; registers U12). - The CD-DA input from the GD-ROM (HYPOTHESIS by analogy with the SCSP's EXTS input on the Saturn and MAME's `cdda` device under the GD-ROM; U13). ## The ARM7DI against arm7tdmi-python [arm7tdmi-python](../../arm7tdmi-python) (the family's ARMv4T core for the GBA, rungs 0-4 passed) is the nearest core. The ARM7DI (ARM7DI Data Sheet) differs: | | ARM7DI (DDI 0027D) | ARM7TDMI (arm7tdmi-python) | | --- | --- | --- | | Architecture | ARMv3 ("eleven basic instruction types", ch. 1) | ARMv4T | | Thumb (T), BX | **none** | yes | | Long multiply (M): UMULL, UMLAL, SMULL, SMLAL | **none**: MUL and MLA only (ch. 4.6) | yes | | Halfword and signed-byte transfers (LDRH, STRH, LDRSB, LDRSH) | **none** (ARMv4 additions) | yes | | 26-bit address mode | can be configured for a 26-bit address bus "for backwards compatibility" (ch. 1); 26-bit modes in the programmer's model (ch. 3) | 32-bit only | | Pipeline, bus cycle types (N, S, I, C), cycle counts | 3-stage, the same cycle-type family (ch. 5.1, ch. 9 "Instruction Cycle Operations") | the same family, tabulated in its docs/timing.md | | Multiplier timing | MUL/MLA early termination per ch. 9.3 | ARMv4T Booth (zaydlang's fuzzed model) | | Undefined encodings | the ARMv4 additions are undefined instructions here (to confirm per encoding: U14) | defined | dc-arm7wrestler's README agrees in substance: its port "remove[d] all the ARMv4/v5 and thumb opcodes which aren't available on the Dreamcast's ARM7DI" (cited only: the repository has no licence, so it was not fetched). **Proposal (chip rule):** the ARM7DI is a CPU, so it gets a core. Rather than a new repository, a **machine variant of arm7tdmi-python** (an `ARM7DI` class, or a construction parameter `arch="v3"`) that turns off Thumb, BX, long multiplies and the halfword transfers, routes their encodings to the undefined-instruction trap, adds the 26-bit configuration if the Dreamcast uses it (it does not appear to: the AICA's ARM boots at address 0 of sound RAM in 32-bit mode, HYPOTHESIS), and takes ARM7DI ch. 9's cycle operations. A request to arm7tdmi-python with these items, raised upstream (fixes start upstream), is open decision 5. The ARM's clock and the sound RAM's wait states are the board's. ## The SH-4 side Sound RAM and AICA registers sit on G2: SH-4 accesses go through Holly's G2 interface with its FIFO and waits (KOS guards them by suspending G2 DMA and waiting on the FIFO), so each is a sync point between the CPU domain and the sound domain. Drivers use sound RAM as a mailbox (KOS `aica_comm.h`: a command queue and a response queue in sound RAM). ## Unknowns U11 the DSP encoding and arithmetic; U12 the AICA's register map in full (KOS and MAME log names give part); U13 the CD-DA path; U14 the ARM7DI's handling of ARMv4 encodings; U15 sound RAM arbitration between the ARM7, the channels, the DSP and G2 (wait states); U16 the AICA's exact sample clock (MAME's 22.57 MHz is 512 x 44.1 kHz: HYPOTHESIS that the output is 44.1 kHz from it).