# Memory map, the 16/8-bit bus, CRU map and interrupts Sources (pins in `scripts/pinned_files.json`; OCR text in `reference/text/` after `scripts/ocr_scans.py`): - **[CTD]** TI-99/4A Console and Peripheral Expansion System Technical Data (TI, undated; a later edition of [HCTD]). Section A (console), B (interface considerations). Tier 2. - **[HCTD]** TI Home Computer Technical Data, © 1982. Tier 2. - **[GPL]** GPL Programmer's Guide (TI), appendix L. Tier 2. - **[DM]**, **[FSD]**: the TMS9900 documents, pinned in `../tms9900-python`. All DOC unless tagged. Page references are [CTD]'s printed numbers. ## Clocks [CTD fig. A] | Clock | Source | Feeds | | --- | --- | --- | | 48 MHz crystal → TIM9904 → φ1-φ4 at **3.000 MHz** | the TIM9904 clock driver | the TMS9900; φ3 is on the I/O port ("CPU clock, phase 3") | | **10.738635 MHz** crystal | the TMS9918A's own | the VDP; its 3.58 MHz output (unused by the CPU on this board) and its **447 kHz** GROMCLK output (figure A: "3.58 MHz, 447 kHz") | | 447 kHz (10.738635 / 24 = 447.443 kHz) | VDP pin | the GROMs and the TMS9919 sound chip (figure A draws the sound chip and the GROMs on that line); MAME 0.285 lists the sound chip at 447,443 Hz (OBSERVED) | | 640 kHz (TMS5220's RC oscillator) | the speech synthesizer | speech (speech.md) | The CPU and the VDP do not share a crystal: two clock domains (domains-and-speed.md). The console ROM holds a "clock byte" at >000C giving the CPU clock in MHz (high nybble integer, low nybble fraction) for peripherals to read [GPL 1-2]. ## Memory map [CTD A.3, B.1.2; HCTD III] | Range | Use | Bus | | --- | --- | --- | | 0000-1FFF | console ROM, 8 KiB (4K × 16: two 4 KiB byte-wide chips, u610 high byte and u611 low byte) | 16-bit, no wait states | | 2000-3FFF | 32K memory expansion (low 8 KiB) | 8-bit via the I/O port | | 4000-5FFF | DSR ROM space, predecoded on the I/O port (MBE); a card answers only while its CRU ROM-select bit is 1 | 8-bit | | 6000-7FFF | cartridge ROM/RAM, predecoded to the cartridge (GROM) connector | 8-bit | | 8000-83FF | 256-byte scratchpad RAM (128 × 16), decoded in 1 KiB so it repeats at 8000, 8100, 8200, 8300; software uses 8300 | 16-bit, no wait states | | 8400-87FF | sound chip write (1 byte needed) | 8-bit | | 8800-8BFF | VDP read: 8800 data, 8802 status | 8-bit (VDP on D0-D7) | | 8C00-8FFF | VDP write: 8C00 data, 8C02 address/register | 8-bit | | 9000-93FF | speech read (SBE on the I/O port) | 8-bit | | 9400-97FF | speech write | 8-bit | | 9800-9BFF | GROM read: 9800 data, 9802 address | 8-bit | | 9C00-9FFF | GROM write: 9C00 data (GRAM), 9C02 address | 8-bit | | A000-FFFF | 32K memory expansion (high 24 KiB) | 8-bit via the I/O port | The memory-mapped devices in 8000-9FFF are **partially decoded**: each answers anywhere in its 1 KiB block [CTD A.3 note, B.1.2]. Which address bits each device sees inside its block (for example whether 8802 and 8806 are both VDP status) is decided by the decode logic in the schematics: U1 in the brief. Banks 1-7 of the device space "available at other addresses, with external decode logic" [HCTD III]. ## The 16/8-bit multiplexer and its wait states - Only the console ROM and the scratchpad are 16-bit. Everything else goes through a "16 bit to 8 bit data bus converter" [CTD fig. A; HCTD I: "the memory bus (with data bus converted to eight bits wide)"]. - A CPU memory cycle to the 8-bit side becomes **two 8-bit cycles, the odd byte (A15 = 1) first, then the even byte**; the two bytes are assembled into a word before the CPU takes it [CTD A.6 "I/O read", "I/O write"]. - Read timing: data from the peripheral must be valid 750 ns after the start of clock cycle 1; "the CPU will look at the full 16-bit data bus during the leading edge of φ1 of clock cycle 6" [CTD A.6]. Read as a 6-clock memory cycle: **2 + 4 wait states**. TI's figure B (a scan) is said to show "two 8-bit read cycles with one wait state inserted in each to work with slow memories": how the 4 waits divide between the two byte cycles is to be read from the figure and the wait-state logic in the schematics (U2). - Write timing: "a write cycle will always be preceded by an ALU cycle" (the TMS9900's sequences guarantee it); the two 8-bit writes keep MBE low for about 1.8 µs (≈ 5.4 clocks), WE low for 666 ns typical in each [CTD A.6]. The write's wait-state count (4 assumed) is U3. - **READY on the I/O port** stretches further: a slow peripheral (the speech synthesizer, the GROMs on the cartridge port) holds READY low [CTD A.2: "READY (when MEMEN is active) indicates external memory is ready"]. Those extra waits come from the device models. - The VDP: figure A draws the TMS9918A on D0-D7 of the CPU-side bus, not behind the converter. Whether its accesses take the converter's wait states (the decode is by address, so they may) is U4. The VDP never asserts READY (tms9918-python consumers.md: the TMS9918A has no wait output); [GPL] L-1 asks software for "a delay of at least 6 µs" between VDP operations. **Read before write.** The TMS9900 reads every destination before writing it (../tms9900-python docs/cpu.md), so a MOVB to a device's write port first reads that address. TI gives the devices separate read and write addresses for exactly this reason: their address registers auto-increment on any access [CTD B.1.2.1]. MAME's bus census shows the effect (OBSERVED): at the title screen 3,322 reads in the GROM *write* block for 3,322 writes there (`tests/detectors/mame-bus-census-2026-11-26.txt`). ## CRU map [CTD A.4, B.1.3; HCTD IV] | CRU address (R12) | Bits | Use | | --- | --- | --- | | 0000-003E | 0-31 | the TMS9901 (keyboard, joysticks, cassette, interrupts, timer: tms9901-keyboard.md) | | 0040-07FE | | console, mirrors of the 9901 (the decode uses A10-A14 for the 9901's select lines: U5) | | 0800-0FFE | | reserved ("for test equipment use on production line" in [CTD]'s CRU map) | | 1000-1FFE | | peripherals, 128 bits (>100 of address) per card; the card's base bit pages its DSR ROM into 4000-5FFF | Peripheral assignments: 1100 disk controller, 1200 modems, 1300 RS232 (primary), 1500 RS232 (secondary), 1700 HEX-BUS, 1800 thermal printer, 1C00 video controller, 1D00 IEEE 488, 1F00 p-code card [CTD A.4]. [HCTD] differs in four rows: 1000 hard disk controller (vs unassigned), 1900 unassigned (vs EPROM programmer), 1B00 debugger (vs unassigned), 1C00 VCR controller (vs video controller): C3, harmless for emulation. The console polls the I/O port on power-up or a software restart, CRU 1000 to 1F00 in steps of 100, looking for a DSR ROM header (>AA at 4000) [CTD B.1.4]. MAME's bus census shows 16 reads in the DSR space in the first two seconds (OBSERVED), one per card base. **Forbidden instructions.** CRUCLK is not decoded with A0-A2, so the TMS9900's external instructions (LREX, CKOF, CKON, RSET, IDLE) look like CRU writes to the console's devices: "DO NOT USE THESE INSTRUCTIONS" [CTD B.1.3.1]. The board must model what such a write does (the code on A0-A2 with A3-A14 as left by the CPU) rather than ignore it: U6. ## Interrupts [CTD A.5; HCTD IV] - Only CPU level 1 is used, wired from the TMS9901; LOAD comes from the I/O port; RESET from the power-up circuit, held at least 5 clocks [CTD A.2]. - Level 1 is "decoded by software to be either (1) VDP vertical sync, (2) 9901 internal timer or (3) I/O bus-generated" [CTD A.5]: the 9901 inputs are INT1 external (I/O port EXT INT), INT2 the VDP's interrupt, INT3 the 9901 timer (tms9901-keyboard.md). - The console's interrupt routine services the VDP and the timer and then calls every peripheral's interrupt routine it can find in the DSR headers [CTD D.4.4]. ## The I/O port (side port) [CTD A.2; HCTD II] 44 pins: A0-A15 (A15 doubles as CRUOUT), D0-D7, MEMEN, DBIN, WE, MBE (4000-5FFF), CRUCLK, CRUIN, READY (READY/HOLD in [HCTD]'s edition), IAQ (HOLDA in [HCTD]'s), LOAD, RESET, EXT INT, φ3, SBE (speech block enable, 9000-97FF), AUDIO IN (speech), +5 and -5 for the speech module. It is the socket every PEB card, the speech synthesizer and the sidecar devices plug into (handoff brief, sockets).