chevron_left chevron_right
Login Register invert_colors photo_library


Stay updated and chat with others! - Join the Discord!
Thread Rating:
  • 0 Vote(s) - 0 Average


Tutorial Intro to CPU design [Part 1: binary and numerical systems] filter_list
Author
Message
Intro to CPU design [Part 1: binary and numerical systems] #1
Preface
Okay, so why don't we make a series of tutorials on CPU design. I will make them complete with drawings, all of the maps, and part numbers. By the end of this series you will have a fully programmable CPU to play around with and hopefully a better understanding of how they work.
For the purpose of simplicity, I will be using a RISC-like architecture. I won't go in-depth on the pipeline used here, just know that there is a very crude implementation of one going on.


Binary and numerical systems
A binary (or base-2) numerical system is a system in which only two values are used:
HIGH - binary 1
LOW - binary 0
This is what we will use at the base level of our CPU. In CPU design we use electron states to determine logic values. We will only use 2 (of the many) electron states, since they are easy to produce. Currently no CPU on the market uses any more than two electron states, quantum computing is still in its early stages.

Counting in binary
It is actually quite simple. Since we will be using a 4-bit CPU, we will include all 4 bits in our counting. 4 different bits means that we will have 16 different values (v(n) = 2^n), so let's count to 16:
Code:
0000 = 0
0001 = 1 ;now we do something funky, we have to do a carry, resulting in this:
0010 = 2 ;1 + 1 = 10, remember that, it is important!
0011 = 3
0100 = 4; 11 + 1 = 100, because 1 + 1 = 10, then we have 1 + 1 again.
0101 = 5
0110 = 6
0111 = 7
1000 = 8
1001 = 9
1010 = 10
1011 = 11
1100 = 12
1101 = 13
1110 = 14
1111 = 15
now, why didn't we make it to 16? Simple. We have 16 possible values, that INCLUDES the 0. The maximum count for each set of bits is m(n) = v(n) - 1
therefore m(4) = v(4) - 1
or
m(4) = (2^4) - 1
or
m(4) = 16 - 1 = 15

Now, I assume you have counting in binary down, we need to work on addition and subtraction.
lets do 7+6 in binary. It helps if you have that table of binary to decimal memorized, we will go into conversion in a minute.
7 = 0111
6 = 0110
Code:
0111
0110
------
ALWAYS go from right to left. remember the rules:
0+0 = 0
0+1 = 1
1+0 = 1
1+1 = 10
Code:
0111
0110
------
xxx1 (0+1 = 1)

0100 (carry the 1)
0111
0110
------
xx01 (1 + 1 = 10)


1100 (carry the 1 again)
0111
0110
------
x101 (1 + 1 = 10, 0 + 1 = 1)

1100
0111
0110
------
1101 (0 + 0 = 0, 1 + 0 = 1)

Final answer: 1101
Now, let's check that, 1101 in binary is 13. 6+7 in decimal (base 10) is 13. SUCCESS!

Subtraction follows the same rules. I really don't need to teach you that one do I?
The only difference in subtraction is:

0000 - 0001 = 1111
When we have to borrow, and we run out of bits to borrow from, we just assume the next bit to the left (bit 5 in this case) is a 1.


numerical systems: hexadecimal
Hexadecimal is basically just a notation system for our binary, it makes it easier to write it all out. Hexadecimal (or hex) is a base-16 system, so for every 4 bits of binary we will have exactly one digit. Just memorize this table for conversion:
Code:
binary hex decimal
0000 = 0 = 0
0001 = 1 = 1
0010 = 2 = 2
0011 = 3 = 3
0100 = 4 = 4
0101 = 5 = 5
0110 = 6 = 6
0111 = 7 = 7
1000 = 8 = 8
1001 = 9 = 9
1010 = a = 10
1011 = b = 11
1100 = c = 12
1101 = d = 13
1110 = e = 14
1111 = f = 15

So, our 0111 + 0110 example, in hex can be written 7 + 6.
For compadibility, we will no longer be using decimal in ANY part of this tutorial. Every number from here out will be either written in binary or hex.



Adding or subtracting hex numbers is best done by converting to binary and using the method I described above, and then using the table to convert it back to hex. If you know the real method, use it.

Next up: binary logic! This is where stuff gets freaky. Boolean algebra and stuff. Let me know what you think/rate this thread/rep.

[+] 5 users Like phyrrus9's post
Reply

RE: Intro to CPU design [Part 1: binary and numerical systems] #2
This is electronics class from my high school all over again haha, and good job on this!
[Image: 3ztiqq-2.png]

Reply

RE: Intro to CPU design [Part 1: binary and numerical systems] #3
(12-22-2014, 01:29 AM)JzJad Wrote: This is electronics class from my high school all over again haha, and good job on this!

Actually, its going to just be a re factored version of EGEE125 (Digital fundamentals), with a more in-depth approach to some of the CPU level concepts.

Reply

RE: Intro to CPU design [Part 1: binary and numerical systems] #4
This and part 2 of this will come in handy for me in the future. Bookmarked. Smile May I ask what you're taking up?
[Image: dHJ4Beo.gif]
Hidden Lesson: Reactions are always instinctive whereas responses are always well thought of.

Reply

RE: Intro to CPU design [Part 1: binary and numerical systems] #5
(12-22-2014, 07:00 AM)OversouL Wrote: This and part 2 of this will come in handy for me in the future. Bookmarked. Smile May I ask what you're taking up?

"taking up"? I don't understand.

[+] 1 user Likes phyrrus9's post
Reply

RE: Intro to CPU design [Part 1: binary and numerical systems] #6
(12-22-2014, 07:05 AM)phyrrus9 Wrote: "taking up"? I don't understand.

Sorry, what I meant was what you're taking up in college? Smile
[Image: dHJ4Beo.gif]
Hidden Lesson: Reactions are always instinctive whereas responses are always well thought of.

Reply

RE: Intro to CPU design [Part 1: binary and numerical systems] #7
(12-22-2014, 11:54 AM)OversouL Wrote: Sorry, what I meant was what you're taking up in college? Smile

Next semester:
ENGL111 (english 2, for the 2nd time)
MATH152 (calculus 2, for the third time [wife made it impossible to go to class])
CHEM115 (chemistry 1)

Last semester:
EGNR140 (linear algebra)
ENGL111
MATH152
EGEE250 (microcontrollers 1)
PHYS231 (applied physics)

Reply

RE: Intro to CPU design [Part 1: binary and numerical systems] #8
(12-22-2014, 11:56 AM)phyrrus9 Wrote:
(12-22-2014, 11:54 AM)OversouL Wrote: Sorry, what I meant was what you're taking up in college? Smile

Next semester:
ENGL111 (english 2, for the 2nd time)
MATH152 (calculus 2, for the third time [wife made it impossible to go to class])
CHEM115 (chemistry 1)

Last semester:
EGNR140 (linear algebra)
ENGL111
MATH152
EGEE250 (microcontrollers 1)
PHYS231 (applied physics)

Hahaha, I'm supposed to finish calculus 2 before even starting my major (CSI) Yawn Yawn

[+] 1 user Likes Motherboard's post
Reply

RE: Intro to CPU design [Part 1: binary and numerical systems] #9
You should take a look at this video
Very interesting
https://www.youtube.com/watch?v=L8jqGOgCy5M

[+] 1 user Likes KuhakuWolf's post
Reply

RE: Intro to CPU design [Part 1: binary and numerical systems] #10
(12-22-2014, 07:05 AM)phyrrus9 Wrote:
(12-22-2014, 07:00 AM)OversouL Wrote: This and part 2 of this will come in handy for me in the future. Bookmarked. Smile May I ask what you're taking up?

"taking up"? I don't understand.

How to Calculate an Encrypted Value with RSA Encryption

Reply






Users browsing this thread: 1 Guest(s)