![]() |
|
Tutorial Intro to CPU design [Part 1: binary and numerical systems] - Printable Version +- Sinisterly (https://sinister.li) +-- Forum: Computers (https://sinister.li/Forum-Computers) +--- Forum: Hardware & Customization (https://sinister.li/Forum-Hardware-Customization) +--- Thread: Tutorial Intro to CPU design [Part 1: binary and numerical systems] (/Thread-Tutorial-Intro-to-CPU-design-Part-1-binary-and-numerical-systems) Pages:
1
2
|
Intro to CPU design [Part 1: binary and numerical systems] - phyrrus9 - 12-21-2014 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 = 15therefore 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
------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: 1101Subtraction 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 = 15So, 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. RE: Intro to CPU design [Part 1: binary and numerical systems] - JzJad - 12-22-2014 This is electronics class from my high school all over again haha, and good job on this! RE: Intro to CPU design [Part 1: binary and numerical systems] - phyrrus9 - 12-22-2014 (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. RE: Intro to CPU design [Part 1: binary and numerical systems] - OversouL - 12-22-2014 This and part 2 of this will come in handy for me in the future. Bookmarked. May I ask what you're taking up?
RE: Intro to CPU design [Part 1: binary and numerical systems] - phyrrus9 - 12-22-2014 (12-22-2014, 07:00 AM)OversouL Wrote: This and part 2 of this will come in handy for me in the future. Bookmarked. "taking up"? I don't understand. RE: Intro to CPU design [Part 1: binary and numerical systems] - OversouL - 12-22-2014 (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?
RE: Intro to CPU design [Part 1: binary and numerical systems] - phyrrus9 - 12-22-2014 (12-22-2014, 11:54 AM)OversouL Wrote: Sorry, what I meant was what you're taking up in college? 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) RE: Intro to CPU design [Part 1: binary and numerical systems] - Motherboard - 08-23-2018 (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? Hahaha, I'm supposed to finish calculus 2 before even starting my major (CSI)
RE: Intro to CPU design [Part 1: binary and numerical systems] - KuhakuWolf - 08-23-2018 You should take a look at this video Very interesting https://www.youtube.com/watch?v=L8jqGOgCy5M RE: Intro to CPU design [Part 1: binary and numerical systems] - Samiscripte - 04-07-2019 (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. How to Calculate an Encrypted Value with RSA Encryption |