Skip to the content
2 layers154 × 160 mmQ2a, the printed circuit board in 3D

12-bit single-board discrete transistor computer

Size
154 × 160 mm
Copper layers
2
Thickness
1.6 mm
Parts
159
Nets
264
Pads
884
Tracks, vias
1,500, 170
Pours
2
Routed
Yes
KiCad
KiCad 7 (file 20221018)
Created
13 Sep 2020
Updated
15 Dec 2024

Overview

Q2a is an open-source printed circuit board by joewing, from the joewing/q2 repository on GitHub. It is a 2-layer board of 154 × 160 mm with 159 parts on 264 nets, routed with 1,500 tracks and 170 vias.

Its parts include 50 resistors, 43 diodes, 32 capacitors, 26 ICs and 3 connectors.

README

README.md

Q2

A home-brew 12-bit mini-computer.

text
         __       __        
        /\ \     /\ \       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
                                  \__________ Dereference

There 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
  • 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:

text
make examples/sieve.lst

This 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:

text
make examples/hello.lst

This will generate the listing file for examples/hello.q2 as examples/hello.lst.

Instruction Set

All instructions are 1 word with the following format:

text
  FFF D Z XXXXXXX
   \  \ \    \____ Operand
    \  \ \________ Zero-Page    
     \  \_________ Dereference 
      \___________ Opcode

Instruction summary:

OpcodeNameFDescription
000LDAZA = [X]
001NORZA = A NOR [X]
010ADDCA = A + [X]
011SHRCA = [X] >> 1
100LEA-A = X
101STA-[X] = A
110JMP-P = X
111JFC-if !F, P = X

The flag is set if carry ('C'), zero ('Z'), or left unchanged ('-').

The following address modes are supported:

ValueDZMeaning
x00current-page relative
@x10indirect through current page
=x01zero-page relative
@=x11indirect through zero page

For convenience, the assembler also supports two additional address modes:

ValueDZMeaning
#x00immediate
#@x10immediate indirect

These cause an extra word to be allocated at the end of the current page for an immediate value.

Examples

text
; Negate: A = -A
  nor   #0
  add   #1
text
; Subtract: A - v
  nor   #0
  add   v       ; A = v - A - 1
  nor   #0      ; A = A - v
text
; Decrement A
  add   #-1
text
; NOT: A = ~A
  nor   #0
text
; OR: A = A | v
  nor   v
  nor   #0
text
; AND: A = A & v
  nor   #0
  sta   =t0   ; t0 = ~A
  lda   v
  nor   #0    ; A = ~v
  nor   =t0   ; A = ~(~A | ~v) = A & v
text
; Jump if F set
  jfc   $+2
  jmp   label
text
; Jump if a >= b
  lda   a
  nor   #0
  add   b
  jfc   ge
text
; Jump if a != b
  lda   a
  nor   #0
  add   b
  nor   #0
  jfc   ne
text
; Function call:
  lea   $+2   ; A = return address
  jmp   func

;...
func:
  sta   =ra   ; Save return address
  ; ...
  jmp   @=ra  ; Return
text
; Long jump
  jmp   @#addr
text
; Long call
  lea   $+2
  jmp   @#addr
text
; 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
text
; Push A on to the stack
  sta   @=sp
  lda   =sp
  add   #-1
  sta   =sp
text
; Pop A off the stack
  lea   =1
  add   =sp
  sta   =sp
  lda   @=sp

I/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

159
QtyValueFootprintReferences
310.1uCapacitor_THT:C_Disc_D5.0mm_W2.5mm_P2.50mmC1, C2, C10, C11, C12, C13, C14, C15, C16, C17, C18, C19, C20, C21, C22, C23 +15
2910kResistor_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P10.16mm_HorizontalR19, R20, R21, R22, R23, R24, R25, R26, R27, R28, R29, R30, R31, R32, R33, R34 +13
29LEDLED_SMD:LED_0805_2012MetricD1, D2, D10, D11, D12, D13, D14, D15, D16, D17, D18, D19, D20, D21, D22, D23 +13
1710kResistor_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P2.54mm_VerticalR1, R2, R3, R4, R5, R11, R12, R13, R14, R15, R16, R17, R18, R48, R49, R50 +1
141N4148Diode_SMD:D_MiniMELFD30, D31, D32, D33, D34, D35, D36, D37, D38, D39, D40, D41, D42, D43
12SlicePackage_DIP:DIP-20_W7.62mm_SocketU6, U10, U11, U12, U13, U14, U15, U16, U17, U22, U23, U27
4100kResistor_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P2.54mm_VerticalR7, R8, R9, R10
4245Package_DIP:DIP-20_W7.62mm_SocketU18, U19, U20, U21
4MountingHole_PadMountingHole:MountingHole_3mm_Pad_ViaH1, H2, H3, H4
114Package_DIP:DIP-14_W7.62mm_SocketU5
147uCapacitor_THT:CP_Radial_D6.3mm_P2.50mmC9
162256Package_DIP:DIP-28_W15.24mm_SocketU8
16264Package_DIP:DIP-28_W15.24mm_SocketU9
1Barrel_Jack_MountingPinConnector_BarrelJack:BarrelJack_HorizontalJ1
1CXOPackage_DIP:DIP-8_W7.62mm_SocketX1
1ClockPackage_DIP:DIP-20_W7.62mm_SocketU1
1Field 0Package_DIP:DIP-20_W7.62mm_SocketU26
1Field 1Package_DIP:DIP-20_W7.62mm_SocketU25
1Field 2Package_DIP:DIP-20_W7.62mm_SocketU24
1IOPackage_DIP:DIP-20_W7.62mm_SocketU3
1IOConnector_Dsub:DSUB-15_Female_Horizontal_P2.77x2.84mm_EdgePinOffset7.70mm_Housed_MountingHolesOffset9.12mmJ2
1OpcodePackage_DIP:DIP-20_W7.62mm_SocketU4
1ProgrammerConnector_IDC:IDC-Header_2x20_P2.54mm_VerticalJ3
1StatePackage_DIP:DIP-20_W7.62mm_SocketU2

More from joewing/q2

3
  • 2 layers198 × 278 mmQ2, the printed circuit board in 3D

    Q2

    joewing/q2

    12-bit single-board discrete transistor computer

    1,660 parts42
  • 2 layers154 × 100 mmFrontpanel, the printed circuit board in 3D

    Frontpanel

    joewing/q2

    12-bit single-board discrete transistor computer

    78 parts42
  • 2 layers85 × 89.2 mmTerminal, the printed circuit board in 3D

    Terminal

    joewing/q2

    12-bit single-board discrete transistor computer

    22 parts42

Similar boards

  • 2 layers314.3 × 108.3 mmKeyboard2, the printed circuit board in 3D

    Keyboard2

    hackclub/OnBoard

    💡 Join 1,000 teenagers and make your first PCB with a $100 grant!

    159 parts915
  • 2 layers285 × 94.2 mmKeyboard ch32x-60-improved, the printed circuit board in 3D

    Keyboard ch32x-60-improved

    rgoulter/keyboard-labs

    Repo with my PCB designs and keyboard firmware

    159 parts236
  • 2 layers275 × 103 mmKeebee, the printed circuit board in 3D

    Keebee

    blakesmith/embedded

    Blake's embedded projects

    159 parts167
  • 2 layers40.3 × 109.6 mmImpact main, the printed circuit board in 3D

    Impact main

    tpcarlson/synth-diy

    Mostly Eurorack projects

    159 parts107
  • 2 layers99.1 × 99.1 mmDev board, the printed circuit board in 3D

    Dev board

    limentic/the-hephaestus-mod

    Transform your Apple Magic Keyboard into a mechanical keyboard. Not affiliated with Apple.

    159 parts44CERN-OHL-S-2.0
  • 2 layers177.8 × 130.8 mmDurango, the printed circuit board in 3D

    Durango

    zuiko21/minimOS

    Scalable OS for 6502/65816

    159 parts23MIT
  • 2 layers70.7 × 53.3 mmGladiolus, the printed circuit board in 3D

    Gladiolus

    greatfet-hardware/gladiolus

    a Software Defined Infrared (SDIR) neighbor

    159 parts19
  • 2 layers98.8 × 69.8 mmPre Ignition, the printed circuit board in 3D

    Pre Ignition

    OpenLogicEFI/Hardware

    Hardware is based off an open source project called Speeduino by Josh Stewart.

    159 parts19

Questions

How big is the Q2a PCB?

It measures 154 × 160 mm and has 2 copper layers, 1.6 mm thick.

What parts does the Q2a use?

159 parts. 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 Q2a KiCad files?

From the joewing/q2 repository on GitHub, at the commit this page was made from: the board is hardware/q2a/pcb/q2a/q2a.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 Q2a design in my own project?

Its repository states no licence, so its author keeps all rights: ask joewing before reusing the design.