Skip to content

Simple 8bit cpu with 8 instructions 3 registers and 256bytes memory that use logiccircuit

License

Notifications You must be signed in to change notification settings

AntoninPvr/8bit_cpu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Worst 8bit CPU

This is a von Neumann 8bit CPU and has a tiny instruction set.

Specifications

  • 7 not powerfull instructions: NOT, OR, AND, ADD, JMP, SEL, CC
  • 3 internal 8bit registers
  • 256 Bytes of RAM
  • 256 Bytes of ROM for programs
  • 8 bit parallel output

Instruction set

Instructions

Instruction Operand Description Cycles
NOT A Not A 1
OR A Or A 1
AND A And A 1
ADD A Full 8 bit adder 1
JMP A Absolute jump to A address in ROM 1
SEL A Expose address A of RAM 1
CC A Clear Carry flag 1

All instructions are 1 byte long and the operand is 1 byte. How compute "A OR B"?

By using the accumulator modifier that allow to use the accumulator as operand. Let's define "new" instructions:

Instruction Operand Cycles
NOT_a A 1
OR_a A 1
AND_a A 1
ADD_a A 1

So A OR B is:

AND_a 0x00; // clear the accumulator
OR_a A;
OR_a B;

Therefore in practice A OR B take 3cycles.

OPCODE

Instruction Opcode
NOT 0x00
OR 0x01
AND 0x02
ADD 0x03
JMP 0x20
SEL 0x08
CC 0x10
NOT_a 0x04
OR_a 0x05
AND_a 0x06
ADD_a 0x07

For JMP the operand is the address to jump to. Value must be even. (if odd it can execute data as instruction, that can be dangerous...)

For SEL the operand is the address of the RAM to expose.

Architecture

Von Neumann architecture with 3 internal registers and 256 Bytes RAM and 256 Bytes ROM.

CPU

PC in CPU

Program Counter

Program counter is a 8 bit loadable counter with clear input. The overflow output has no purpose is this version. If the program is designed correctly, the program counter will either never overflow, or design to seamlessly from 0xFF address 0x00.

PC in CPU

PC

Counter use JKFlipFlop.

PC details

Fetcher

The fetcher read ROM and alternatively write in instruction or data register. Even address are for instructions and odd for data.

Fetcher

Instruction Decoder

The instruction decoder decode the instruction and set the control signals. Is divided in two part, one for ALU and one for flow control.

Instruction_decoder

This is an heterogenous instruction decoder. This helps to alleviate the overwhelming aspects of the design. Only ALU use demux decoder, other control flow use One-hot decoder.

ALU_Instruction_decoder

Compute unit

This unit is the heart of the CPU. It is composed of the ALU, internal register and the RAM.

compute_unit

ALU

The ALU is a simple 8 bit ALU with 4 operations: NOT, OR, AND, ADD. ALU instruction decoder is directly connected to control logic, It is a 4 to 1 demux.

ALU

Logic Unit

Logic unit is responsible for NOT, OR and AND.

LU

Full 8bit Adder

This is a 8 bit adder with carry in and carry out. No more, no less.

AU

Register

The first register 0x00 is the output register

Register

RAM

Ram with 8 bit address register on the left.

RAM

About

Simple 8bit cpu with 8 instructions 3 registers and 256bytes memory that use logiccircuit

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages