# The DSP: CEVA's XpertTeak, and one teak core for the DSi and the 3DS Sources: GBATEK "DSi XpertTeak (DSP)" and its subsections, and "3DS Sound and Microphone" (the ARM11-side registers at 10203000h, "These are same as on DSi"); teakra (wwylele, MIT, pinned at 3d697a1), its `src/*.md` documentation and its 3DS hardware-test programs. DOC unless marked. The DSi's use of the same part is in nds-python's docs/dsi.md. ## What it is - A Teak-family DSP core plus peripherals ("XpertTeak"): timers, a serial port, the on-chip emulation module, a PLL/power unit, the host port (APBP: the ARM's window), the AHB master (AHBM: the DSP's window onto the ARM's memory), the memory interface unit, the code replacement unit, DMA, the interrupt control unit, and the audio ports (BTDMP) (GBATEK's MMIO list at 8000h-8280h; teakra's ahbm/apbp/btdmp/dma/icu/miu/... .md). - **16-bit words everywhere**: no byte addressing; 40-bit accumulators, 33-bit products, an 18-bit program counter (plus a 4-bit page register always 0 on the DSi/3DS); separate program and data spaces. The DSi/3DS give it 0x20000 words of program memory and 0x20000 words of data memory, the data side reached through bank switching in the MIU (teakra processor_general.md). On the 3DS that is the 256 KB + 256 KB at 1FF00000h and 1FF40000h, which the ARM11 maps too (GBATEK memory map). - **Clock**: about 134 MHz. teakra's evidence: the number 134,060,000 in the disassembly of the 3DS's DSP program, and a sample rate of 32,728 Hz said to match 134 MHz / 4100 (teakra processor_general.md, which cites 3dbrew for the sample rate). GBATEK gives Teak timer clocks of 134.055928 MHz and 107.244742 MHz ("aka 134MHz/1.25"). DOC, through firmware disassembly by the teakra author: not a measurement we hold. - **Timing**: "Most instructions can complete in a single clock cycle, except for double-word instructions, multiple data read/write instructions and flow control instructions" (teakra). No cycle table exists in what was read: U14. ## Which architecture: a contradiction - GBATEK: "a TeakLite II processor, plus some expert features", from a TeakLite II disassembler DLL bundled with RVDS 4.0 Pro, disassembled exhaustively by Normmatt. - teakra's README: Lauterbach's TRACE32 debugger shows the "TEAK(-REVA, -REVB, DEV-A0, -RTL2_0)" register set and instructions "very similar" to GBATEK's, while its "TeakLite-II" entry is "very different": so the core is "likely the original Teak". Recorded as **C1**. The encoding tables agree enough that both projects decode the same programs; the name decides only which outside description would apply, and neither is public. Proposal: name the core after the part (`teak-python`), say "Teak family" in its README, keep both readings. ## Proposal: one teak core The chip rule makes it a core in any case (a programmable processor). It has **two family boards**: nds-python's DSi row (the DSi Sound and Nintendo Zone utilities, "Cooking Coach": GBATEK) and n3ds-python (every 3DS game's sound goes through it: teakra's README). So: - **`teak-python`**, package `teak_python`: the Teak CPU (registers, the decoder, the interpreter) and the XpertTeak peripherals that are inside the DSP block (timers, SIO, OCEM as far as software touches it, PMU, APBP's DSP side, AHBM, MIU, CRU, DMA, ICU, BTDMP), with a memory object and the ARM-side APBP registers as sockets for the board. - The boards own the ARM side: the DSi's ARM9 window (GBATEK "DSi Teak I/O Ports (on ARM9 Side)") and the 3DS's ARM11 window (10203000h, CFG11_DSP_CNT), the shared-WRAM mapping (DSi MBK; 3DS fixed at 1FF00000h), and where the BTDMP audio goes (the codec). - **Readable reference**: teakra is MIT, so its documentation and its decoder tables may be read and cited with its notice (and a table taken from it carries `MIT` with the notice line; it is MIT already). Its interpreter is an implementation, a detector at tier 5. ## Judges | Judge | Tier | Licence | Status | | --- | --- | --- | --- | | teakra's `test_verifier` data, `teaklite2_tests_result.bin`: random instruction cases generated by its `test_generator` and **run on a 3DS** by `hwtest/dsptester` | 3 (hardware-captured by the author, not by us) | MIT | **not fetched**: a Git LFS object (oid sha256 baffcd4f..., 357,257,824 bytes), and git-lfs is not installed here. Fetch it when teak-python starts (decision N3) | | teakra's `dspmemorytester`, `dspapbptester`, `dspvictester` | 3 when run on a console | MIT | source only | | teakra's interpreter | 5 | MIT | readable | | GBATEK's Teak chapters | 3 | free to read | pinned | One provenance flag: GBATEK's TeakLite II encoding came from a leaked RVDS DLL and its references list a leaked "TeakLite Architecture Specification"; its MMIO bits from a public Lauterbach download. We never fetch or read the leaked documents. Whether facts that reached GBATEK or teakra through them may be cited is decision N6. ## On the 3DS: the DSP program is firmware The program the Teak runs on a 3DS is Nintendo's (a DSP1 binary, GBATEK "3DS Files - Sound DSP Binary (DSP1 aka .cdc)"). Two ways to have sound: - **LLE**: teak-python runs the player's own DSP program. Exact to the extent the core is; costs a host core (execution-architecture.md). - **HLE**: a functional model of what Nintendo's audio program does (its shared-memory interface with the ARM11's dsp service, its mixing of voices, its ADPCM/PCM decoding, its effects). This is a model of firmware, judged against the LLE run where a player has the program (decision N4). It is the only way phones and browsers get sound at speed. Every difference from the LLE is a named concession. Teakra's `hwtest/dsptester/data/cdc.bin` (1,092 bytes, the program its tester loads) is of unknown authorship: it is not read, copied or run here.