Skip to content

DSP microcode

github-actions edited this page Dec 3, 2026 · 3 revisions

DSP microcode

starlet::dsp (starlet_dsp, include/starlet/dsp/microcode.hpp) runs the audio DSP's microcode as host models at the mailbox. The port's DSP device performs the boot ROM's upload, hashes the IRAM image with microcode_hash and asks create_microcode for the model. From then on the CPU's mails go to Microcode::mail in order. The model answers through Host: mails, the DSP interrupt, and DMA between its data memory and main memory or ARAM. C++17 and threads; it builds on every host.

Microcode IRAM hash Model
Early JAudio, Luigi's Mansion (GLME01, 6112 bytes) 64d75375 src/dsp/jaudio_early.cpp
JASystem, Super Mario Sunshine (GMSE01, 7392 bytes) 9a483303 src/dsp/jasystem.cpp
Later JASystem, The Wind Waker (GZLE01, 7456 bytes) b7f560f5 src/dsp/jasystem_later.cpp
Later JASystem, Pikmin 2 (GPVE01, 7456 bytes) 7d3da25c src/dsp/jasystem_later.cpp

Each model holds its own mail protocol. All share the JAudio signal path in src/dsp/jaudio_dsp.cpp, which keeps the microcode's 4K-word data memory and its arithmetic.

Host contract

  • send_mail and raise_interrupt come on the thread that delivers mails (the CPU's).
  • post_interrupt comes from the model's render thread: the host raises the DSP interrupt on the CPU side, for example through an event the guest thread runs.
  • Every DMA with main memory goes through read_main and write_main, also on the render thread. They get the address the microcode programs and what the words hold (DmaData: samples, a voice block, the effect-line table, a table of 32-bit values or mixed output). The defaults take address & 0x01FFFFFF as a physical address, read big-endian bytes from main_memory and write through dma_from_dsp. A port whose game keeps these structures in host byte order overrides both and converts each field.
  • main_memory takes physical addresses and returns big-endian bytes, or nullptr outside RAM.
  • aram returns kAramBytes (16 MiB) that stay valid for the model's lifetime.
  • log may come from any thread.

By default the models render on their own thread, in parallel with the CPU as on the console:

  • Early JAudio renders each sub-frame there.
  • JASystem renders the bus side of each block there, one block behind or more.
  • Later JASystem has no render thread: it always renders on the mail thread.

Options::render_inline keeps all work on the mail thread. Recording (docs/DSP-replay.md), a comparison with Dolphin's LLE and deterministic runs need it. Destroying a model waits for its render thread.

Accuracy

The models follow the console microcode as Dolphin's DSP LLE runs it. Luigi's Mansion's model is bit-exact in gc-recomp's closed loop (GCRT_DSP_LLE with GCRT_DSP_COMPARE, docs/DSP-replay.md): mails, interrupts, output and every DMA word match over 45 s from boot to the title. Sunshine's model is bit-exact the same way over 120 s from boot with Start and A pressed, sound from 6 s on: 102,604 mails, 54,722 interrupts, 7.66 million output words and 58 million voice and other DMA words.

The Wind Waker's and Pikmin 2's models are checked with recordings from their source ports (dsp-replay, docs/DSP-replay.md). Every mail and interrupt matches, so the CPU input is what the microcode itself would have received. The Wind Waker, 330 s from boot through a new file's opening and the Outset load: 266,092 mails, 141,915 interrupts and 2.29 GB of compared memory, all equal. Pikmin 2, 200 s from boot through the file select into play: 166,550 mails, 88,826 interrupts and 144 MB of compared memory, all equal.

tests/dsp checks the protocols (greetings, command lengths, acks) and a synthetic workload whose main memory must match a fixed hash in both render modes.

Clone this wiki locally