# Memory, the PLA and banking ## The PLA (U17, 906114-01) A Signetics 82S100-type field-programmable logic array (later boards: Commodore's own parts with the same logic) decodes every access of both bus masters. Its inputs: #CAS from the VIC, LORAM/HIRAM/CHAREN from the 6510 port, A15-A12 (from the CPU or the VIC depending on AEC), VA13/VA12 for VIC accesses, BA, AEC, R/W, and EXROM/GAME from the cartridge port. Its outputs: #CASRAM, #BASIC, #KERNAL, #CHAROM, GR/#W (colour RAM write), #I/O, #ROML, #ROMH (DOC/DIE: PLA sections 2.4-2.7, from schematic 251138). - **Evidence:** PLA (Giesel 2012, CC BY-SA 3.0) contains the full logic table read out of real PLAs, the original equations, measured timings, and a CSG PLA **opened, photographed and reverse engineered down to the transistor level** (its chapter 4): tier 1 for the logic. PLA94 (Mäkelä, 1994) has the equations from Jens Schönfeld's 1994 read-out of real chips. MAME's set carries a 245-byte `906114-01.u17` file (SHA-1 efb315f5..., census.md): a third, independent form of the same table (closed box: identified, not opened). - **Revisions:** "REV3 8411" is the logic in every PLA read out; an earlier "REV2 7E17" is "said to have a different logic" and no dump exists (PLA 2.3): U2. - **Specification shape:** the board's decoder is the logic table itself, one function of the inputs evaluated per half-cycle (phase 1 for the VIC, phase 2 for the CPU or the VIC when AEC is low), not a hand-made memory map. Unit tests: every row of PLA's appendix A ("C64 Memory Configurations Explained") and PRG ch. 5's banking table. - **Propagation delays and the "PLA timing" effects** (a replacement PLA that is too slow breaks some cartridges and fast loaders: PLA ch. 3, 6) are electrical; the board models logic only. Recorded as a concession candidate only if a test needs it. ## The CPU's view (5 bits: LORAM, HIRAM, CHAREN, GAME, EXROM) 32 configurations (PRG ch. 5, "Memory management on the Commodore 64"; PLA appendix A; VIC 2.4.1). The common ones: $A000-$BFFF BASIC when LORAM and HIRAM are both high; $E000-$FFFF KERNAL when HIRAM is high; $D000-$DFFF I/O when CHAREN is high and either LORAM or HIRAM is high, the character ROM when CHAREN is low (and LORAM or HIRAM high), RAM when both are low. Writes to a ROM area go to the RAM underneath. The cartridge lines add the 8K ($8000 ROML), 16K (ROML + ROMH at $A000) and **Ultimax** modes (GAME low, EXROM high: ROML at $8000, ROMH at $E000, $1000-$7FFF and $A000-$CFFF unmapped, the VIC sees ROMH; PRG ch. 5, PLA appendix A, VIC 2.4.1). ## The I/O area ($D000-$DFFF when mapped) | Range | Device | Mirrors | | --- | --- | --- | | $D000-$D3FF | VIC-II: 47 registers ($00-$2E), repeated every 64 bytes; $2F-$3F read $FF | VIC 3.2 | | $D400-$D7FF | SID: 29 registers, repeated every 32 bytes | PRG appendix O; SID | | $D800-$DBFF | colour RAM, 1K x 4 bits; the upper nybble of a read is the floating bus | VIC 2.3, section 4 | | $DC00-$DCFF | CIA 1 (keyboard, joysticks, paddles' select, IRQ), 16 registers repeated | PRG appendix M | | $DD00-$DDFF | CIA 2 (serial bus, user port, VIC bank bits, NMI) | PRG appendix M | | $DE00-$DEFF | I/O 1 (cartridge port #IO1) | | | $DF00-$DFFF | I/O 2 (cartridge port #IO2) | | The VICE test harness's debug-cartridge register $D7FF lives in the SID mirror area; the board offers it only behind a test switch ([validation.md](validation.md)). ## The VIC's view The VIC addresses 16K; CIA 2 port A bits 0-1 (inverted) choose which 16K bank (VIC 2.4.2, PRG ch. 3/5). In banks 0 and 2 the PLA shows the **character ROM** to the VIC at $1000-$1FFF of the bank ($1000 and $9000 absolute), wherever the CPU's banking stands. In Ultimax mode the VIC sees ROMH in the top 4K of every bank. The VIC also reads the 4 bits of colour RAM on its upper data lines, for every c-access, through the 12-bit data bus (VIC 2.3). ## Open bus - **What the CPU reads from unmapped space** (I/O 1 and 2 without a cartridge, the colour RAM's upper nybble, the Ultimax holes): on some machines the byte the VIC read in the preceding phase 1, "not reproducible on all machines and not always reliable" (VIC section 4). VICE tests `C64/openio` (interactive) and several `VICII` timing tests use it. Proposal: the board's open-bus value is the VIC's last phase-1 byte (a model consistent with VIC section 4), marked FITTED, with a row switch for "random" if a test or game shows otherwise. - **Writes to $00/$01** put the VIC's phase-1 byte into RAM ([cpu-6510.md](cpu-6510.md)). ## RAM 64K of DRAM (eight 4164 or two 41464 depending on board: SM). **Power-on contents** matter: "a surprising number of programs (probably not deliberately) depend on the 'correct' RAM init pattern", which depends on the RAM type and board (VICE `C64/raminitpattern` readme, with a procedure for reading it on a real machine; tier 3 where results were taken that way). The test list's entries are `cyberloadtest`, `platoontest`, `darkstarbbstest`, `typicaltest`, `pattern00ff`). Proposal: a row-level initial pattern (the "typical" one from that test as the default, FITTED), with alternatives selectable. The colour RAM is a 2114 static RAM, U6 (SM parts list: "2114L-20 RAM"; a 2114 is 1K x 4: 4,096 bits, which SM's prose counts as "512 bytes of memory"; the VIC and CPU see 1,024 four-bit cells). Its power-on contents are undefined (U3).