419 DJ8 8-bit CPU

419 : DJ8 8-bit CPU

Design render
  • Author: DaveX
  • Description: DJ8 8-bit CPU with parallel Flash / RAM interface
  • GitHub repository
  • Clock: 13760000 Hz

How it works

DJ8 is a 8-bit CPU featuring:

  • 8 x 8-bit register file
  • 3-4 cycles per instruction
  • 15-bit external address bus
  • 8-bit external data bus
  • Built-in 256-bytes demo ROM with 2 demos

Thanks to its external parallel bus, it could be connected to parallel flash or RAM and can run at full speed without (de)serialization overhead.

Sample assembly code could be found in test bench and demo ROM.

Previous implementations:

Memory Map

From To Description
0x0000 0x7fff External memory
0x8000 0xffff Internal Test ROM (256 bytes, mirrored)
External memory map if using the recommended setup (see pinout)
From To Description
0x2000 0x3fff External RAM (32 bytes)
0x4000 0x5fff External Flash ROM (16KB)

Registers

There are 8 general purposes 8-bit registers (A,B,C,D,E,F,G,H), two flag registers (CF, ZF), and 16-bit PC.

For memory addressing, 16-bit combined registers EF and GH are used.

At reset time, PC is set to 0x4000. All other registers are set to 0x80.

Instruction Set

For future compatibility, please set the don't care bits (?) to 0.

ALU reg, imm8: Immediate ALU operation
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
1 1 A A A D D D I I I I I I I I
  • A : ALU operation
    • 000: ADD: reg = reg + imm8
    • 001: ADC: reg = reg + imm8 + CF
    • 010: SUBC: reg = reg - (imm8 + CF)
    • 011: MOVR: reg = reg
    • 100: XOR: reg = reg ^ imm8
    • 101: OR: reg = reg | imm8
    • 110: AND: reg = reg & imm8
    • 111: MOVI: reg = imm8
  • D : register
  • I : imm8
ALU dest, src, A {,shift}: ALU operation with src register & register A
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
1 0 A A A D D D S S S ? F F 0 0
  • A : ALU operation
    • 000: ADD: dest = src + A
    • 001: ADC: dest = src + A + CF
    • 010: SUBC: dest = src - (A + CF)
    • 011: MOVR: dest = src
    • 100: XOR: dest = src ^ A
    • 101: OR: dest = src | A
    • 110: AND: dest = src & A
    • 111: MOVI: dest = A
  • D : dest register
  • S : src register
  • F : final shift operation
    • 00: No shift
    • 01: Shift right logical (shr)
    • 10: Shift right arithmetic (sar)
ALU dest, [mem], A {,shift}: ALU operation with memory & register A
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
1 0 A A A D D D ? ? ? M F F 1 0
  • A : ALU operation
    • 000: ADD: dest = [mem] + A
    • 001: ADC: dest = [mem] + A + CF
    • 010: SUBC: dest = [mem] - (A + CF)
    • 011: MOVR: dest = [mem]
    • 100: XOR: dest = [mem] ^ A
    • 101: OR: dest = [mem] | A
    • 110: AND: dest = [mem] & A
    • 111: MOVI: dest = A
  • D : dest register
  • M: memory mode
    • 0: [GH]
    • 1: [EF]
  • F : final shift operation
    • 00: No shift
    • 01: Shift right logical (shr)
    • 10: Shift right arithmetic (sar)
MOVR [mem], reg: Store content of register in memory
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
1 0 0 1 1 D D D ? ? ? M ? ? 0 1
  • D: register
  • M: memory mode
    • 0: [GH]
    • 1: [EF]
Jxx imm12: Conditional or unconditional jump to absolute address
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 J J I I I I I I I I I I I I
  • J: jmpcode
    • 01: Jump if zero (JZ)
    • 10: Jump if not zero (JNZ)
    • 11: Unconditional jump (JMP)
  • I: imm12
    • PC = (PC & 0xe000) | (imm12 << 1)
JMP GH: Unconditional jump to address GH
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 1 ? ? ? ? ? ? ? ? ? ? ? ? ? ?

Pinout

Due to TTIHP IO constraints, pins are shared between Address bus LSB and Data bus OUT. It means that during memory write instructions, the address space is only 128 bytes.

Pins Standard mode During memory write execute+writeback cycles
ui[7..0] Data bus IN Data bus IN
uio[7..0] Address bus LSB (7..0) Data bus OUT
uo[6..0] Address bus MSB (14..8) Address bus MSB (14..8)
uo[7] Write Enable Write Enable

You can connect a 8KB parallel Flash ROM + 32b SRAM without external logic and use uo[6] for RAM OE# and uo[5] for Flash ROM OE#.

To get a bidirectional data bus (needed for SRAM), uio bus must be connected to ui bus with resistors. To be tested!

How to test

An internal test ROM with two demos is included for easy testing. Just select the corresponding DIP switches at reset time to start the demo (technically, a jmp GH instruction will be seen on the data bus thanks to the DIP switches values, with GH=0x8080 at reset).

Demo 1: Rotating LED indicator

SW1 SW2 SW3 SW4 SW5 SW6 SW7 SW8
0 0 0 0 0 0 1 0

No external hardware needed. This demo shows a rotating indicator on the 7-segment display. Its speed can be changed with DIP switches, the internal delay loop is entirely deactivated when all switches are reset.

Demo 2: Bytebeat Synthetizer

SW1 SW2 SW3 SW4 SW5 SW6 SW7 SW8
0 0 0 0 0 1 1 0

Modem handshakes sound like music to your hears? It's your lucky day! Become a bit-crunching DJ thanks to 256 lo-fi glitchy settings.

Connect a speaker to uo[4] or use Tiny Tapeout Simon Says PMOD. Play with the DIP switches to change the loop settings.

It is highly recommended to add a simple low-pass RC filter on the speaker line to filter out the buzzing 8kHz carrier. Ideal cut-off frequency between 3kHz and 8kHz, TBD.

Set SW1 and/or SW2 at reset time to adjust speed in case the design doesn't run at 14MHz.

External hardware

  • No external hardware for Demo 1
  • Speaker for Demo 2
  • Otherwise: Parallel Flash ROM + optional SRAM

IO

#InputOutputBidirectional
0data in 0address out 8address out 0 / data out 0
1data in 1address out 9address out 1 / data out 1
2data in 2address out 10address out 2 / data out 2
3data in 3address out 11address out 3 / data out 3
4data in 4address out 12address out 4 / data out 4
5data in 5address out 13address out 5 / data out 5
6data in 6address out 14address out 6 / data out 6
7data in 7write enableaddress out 7 / data out 7

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)