How are individual bits controlled inside of a CPU?

335 views

I know there are transistors to represent 1 and 0 (on and off), and I know that assembly is the lowest human-readable level you can get to telling the CPU exactly what to do. Any and all processes between that are an enigma to me, and I would love to know how it works.

In: 35

10 Answers

Anonymous 0 Comments

Transistors are simply switches. They output a high voltage or a low voltage, which we say is a 1 or a 0. We combine transistors in a myriad of interesting ways to make them do specific things. One of the most common things you can make out of a transistor is called a logic gate.

At the lowest level, a logic gate is just a device that changes it’s output based on a logical relationship between its inputs. This relationship, fortunately, is usually easily translated into English. For example, an AND gate has two or more inputs (a, b, … n) and one output. The AND gate works by changing it’s output to a 1 when input ‘a’ is 1, AND input ‘b’ is 1, and so on and so forth. If any input is not 1, the logic isn’t satisfied and the output will be 0. An OR gate works similarly but is constructed slightly differently, such that if input ‘a’ is 1, OR input ‘b’ is 1, then the output is 1.

I can combine logic gates in interesting ways too, and wind up with even more interesting components, like flip-flops and registers. There’s different kinds of both of those things, but one of the main additions to these components that isn’t present in simpler devices is what’s called a clock signal.

If I have an AND gate, and I make one input a 1, then the other, then some small amount of time will pass while the logic gate works and the output changes to one. This time is very small, but what’s more important is that it might not be exactly the same from one logic gate to the next. If don’t know how long to wait to let the logic gate do its thing, I might look at the output before it’s finished, and the output I get might not be accurate. The clock signal solves this problem. Basically, things with clock signals only read outputs, or change inputs, once a clock signal is received.

Now I have everything I need to make a computer. I have data in the form of 1’s and 0’s, and I can use logic gates to do some simple operations and draw conclusions about that data. By using clock signals, I can synchronize lots of different logic gates, and make sure everything is accurate.

When a computer program runs, it translates what we want into more and more basic instructions to the computer, ultimately breaking everything down to one of a small set of very simple operations like adding two numbers, or moving a piece of information from one place to the other. So, a clock pulse may copy some data in memory into a register, while the next clock pulse adds that data to the data in another register, and the next clock pulse stores the result in a new spot on memory, and so on and so forth. This happens billions of times a second. Some of the processing can be offloaded to other forms of hardware, and the operating system is partially responsible for determining what is the most efficient way to handle it, but at its core everything you can do on a computer boils down to taking an input, storing it somewhere, doing something to it, and outputting it somewhere else.

You are viewing 1 out of 10 answers, click here to view all answers.