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 |
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.
-
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 or a table of 32-bit values). 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.
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.
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.