# The ULA (HCS10017) The Oric's gate array: it divides the 12 MHz crystal into the CPU clock, drives the DRAMs, decodes ROM and page-3 I/O, and draws the screen from **serial attributes**: control bytes in the screen data that change ink, paper, character set, height, blink and mode for the rest of the line (or the frame). This chip has a **die-level source**: Mike Connors (Datel) generated a transistor netlist from a die photograph; Mike Brown (signal11) corrected and annotated it; Erik Persson completed it, extracted RTL automatically and wrote equivalent hand-written RTL, checked against the extraction by testbench (`erik-persson/oric-ula`, MIT, pinned at `1c23a3b`; its README records both Mikes' permission). Citations: **ULA-RTL** (`design/oric_ula.v`, the hand-written RTL, by line), **ULA-NET** (`netlist/006_mjb_sorted.v` and `008_ep_extracted.v`), **OSM** (the service manual), **OFF** (Fabrice Francès's "Hardware Programming on the Oric"), **MAME** (OBSERVED). The RTL is read for facts and cited as DIE; it is MIT, so quoting it with the notice would be allowed, but the board writes its own Python from the facts. ## Clocks and the bus (DIE) | Fact | Source | | --- | --- | | A 4-bit counter runs 0-11 on the 12 MHz clock: one CPU cycle is 12 clocks = 1 MHz | ULA-RTL 116; OSM p. 15 (12 MHz crystal) | | PHI (the CPU clock) is counter bit 3: high for counts 8-11, so phase 2 is 4 clocks (333 ns) of the 12 | ULA-RTL 180 | | Counts 0-7 belong to the ULA: two video fetches per microsecond (the screen byte, then the character pattern), the address multiplexed onto the DRAM | ULA-RTL 153-155 | | The CPU's write enable is gated by PHI | ULA-RTL 183 | | ROM selected on a read at $C000-$FFFF unless MAP is asserted; I/O for the whole of page 3 ($0300-$03FF) | ULA-RTL 185-186; OSM pp. 13-14 | | **The CPU is never stalled**: video and CPU accesses interleave inside every microsecond | follows from the above | The OSM agrees: "XT1 provides a 12 MHz clock for the ULA (IC7), from which all synchronisation and phasing signals are derived". MAME: 6502 @ 1.00 MHz, screen pixel clock 6 MHz, 384 x 312 total, 50.080128 Hz (`-listxml`), i.e. 64 us lines. ## Raster (DIE) | Fact | Source | | --- | --- | | Horizontal: a 6-bit counter of microseconds, 64 a line; 40 active (counts 0-39), 6 pixels each = 240 pixels | ULA-RTL 101, 117, 218 | | Vertical: **312 lines (50 Hz) or 264 lines (60 Hz)**, chosen by the mode bit | ULA-RTL 105 | | Vertical sync on lines 256-259 (50 Hz) or 236-239 (60 Hz) | ULA-RTL 106 (vcnt[8:2] = 64 or 59) | | 224 active lines | ULA-RTL 219; OFF ("224 lines of 240 pixels") | | A 5-bit frame counter; **blink uses its bit 4**: 16 frames on, 16 off | ULA-RTL 36, 122, 266 | Arithmetic: 312 x 64 us = 19.968 ms = 50.08 Hz; 264 x 64 us = 16.896 ms = 59.19 Hz. ## Addresses (DIE) - **Screen byte**: $A000 + row x 40 + column, where row = the line number on a hires line (line < 200 and hires mode), else $B0 + line/8. So text rows start at $BB80 ($A000 + $B0 x 40), and in hires mode the last 24 lines (3 text rows) come from $BF68, as OFF says (ULA-RTL 129-142). An overflow past $BFFF on the last row's last 8 columns, off screen, is handled (ULA-RTL 133-135). - **Character pattern**: $B400 (text mode) or $9800 (hires mode), + $400 for the alternate set, + code x 8 + line within the cell (line/2 when double height) (ULA-RTL 146-151). - Hires: the low 6 bits of a byte are 6 pixels; bit 7 inverts the byte's colours; a byte with bits 6-5 = 00 is an attribute (ULA-RTL 197; OFF). ## Serial attributes (DIE, with OFF's table agreeing) A byte whose bits 6-5 are 00 is decoded by bits 6-3 (ULA-RTL 222-226): | Bits 6-3 | Codes | Effect | Reset at each line's sync? | | --- | --- | --- | --- | | 0000 | 0-7 | ink = bits 2-0 | yes, to 7 (white) | | 0001 | 8-15 | bit 0 alternate set, bit 1 double height, bit 2 blink | yes, to off | | 0010 | 16-23 | paper = bits 2-0 | yes, to 0 (black) | | 0011 | 24-31 | bit 2 = 0: text, 1: hires; bit 1 = 0: **60 Hz**, 1: 50 Hz | **no**: mode persists across lines and frames | The attribute's own cell shows paper (the shift register is not loaded for it), inverted by its bit 7 like any byte (ULA-RTL 197, 239). The ink/paper/attribute reset happens at horizontal sync (ULA-RTL 231-236). The 60 Hz switch per row is real hardware behaviour (an open issue in another emulator, emu198x #341, says so too; tier 5). **Conflict C1:** MAME's `-listxml` reports a fixed vtotal of 312; whether MAME switches to 264 lines on a 60 Hz attribute is not visible from its XML (run a test at M3). ## Video output RGB, one bit each (8 colours), plus composite sync; a PAL encoder on the board (IC23 ROM with a resistor ladder, IC24/IC25 sample clocks in phase quadrature from XT2 4.43 MHz) makes the colour signal (OSM pp. 19-20). That encoder ROM is board firmware: a front-end BIOS pack here holds a 'colour.rom' (SHA-1 `bda81f64be319d8793d284bf9d40f01d19b33515`) whose identity with IC23 is unverified (U4). The board outputs RGB indices; the encoder is a host concern unless composite artefacts are wanted. ## Oracles | Oracle | Tier | Decides | Cannot decide | | --- | --- | --- | --- | | erik-persson/oric-ula netlists and RTL | 1 (die-derived) | every counter, address, decode, attribute and timing inside the ULA | analogue output; whatever the netlist got wrong (its README asks whether CLK's polarity is right: U1) | | OSM | 2 | the board around the ULA | the ULA's internals | | OFF | 3 | software-visible behaviour, as its author measured for Euphoric | | | OCULA (sodiumlb, BSD-3-Clause) | 4 | a working replacement in real Orics: a detector | | | MAME 0.285 | 5 | boot lockstep, snapshots | 60 Hz mode (C1) | The board's ULA can be **judged against the netlist itself**: an iverilog run of `008_ep_extracted.v` (two-phase latch RTL, "can be simulated using a plain digital simulator such as iverilog") over a memory image gives the RGB/sync stream, address and PHI per 12 MHz clock. That is the tier-1 referee for M2 (iverilog is a tool; the netlist is MIT; it can live in this repository's `validation/` or in emu-tools: decision 4). Neither iverilog, Verilator nor Yosys is installed on this machine (checked 2026-11-26; no sudo), so the referee was not run tonight. ## Chip rule The HCS10017 is used by the Oric-1, Atmos and their clones (Pravetz 8D) only: board (`ula.py`). The Telestrat's second ULA (with the Microdisc logic) is a later row's concern.