Skip to the content
4 layers190 × 120 mmZ80mgc, the printed circuit board in 3D

z80 game console

Size
190 × 120 mm
Copper layers
4
Thickness
1.6 mm
Parts
91
Nets
126
Pads
491
Tracks, vias
1,146, 63
Routed
Yes
KiCad
KiCad 7 (file 20221018)
Created
22 Jan 2023
Updated
8 Dec 2024

Overview

Z80mgc is an open-source printed circuit board by martinber, from the martinber/z80mgc repository on GitHub, published under the GPL-3.0 licence. It is a 4-layer board of 190 × 120 mm with 91 parts on 126 nets, routed with 1,146 tracks and 63 vias.

It is built around the 74HC245D, 74HC00D and 74HC02, with the 74HC04D, 74HC138 and 74HC86D among its other parts. Its parts include 20 connectors, 17 diodes, 14 resistors, 11 ICs and 4 capacitors. It belongs with the retro computing and games boards of this library.

Main components

7

README

README.md

z80mgc

A minimal game console based on the z80 CPU. Something like a console from the 70s/80s such as the original PAC-MAN arcade, but without video/sound chips which are hard to find.

This repo contains:

Board:

Board

Emulator:

Emulator

Specs:

  • CPU: Z80 CMOS at 6MHz MHz
  • ROM: 16384 bytes (2 x 28C65 EEPROM)
  • RAM: 32768 bytes (1 x 71256 RAM)
  • Screen: 128x64 px LCD for text and graphics (ST7920 driver)
  • Input: 8 buttons, read by polling
  • Also:
    • Port with 8 I/O pins
    • Extension port with most z80 pins available
    • 555 timer at 1/126 seconds

Working games:

  • Snake
  • Brick breaker

Possible future games:

  • Tanks
  • Frogger

Timing

  • Tick: Approx 1/126 of a second, timer counters are incremented each tick thanks to a 555 timer at around 126Hz that does NMI regularly.
  • Frame: Depends in the game, for example the snake might move every every frame that happens every 16 ticks.

Maximum clock speed

  • CPU is Z84C0006TPG. Maximum is 6.17MHz, equivalent to 166ns per clock. It waits memory for 2 clock cycles (this time is shortened a bit because of the logic gates I use to select memory).
  • Logic gates have around 10ns propagation time.

I can use RAM/ROM at full speed without caring about read times:

  • RAM is 71256 SA25TPG. Has 25ns access time: data is valid 25ns after OE and CS are set.
  • ROM is 28C64 25P. I think it has is 250ns access time: data is valid 250ns after OE and CS are set.

I can read the LCD without caring about read times. But LCD instructions are slow, I always have to poll if it is ready before using it:

  • LCD takes 1.6ms for clearing and 72 µs (72000ns) for each of the other instructions. When writing make the E pulse at least 160ns long (CPU does this for around 2 clock cycles) and leave the data for 20ns after disabling (CPU does this for around half a clock cycle). When reading, data is valid 260ns after enabled (CPU waits for around 2 clock cycles)

LCD speed:

  • If I run CPU at 5MHz, with 15fps, assuming instructions of 20 clocks, I can do around 16000 CPU instructions/frame.
  • But the LCD is slower, it takes around 74µs per LCD instruction so if I run at 15fps, I can do around 900 LCD instructions per frame. Considering sprites of 8 tiles and that I have to give X and Y coordinates, it takes 24 instructions per sprite max I can draw a max of around 37 sprites per frame.
  • To display an entire framebuffer in the LCD: For each pair of lines, I need 18 LCD instructions (2 for X/Y coordinates and 16 for the data), and since there are 64 lines, then I need 576 LCD instructions, which take around 43000µs which would be 23fps.
  • Anyway the LCD is not that fast. I should consider drawing the framebuffer in an interlaced way, and if I need something better I should start somehow only drawing the updated parts of the screen.
  • I don't want to spend too much time optimizing code for this LCD, I would prefer to spend the time adding a composite video output.

Game timimg

I don't have a timer chip like the z80 CTC. So I can count in software the amount of NMI, comes from a 555 timer. The interrupt happens at falling edge so there is no problem on leaving the NMI pin low for a long time.

The counter will be 8 bit. The value 255 could be equivalent to approx 2s so in that case I should call NMI at approx 128Hz. I do this with a 555 which apparently can reach until 100kHz.

Dropped ideas

  • Leave a clock input so I can drive it slowly clock by clock
  • Print a PCB, but it is so expensive to do a double layer. Doing a single layer PCB in KiCad is too hard because of crossings.
  • Headers to Data, Address and EEPROMs pins so I can write EEPROMs without taking them out
  • Other timer options:
    • Z80 CTC
    • I could use binary counters. If I have a clock of 6MHz, after 16 bits of counters I would have 91.55Hz. I also could give the 8 most significative digits in an input port.
  • Other display options I considered:
  • I considered adding sound with SN76489
  • A buzzer can be done in an expansion board:
    • An 74HC245 that receives 8 bits of data as input
    • The outputs of the 74HC245 go directly to a R-2R resistor ladder to implement a DAC (Digital Analog Converter)
    • The output of the DAC goes to a 555 VCO (Voltage Controlled Oscillator). Maybe the bit 7 of the 74HC245 should enable and disable the 555
    • The output of the 555 goes directly to a buzzer
    • In software, I should write a certain number to the I/O port and the buzzer should sound until I write zero
    • Add LEDs to bus, MREQ, IOREQ, WR, RD, etc. But then I realized that if the CPU works at 6MHz and I wont even see them blink.

Bricks game

With framebuffer:

Game start:

  • Bricks: Draw all bricks

Game loop, in order:

  • Ball: Clear old position of ball and move ball coordinate

  • Bricks: If collision with ball, redraw if modified or draw zeros to clean area.

  • Powerups: If collision with pad, draw zeros to clean area and give powerup.

  • Powerups: Draw the 8x3 graphic with OR. Should draw even if not descending because if the ball comes and it is stationary then there will be conflicts, but very unlikely and avoidable if both ball and powerup move together

  • Pad: Draw with OR with shifting/rotation.

  • Ball: Draw with OR with shifting/rotation.

Old ideas

Powerups:

  • Bigger pad

  • Smaller pad

  • Faster ball

  • Slower ball

  • Extra ball

  • Move all bricks downwards

  • Extra life

Will have a DUL (Drawing Update List) containing coordinates and the byte of graphics that will be drawn. Some kind of compressed framebuffer. This is used so I can overlap graphics with AND operations in RAM before writing to the LCD.

Game start:

  • Bricks: Draw all bricks

Drawing/updating, in order:

  • Bricks: If collision with ball, redraw if modified or draw zeros to clean area.

  • Powerups: If collision with pad, draw zeros to clean area and give powerup.

  • Powerups: Draw in the DUL the 8x4 graphic. The graphic is actually 8x3 but the top line is empty so it will erase the old frame. Draw even if not descending because if the ball comes and it is stationary then there will be conflicts

  • Pad: Draw in the DUL using shifting/rotation.

  • Ball: Draw in the DUL using shifting/rotation.

Old ideas:

  • Powerups: Collision detection with ball and pad, redraw to clean area in that case. If moving downward in this frame, draw full 8x4 object. The graphic is actually 8x3 but the top line is empty so it will erase the previous. Will be destroyed as soon as it touches the ball or the pad, so no problems in drawing order.

  • Pad: Draw using shifting/rotation. Draw each time it moves. Draw it in a framebuffer that only covers the last

  • Ball: Draw using shifting/rotation. Draw each time it moves, do it last

PCB design notes

  • Ground plane in the back layer?

  • Check datasheet for recommendations of decoupling capacitors

  • Check "return paths" for high speed signals

  • Route more important signals first so I minimize the length, vias, etc.

  • Add test points, with ground clips

  • Add mounting holes in corners first

  • I can add jumper resistors

  • I can make the SRAM with wide holes too

  • Vertial traces in one side and horizontal traces on the other, that way the ground plane is mostly intact

  • No 90deg angles, https://www.alternatezone.com/electronics/files/PCBDesignTutorialRevA.pdf

  • "I rarely go smaller than 10 mil for any trace unless I have to, and for power I try to use at least 30 mil" As a start, you may like to use say 25 thou for signal tracks, 50 thou for power and ground tracks, and 10-15 thou for going between IC and component pads

  • Pads 2x the diameter og the hole. There are some common practices used when it comes to generic component pads. Pads for leaded components like resistors, capacitors and diodes should be round, with around 70 thou diameter being common. Dual In Line (DIL) components like IC’s are better suited with oval shaped pads (60 thou high by 90-100 thou wide is common). Pin 1 of the chip sould always be a different pad shape, usually rectangular, and with the same dimensions as the other pins.p

  • At least 15 thou is a good clearance limit for basic through hole designs

  • Ensure that no part of the silkscreen overlaps a bare pad.

  • As a general rule, you should use at least one bypass capacitor per IC or other switching component if possible. Common values of bypass capacitors are 100nF for general purpose use, 10nF or 1nF for higher frequencies, and 1uF or 10uF for low frequencies.

  • Put name and description in silkscreen

  • Check that solder points have thermal relief pads

Parts

91
QtyValueFootprintReferences
14LEDLED_THT:LED_D3.0mmD0, D1, D2, D3, D4, D5, D6, D7, D9, D13, D14, D15, D16, D17
110.1uFCapacitor_THT:C_Disc_D3.0mm_W1.6mm_P2.50mmCD1, CD2, CD3, CD5, CD6, CD7, CD9, CD10, CD11, CD12, CD13
81kResistor_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P10.16mm_HorizontalR1, R2, R3, R4, R5, R18, R22, R23
410kResistor_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P10.16mm_HorizontalR2, R3, R4, R21
3, ,
210kResistor_THT:R_Array_SIP9RN1, RN2
21kResistor_THT:R_Array_SIP9RN3, RN4
21kResistor_THT:R_Array_SIP7RN5, RN6
228C256Package_DIP:DIP-28_W15.24mm_LongPadsU5, U6
233pFCapacitor_THT:C_Disc_D4.3mm_W1.9mm_P5.00mmC3, C5
274HC245Package_DIP:DIP-20_W7.62mm_Socket_LongPadsU9, U10
1clipboard:a9ab44e1-df2f-4d8c-8125-f91eaead8355
10.1ufCapacitor_THT:C_Disc_D3.0mm_W1.6mm_P2.50mmC4
1100kResistor_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P10.16mm_HorizontalR19
11uFCapacitor_THT:CP_Radial_D5.0mm_P2.50mmC2
1260Resistor_THT:R_Axial_DIN0204_L3.6mm_D1.6mm_P5.08mm_HorizontalR20
16MHzCrystal:Crystal_HC49-4H_VerticalY1
171256Package_DIP:DIP-28_W7.62mm_Socket_LongPadsU1
174HC00Package_DIP:DIP-14_W7.62mm_Socket_LongPadsU2
174HC02Package_DIP:DIP-14_W7.62mm_Socket_LongPadsU4
174HC04Package_DIP:DIP-14_W7.62mm_Socket_LongPadsU3
174HC138Package_DIP:DIP-16_W7.62mm_Socket_LongPadsU7
174HC86Package_DIP:DIP-14_W7.62mm_Socket_LongPadsU8
1FCapacitor_THT:C_Disc_D3.0mm_W1.6mm_P2.50mmCD4
1IO_Az80mgc:PinHeader_2x08_P2.54mm_VerticalJ1
1IO_BTNz80mgc:PinHeader_2x08_P2.54mm_VerticalJ3
1IO_EXPz80mgc:PinHeader_2x08_P2.54mm_VerticalJ6
1NE555PPackage_DIP:DIP-8_W7.62mmU12
1POWERConnector_PinHeader_2.54mm:PinHeader_1x02_P2.54mm_VerticalJ4
1QC12864Bz80mgc:QC12864B_HeaderDS1
1RESETConnector_PinSocket_2.54mm:PinSocket_1x02_P2.54mm_VerticalJ5
1USB_BConnector_USB:USB_B_OST_USB-B1HSxx_HorizontalJ2
1Z80CPUPackage_DIP:DIP-40_W15.24mm_Socket_LongPadsCPU1
1~{BUSACK}Connector_PinHeader_1.27mm:PinHeader_1x01_P1.27mm_VerticalJ20
1~{BUSRQ}Connector_PinHeader_1.27mm:PinHeader_1x01_P1.27mm_VerticalJ14
1~{CLK}Connector_PinHeader_1.27mm:PinHeader_1x01_P1.27mm_VerticalJ11
1~{HALT}TestPoint:TestPoint_THTPad_D2.0mm_Drill1.0mmJ9
1~{IORQ}Connector_PinHeader_1.27mm:PinHeader_1x01_P1.27mm_VerticalJ19
1~{M1}Connector_PinHeader_1.27mm:PinHeader_1x01_P1.27mm_VerticalJ7
1~{MREQ}Connector_PinHeader_1.27mm:PinHeader_1x01_P1.27mm_VerticalJ18
1~{MREQ}LED_THT:LED_D3.0mmD12
1~{NMI}Connector_PinHeader_1.27mm:PinHeader_1x01_P1.27mm_VerticalJ8
1~{RD}LED_THT:LED_D3.0mmD10
1~{RD}Connector_PinHeader_1.27mm:PinHeader_1x01_P1.27mm_VerticalJ16
1~{RESET}Connector_PinHeader_1.27mm:PinHeader_1x01_P1.27mm_VerticalJ15
1~{RFSH}TestPoint:TestPoint_THTPad_D2.0mm_Drill1.0mmJ12
1~{RFSH}Connector_PinHeader_1.27mm:PinHeader_1x01_P1.27mm_VerticalJ13
1~{WAIT}Connector_PinHeader_1.27mm:PinHeader_1x01_P1.27mm_VerticalJ10
1~{WR}Connector_PinHeader_1.27mm:PinHeader_1x01_P1.27mm_VerticalJ17
1~{WR}LED_THT:LED_D3.0mmD11

Similar boards

  • 2 layers194.3 × 174 mmMotherboard, the printed circuit board in 3D

    Motherboard

    aversey/suen

    A simple computer on M68k

    99 parts
  • 2 layers208 × 110 mm8 16 computer 2, the printed circuit board in 3D

    8 16 computer 2

    halfburnttoast/TCPU816-v1

    Version 1.1 of my 8-bit, TTL computer.

    120 parts21
  • 2 layers299.7 × 198.1 mmCisc-8, the printed circuit board in 3D

    Cisc-8

    nailed-barnacle/Cisc-8-ttl-processor

    A cut-down version of the 8080 processor using HCTTL and including a discrete ALU and instruction decoder

    319 parts1MIT
  • 2 layers191.8 × 121.3 mm8-Bit CPU 32k, the printed circuit board in 3D

    8-Bit CPU 32k

    slu4coder/Minimal-UART-Computer-1-2

    Legacy: Version 1 and 2 of my TTL-only CPU featuring UART I/O, an expansion port, 512KB SSD at up to 10MHz clock speed

    109 parts184
  • 4 layers304.5 × 217.2 mmLatest Full Backplane, the printed circuit board in 3D

    Latest Full Backplane

    Trilobyte-CPU/8-bit-computer

    A DIY 8-bit computer built mostly with discrete logic chips

    478 parts2
  • 2 layers180.3 × 112.4 mm8-Bit CPU 32k, the printed circuit board in 3D

    8-Bit CPU 32k

    slowcorners/Minimal-UART-CPU-Dev

    89 parts

Questions

How big is the Z80mgc PCB?

It measures 190 × 120 mm and has 4 copper layers, 1.6 mm thick.

What parts does the Z80mgc use?

91 parts, built around the 74HC245D, 74HC00D, 74HC02 and 74HC04D. 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 Z80mgc KiCad files?

From the martinber/z80mgc repository on GitHub, at the commit this page was made from: the board is hw/z80mgc.kicad_pcb and its schematic hw/io.kicad_sch. PCBKit opens the board in the browser, with nothing to install.

Can I use the Z80mgc design in my own project?

Its repository publishes it under the GPL-3.0 licence: you may reuse it on that licence's terms (keep the author's notice, and for a copyleft licence share your changes alike).