171 Zilog Z80

171 : Zilog Z80

Design render
  • Author: ReJ aka Renaldas Zioma
  • Description: Z80 open-source silicon. Goal is to become a silicon proven, pin compatible, open-source replacement for classic Z80.
  • GitHub repository
  • Clock: 16000000 Hz

How it works

On April 15 of 2024 Zilog has announced End-of-Life for Z80, one of the most famous 8-bit CPUs of all time. It is a time for open-source and hardware preservation community to step in with a Free and Open Source Silicon (FOSS) replacement for Zilog Z80.

The implementation is based around Guy Hutchison's TV80 Verilog core.

The future work

  • Add thorough instruction (including 'illegal') execution tests ZEXALL to testbench
  • Compare different implementations: Verilog core A-Z80, Netlist based Z80Explorer
  • Create gate-level layouts that would resemble the original Z80 layout. Zilog designed Z80 by manually placing each transistor by hand.
  • Tapeout QFN44 package
  • Tapeout DIP40 package

Z80 technical capabilities

  • nMOS original frequency 4MHz. CMOS frequency up to 20 MHz. This tapeout on 130 nm is expected to support frequency up to 50 MHz.
  • 158 instructions including support for Intel 8080A instruction set as a subset.
  • Two sets of 6 general-purpose reigsters which may be used as either 8-bit or 16-bit register pairs.
  • One maskable and one non-maskable interrupt.
  • Instruction set derived from Datapoint 2200, Intel 8008 and Intel 8080A.

Z80 registers

  • AF: 8-bit accumulator (A) and flag bits (F)
  • BC: 16-bit data/address register or two 8-bit registers
  • DE: 16-bit data/address register or two 8-bit registers
  • HL: 16-bit accumulator/address register or two 8-bit registers
  • SP: stack pointer, 16 bits
  • PC: program counter, 16 bits
  • IX: 16-bit index or base register for 8-bit immediate offsets
  • IY: 16-bit index or base register for 8-bit immediate offsets
  • I: interrupt vector base register, 8 bits
  • R: DRAM refresh counter, 8 bits (msb does not count)
  • AF': alternate (or shadow) accumulator and flags (toggled in and out with EX AF, AF' )
  • BC', DE' and HL': alternate (or shadow) registers (toggled in and out with EXX)

Z80 Pinout

                    ,---------.__.---------.
         <--    A11 |1                   40| A10    -->       
         <--    A12 |2                   39| A9     -->        
         <--    A13 |3       Z80 CPU     38| A8     -->        
         <--    A14 |4                   37| A7     -->        
         <--    A15 |5                   36| A6     -->
         -->    CLK |6                   35| A5     -->
         <->     D4 |7                   34| A4     -->
         <->     D3 |8                   33| A3     -->            
         <->     D5 |9                   32| A2     -->            
         <->     D6 |10                  31| A1     -->            
                VCC |11                  30| A0     -->           
         <->     D2 |12                  29| GND           
         <->     D7 |13                  28| /RFSH  -->          
         <->     D0 |14                  27| /M1    -->           
         <->     D1 |15                  26| /RESET <--      
         -->   /INT |16                  25| /BUSRQ <--      
         -->   /NMI |17                  24| /WAIT  <--      
         <--  /HALT |18                  23| /BUSAK -->     
         <--  /MREQ |19                  22| /WR    -->       
         <--  /IORQ |20                  21| /RD    -->       
                    `----------------------'

How to test

Hold all bidirectional pins (Data bus) low to make CPU execute NOP instruction. NOP instruction opcode is 0. Hold all input pins high to disable interrupts and signal that data bus is ready.

Every 4th cycle 8-bit value on output pins (Address bus low 8-bit) should monotonously increase.

     Timing diagram, input pins

      Z80CLK____      ____      ____      ____      ____      ____         
         __/    \____/    \____/    \____/    \____/    \____/    `____ ...
           |        |         |         |         |         |
           |        |         |         |         |         |

      /RESET___________________________________________________________
         __/
      /WAIT ___________________________________________________________
         __/
      /INT  ___________________________________________________________
         __/
      /NMI  ___________________________________________________________
         __/
      /BUSRQ___________________________________________________________
         __/

      D7..D0             NOP       NOP       NOP       NOP       NOP
         __ XXXXXXXXX ___#00___ ___#00___ ___#00___ ___#00___ ___#00___

      Expected signals on output pins
      /M1   _________                    ____________________
                     \__________________/                    \_________
      /MREQ ___________________          ______________________________
                               \________/ 
      /RD   ___________________          ______________________________
                               \________/
      A0..A7         
         __ XXXXXXXXX ___#00___ ___#00___ XXXXXXXXX XXXXXXXXX ___#01___
 

External hardware

Bus de-multiplexor, external memory, 8-bit computer such as ZX Spectrum.

Alternatively the RP2040 on the TinyTapeout test PCB can be used to simulate RAM and I/O.

IO

#InputOutputBidirectional
0/WAIT/M1, A0, A8D0
1/INT/MREQ, A1, A9D1
2/NMI/IORQ, A2, A10D2
3/BUSRQ/RD, A3, A11D3
4/WR, A4, A12D4
5/RFSH, A5, A13D5
6/HALT, A6, A14D6
7/BUSAK, A7, A15D7

Chip location

Controller Mux Mux Mux Mux Mux Mux Mux Mux Mux Mux Mux Mux Mux Mux Mux Mux Mux Mux Mux Mux tt_um_chip_rom (Chip ROM) tt_um_factory_test (TinyTapeout Factory Test) tt_um_MichaelBell_tinyQV (TinyQV Risc-V SoC) tt_um_urish_silife_max (Game of Life 8x32 (siLife)) tt_um_vc32_cpu (VC 16-bit CPU) tt_um_tinytapeout_logo_screensaver (VGA Screensaver with Tiny Tapeout Logo) tt_um_htfab_rotfpga2 (ROTFPGA v2a) tt_um_htfab_latch_test (Latch test) tt_um_no_time_for_squares_tommythorn (No Time For Squares, IHP edition) tt_um_tommythorn_maxbw (Asynchronous Multiplier) tt_um_urish_simon (Simon Says memory game) tt_um_htfab_rotfpga2_ff (ROTFPGA v2b) tt_um_meiniKi_ttihp_fazyrv_exotiny (FazyRV-ExoTiny) tt_um_rebeccargb_hardware_utf8 (Hardware UTF Encoder/Decoder) tt_um_rebeccargb_universal_decoder (Universal Binary to Segment Decoder) tt_um_algofoogle_raybox_zero (raybox-zero TTIHP0p2 edition) tt_um_z2a_rgb_mixer (RGB Mixer demo) tt_um_vga_clock (VGA clock) tt_um_frequency_counter (Frequency counter) tt_um_brandonramos_VGA_Pong_with_NES_Controllers (VGA Pong with NES Controllers) tt_um_demosiine_sda (DemoSiine) tt_um_toivoh_demo_deluxe (Sequential Shadows Deluxe [TT08 demo competition]) tt_um_edwintorok (Rounding error) tt_um_2048_vga_game (2048 sliding tile puzzle game (VGA)) tt_um_hpretl_spi (SPI Test) tt_um_top_mole99 (One Sprite Pony) tt_um_urish_spell (SPELL) tt_um_rebeccargb_vga_pride (VGA Pride) tt_um_autosel (I2C EEPROM Project Selection) tt_um_a1k0n_nyancat (VGA Nyan Cat) tt_um_a1k0n_vgadonut (VGA donut) tt_um_rebeccargb_colorbars (Color Bars) tt_um_crispy_vga (Crispy VGA) tt_um_kbeckmann_flame (Flame demo) tt_um_jamesrosssharp_1bitam (1bit_am_sdr) tt_um_simon_cipher (simon_cipher) tt_um_htfab_bouncy_capsule (Bouncy Capsule) tt_um_phansel_laplace_lut (Experiment Number Six: Laplace LUT) tt_um_kianv_bare_metal (KianV RISC-V RV32E Baremetal SoC) tt_um_calonso88_rsa (8 bit RSA encryption) tt_um_silice (Warp) tt_um_rejunity_vga_test01 (VGA Drop (audio/visual demo)) tt_um_a1k0n_demo (Demo by a1k0n) tt_um_MichaelBell_canon (TT08 Pachelbel's Canon demo) tt_um_htfab_caterpillar (Simon's Caterpillar) tt_um_ravenslofty_chess (Chess) tt_um_fountaincoder_top_V2 (maddihp) tt_um_tomkeddie_a (VGA Experiments in Tennis) tt_um_MichaelBell_mandelbrot (VGA Mandelbrot) tt_um_MichaelBell_rle_vga (RLE Video Player) tt_um_jayjaywong12 (mulmul) tt_um_wokwi_392873974467527681 (PILIPINASLASALLE) tt_um_froith_goldcrest (Goldcrest RISC-V) tt_um_dvxf_dj8v (DJ8 8-bit CPU) tt_um_hpretl_minilogix (Minilogix) tt_um_tomkeddie_b (Transmit UART) tt_um_joerdsonsilva_modem (Multimode Modem) tt_um_oled_frequency_counter (Frequency Counter SSD1306 OLED) tt_um_stochastic_addmultiply_CL123abc (Stochastic Multiplier, Adder and Self-Multiplier) tt_um_QIF_8bit (8 Bit Digital QIF) tt_um_toivoh_retro_console (Retro Console) tt_um_cejmu (CEJMU Beers and Adders) tt_um_rejunity_sn76489 (Classic 8-bit era Programmable Sound Generator SN76489) tt_um_dlmiles_tt05_i2c_bert (I2C BERT) tt_um_dlmiles_muldiv8 (MULDIV unit (8-bit signed/unsigned)) tt_um_dlmiles_loopback (IHP loopback tile with input skew measurement) tt_um_dlmiles_bad_synchronizer (Example of Bad Synchronizer) tt_um_wokwi_407306064811090945 (DDR throughput and flop aperature test) tt_um_urish_giant_ringosc (Giant Ring Oscillator (3853 inverters)) tt_um_digital_clock_example (Digital Desk Clock v2.0) tt_um_rejunity_z80 (Zilog Z80) tt_um_rejunity_ay8913 (Classic 8-bit era Programmable Sound Generator AY-3-8913) tt_um_rtfb_collatz (Collatz conjecture brute-forcer) tt_um_ccattuto_conway (Conway's Game of Life on UART and VGA) tt_um_snow (Snow) tt_um_calonso88_74181 (8-bit ALU based on 2x 74181) tt_um_rejunity_vga_logo (VGA Tiny Logo (1 tile)) tt_um_NicklausThompson_SkyKing (SkyKing Demo) tt_um_htfab_cells (Cell mux) tt_um_htfab_pg_1x1 (Power gating test (1x1)) tt_um_htfab_pg_1x2 (Power gating test (1x2)) tt_um_dlmiles_ringosc_5inv (Ring Oscillator (5 inverter)) tt_um_devinatkin_pulse_width_counter (Pulse Width Counter) tt_um_algofoogle_vga_fun_wrapper (TTIHP VGA FUN!) tt_um_cfib_demo (cfib Demoscene Entry) tt_um_vga_glyph_mode (Glyph Mode) tt_um_favoritohjs_scroller (VGA Scroller) tt_um_pulse_generator (TTL Pulse Generator) tt_um_rajum_iterativeMAC (Iterative MAC) tt_um_algofoogle_tinyvga_fun_wrapper (TTIHP TinyVGA FUN!) tt_um_urish_sram_test (SRAM (1024x8) test) tt_um_one_bit_puf_wrapper (One Bit PUF) tt_um_multi_bit_puf_wrapper (One Bit PUF) tt_um_gray_sobel (Gray scale and Sobel filter) tt_um_rebeccargb_intercal_alu (INTERCAL ALU)