Code_ The Hidden Language of Computer Hardware and Software - Charles Petzold [67]
It's fairly easy to assemble multiple 1-bit latches into a multibit latch. All you have to do is connect the Write signals:
This 8-bit latch has eight inputs and eight outputs. In addition, the latch has a single input named Write that's normally 0. To save an 8-bit value in this latch, make the Write input 1 and then 0 again. This latch can also be drawn as a single box, like so:
Or to be more consistent with the 1-bit latch, it can be drawn this way:
Another way of assembling eight 1-bit latches isn't quite as straightforward as this. Suppose we want only one Data In signal and one Data Out signal. But we want the ability to save the value of the Data In signal at eight different times during the day, or maybe eight different times during the next minute. And we also want the ability to later check those eight values by looking at just one Data Out signal.
In other words, rather than saving one 8-bit value as in the 8-bit latch, we want to save eight separate 1-bit values.
Why do we want to do it this way? Well, maybe because we have only one lightbulb.
We know we need eight 1-bit latches. Let's not worry right now about how data actually gets stored in these latches. Let's focus first on checking the Data Out signals of these eight latches using only one lightbulb. Of course, we could always test the output of each latch by manually moving the lightbulb from latch to latch, but we'd prefer something a bit more automated than that. In fact, we'd like to use switches to select which of the eight 1-bit latches we want to look at.
How many switches do we need? If we want to select something from eight items, we need three switches. Three switches can represent eight different values: 000, 001, 010, 011, 100, 101, 110, and 111.
So here are our eight 1-bit latches, three switches, a lightbulb, and something else that we need in between the switches and the lightbulb:
The "something else" is that mysterious box with eight inputs on top and three inputs on the left. By closing and opening the three switches, we can select which of the eight inputs is routed to the output at the bottom of the box. This output lights up the lightbulb.
So what exactly is "What Is This?"? We've encountered something like it before, although not with so many inputs. It's similar to a circuit we used in Chapter 14 in the first revised adding machine. At that time, we needed something that let us select whether a row of switches or the output from a latch was used as an input to the adder. In that chapter, it was called a 2-Line-to-1-Line Selector. Here we need an 8-Line-to-1-Line Data Selector:
The 8-to-1 Selector has eight Data inputs (shown at the top) and three Select inputs (shown at the left). The Select inputs choose which of the Data inputs appears at the Output. For example, if the Select inputs are 000, the Output is the same as D0. If the Select inputs are 111, the Output is the same as D7. If the Select inputs are 101, the Output is the same as D5. Here's the logic table:
Inputs
Outputs
S2
S1
S0
Q
0
0
0
D0
0
0
1
D1
0
1
0
D2
0
1
1
D3
1
0
0
D4
1
0
1
D5
1
1
0
D6
1
1
1
D7
The 8-to-1 Selector is built from three inverters, eight 4-input AND gates, and an 8-input OR gate, like this:
Now, this is a fairly hairy circuit, but perhaps just one example will convince you that it works. Suppose S2 is 1, S1 is 0, and S0 is 1. The inputs to the sixth AND gate from the top include S0, 1, S2, all of which are 1. No other AND gate has these three inputs, so all the other AND gates will have an output of 0. The sixth AND gate from the top will possibly have an output of 0 if D5 is 0. Or it will have an output of 1 if D5 is 1. The same goes for the OR gate at the far right. Thus, if the Select inputs are 101, the Output is the same as D5.
Let's recap what we're trying to do here. We're trying to wire eight 1-bit latches so that they can be individually written to using a single Data In signal and individually examined using