

12-bit single-board discrete transistor computer
- Size
- 198 × 278 mm
- Copper layers
- 2
- Thickness
- 1.6 mm
- Parts
- 1,660
- Nets
- 989
- Pads
- 4,604
- Tracks, vias
- 12,552, 2,528
- Pours
- 2
- Routed
- Yes
- KiCad
- KiCad 7 (file 20221018)
- Created
- 13 Sep 2020
- Updated
- 15 Dec 2024
Overview
Q2 is an open-source printed circuit board by joewing, from the joewing/q2 repository on GitHub. It is a 2-layer board of 198 × 278 mm with 1,660 parts on 989 nets, routed with 12,552 tracks and 2,528 vias.
It is built around the 2N7002K and BAT43W. Its parts include 1,016 transistors, 463 resistors, 96 diodes, 44 capacitors and 23 switches.
Main components
2README
README.mdQ2
A home-brew 12-bit mini-computer.
__ __
/\ \ /\ \ 000 | LDA | Z | A = [X]
/ \ \ / \ \ 001 | NOR | Z | A = A NOR [X]
/ /\ \ \ / /\ \ \ 010 | ADD | C | A = A + [X]
/ / /\ \ \\/_/\ \ \ 011 | SHR | C | A = [X] >> 1
/ / / \ \_\ / / / 100 | LEA | - | A = X
/ / / __/ / / / / / 101 | STA | - | [X] = A
/ / / /\ \/ / / / / __ 110 | JMP | - | P = X
/ / /__\ \ \/ / / /_/\_\ 111 | JFC | - | if !F: P = X
/ / /____\ \ \ / /_____/ / |
\/________\_\/ \________/ OOO D Z XXXXXXX - Operand
joewing.net \ \_________ Zero Page
\__________ DereferenceThere are currently two hardware implementations of the Q2 instruction set:
- Q2 - The bit-serial single-board discrete transistor implementation.
- Q2A - A faster, parallel implementation using ATF16V8 PLDs.
Compared to the DEC PDP-8, the original Q2 would be like the PDP-8/S and the Q2A would be like the PDP-8/I.
This repo contains the following subdirectories:
- hardware - Hardware realizations.
- q2 - The original discrete transistor Q2.
- hdl - A Verilog model and test bench for simulating Q2 programs.
- scad - An OpenSCAD 3d model for the case.
- pcb - Schematics and PCB in KiCad
- q2a - Programmable logic device implementation
- pld - PLD files for programming the ATF16V8s and Verilog test bench
- scad - An OpenSCAD 3d model for the case.
- pcb - Schematics and PCB in KiCad
- q2 - The original discrete transistor Q2.
- q2asm - A Q2 assembler (in Rust).
- q2lc - A compiler for a simple language (in Rust).
- q2prog - A Q2 programmer (in Rust) for a Raspberry Pi (this is for the Q2 only; the Q2A requires an EEPROM programmer).
- examples - Q2 example programs (assembly and Q2L).
See joewing.net/projects/q2 for more information.
q2lc
q2lc is a compiler for Q2 programs. It is built using 'cargo build' in the q2lc directory.
The Makefile will take care of compiling and assembling Q2L programs in the examples directory automatically:
make examples/sieve.lstThis will compile sieve.q2l into sieve.q2 and then assemble sieve.q2 using q2asm to generate sieve.lst along with sieve.q2p.
q2asm
q2asm is the assembler for Q2 programs. It is built using 'cargo build' in the q2asm directory.
The Makefile will take care of assembling programs in the examples directory automatically:
make examples/hello.lstThis will generate the listing file for examples/hello.q2 as examples/hello.lst.
Instruction Set
All instructions are 1 word with the following format:
FFF D Z XXXXXXX
\ \ \ \____ Operand
\ \ \________ Zero-Page
\ \_________ Dereference
\___________ OpcodeInstruction summary:
| Opcode | Name | F | Description |
|---|---|---|---|
| 000 | LDA | Z | A = [X] |
| 001 | NOR | Z | A = A NOR [X] |
| 010 | ADD | C | A = A + [X] |
| 011 | SHR | C | A = [X] >> 1 |
| 100 | LEA | - | A = X |
| 101 | STA | - | [X] = A |
| 110 | JMP | - | P = X |
| 111 | JFC | - | if !F, P = X |
The flag is set if carry ('C'), zero ('Z'), or left unchanged ('-').
The following address modes are supported:
| Value | DZ | Meaning |
|---|---|---|
| x | 00 | current-page relative |
| @x | 10 | indirect through current page |
| =x | 01 | zero-page relative |
| @=x | 11 | indirect through zero page |
For convenience, the assembler also supports two additional address modes:
| Value | DZ | Meaning |
|---|---|---|
| #x | 00 | immediate |
| #@x | 10 | immediate indirect |
These cause an extra word to be allocated at the end of the current page for an immediate value.
Examples
; Negate: A = -A
nor #0
add #1; Subtract: A - v
nor #0
add v ; A = v - A - 1
nor #0 ; A = A - v; Decrement A
add #-1; NOT: A = ~A
nor #0; OR: A = A | v
nor v
nor #0; AND: A = A & v
nor #0
sta =t0 ; t0 = ~A
lda v
nor #0 ; A = ~v
nor =t0 ; A = ~(~A | ~v) = A & v; Jump if F set
jfc $+2
jmp label; Jump if a >= b
lda a
nor #0
add b
jfc ge; Jump if a != b
lda a
nor #0
add b
nor #0
jfc ne; Function call:
lea $+2 ; A = return address
jmp func
;...
func:
sta =ra ; Save return address
; ...
jmp @=ra ; Return; Long jump
jmp @#addr; Long call
lea $+2
jmp @#addr; Rotate right function
; x0 >>> 1
ror:
sta =ra ; save return address
shr =x0 ; A = x0 >> 1
jfc @=ra ; return if no carry
add 0x800
jmp @=ra; Push A on to the stack
sta @=sp
lda =sp
add #-1
sta =sp; Pop A off the stack
lea =1
add =sp
sta =sp
lda @=spI/O
I/O is handled through address 0xFFF.
LCD
Writes are directed to the LCD when the top 3 bits written to 0xFFF are zero. Writes to the LCD can be either commands or data. The low 8-bits are sent directly to the LCD and the 9th bit determines if data (0) or a command (1) is to be sent. Reads are not supported.
Buttons
There are 5 buttons. Reading from 0xFFF returns the state of the buttons in the low five bits where 0 is returned if the button is pressed and 1 is returned if the button is not pressed.
I2C
The SCL and SDA bits can be set by writing to 0xFFF with the top bit set. Bit 9 controls SCL and bit 8 controls SDA. Reads from 0xFFF return the state of the SCL and SDA bits.
Memory Extension
The memory extension device allows the Q2 to address more than 4096 words of memory. This is accomplished through the use of two additional latches: the data field (DF) and the instruction field (IF). Memory accesses for indirect loads or stores have the data field appended to the address. All other accesses have the instruction field appended.
On reset, both the data and instruction fields are set to 0. The data field can be set by writing 0xCxx to address 0xFFF (note that the field is ignored for I/O). This will set the data field to xx. The data field is copied to the instruction field when a jump takes place.
Summary
Writes:
- 00 0 C DDDDDDDD - LCD
- 10 C D 00000000 - I2C (C for SCL, D for SDA)
- 11 0 0 0000000F - Field
Reads:
- 11 C D 111KKKKK
Parts
1,660| Qty | Value | Footprint | References |
|---|---|---|---|
| 940 | 2N7002 | Package_TO_SOT_SMD:SOT-23 | Q1, Q10, Q100, Q101, Q1000, Q1001, Q1002, Q1003, Q1004, Q1005, Q1007, Q1009, Q1010, Q1011, Q1012, Q1013 +924 |
| 244 | 10k | Resistor_SMD:R_0603_1608Metric | R1, R10, R11, R12, R100, R101, R102, R104, R107, R109, R111, R114, R115, R117, R120, R121 +228 |
| 81 | 1k | Resistor_SMD:R_0603_1608Metric | R16, R106, R113, R119, R128, R136, R143, R149, R158, R165, R173, R179, R188, R195, R203, R209 +65 |
| 76 | 2N7002K | Package_TO_SOT_SMD:SOT-23 | Q2, Q114, Q116, Q117, Q118, Q142, Q184, Q186, Q187, Q188, Q212, Q254, Q256, Q257, Q1006, Q1016 +60 |
| 75 | Yellow | LED_SMD:LED_0805_2012Metric | D1, D2, D10, D11, D12, D13, D14, D15, D16, D17, D18, D19, D20, D21, D22, D23 +59 |
| 48 | 22k | Resistor_SMD:R_0603_1608Metric | R15, R105, R112, R118, R127, R135, R142, R148, R157, R164, R172, R178, R187, R194, R202, R208 +32 |
| 48 | 6.8k | Resistor_SMD:R_0603_1608Metric | R13, R20, R103, R110, R116, R125, R133, R140, R146, R155, R162, R170, R176, R185, R192, R200 +32 |
| 33 | 0.1u | Capacitor_SMD:C_0805_2012Metric | C1, C2, C3, C12, C13, C15, C16, C17, C22, C23, C25, C28, C30, C31, C32, C33 +17 |
| 31 | 100k | Resistor_SMD:R_0603_1608Metric | R18, R108, R123, R138, R153, R160, R183, R190, R213, R220, R243, R250, R282, R283, R284, R285 +15 |
| 21 | BAT43W | Diode_SMD:D_SOD-123 | D38, D39, D40, D41, D42, D43, D44, D45, D46, D47, D48, D49, D50, D51, D52, D53 +5 |
| 13 | Switch | Button_Switch_SMD:TA-3524S-A2 | SW1, SW7, SW8, SW9, SW10, SW11, SW12, SW13, SW14, SW15, SW16, SW17, SW18 |
| 10 | 4.7k | Resistor_SMD:R_0603_1608Metric | R275, R276, R277, R301, R302, R305, R306, R308, R310, R323 |
| 10 | Button | Button_Switch_SMD:SW_SPST_PTS645 | SW2, SW3, SW4, SW5, SW6, SW19, SW20, SW21, SW22, SW23 |
| 8 | 1u | Capacitor_SMD:C_0805_2012Metric | C10, C14, C18, C19, C20, C21, C26, C29 |
| 6 | MountingHole_Pad | MountingHole:MountingHole_3.2mm_M3_Pad_Via | H1, H2, H3, H4, H5, H6 |
| 2 | 10k | Potentiometer_THT:Potentiometer_Bourns_3386P_Vertical | RV1, RV3 |
| 2 | 470p | Capacitor_SMD:C_0805_2012Metric | C11, C24 |
| 2 | 6264 | Package_SO:SOP-28-330 | U1, U2 |
| 1 | 100 | Resistor_SMD:R_1206_3216Metric | R274 |
| 1 | 10u | Capacitor_SMD:C_0805_2012Metric | C27 |
| 1 | Battery | Batteries:BATTCOM_20MM_PTH | BT1 |
| 1 | CAT809J | Package_TO_SOT_SMD:SOT-23 | U3 |
| 1 | CLK | TestPoint:TestPoint_Loop_D2.50mm_Drill1.0mm | TP1 |
| 1 | I2C | Connector_PinHeader_2.54mm:PinHeader_1x05_P2.54mm_Horizontal | J3 |
| 1 | LOGO | q2:q2-logo | G*** |
| 1 | Programmer | Connector_IDC:IDC-Header_2x20_P2.54mm_Vertical | J1 |
| 1 | USB_B | Connector_USB:USB_B_OST_USB-B1HSxx_Horizontal | J2 |
| 1 | WC1602A | Display:WC1602A | DS1 |
Questions
How big is the Q2 PCB?
It measures 198 × 278 mm and has 2 copper layers, 1.6 mm thick.
What parts does the Q2 use?
1,660 parts, built around the 2N7002K and BAT43W. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.
Where can I download the Q2 KiCad files?
From the joewing/q2 repository on GitHub, at the commit this page was made from: the board is hardware/q2/pcb/q2/q2.kicad_pcb and its schematic hardware/q2/pcb/q2/address.kicad_sch. PCBKit opens the board in the browser, with nothing to install.
Can I use the Q2 design in my own project?
Its repository states no licence, so its author keeps all rights: ask joewing before reusing the design.
More from joewing/q2
3- 2 layers154 × 160 mm

- 2 layers154 × 100 mm

- 2 layers85 × 89.2 mm

Similar boards
- 4 layers272 × 112 mm

- 2 layers20.2 × 46.3 mm

Tcd1304pcb
Alohom/ESP32-Compatible-TCD1304-Linear-CCD-Sensor-PCB
A custom ESP32-compatible PCB interface board to drive and read the Toshiba TCD1304 linear CCD sensor for spectrometry and optical measurement applications.
17 parts - 2 layers50.8 × 25.4 mm

- 4 layers118 × 74 mm

VFODial
PAPRST/VFODialHID
Proposal for a standard HID descriptor for radio interface device (dial, knob, keypad, ...)
96 partsMIT - 4 layers193 × 105.2 mm

AFE V3
Pgr18/CELL_Z_SPECT_hardware
Печатные платы для проекта клеточной импедансной спектроскопии
293 parts - 2 layers27.9 × 101.6 mm

- 2 layers100.3 × 69.9 mm

HDD Synth Prototype MK4
MaverickUK/HDDSynth
Recreate the sound of mechanical spinning HDDs on retro PCs that use a solid state drive
46 parts16 - 4 layers46.8 × 34.8 mm

SmartWatch V4
Bellafaire/ESP32-Smart-Watch
An open source smartwatch based on the ESP32 compatible with the Arduino IDE.
74 parts258MIT