4 ms·
So, you seem to be laboring under some drastic misunderstandings. Let me try to lay out an example that may make things clearer. I have a CPU. A CPU consists
by salawat 8y ago
So, you seem to be laboring under some drastic misunderstandings.
Let me try to lay out an example that may make things clearer.
I have a CPU.
A CPU consists of a collection of general registers (data is generally read from and into here), a special set of registers containing metainformation about the state of the CPU, an arithmetic processing unit, and a clock circuit. This is a dirt simple CPU.
Now. If you're using a Von Neumann based architecture, your CPU doesn't distinguish data from instructions. (Modern ones do, but ignore that for now.)
An "instruction" consists of an op-code (basically a number), plus addresses indicating where input data is being read from, and where it's being written to.
So a set of commands for this CPU might look like
load $1 1
load $2 1
Add $1 $2 $3
Assuming we're "wired" into some input pin the CPU knows to listen to, we're running a rudimentary set of computations. We're sending in some number that the CPU recognizes as the beginning of a "load" command, it looks at the 8 bits or so following, and loads 00000001 into register $1. Done for that cycle.
Next cycle, same deal, but in register $2.
Next cycle, we send the contents of $1 and $2 to the adder, which outputs the result into $3.
Easy right?
Now. Let's do some REAL computation. Let's say I have a ridiculous amount of data to crunch.
I have 30 8 bit registers for general use, and my 5 or 6 special registers, and my input pin.
But I have 300000000000000 8 bit numbers that I want to add!
I can make this work with just the CPU logic. I can do a bunch of serial computations, then record the results by hand, and re-input that result as an input to the next computation over and over again, But dear God, that's boring!
Wouldn't it be great if somehow, I could stage all of my information ahead of time, and somehow have the processor look up that information to do it's calculating, with out me having to remember everything for it?
The answer to that conundrum is Random Access Memory. It's a separation of concerns if you will.
CPU's do computation. That's what they are for. Doing the stuff that might cause a state change. We don't want values sticking around in the processor that aren't changing if we can help it. Once something is done we want it out of the processor so we can accommodate the next state changes.
In CS, we tend to have two main axes on which we measure the footprint of computation: CPU time, and space (memory footprint).
If I have high space constraints, I can set up the CPU to handle all the state, but for every new computation, I have to reset everything back to basics, and still keep track of all my information. This quickly turns a simple one cycle operation into many cycles worth of operation and bookkeeping about where everything is.
Or, If I have memory to write to, I can do my computation, write it out to somewhere that's memory managed, and let the magic Memory Management Unit feed me new data and instructions while also cleaning up results, and holding onto them elsewhere on the motherboard so I can use my full CPU die to do computations more quickly.
Look at it like having a helper to get books for you at a library while you're sitting at home reading books and doing math problems.
The library is RAM, you are the CPU, and your home is the CPU cache. Without your helper fetching books for you, you have to stop all the time, and take the books you're done with back, check out new ones, go home, and only then start doing math again. (You're not independently wealthy, or psychic, so absurdly big house, or magical access to all of the books by telekinesis is not allowed, sorry!)
With your helper, you're doing math (yay!), and he/she's swapping out books to/from the library to keep you running smoothly.
Try not to get caught up thinking about wires. Circuits have about as much to do with Computer Science as a scalpel does to Surgery. They're a tool. Nothing more. The important thing is to understand how all the pieces work together to create a functional whole.
If you're still confused about why RAM is a thing, let me introduce you to
https://en.m.wikipedia.org/wiki/ENIAC https://en.m.wikipedia.org/wiki/ENIAC
A computer that, quite literally, was absolutely dependent on the people around it to play the role of "memory" since each computation required rewiring the damn thing.
Ain't nobody got the patience for that anymore!
- terrycody 8y agohey sir, first thank you so much for your typing, this must cost you some times, really appreciated actually trying to help a stupid guy! I googled another several hours till now, yes still confusing as hell, but I indeed learned a lot new things regard "Memory", I think my problem lies in PC architecture, why engineers design a PC like this bla bla, and I indeed know its because practical usage to do this lol, just can't get the real CORE of WHY this. I understand most part of what u said, yes its all about efficiency and best practices. What I still confused about is am I right about the wires things? For example, I don't care about the efficiency or engineering reasons to have "individual Memory" for computers, now I want to build my own PC, I just want to use the wires inside a CPU to do everything! Say, we have a ton of wires now in my CPU, fist input 2 8 bits number, 00000011 and 00100101, because the wires got voltage when it got "1", this wire will always keep at "1" if I don't rewrite any of these wires to another value. So now let's send this 2 number to an adder, so maybe adder need locate the wire numbers (in this case, #1-16), or adder need physically wired onto those 16 lines or whatever,(I think this way is impossible, because if connected, the charges will flow through already, make it harder to add them together?! ) Anyway, if first method is doable, then in my CPU, I done the calculation without any Memory system lol. If I need more numbers, just use more wires! (sry I don't know how many such circuits inside a CPU, I think its limited though) ---------------------------------------------------------------- I think there must be errors of this such logic, just I don't where :( I can't find the exact thing online, I think I am just a fool, because maybe nobody think like this, I fall into some wrong circle. Maybe at the very end of day, just try to convince myself like this: why PC need memory system? because we need store data. Why not just use wires inside a CPU? Because its not efficient lol. Thank you for your help again, I think I will face more problems along the way, what a though journey to self taught CS :(
- pwg 8y ago> What I still confused about is am I right about the wires things? No, you are not right about the wires thing. In my other answer, one of your statements implied you seem to think of wires and transistors as the same, but they are not. Wires transport voltages around between the transistors, the transistors switch on/off depending upon what voltages the wires transport to them. The combination of the wires transporting different voltages at different points in time, and the transistors switching on/off dependent upon the transported voltages, is what creates the basic building block of a CPU. > Anyway, if first method is doable, then in my CPU, I done the calculation without any Memory system lol. Is your real question here this one: "Why is the memory located in a separate box apart from the CPU"? Because if that is your real question, then there is a good explanation of why this is so. It is so because the best design of the circuits for the CPU portion is different from an engineering perspective than the best design for the circuits for the RAM portion. And due to restrictions on integrated circuit manufacturing, it is easier and cheaper to build the two components separate, using different integrated circuit techniques, and then connect them together via bus lines, than to build them all together in one single component. The circuit designs for the CPU center around fast operation often at the expense of additional energy consumption. The circuit designs for bulk memory (RAM) center around much lower energy consumption (often at the expense of some speed of operation) and very high density packing of storage cells. Attempting to mix both of these techniques on a single chip is possible, but much more expensive and difficult than building them independently on separate chips. But, also, there have been experimental CPU designs that attempt to do some of what you suggest, the (generally) external RAM cells are actually built on the CPU itself, right near where the data stored therein will be used by the CPU. So what you suggest has been done, it is just not the design that gained traction for our current IBM-PC architecure PC's. Also, one other item to consider. If you build a CPU and RAM on the same chip, then to offer different amounts of RAM in the market, you have to design and build different chips. But if you build the CPU separate from the RAM, you can change the amount of RAM in a system by adding/subtracting RAM modules (presuming the system was designed with plugs for adding/subtracting RAM modules) while only having to build one kind of CPU chip, and one kind of RAM module. Lower cost of production, much more market flexibility.