Skip to content

DSP microcode

github-actions edited this page Dec 3, 2026 · 2 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

Each model holds its own mail protocol. Both 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.
  • main_memory takes physical addresses and returns big-endian bytes, or nullptr outside RAM. It is also called on the render thread.
  • 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.

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 has not yet been compared in a closed loop.

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