BORIS CPU's

BORIS CPU's

Intro

Intro Designing Task list ALU ↓ to bottom ↓

Intro

this part of the course is gonna go over how to make your own cpu

if u havent, i would reccommend going through Begining so that u understand the basics of computer science logic shit


main things i will be talking about are:

constructing, from the transistor level to an 8-BIT CPU

different computer architecture




Designing

to make a cpu, u need to think about: what do u want ur cpu to do, e.g. do you u want it to be able to add or subtract or be able to save data to memory

how many bits can it work with? (8-BIT, 32-BIT, 64-BIT)

u gotta think about what the clock cycle might be aswell

what specific instructions

how much memory/RAM do you want it to have

how many general purpose registers, and what specific registers and are needed

we need to answer these question before we get anywhere near CircuitVerse


so the cpu that i will be making will be/have:

- 8-BIT

2 specific registers: IR & PC

- 4 general purpose registers which i will call "R0" .... "R3"

- an ALU which can: "ADD", "SUB", "INC" (increment), "DEC" (decrement)

- 16 Bytes of memory/RAM (yes 16B of memory, not MB(megabytes) or even KB(kilabytes), just B(bytes, 8 bits))


now would be a good time to mention that i read binary from the least significant bit to the most significant bit aka from right to left

also since this is an 8-BIT CPU i wont be saying more than 8 bits so it shouldnt be too long or confusing

so if i said: "zero one one zero zero zero one one", that would be: "11000110"

or "zero one", that would be: "10"


now we need to make our own instruction set for this specific cpu, basically making our own assembly for out cpu

since its 8-BIT, we have 8 bits to work with here and we have 4 general purpose registers and 16 bytes of memory/RAM

i will be designating the first 2 bits for instructions, next 2 bits being data/sub instructions, and the last 4 bits for data

having 2 bits for instructions means the cpu can do 4 different instructions: "00", "01", "10", "11" (all in binary)

e.g. "01" (in binary) could be "SAVE" (in assembly) something to memory

below is an image which lays "11010010" out visually

so here would be the whole instruction set that ive made:



if we wanted to write a line of assembly it would look a bit like this:
"ALU SUB R2 R3" and the binary equivalent would be: "11 10 01 00"
so "ALU SUB R2 R3" = "11 10 01 00"

here are a few examples:


here is a python script which shows it very well, just copy it and go below or to: https://online-python.com


ARCHITECTURE

now im gonna talk about architecture. Im gonna do this a lot, mainly to show different ways that a cpu could be made

there r obviously billions of different combinations of different sizes of different components

e.g. we could have chosen to have 64B of memory/RAM or maybe 300 general purpose registers but that would be unnecessary for what we are doing


but here is the different things i could make done for this CPU:

it could be 1-BIT, 2-BIT, 3-BIT .... all the way to however big u want to make ur CPU, ur computer is prob 64-BIT

you could have 1 general purpose register, 2 general purpose registers, .... to how ever many you want

you could maybe not even have an ALU or ur ALU could have a lot more functions

u could have more bits designated to more different operations that ur CPU can do although it might be hard to use the rest of the bits

e.g. maybe u could have the first 4 bits for 16 different operation ("0000", "0001" .... "1111"), and the last 4 for a memory location or registers

you could maybe have "01" be a different operation like "JZR" or it could be "zump if zero" or smthing completly different like "OPChell0wo4ldx" which could be whatever name that does whatever you build it to do

it doesnt rlly matter what u call ur assembly i wanted to keep it to 3 characters and faily simple

you could maybe have 16GB of RAM but that would be unnecessary for what we are doing




Task list

(in order of difficulty) we need to make and link:

- an ALU which can "ADD", "SUB", "INC", "DEC";

- 4 general purpose registers;

- IR & PC;

- 16B of memory;

- Control Unit;




ALU

Okay lets start with making an ALU

We want the ALU to do 4 different functions:

"ADD", "SUB", "INC", "DEC"

as we already did in Begining, we made a 1-BIT Full Adder

but we are making an 8-BIT CPU so we need an 8-BIT ALU so we need to make an 8-BIT Full Adder

essentially, an 8-BIT Full Adder is just 8, 1-BIT Full Adders in sequence

so lets try to make that


so in CircuitVerse lets start with a 1-BIT Full Adder

CircuitVerse link here and go to "1-BIT FULL ADD" at the top

you can copy whats there in the "1-BIT ADD" to your own circuit

and we will go from there

watch the vid below and c how to make an "8-BIT FULL ADDER" in CircuitVerse




WIP