Close
0%
0%

The simplest 8-bit RISC CPU

In this project, I built a very simple 8 bit RISC CPU
Using small number of TTL chips.

Similar projects worth following
A very simple 8-Bit RISC CPU made using smallest amount of TTL chips and parts.

In my prior completed project, I built the simplest 4-Bit RISC CPU and computer. It was functional "computer", but very limited without RAM and only 4 bit address and data and with only Add instruction.
https://hackaday.io/project/191290-the-simplest-4-bit-risc-cpu

This project is the expansion of same architecture to 8-Bit RISC which is more functional computer. Address and data expanded to 8 bits, with Add and Subtract instructions, and I/O ports, and RAM.

Uses only 16 TTL logic chips, 2 EEPROM, and 1 SRAM, and one 555 timer.
Design choices:

Simple 8-Bit RISC CPU.

Harvard architecture with separate program memory and RAM.

Minimal instruction set (only 14 instructions) allows to execute simple program.

8-Bit data and 8-Bit Address,
16 Bit instruction, with 8 bit data, 8 bit opcode,
RAM memory 256 bytes.

One 8-Bit output port (for example for 7-segment LED),
and on

This is very simple educational 8-Bit RISC CPU and computer. 
Uses only 16 logic chips, two EEPROM, and one SRAM chip, and one 555 timer.

This is much smaller then other comparable 8-Bit computer designs.
(For comparison, Ben Eater's 8-Bit computer uses about 40 logic chips.)

Uses Harvard architecture, with separate instruction and data memory.

Clock is generated by 555 timer with frequency from 1 Hz to 1000 Hz.
Although schematic will probably allow higher frequency up to 1 Mhz.

Instruction format 16 Bit, with 8 bit opcode, and 8 bit address or data.

Instructions stored in two EEPROM chips.

There is one 256x8  SRAM. Address space is 8 bits (256 bytes).

Actually the RAM and EEPROM chips have 11 bits address, i.e. 2 kbytes;
but the CPU address is only 8 bits (256  bytes).

Each instruction executes in 1 clock. That simplifies control logic.
On positive edge of the clock, instruction executed.
On negative edge of the clock, instruction address is incremented.

ALU instructions: Add and Subtract and clear Accumulator.

One output 8-Bit port, and one input or bidirectional 8-Bit port.

ALU executes instructions Add and Subtract and clear Accumulator.

One Accumulator 8-Bit register A.  

Instructions set is very small but allows to execute short programs.

Instructions:

No-op.

Clear Accumulator A. ( zero to A)

Add operand to A and store in A.

Subtract operand from A and store to A.

Store value from A to SRAM at address N.

Input operand from input port and add to A.

Output value A to output port. 

Jump conditional when Flag overflow.

Jump unconditional.


Operand of Add or Subtract instructions can be:
      immediate value # from instruction EEPROM,

      value from SRAM at address N,

      value from input port.

      value from accumulator A (add to itself).

Notes:

There is no load A instruction. But one can use ‘Clear’ instruction,
following by ‘Add’ instruction to load value to the A accumulator.

ALU and Accumulator operate on 8 bits. But program can compute
multi-byte arithmetic operation (add or subtract 16 or 32 bit numbers),
in multiple steps.

There is only one conditional Jump instruction and flag carry.
But one can use it to test different conditions.
For example, to test if A register in not zero: Add value hex FF to A.
If flag carry is set then the value in A was not zero.

Input and output 8 bit ports can by connected to devices, like
7-segmend LED display, and keypad, for example.

CPU opcode bit 3 is not affecting execution, only connected to LED.
Used to implement simple Blink irrespective of cpu operation.

In current schematic, direction of the input 8-bit port is fixed.

But, a simple modification can convert port to bi-directional,
by connecting buffer's direction pin with the unused CPU
instruction opcode bit 3.

RISC CPU 8bit 2024-12-10.pdf

Updated schematics, 8 -bit Risc CPU and computer.

Adobe Portable Document Format - 305.69 kB - 12/13/2024 at 03:07

Preview

  • 1
    Step 1

    Most chips and components can be soldered directly on PCB.
    It is possible to add LEDs to schematics to display status, instruction opcodes, address and Accumulator data. But that would complicate PCB and make it larger.

    Recommended to install EEPROM chips U3 and U15 on a DIP 24 pin socket, so that EEPROM could be easily removed and reprogrammed when needed.

    EEPROM chip U3 stores instruction opcode, 8 bits,  EEPROM chip U15 stores address/data.

  • 2
    Program instruction opcodes

    The CPU program is stored in two EEPROM chips U3 and U15.
    A is 8 bits accumulator register.

    Here is list of 16 bits binary opcodes:
       data/addr    opcode Hex
               00     00  h - noop
               00     01   h - clear Accumulator A

    ...address     02  h - jump conditional if overflow
    ...address     03  h - jump unconditional
    ......#data..     14  h - add data to A
                00    15 h - add value of A to A 
    ....address    16  h - add SRAM value to A
    .... .....port..    17  h - add value from input port to A
    .......#data..    34  h -  subtract data from A
               00     35  h -  subtract value of A from A
    ....address    36  h - subtract SRAM value from A
    ..........port..    37  h - subtract value from input port from A
    ....address    45  h - store value A to SRAM by address
    ..........port..    85 h  - write value A to output port

    Notes:
    In each opcode, free bit  x (bit 3) allows to lit LED
              when x is 1 LED is lit.

    Port parameter is currently not used. But in future designs it may
    be used to select port number.

View all instructions

Enjoy this project?

Share

Discussions

Marsianin245 wrote 12/13/2024 at 03:21 point

Updates:
Schematics pdf file, and opcode list are updated.
Logisim model tested.

  Are you sure? yes | no

Ken Yap wrote 11/23/2024 at 23:18 point

Cool. Could we have a blinky program for it?

I see from the date on the schematic that this was designed back in 2020. Do you have the schematics in an ECAD format like KiCad, EasyEDA, Eagle, etc? Would also be nice if one could simulate it using Logisim.

  Are you sure? yes | no

Marsianin245 wrote 11/24/2024 at 01:35 point

Yes, schematic in EasyEDA.
I just uploaded PDF latest version, 2024.
I do not have a Logisim simulation model.
This is work in progress.

the blink LED example program code is

16 bits binary code
            data     opcode
00000000 00000000 b - noop
00000000 00001000  b LED on
00000000 00000000 b - LED off
00000000 00000011   b - jump to address 0

  Are you sure? yes | no

Ken Yap wrote 11/24/2024 at 02:01 point

👍

BTW I think blinky should be twice as long. The program as it stands only turns it on. You need a few more instructions to turn it off.

  Are you sure? yes | no

Marsianin245 wrote 11/24/2024 at 05:58 point

Actually this program will blink on and off repeatedly. This is because bit 3 of the opcode is directly connected to LED! :) i.e when bit is 1 LED is on, when bit is 0 LED is off. And the last instruction is jump unconditional back to address 0.
Opcodes designed such to simplify the control logic.
I will post a list of instruction opcodes soon.

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates