Missing information on how a CPU works? I want to learn!

lcandy

Distinguished
Jul 14, 2006
260
0
18,780
Hi all,

I’m looking for an explanation of how CPU’s work. I’m going to explain roughly what I know already (I say that with some scorn, as on this level I know very little), and a brief explanation of the level I’m at in general.

Let’s say, I’m using Windows XP, and I tell the computer, factorise this cubic equation (perhaps a small macro written in Excel). In a general explanation, executing this command, will have the CPU draw the information from the RAM on what to do, it will then start decoding the macro within Excel. It will return the lower level commands to memory and repeat until it is in the form it likes (because the language is VBasic and 1’s and 0’s are required?).

Once it has its 1’s and 0’s it will start executing the commands, trying various factors until the conditions are met. It will then return the solution to memory and re-process them until they are in a form in which Excel likes, finally displaying them on the screen.

That’s a rough, how thing’s work in general, from what I can gather. Now the CPU bit, which is even less clear to me.

Electricity flows towards the CPU from the RAM in fits and starts, i.e. 1’s are electricity, and 0’s are no electricity? As these first bits of 1’s and 0’s enter the CPU, it recognises what it must do with the rest, somehow and then somehow points the rest of the electricity in the right direction. Almost like on off switches in a puzzle, each combination of on and off, results in a new set of on and offs. But how? What makes this actually happen?

This last bit is really hazy and I constantly struggle to put into words. I have a feeling I know what happens, but nothing concrete. For years I have wondered what exactly happens, now I want to find out.

My level of education is thus: post graduate with up to, an equivalent of a Masters. Specialities in business, accounting, maths and education. I’m really dyslexic though (reading technical information that I am unfamiliar with is torture), so researching is my weakest point, and why I’ve asked here rather than look through the impossibly colossal WWW. So basically, I’m a smart girl mostly and I can understand most levels of explanation, but where there are heavy uses of unfamiliar terminology, my head’s going to explode.

For anyone with an interest in this sort of thing, I figure it could be quite cool topic, which also does not mention CPU manufacturers. There are two topics also really, how computers work on a general level, with operating systems and programs etc. Then what physically happens on the CPU level.

P.S. if you don’t like the topic idea or think it’s too dumb, please simply PM me with your insults and leave the thread clean :D
 

306maxi

Distinguished
Feb 7, 2006
679
0
18,980
Hi all,

I’m looking for an explanation of how CPU’s work. I’m going to explain roughly what I know already (I say that with some scorn, as on this level I know very little), and a brief explanation of the level I’m at in general.

Let’s say, I’m using Windows XP, and I tell the computer, factorise this cubic equation (perhaps a small macro written in Excel). In a general explanation, executing this command, will have the CPU draw the information from the RAM on what to do, it will then start decoding the macro within Excel. It will return the lower level commands to memory and repeat until it is in the form it likes (because the language is VBasic and 1’s and 0’s are required?).

Once it has its 1’s and 0’s it will start executing the commands, trying various factors until the conditions are met. It will then return the solution to memory and re-process them until they are in a form in which Excel likes, finally displaying them on the screen.

That’s a rough, how thing’s work in general, from what I can gather. Now the CPU bit, which is even less clear to me.

Electricity flows towards the CPU from the RAM in fits and starts, i.e. 1’s are electricity, and 0’s are no electricity? As these first bits of 1’s and 0’s enter the CPU, it recognises what it must do with the rest, somehow and then somehow points the rest of the electricity in the right direction. Almost like on off switches in a puzzle, each combination of on and off, results in a new set of on and offs. But how? What makes this actually happen?

This last bit is really hazy and I constantly struggle to put into words. I have a feeling I know what happens, but nothing concrete. For years I have wondered what exactly happens, now I want to find out.

My level of education is thus: post graduate with up to, an equivalent of a Masters. Specialities in business, accounting, maths and education. I’m really dyslexic though (reading technical information that I am unfamiliar with is torture), so researching is my weakest point, and why I’ve asked here rather than look through the impossibly colossal WWW. So basically, I’m a smart girl mostly and I can understand most levels of explanation, but where there are heavy uses of unfamiliar terminology, my head’s going to explode.

For anyone with an interest in this sort of thing, I figure it could be quite cool topic, which also does not mention CPU manufacturers. There are two topics also really, how computers work on a general level, with operating systems and programs etc. Then what physically happens on the CPU level.

P.S. if you don’t like the topic idea or think it’s too dumb, please simply PM me with your insults and leave the thread clean :D

Goes into the socket and the magical little binary leprechauns move the 0's and 1's around. If you know what purpose the CPU serves there is really no need to know how it does it tbh.
 

jimw428

Distinguished
Jul 9, 2006
392
0
18,780
It sounds like you're looking for "instant soup" (simple answers to complex questions). To answer your question properly would require a great of time and pages upon pages of material. I suggest you visit the Intel and/or AMD web sites where you will find a wealth of information.

It's not as simple as 1's and 0's being switched on and off. I'm not sure what level of understanding you're seeking, but I doubt you'll find it here. I have a EE, and many years of experience in computing, and I can't answer your question in a couple of paragraphs. Perhaps someone else can.
 

Pain

Distinguished
Jun 18, 2004
1,126
0
19,280
It sounds like you're looking for "instant soup" (simple answers to complex questions). To answer your question properly would require a great of time and pages upon pages of material. I suggest you visit the Intel and/or AMD web sites where you will find a wealth of information.

It's not as simple as 1's and 0's being switched on and off. I'm not sure what level of understanding you're seeking, but I doubt you'll find it here. I have a EE, and many years of experience in computing, and I can't answer your question in a couple of paragraphs. Perhaps someone else can.

No, no one can answer it in a few paragraphs.

On a very very basic level. 1's and 0's are both electricity, just different voltage, a zero is a low level and a one is a high level of voltage. The machine moves information around by looking for these voltage levels on the various paths of the machine at predetermined time periods, called the clock. Between the perdetermined time intervals, the voltages are given time to change and stabalize before the next sampling interval where they are sampled again.

There, you know everything about computers. :wink:
 

1Tanker

Splendid
Apr 28, 2006
4,645
1
22,780
It sounds like you're looking for "instant soup" (simple answers to complex questions). To answer your question properly would require a great of time and pages upon pages of material. I suggest you visit the Intel and/or AMD web sites where you will find a wealth of information.

It's not as simple as 1's and 0's being switched on and off. I'm not sure what level of understanding you're seeking, but I doubt you'll find it here. I have a EE, and many years of experience in computing, and I can't answer your question in a couple of paragraphs. Perhaps someone else can.

No, no one can answer it in a few paragraphs.If anybody can explain it, it would have to be JumpingJack . He knows mega about the technology's and workings of a processor, but i think some of what lcandy wants relates to the software side also.
 

sithscout80

Distinguished
Feb 15, 2006
239
0
18,680
I'll try to answer your question, but I'm going to have to do it in multiple posts because of time constraints in writing it. I won't answer your questions in any logical order.

First of all, the signalling with 1s and 0s.

The wires within a computer each have 2 basic properties, resistance and capacitance. When sending a signal through the a wire, it is a lot like having a rope on the ground that you yank up and down and the crest of the wave moves down the rope. The same concept applies to wires. If one end of the wire is connected to VDD (the highest voltage) and them the VDD side is changed to be GND (the lowest voltage). The change from high to low will continue to move away from the end of the wire.

I'm impressed that you are trying to understand CPUs instead of just being content with ignorance. I'll try my best to continue to explain.
 

sruane

Distinguished
Aug 18, 2006
707
0
18,980
As others have said, many thick books have been written on the subject, but I think I can contribute a paragraph, or so.

Inside the CPU there is a unit called the ALU (Arithmetic-Locical unit). This is where the wpork is done. Also in the CPU are several registers. A register is one word wide - which for a 64-bit processor will be 64 bits. The ALU does operations on the registers. Executable code is fetched from memory one word at a time and gets loaded into the ALU. Machine instructions are represented by bytes - for example a MOV (move) instrudction is a certain bit pattern, an ADC (add with carry) instruction is represented by another - and so on.

Lets say you want to add two numbers, so you load one into a register and the other into the ALU. You preform the operation and store the result in a second register. Then, in a seperate operation, you might move the result into main memory (another pair of registers will hold the address in memory)

As far as how the math works, if you can add binary numbers manually on paper, the algorthim the CPU uses is similar.

Multiplication is a series of add operations when the operator is "rotated" (shifted left one bit) and added to the ALU over and over again until the entire word has been rotated and added. The result may be written to memory after that.

Compares are similar - the contents of the ALU can be compared to the contents of a register, two registers can be compared and so on. The result will be either true or false. This condition can them be used to start fetching code out of a particular memory address.

The memory address of the code being executed is held in a register and the value in this register increments as the code executes. A branch operation (like you might get as the result of a compare) will cause a whole new address to be loaded into this register.

I suggest you get an introductory book on assembly-language programming - it'll give you a real insight into how a processor works.
 

JonathanDeane

Distinguished
Mar 28, 2006
1,469
0
19,310
If you can find it... there is an old old old book, I have a copy sitting here in front of me :)

The book is called "Computer Design" by Glen G. Langdon Jr.
The reason I recomend it is that it is so old it pretty much describes the old 8 bit machines down to the circut path level. Diode's and all that :)
and its a little easyer to understand since its dealing with stuff from a simpler time.

Remember to visit your local library !!! (Or Books a Million lol)
 

antoant

Distinguished
Jun 22, 2006
27
0
18,530
Well you have a nice general idea of what's going on, although some of the stuff you described are a bit (or maybe a couple of bits) off. Your puzzle analogy though is very good.

Now if I understand correctly you have two questions.

1.How does the on off works in the cpu
and
2.How the cpu executes instructions.

Answers:

1.The CPU is full of transistors. (You already knew this right?). All transistors are devices that act like switches. Like all switches they have three terminals. The first one is where electricity comes in, the second is where it goes out and the third is the terminal that controls if the switch is on or off (If the two other terminals are connected or not). Now, in a physical switch the third terminal is control by your finger in a transistor the third terminal is controlled by voltage (and to be more exact electrical charge but I will not go into the physics). There are two different kinds of transistors. The first one requires voltage to be present at the third terminal in order for the othe other two to be connected, while the other one does the exact opposite, when voltage is present it disconnects the other two terminals. Different combinations of transistors will yield different logical functions. If you need more details about how transistors work I know of a couple of good books which you can read.

2.I am going to try and answer this one as simply as possible. An instruction is just a sequence of ones and zeros. (1 being a certain level of voltage and 0 being 0 volts). The CPU will get an instruction from memory (This is called the fetch). Depending on what the first couple of bits (1 bit = a 1 or a 0) look like it will decide what kind of instruction it is.

ex 1010 is an add instruction
1011 is a subtract instruction
(These examples are made up if you want to know how each command is encoded you can look it up on the intel or amd website)

When it finds out what kind of instruction is executing the CPU will then decide which parts of it need to be used depending on the rest of the bits in the instruction and the instrunction itself. All these actions are called the decoding. It will then execute the instruction by doing either an arithmetic or logical operation or by storing or reading something from memory. These are a couple of stages together and they are called execute and memory access. The last stage is called a write back and this is where the CPU changes the internal state of it, if it has to. After all these stages the CPU goes back and fetches another instruction.

All of these stages are basicly different logical functions and as such they are implemented with transistors.

Again these little paragraph (compared with all the literature on the subject) is a very simplified presentation of things. Again I can direct you towards some books if you want to read some more on this.

If you have any more questions about the subject let us know.
 
G

Guest

Guest
There is a book by Andrew S. Tanenbaum and James Goodman. It's called Computer Architecture. Starts at the beginning and will answer your question.
 

Pain

Distinguished
Jun 18, 2004
1,126
0
19,280
The probelm is that in the original post it says she has problems reading books. I don't think she is going to have a better time by reading forum posts, especially with everyone jumping around like a mexican jumping bean, but that's another subject. :wink:
 
G

Guest

Guest
Well; there are two ways to learn it. Take classes or read a book. Consulting a forum is surely not the way to go. If this person really cared about learning something like this she wouldn't bother with books right?
 

sithscout80

Distinguished
Feb 15, 2006
239
0
18,680
I found a useful website if you want to learn about logic of a computer. It runs all on Java, but is interactive learning.
Hades Simulation Framework

If you do feel like reading a book, there is one author I would recommend, Grant McFarland. The book is called Microprocessor Design. I took 7 classes that were created by him and are based on the book (The classes are only available to Intel employees). He teaches at a level for non-engineers and makes understanding the concepts really easy.
 

jimw428

Distinguished
Jul 9, 2006
392
0
18,780
The probelm is that in the original post it says she has problems reading books. I don't think she is going to have a better time by reading forum posts, especially with everyone jumping around like a mexican jumping bean, but that's another subject. :wink:

If she can't read a book, I wonder how she got the education she claims to have. :eek:
 

lcandy

Distinguished
Jul 14, 2006
260
0
18,780
First off, I said I was dyslexic and researching/reading was not my strong point. I actually have several coping strategies, but as I stated, find reading material where the use of unknown terminology is prevalent, really difficult. I've read many books, but find I learn very poorly with that method. Practical experience is always the best for me, sadly, I am not in a position to take a non-theoretical course on this. For anyone that is interested, you can learn more about this at this good site.

Ok, some fantastic answers here, I already feel the wiser. I also feel totally cool with the "on off" mechanism inside the CPU now. That's great!

There's still something missing though. I can't seem to grasp the concept of the execution of code. I'm switching between antoant's and sruane's posts, trying to piece it together, but am not there yet. I sort of get the "what it does bit", but the how is still a mystery. For example, how are those words or bits of data compared between the register and the ALU? If it returns a true or false (1 or 0?) does that mean, based on what is in the ALU, it will either change the output or simply write a 1 or 0 back to a memory address? Was this what, “changes the internal state of it” meant? If so, by which method does it do this?

I do expect I am trying to learn too much in one go, perhaps in the wrong place, but I really appreciate the efforts of you guys that tried to help. I’ll consider taking a look at that book, but ugh, a whole book? Do I have to? :wink: I’m interested enough to do so at this stage (and feel more empowered with knowledge to not fear opening up a book on this).

Thanks again!!! 8)
 

sruane

Distinguished
Aug 18, 2006
707
0
18,980
I'll try to elaborate a little more on code execution.

First, a word is however many bits one of the registers in the processor can hold. A 64-bit processor is using a 64 bit word.

lets say you load regisers CX with FFh (all bits on) and DX with the value found in some random memory location

Load BX with a location in memory you want executed if these values don't match.

and you execute the instruction
CMP CX,DX

The compare (CMP) instruction does a bitwise compare of the values in the registers and returns FALSE if any of the bits don't match)

You might follow with a JNE (jump if not equal)

JNE BX (jump to the memory address in register BX and resume execution there)

The processor will start fetching code starting at the address stored in BX and start executing it.

A word in memory is just bits. Some of these bits are instructions, some are data. The instruction set is built into the processor and the processor can tell the difference between code and data, based on the instruction.

I hope that helps a little
 

1Tanker

Splendid
Apr 28, 2006
4,645
1
22,780
First off, I said I was dyslexic and researching/reading was not my strong point. I actually have several coping strategies, but as I stated, find reading material where the use of unknown terminology is prevalent, really difficult. I've read many books, but find I learn very poorly with that method. Practical experience is always the best for me, sadly, I am not in a position to take a non-theoretical course on this. For anyone that is interested, you can learn more about this at this good site.

Ok, some fantastic answers here, I already feel the wiser. I also feel totally cool with the "on off" mechanism inside the CPU now. That's great!

There's still something missing though. I can't seem to grasp the concept of the execution of code. I'm switching between antoant's and sruane's posts, trying to piece it together, but am not there yet. I sort of get the "what it does bit", but the how is still a mystery. For example, how are those words or bits of data compared between the register and the ALU? If it returns a true or false (1 or 0?) does that mean, based on what is in the ALU, it will either change the output or simply write a 1 or 0 back to a memory address? Was this what, “changes the internal state of it” meant? If so, by which method does it do this?

I do expect I am trying to learn too much in one go, perhaps in the wrong place, but I really appreciate the efforts of you guys that tried to help. I’ll consider taking a look at that book, but ugh, a whole book? Do I have to? :wink: I’m interested enough to do so at this stage (and feel more empowered with knowledge to not fear opening up a book on this).

Thanks again!!! 8)
I find that Hardware Secrets has some pretty good tutorials on various hardware, and technical items. If you're like me(sounds like it) you can bookmark it, then go in and read a page or two every day, so as to not overload your mind all at once. :wink:

http://www.hardwaresecrets.com/

This one should help you out. :)

How a CPU Works:

http://www.hardwaresecrets.com/article/209
 
Probably the simplest point to start with is a flip-flop which is an arrangement of transitors that allow you to store, read and write 1 bit of data, i.e. a 0 or a 1. Aside from in RAM these also exist as registers that are words of bits, i.e. 8, 16 or 32 bits depending on the age of the CPU.

Beyond this there are specialist arrangements, that add, count (a type of adding) and do other functions.

If you want to start educating yourself these are all functions of boolean logic and truth tables. You should be able to use the term flip-flop to get you started I think.

This is all a bit hazy for me as the last time I covered anything like this in 1989ish. and we were only looking at theory.

Hope this helps a little, but yes you are potentially getting out of your depth trying to understand how a modern CPU works, but an old one was fairly easy, and the principles are similar, just managed differently and on a different scale and with massively different degrees of parallelism. From a technical terminology viewpoint, I wouldn't think there was much to learn at that level.
 

jimw428

Distinguished
Jul 9, 2006
392
0
18,780
God, what a bunch of techno gibberish being posted in response to the question she asked. However well intentioned, how could you expect her to understand what a "flip flop" is and how it works?

And I love the example using CX, DX and BX registers and executing a compare and jump not equal. What makes you think she knows hexadecimal (FFh) and how does that post answer this question?

Electricity flows towards the CPU from the RAM in fits and starts, i.e. 1’s are electricity, and 0’s are no electricity? As these first bits of 1’s and 0’s enter the CPU, it recognises what it must do with the rest, somehow and then somehow points the rest of the electricity in the right direction. Almost like on off switches in a puzzle, each combination of on and off, results in a new set of on and offs. But how? What makes this actually happen?

Icandy, I said it before and I'll say it again. There are no short cuts to knowledge, and this isn't the place for the answers you seek. If you have trouble reading a book, how can you read and comprehend what's posted here?

BTW, who in the world calls themselves "eye candy"?
 

antoant

Distinguished
Jun 22, 2006
27
0
18,530
Dude you are probably right if by knowledge you mean the knowledge needed to design high speed ASICs for a living. However, I don't think that the original poster wants to learn how to design ICs for a living, she just wants to learn how the little tiny thing, that she pays $200 for, does its job. And I am sure that knowledge can be had here on this forum and that is why I replied to the question as best as I could.

At least she is asking for a simple answer to something that is hard to learn by yourself if you don't know anything about it and not the same old "Should I buyt this video card or that video card or should I wait for DX10" question. That is something that you can easily research by yourslef because the same question has been asked 1000 times. The question the OP asked is not.
 

exit2dos

Distinguished
Jul 16, 2006
2,646
0
20,810
Powerpoint slideshow for "The Little Man Computer"

The little man computer is a model designed to assist in the understanding of the fetch/execute cycle, through the visualization of elements of the computer architecture that would normally remain hidden.

We hope that by using this tool, you will be able to form a better understanding of the five basic components of a processor and the ways in which they interact, as each instruction is carried out.

This is augmented by the capability to get the little man to 'test' you to see if you have learned the paths that he takes on his day to day routine. By visualizing the components, and their interactions, we hope that you can gain a fuller understanding of the fetch/execute cycle.

Main Page Link

A good place to start. :D