Close
0%
0%

The simplest 8-bit RISC CPU

In this project, I built a very simple 8 bit RISC CPU.
This is expansion of the prior project, the simplest 4 bit CPU.

Similar projects worth following
A very simple 8-Bit RISC CPU.

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, and added 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.
8-Bit data and 8-Bit Address,
16 Bit instruction, with 8 bit data, 8 bit opcode.
Each instruction executes in 1 clock,
On positive edge of the clock instructions executed.
On negative edge instruction address is incremented.
Instructions Add and Subtract and clear Accumulator.
One 8-Bit output port (for example for 7-segment LED),
and one 8-Bit input.output port.

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 8-Bit SRAM chip. Address space is 8 bits.

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.

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. 

Schematic-8bit_2024-11-23-1.pdf

Adobe Portable Document Format - 283.00 kB - 11/24/2024 at 01:23

Preview

8-Bit computer schematics main.png

Portable Network Graphics (PNG) - 102.64 kB - 11/23/2024 at 21:05

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
    00000000  0100x000  - noop
    00000000  0100x001   - clear Accumulator A

    ...address     0100x010    - jump if overflow
    ...address     0100x011     - jump unconditional
    ......#data..     0101x100     - add data to A
    00000000  0101x101      - add value of A to A 
    ......address   0101x110      - add SRAM value to A
    ............port..   0101x111       - add value from input port to A
    ..........#data..  0111x100     - subtract data from A
    00000000   0111x101      - subtract value of A from A
    ......address   0111x110      - subtract SRAM value from A
    ............port..   0111x111       - subtract value from input port from A
    .......address  0000x101    - store value A to SRAM by address
    .............port..  1100x101     - write value A to output port

    Notes:
    x (bit 3) allows to lit LED
              when x is 1 LED is lit.

    w (bit 6) is connected to WR# pin of SRAM,
            when w is 0, value stores to SRAM.

    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

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 01000000 b - noop
00000000 01001000  b LED on
00000000 01000000 b - LED off
00000000 01000011   b - jmp to addr 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