// tia-fpga — pin constraints for the Sipeed Tang Nano 9K (GW1NR-LV9QN88PC6/I5) // // Copyright 2026 Leonardo Roman da Rosa // SPDX-License-Identifier: CERN-OHL-S-2.0 // Source location: https://github.com/lrrosa/tia-fpga // // Pin numbers verified against BOTH revisions of the official Sipeed board // schematic — Tang_Nano_9k_3672 and Tang_nano_9K_3674 — which agree exactly. // Signal names match the net labels in tia-fpga.kicad_sch (FPGA side). // // WHICH signal sits on WHICH header position is solved, not listed. Each FPGA // pin is put as close as it can be to the pad its net really reaches on the // board -- the buffer or gate between it and the TIA socket, not the socket pin // beyond it -- over all 29 signals at once (a Hungarian assignment). F_OSC is // held to J6/1, the right PLL's own input. Do not reshuffle these casually: the // layout depends on them. // // Which board socket is which module row is fixed by the module itself. Seen // from above with the USB-C end on the left, J6 is the row nearer the top and // J5 the row nearer the bottom, so on this board J6 goes to J1, beside the // TIA's pins 1-20, and J5 to J4. The rows are 22.86 mm apart (Sipeed's own // dimension drawing); pin 1 of each is at the USB-C end. // // Still check these against the silkscreen on your own board before powering up // with a 5 V 6507 on the other side of the bus. // // =========================================================================== // HEADER MAP (Sipeed J5 / J6, 24 pins each) // =========================================================================== // J5 hdr FPGA IO name module function J6 hdr FPGA IO name function // 1 38 IOB31B TF_CS 1 63 IOR5A RGBINIT // 2 37 IOB31A TF_MOSI 2 86 IOT8A 1.8 V ! // 3 36 IOB29B TF_SCLK 3 85 IOT8B 1.8 V ! // 4 39 IOB33A TF_MISO 4 84 IOT10A 1.8 V ! // 5 25 IOB8A free 5 83 IOT10B 1.8 V ! // 6 26 IOB8B free 6 82 IOT11A 1.8 V ! // 7 27 IOB11A free 7 81 IOT11B 1.8 V ! // 8 28 IOB11B free 8 80 IOT12A 1.8 V ! // 9 29 IOB13A free 9 79 IOT12B 1.8 V ! // 10 30 IOB13B free 10 77 IOT37A SPILCD_MO // 11 33 IOB23A RGB_DE 11 76 IOT37B SPILCD_MCLK // 12 34 IOB23B RGB_VS 12-17 -- -- HDMI pairs // 13 40 IOB33B RGB_HS 18 -- -- +5V // 14 35 IOB29A RGB_CK 19 48 IOR24B SPILCD_CS // 15 41 IOB41A RGB_B7 20 49 IOR24A SPILCD_RS // 16 42 IOB41B RGB_B6 21 31 IOB15A RGBINIT // 17 51 IOR17B RGB_B5 22 32 IOB15B RGBINIT // 18 53 IOR15B RGB_B4 23 -- -- GND // 19 54 IOR15A RGB_B3 24 -- -- +3V3 // 20 55 IOR14B RGB_G7 // 21 56 IOR14A RGB_G6 // 22 57 IOR13A RGB_G5 // 23,24 -- -- HDMI_CK_N / HDMI_CK_P // // USABLE 3.3 V GPIO: 22 (J5/1-22) + 7 (J6/1,10,11,19,20,21,22) = 29. // J6/2-9 are BANK3 at 1.8 V and CANNOT carry 3.3 V signalling. // "module function" is what the Tang Nano itself wires there; those are free to // reuse as long as you do not fit the SD card, the RGB LCD or the SPI LCD. HDMI // pins are differential pairs, not GPIO. // // ASSIGNMENT // J5/1 F_PHI0 J5/7 F_BLK J5/13 F_A2 J5/19 F_D3 J6/1 F_OSC // J5/2 F_CS_N J5/8 F_I4 J5/14 F_A4 J5/20 F_D5 J6/10 F_COL // J5/3 F_RDY J5/9 F_I5 J5/15 F_RW J5/21 F_D7 J6/11 F_LUM0 // J5/4 F_CSYNC J5/10 F_A3 J5/16 F_D1 J5/22 F_D6 J6/19 F_AU1 // J5/5 F_LUM1 J5/11 F_A0 J5/17 F_D0 J6/20 F_AU0 // J5/6 F_LUM2 J5/12 F_A1 J5/18 F_D2 J6/21 F_A5 // J6/22 F_D4 // // All 29 are used. BLK has a pin because the FPGA reads /CS0 OR /CS3 from U5, // which makes it for the 245's /OE anyway, instead of the two selects apart. // The four paddles still do not fit; see the README. // =========================================================================== // ---------------------------------------------------------------- clock // 3.579545 MHz from the 2600's crystal, via U4 (74LVC541A). // Do NOT use the board's 27 MHz oscillator: 27 MHz cannot produce exactly // 3.579545 MHz, and the NTSC subcarrier has to be exact. // // Pin 63 is RPLL_T_in, the input the right-hand PLL takes directly. No global // clock pin is on the headers -- the only one, pin 52 (XTAL_IN), is not brought // out. It goes straight into the rPLL in fpga/tia_fpga_top.v, which multiplies // it into the core's clock; nothing in the design samples it directly. IO_LOC "F_OSC" 63; IO_PORT "F_OSC" IO_TYPE=LVCMOS33; // ---------------------------------------------------------------- data bus // Bidirectional through U2 (74LVC245A), A side = FPGA. IO_LOC "F_D0" 51; IO_LOC "F_D1" 42; IO_LOC "F_D2" 53; IO_LOC "F_D3" 54; IO_LOC "F_D4" 32; IO_LOC "F_D5" 55; IO_LOC "F_D6" 57; IO_LOC "F_D7" 56; IO_PORT "F_D0" IO_TYPE=LVCMOS33; IO_PORT "F_D1" IO_TYPE=LVCMOS33; IO_PORT "F_D2" IO_TYPE=LVCMOS33; IO_PORT "F_D3" IO_TYPE=LVCMOS33; IO_PORT "F_D4" IO_TYPE=LVCMOS33; IO_PORT "F_D5" IO_TYPE=LVCMOS33; IO_PORT "F_D6" IO_TYPE=LVCMOS33; IO_PORT "F_D7" IO_TYPE=LVCMOS33; // The 245's DIR and /OE are NOT driven by the FPGA: DIR comes straight from the // buffered R/W, and /OE from U5 (/CS0 OR /CS3). // ---------------------------------------------------------------- address and select IO_LOC "F_A0" 33; IO_LOC "F_A1" 34; IO_LOC "F_A2" 40; IO_LOC "F_A3" 30; IO_LOC "F_A4" 35; IO_LOC "F_A5" 31; IO_PORT "F_A0" IO_TYPE=LVCMOS33; IO_PORT "F_A1" IO_TYPE=LVCMOS33; IO_PORT "F_A2" IO_TYPE=LVCMOS33; IO_PORT "F_A3" IO_TYPE=LVCMOS33; IO_PORT "F_A4" IO_TYPE=LVCMOS33; IO_PORT "F_A5" IO_TYPE=LVCMOS33; // /CS0 OR /CS3 -- A12 and A7 on the 2600 -- the same net as the 245's /OE. // The TIA is selected only when both are low, so the FPGA never needs them apart. IO_LOC "F_CS_N" 37; IO_PORT "F_CS_N" IO_TYPE=LVCMOS33; // ---------------------------------------------------------------- 6507 handshake // F_PHI0 leaves through U1 (74AHCT125 at 5 V) — it is the CPU clock, OSC/3. // F_RDY also goes through U1; this is what WSYNC uses to stall the CPU. IO_LOC "F_PHI0" 38; IO_LOC "F_RW" 41; IO_LOC "F_RDY" 36; IO_PORT "F_PHI0" IO_TYPE=LVCMOS33 DRIVE=8; IO_PORT "F_RW" IO_TYPE=LVCMOS33; IO_PORT "F_RDY" IO_TYPE=LVCMOS33 DRIVE=8; // ---------------------------------------------------------------- video // On the die every one of these -- sync, luma, chroma, BLK and both sound pads // -- is a pull-down transistor and nothing more, and the console supplies the // pull-ups. Each pin here drives one input of U6-U9 (74LVC2G07, open-drain // outputs, 5 V tolerant), and that output is the TIA socket pin: 0 pulls the // line low, 1 leaves it to the console's pull-up. See "Pads and levels" in the // README. IO_LOC "F_CSYNC" 39; IO_LOC "F_BLK" 27; IO_LOC "F_LUM0" 76; IO_LOC "F_LUM1" 25; IO_LOC "F_LUM2" 26; IO_PORT "F_CSYNC" IO_TYPE=LVCMOS33; IO_PORT "F_BLK" IO_TYPE=LVCMOS33; IO_PORT "F_LUM0" IO_TYPE=LVCMOS33; IO_PORT "F_LUM1" IO_TYPE=LVCMOS33; IO_PORT "F_LUM2" IO_TYPE=LVCMOS33; // Chroma. This pin used to be PHI2. The trade is deliberate: the FPGA generates // PHI0 itself, so it knows where it is in the bus cycle and can time accesses // from its own clock instead of the 6507's output. That costs a little timing // fidelity and buys back the pin that makes RF and composite video work - which // is what you want if you are reviving a console with a dead TIA and keeping // its original video path. // // PHI2 is still buffered by U3 and its output is brought to an unconnected pad, // so a later board that recovers pins from the 1.8 V bank can wire it back. IO_LOC "F_COL" 77; IO_PORT "F_COL" IO_TYPE=LVCMOS33; // ---------------------------------------------------------------- audio // An unmodified 2600 joins these two pins with a trace, so by default both // carry the same pulse-width mix of the two channels (AUDIO_STEREO in // rtl/tia_board.v). IO_LOC "F_AU0" 49; IO_LOC "F_AU1" 48; IO_PORT "F_AU0" IO_TYPE=LVCMOS33; IO_PORT "F_AU1" IO_TYPE=LVCMOS33; // ---------------------------------------------------------------- controllers // Joystick triggers, via U4. Pulled up, as on the 2600. IO_LOC "F_I4" 28; IO_LOC "F_I5" 29; IO_PORT "F_I4" IO_TYPE=LVCMOS33 PULL_MODE=UP; IO_PORT "F_I5" IO_TYPE=LVCMOS33 PULL_MODE=UP; // Paddles (TIA pins 37-40) need an external comparator plus a discharge switch: // the TIA grounds the capacitor when VBLANK bit 7 is set, then detects the // threshold crossing. No pins left for them on this board either. // IO_LOC "F_PADDLE_DUMP" ; // IO_LOC "F_PADDLE_CMP" ;