I can't get my head around how microchips work.
April 12, 2004 2:28 PM   Subscribe

How do microchips work?

I understand it at a very basic level. I know that when you apply current to a semiconductor, it becomes conductive, and that this closes the gate in a transistor. By opening or closing the right gates, you're able to do basic counting and logical operations.

Here though, my conceptual model totally falls apart. Because try as I might, I can't get my head around exactly what it is that controls the current going to the semiconductor in the gate in the first place. How does the microprocessor know to open or close a particular gate? It seems like if it already knew to open or close a gate, then the operation has already been done. It's like you'd need another microprocessor controlling the current within the first microprocessor, and so an and so on back to some omniscient prime mover.
posted by willnot to Computers & Internet (13 answers total)
I'm not certain it answers your question completely, but this might help somewhat.
posted by Grod at 2:34 PM on April 12, 2004

Obviously there's no "prime mover," but I think the bit that's missing from your conceptual model is that a gate's on/off state can be controlled by more than one other gate, and eventually by multiple inputs: the clock signal, data on the bus, your mouse wiggling, whatever. Once you've got AND and NOT gates (or a NAND) and some buffering, you can pretty much control the computational universe.

Rather than receding into the distance toward a single omniscient transistor, a complex integrated circuit both folds in on itself and spreads outward in complexity.
posted by majick at 2:46 PM on April 12, 2004

there's a clock. so the setting of one gate alters another only at the next clock tick (you can design circuits that do this). so the process isn't instantaneous - gates change, which then change other gates, step by step.

the prime mover is the program, which is read off disk, and used to set some gates. the rest is just clockwork, as you have noticed.
posted by andrew cooke at 2:52 PM on April 12, 2004

Well, if programs only ever operated on internal data--that is, data contained within the program itself, you'd be exactly right. There'd be no point in writing a program that figured out 2+3 if you could simply store the result, 5.

But of course, programs don't operate just on internal data, they operate on user input, etc. It's hard to trace the logical flow from "user waves mouse around and clicks" down to the level of individual AND and OR gates, but suffice it to say that as long as there can be novel information coming into the system, the states of these gates can change unpredictably, and these changes will ripple through the code being executed.

When one gate's state changes, it will affect other gates that are connected to it. And some of these gates are (indirectly) connected to the outside world.
posted by adamrice at 2:54 PM on April 12, 2004

How Stuff Works tells you... er, how it works. They have a really good walk-through on the progression from user question, to code, to assembly, to the actual processor work.
posted by falconred at 3:01 PM on April 12, 2004

Starting with Von Neumann architecture may help.
A microprocessor consists of four basic elements. These are arithmetic, memory, control, and connection.

As I understand it ... (This may not be correct)

Connection is easy, and is simply the link from the microprocessor to the outside world. The link to the I/O consists at its most basic level of a number of switches. These can be read / or written to.

Memory can be treated in the same way as a connection, but as well as holding data, it also holds a list of computer instructions. The rest of the processor has the ability to read a specific section of memory and to write to a piece of memory. There are a number of special memory areas called registers, and these are used extensively in programs, and there are specific sections of the microprocessor designed to interact with these. The most important register is the current position being executed in memory.

The control section - I think - manages all this, and ensures that the timing is correct.

The Arithmetic unit has the ability to add, xor, multiply, etc numbers.

A basic program - adding a number to itself three times would look like this...

Assuming the number to be added is in memory position 1100.

position, command.
998, put 3 in register C
1000, Get Memory Address 1100 into register A
1002, Get Memory Address 1100 into register B
1005, Add A to B
1006, put B to memory 1100
1009, reduce register C by 1
1010, if C = 0 change the Program Position to 1000
1013 - finished......
1100, 900

The microprocessor will have the value 998 in it's program position register, and will inspect the instruction at 1000.
There will be explicit hardware in the control unit to route this value and the value after it (1100) to the memory section of the microprocessor. (Like a grading machine on an egg sorter). Likewise, the memory section of the microprocessor will (using NAND gates and the like) will use the instruction to get the value at the required memory position. On the next clock cycle, the control unit will increment the program position (using the arithmetic unit) by 3. This is all done using Logic Gates, and as such, there is no program controlling this.

With the program position register incremented, the microprocessor is in exactly the same position as it was when it started running the program. The whole cycle can then begin again.

The question you're asking I suppose is how does the control unit know how to send instructions to the memory unit, etc. I doesn't. It has a number of states, and these are controlled by the clock. When the control unit recieves a clock pulse, it pushes what is in is registers out to the various units, waits a tick, (So the registers can be written back), and then increments the program position. The arithmetic unit, etc have filters in front of them that only deal with instructions that they know how to deal with. Likewise, the arithmetic unit will have a filter in it which will take a command like "add" and filter the contents of the registers to the correct part of the microchip.

Like I say, this is mostly from memory, and theres a bit of guesswork in there, but hopefully, if I've got anything wrong, people can put me right.

What is truly amazing is that the very basic instruction sets described above can be used to create something as complicated as an operating system or a word processor.
posted by seanyboy at 3:33 PM on April 12, 2004


I can go deeper if you want or if I've gone in the wrong direction for this
but if I understand your question it's: There's all these transistors in
a microprocessor. When you turn it on how does it know what to do?

The microprocessor is a machine, and it has certain operations that it's
designed to do as soon as power is turned on. If you simplify a microprocessor
all it ever does is execute instructions in memory. These instructions tell
it to read in memory from other locations, do calculations on them, and write
them out to yet another memory location. When it's first turned on it's
programmed to start executing code at some predetermined location. If you
store code in this location then as soon as power is applied it'll start
executing it. This is like the BIOS on a PC. The PC is turned on, it executes
the BIOS and then the BIOS in turn does loads up other code to do more
complicated things.

That's the 1000 meter view of a microprocessor. If you zoom in for the
nanometer view then you see individual transistors. If you look at them
they're usually wired in serial and parallel combinations. You can think
of them as bits of pipe connected in series or parallel with taps in
between them.

In a series connection if only one tap is opened up water doesn't flow. If
you open both taps water does flow. In parallel if either or both taps are
opened then water flows but if both are closed then water doesn't flow. In
a circuit the flowing water can be hooked up to a tap to turn it on or off.
posted by substrate at 3:37 PM on April 12, 2004

Read Code. It starts at the level of switches and relays and conceptually builds more complex cirucits from there.

The short answer to your question is, the various circuits in a computer are controlled by other circuits which are controlled by other circuits which are controlled by other circuits, etc. until you finally get to a circuit that is controlled by data stored in memory. This data is a list of codes for the operations the processor can perform and information on what data to perform these operations on, and we call it a program.
posted by kindall at 3:50 PM on April 12, 2004

The answer is ROM (Read Only Memory). The CPU has small amounts of ROM along with everything else in it, so as soon as it is powered on it will already know some things and run certain codes to prepare itself to begin receiving input from the outside.
posted by NortonDC at 4:26 PM on April 12, 2004

Or, what substrate said.
posted by NortonDC at 4:28 PM on April 12, 2004

Also key to the design of microprocessors is feedback. Connecting groups of gates' inputs back to their inputs creates a flip-flop. Flip-flops output a steady signal until they get tripped by an input. For example, in an S-R flip-flop, triggering the S input momentarily makes the flip flop output a steady signal forever, until the R input is triggered. This is the basic way RAM storage and the temporary storage registers inside a CPU work.
posted by zsazsa at 8:41 PM on April 12, 2004

Response by poster: Thanks all. Very informative/interesting.
posted by willnot at 11:38 PM on April 12, 2004

Bebop Bytes Back by Brown & Maxfield is the absolute best book out there for explaining this and a lot more in what would be excrutiating detail, if it weren't so well written. Bebop Bytes Back takes you through the design of a computer from individual transistors on up. Bebop to the Boolean Boogie by Maxfield deals with electronics in general. Both are technical, but aimed at the intelligent layperson who's willing to do some work.
posted by tdismukes at 7:55 AM on April 13, 2004

« Older Food photography camera   |   DVD +/- RW format war. Newer »
This thread is closed to new comments.