BORIS CPU's

BORIS CPU's

Begining

The Begining Start Basics Half Adder &
Full Adder
↓ to bottom ↓

The Begining

im expecting u to know a bit already about cpu's and transistors and 0's and 1's

but mostly for this course im taking a "forget everything already know" type aproach

that means im starting from the basics but kinda throwing a lot at you quickly

im not going to be streching out topics too much im going to be very straight to the point

if u dont understand something, ur always free to just stop and go back, work at your own pace

u wont be done in a week (prob)

i encourage going of on tangents and trying to do stuff on ur own rather than just copy-pasting wut i have

u will learn much more this way and it might be more fun and motivating to have completed something on ur own

u can at anytime (on whatsapp) ask me questions but please go to ChatGPT or Copilot first, then u can ask me and it better be a good question

but with that out of the way lets actually start




Start

Alright lets begin


there is kinda 2 ways of learning all of this:

1. slowly and abtractly (slow and tedious but learn more and more specifics)

2. quickly with a lot of information thrown at u very quickly (quick but may not understand everything down to small details and u can miss things)


if ur going 2 then u can watch the following videos otherwise if ur going 1 u can ingore the videos directly below and continue to Basics

my recommendation and prob the most optimal way to go through this course:

watch the videos so that u get a general understanding of everything and a good overview of everything that we are gonna do and why

then go through this course but at a faster pace maybe skipping a few uneccesary details

its important that u go in this order, 0 -> 5

0. Ben Eater - Making logic gates from transistors
1. Code Dumped - HOW TRANSISTORS RUN CODE?
2. Code Dumped - HOW TRANSISTORS REMEMBER DATA
3. Code Dumped - CRAFTING A CPU TO RUN PROGRAMS
4. Code Dumped - How computer processors run conditions and loops
5. Code Dumped - How the Clock Tells the CPU to "Move Forward"



Basics

lets go all the way down to binary 0's & 1's and transistors so that we can understand more complicated circuits consisting 1000's of them


what is binary?

Binary is a way of represting information in 2 simple forms using electricity:

0: "OFF", "FALSE", "NO". This means that no electricity is passing through the wire

1: "ON", "TRUE", "YES". This means that there is electricity passing through the wire

that is the basic fundamental of all electronics


what is a transistor? what can we do with it?

well im not great at explaining shit in words but these 2 vidoes below explain it very well

u should watch this video ↓ from 00:00 - 04:10,

and this video ↓ from 00:00 - 08:26


now that we understand the basics lets put it in practice. How u might ask, well the next chapter will explain.




CircuitVerse

now i want to introduce u to CircuitVerse. CircuitVerse is a free opensource on the web binary logic simulation sandbox

this is where we will build out circuits and eventualy our CPU

you can go to curcuitverse here -> circuitverse.org/simulator and figure it out on ur own or watch the vid ive prepared below (no audio)


i would try to get very familier with ciruitverse as thats where most of your time will be spent

and please use a different theme (i will be using a custom one)





Half Adder & Full Adder

now we can start making some circuits

we will start by making a Half Adder


the procces of designing and making a circuit:

to start we need to know what we want to circuit to actually do, or what is it doing in the bigger picture

we need a half Adder to add 2 bits together in binary

so if we input "0" & "1", we should get "01" (in decimal we are basically doing 0+1=1)

we also need to know what inputs we want and what outputs those inputs will make

to do this we can make a truth table

its important that we can into account every posibility of inputs and outputs, to calculate that: 2 to the power of the amount of inputs

so a Half Adder truth table would look like this:

"A" & "B" are inputs and "SUM" & "Cout" (Carryout) are outputs


now we can try to make this

we start with making the "SUM" as its the least significant bit

since the "SUM"s truth table is just an "XOR" gate we can just hook up A & B straight to an "XOR" gate and straight to "SUM"

now we do "Cout", ist truth table is just an "AND" gate so we can just hook up A & B straight to an "AND" gate and straight to "Cout"

a half adder would look like this:

this would be a good time to mention that i typicaly make circuits going from left (inputs) to right (outputs)


now lets make a Full Adder

using the same process

a Full Adder add 3 bits in binary

so if we had "0" + "1" + "1" we would get "10" (in decimal we are basically doing 0+1+1=2)

the truth table would look somthing like this

"A", "B" & "Cin"(Carryin) are inputs and "SUM" & "Cout" (Carryout) are outputs



lets try to make the "SUM", we are adding 3 bits together, so we are escentialy just adding the first 2, then adding the third to that

so we need to do: "A" + "B" = "X"    then: "X" + "Cin" = "SUM"

lets go step by step, so the truth table for "X" would be:

and therefore the truth table for "SUM" would be:

notice how the truth table for both outputs: "X" and "SUM" and the same as an "XOR" gate (0 1 1 0)

so "SUM" = ("A" + "B") + "Cin"    can be writen as "SUM" = ("A" XOR "B") XOR "Cin"

so with all that, this is what it would look like:



now lets do the same for "Cout", Cout (Carryout) is an overflow bit, so if the output is "10" or "11" we need "Cout" to be "1"

so if any 2 of "A", "B" or "Cin" are "1" then cout should be "1"

a way we can do that is to do "A" AND "B", lets call that "Y" so: "Y" = ("A" AND "B"), this will make "Cout" = "1", when the output is "10"

and to do "X" AND "Cin", lets call that "Z" so: "Z" = ("X" AND "Cin"), this will make Cout" = "1", when the output is "11"

then we hook these 2 up together as they going to the same output with an "OR" gate as if any1 of them("Y" or "Z") are "1" then "Cout" should be "1" aswell

so all this can be writen as "Cout" = ("A" AND "B") OR ("X" AND "Cin")


finally this is the entire Full Adder:






and thats is for basics

if u understand most of this ^^^

then u should be good to go ahead to CPU