Register
This article is a continuation of the article describing the digital computer. This article is the only one in the series that describes how the hardware in a computer works at a relatively detailed level. Registers are primarily a part of the CPU portion of a digital computer. A CPU uses registers to store temporary data and can also use them to hold data that controls hardware. Each register can typically hold one word of data.
[edit] Hardware design
A digital computer is built using millions of transistors. However, the hardware design can be abstracted to the point of using Boolean logic elements to represent the design. Digital functions are based on the idea of a switch that can be either on or off. Generally this can be represented as a high value (1) when the switch is on and a low value (0) when the switch is off. These values of 1 and 0 can abstractly represent the state of the hardware switch.
Basic logic functions can typically include AND, OR, and Invert functions combined to form more advanced logic. Inverting means that a high signal level (1) on the input to the device will be converted to a low level signal (0) on the output. Truth tables are used to show how the logic works.
input | output |
---|---|
0 | 1 |
1 | 0 |
Inverters can be discrete logic elements or can be combined with other logic elements. For example an inverter and a AND function can be combined to form an NAND function, also known as a gate. It has been said that an entire computer can be built using nothing but NAND gates. The truth table for a two input NAND gate is:
input | output | |
---|---|---|
A | B | C |
0 | 0 | |
0 | 1 | |
1 | 0 | |
1 | 1 |
Which can be interpreted to mean that the output is 0 only if both A AND B are 1's. Otherwise the output is a 1.
Note that it is also true that the output is a 1 if A OR B are 0's, hence the idea that this gate could also perform an inverted OR function. If the A and B inputs were tied together it can be shown that the logic will be exactly the same as the inverter function. Thus a NAND gate can perform AND, OR, and INV logic. It is possible to easily add more inputs to extend the function capabilities. You could even feed the output back to the input to produce an oscillator or clock at the frequency based on the delay of the signal going through the gate.
[edit] Flip-Flop
A simple form of a flip-flop is shown in the figure. A flip-flop is a storage element in that in the absence of a signal on the input the logic state will be remembered. This feature is formed by tying the output of one gate to the input of the other.
input | output | ||
---|---|---|---|
S | R | Q | /Q |
0 | 0 | 1 | 1 |
0 | 1 | 1 | 0 |
1 | 0 | 0 | 1 |
1 | 1 | Q | /Q |
Note that when the inputs are both high the output is whatever it was before which means it can remember the value that is stored inside the flip-flop.
[edit] Register
A computer register can be built by using multiple flip-flops were each flip-flop stores one bit from the register word. Real register design uses a more complicated flip-flop than the one shown here which is just an illustration. This one can have a problem if both the R and S inputs are switched to a 1 an exactly the same time. It would be unclear what the value stored in the flip-flop would be under this condition (called a race condition).