Repository navigation
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.
-
send_mailandraise_interruptcome on the thread that delivers mails (the CPU's). -
post_interruptcomes 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_mainandwrite_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 takeaddress & 0x01FFFFFFas a physical address, read big-endian bytes frommain_memoryand write throughdma_from_dsp. A port whose game keeps these structures in host byte order overrides both and converts each field. -
main_memorytakes physical addresses and returns big-endian bytes, or nullptr outside RAM. -
aramreturnskAramBytes(16 MiB) that stay valid for the model's lifetime. -
logmay 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.
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.