# Architecture: modelling levels, domains and channels, evidence tags The charter asks every specification to state how deep each component is modelled (axis B), which clock domains the machine has and the channels between them, and to tag the evidence behind every constant, rule and quirk. This is that statement for the 7800 board; the detail of each behaviour is in [timing.md](timing.md), [start-here.md](start-here.md) and the module docstrings. ## Modelling level per component | Component | Where | Level | Notes | | --- | --- | --- | --- | | SALLY (NMOS 6502 with HALT) | 6502-python `741419a` (pinned) | cycle | one bus callback per CPU cycle, dummy cycles included; HALT and RDY are board logic around the callbacks (timing.md "SALLY's HALT") | | Board: decoders, INPTCTRL, slow cycle, floating bus | `board.py` | cycle, timed per MARIA clock | each CPU cycle is 4 or 6 MARIA clocks; HALT and RDY hold the CPU in whole 4-clock periods | | MARIA | `maria.py` | cycle (per MARIA clock) | DMA engine stepped per clock by the bytes it reads; line RAM per cell; pixels per clock. Not signal level: there is no die or netlist, only GCC's gate-level diagrams ([GLD]), read for counters, decodes and the DLI latch | | TIA | a2600-python `28fb095` (pinned; the rebuilt project, restarted 2026-11-14) | signal level in a2600-python (its half-clock latches, judged by 39 Sim2600 die traces, replayed here into the TIA as `board.py` makes it); the 7800 board steps it one half colour clock per MARIA clock | revision fields from the 2600-mode row (`PAL_7800`: the #699 revision; `NTSC_7800`: the reference 10444D, unmeasured) | | RIOT (6532) | a2600-python `28fb095` (pinned) | cycle | its timer counts Φ2 periods, HALT periods included (C12, U10); the controllers read its port registers through its listed read-only names (`input_a`, `ddr_b`, `out_b`) and drive pins only through `set_input_a` | | Cartridge POKEY | pokey-python `6ed1ffa` (pinned; the core restarted 2026-11-14) | cycle (per Φ2 period) | its docs/adoption.md: the access, then one `tick()` per period, stretched and DMA periods included (C22); `mix()` feeds the sound mix; /IRQ, pots and keyboard lines not wired | | Cartridges and schemes | `cartridge/` | cycle (bus transaction per CPU cycle) | every cartridge sees every bus cycle and decodes for itself; DMA reads arrive with `halt` true | | Controllers | `controllers.py` | functional at the port pins | joystick and two-button wiring read from the ports each access; the light gun, paddles and trak-ball are fits (U22, U24, U25) | | Sound mix | `sound.py` | functional | the TIA and POKEY streams are the chips' own; their weighted sum is a fit (U15); the POKEY is read at each TIA sample through a2600-python's `Audio.on_sample` hook | | BIOS | the player's image, by hash | not modelled | real firmware run on SALLY; nothing about it is reimplemented | | 2600 mode | `mode2600.py` | as a2600-python's board | after the hand-off the 7800's SALLY, TIA and RIOT run on a2600-python's board and system (`System(row, board=Board(row, cartridge, tia=, riot=, cycles=), cpu=SALLY)`, its docs/api.md: the CPU adopted as it stands, not powered on); `System2600` is a subclass of that `System`; the cartridge is a2600-python's, on the 7800 connector through `Cart2600` until then, loaded with the row's `cpu_hz` (DPC's oscillator) | | Television, frontend | `television.py`, `frontend.py` | host side | crop, PNG, palettes and the composite option shape what is shown; they define no machine behaviour | Profile in one line: *SALLY, MARIA, RIOT and POKEY at cycle level and the TIA at a2600-python's signal level, on one MARIA-clock timeline; controllers and the audio mix functional; nothing of this board's own at signal level.* ## Domains and channels **One domain.** The whole console runs from one crystal: MARIA divides it to its own clock (crystal / 2) and from that clocks the CPU (divide by 4, or 6 on slow cycles), the TIA (one half colour clock per MARIA clock) and, through Φ2, the RIOT and the cartridge. `board.py` advances everything one MARIA clock at a time inside each CPU bus callback: that serial order is the order of record, and a Rust transcription keeps it. Channels between the parts, all explicit in the code: | Channel | From → to | In the code | | --- | --- | --- | | HALT line | MARIA → CPU clock | `maria.halt`; the board holds the CPU in whole Φ2 periods and sets `maria.granted` (gated by INPTCTRL after two writes) | | RDY line (wire-AND) | MARIA's WSYNC latch and the TIA's WSYNC → CPU | `maria.rdy_low`, `tia.rdy_low`; reads repeat in 4-clock periods | | NMI line (DLI) | MARIA → CPU | `maria.nmi`, passed one cycle after HALT's release (`board.nmi_after`) | | IRQ line | cartridge → CPU | `cartridge.irq` (a cartridge POKEY's `chip.irq` is not wired to it: no licensed dump is known to connect it) | | The shared bus | CPU and MARIA's DMA → memory, devices, cartridge | MARIA reads through the `read` callable the board hands it (MARIA imports nothing from the board, `tests/test_boundary.py`); `data_bus` is the floating latch | | INPTCTRL latch | CPU writes → decoders, MARIA enable, BIOS/cartridge select, HALT gate | `board.inptctrl` | | Ports | controllers ↔ RIOT port A/B and TIA inputs | `controllers.py` | | Φ2 | board → RIOT pulse count, cartridge `tick()` | once per 4- or 6-clock period, HALT periods included | | Line output | MARIA → host | `maria.on_line(line, pixels, colour_kill)` | No part pokes another's state outside these. Two places to watch in a transcription: `mode2600.py`'s hand-off passes the CPU, TIA and RIOT objects and the data-bus latch to a2600-python's system and board (a one-time transfer of ownership, not a running channel); before it, `Cart2600` delivers a2600-python's `snoop` from the 7800 board's data-bus latch at each read's period end (the connector's data lines, for FE); and `sound.py` samples the POKEY's level at the TIA's sample instants (a host-side read of two streams, not a machine channel). ## Evidence tags in `src/` Every constant, rule and quirk carries one of the methodology's tags. How they are used here: - **DOC**: GCC's gate-level diagrams [GLD] (schematic-read), [MT84], [1702B], [SG], the console schematics, the 7800 wiki (Stolberg's guide, the A78 header specification, the interfacing guide). Console measurements other people report in prose ([HF], [SG] App. 3) are DOC with "reported console measurement": this project has no console of its own. - **MEASURED**: none. No capture of a 7800 exists here (U1 lists the captures that would be the first). - **DIE**: only the TIA, inherited from a2600-python's Sim2600 judge. - **TEST ROM**: a test program whose verdicts were captured on consoles, named. - **OBSERVED**: another implementation's behaviour, named: MAME 0.285, ProSystem, A7800 5.2 (closed boxes), and k7800 [MiS] (an FPGA core, read under MIT). Power-on values matched to MAME's trace are OBSERVED. - **FITTED**: chosen to pass named judges (the sound mix, light gun, palettes' phase and saturation, paddles, trak-ball), with what else was tried. - **HYPOTHESIS**: a choice with no direct evidence, with the experiment that would settle it (the U table in [undocumented-behavior.md](undocumented-behavior.md) names most of them). - Values that are not hardware claims (buffer sizes, instrumentation, detector settings such as `c23-mame`) say so instead of carrying a tag.