Online Book Reader

Home Category

Code_ The Hidden Language of Computer Hardware and Software - Charles Petzold [62]

By Root 1619 0
a little in changing. More sophisticated counters are synchronous, in which all the outputs change at the same time.

I've labeled the outputs Q0 through Q7. These are arranged so that the output from the first flip-flop in the chain (Q0) is at the far right. Thus, if you connected lightbulbs to these outputs, you could read an 8-bit number. A timing diagram of such a counter could show all eight outputs separately, or it could show them together, like this:

At each positive transition of the Clock, some Q outputs might change and some might not, but together they reflect increasing binary numbers.

I said earlier in this chapter that we'd discover some way to determine the frequency of an oscillator. This is it. If you connect an oscillator to the Clock input of the 8-Bit Counter, the counter will show you how many cycles the oscillator has gone through. When the total reaches 11111111 (255 in decimal), it goes back to 00000000. Probably the easiest way to use this counter to determine the frequency of an oscillator is to connect eight lightbulbs to the outputs of the 8-Bit Counter. Now wait until all the outputs are 0 (that is, when none of the lightbulbs are lit) and start a stopwatch. Stop the stopwatch when all the lights go out again. That's the time required for 256 cycles of the oscillator. Say it's 10 seconds. The frequency of the oscillator is thus 256 ÷ 10, or 25.6 Hz.

As flip-flops gain features, they also gain in complexity. This one is called an edge-triggered D-type flip-flop with preset and clear:

The Preset and Clear inputs override the Clock and Data inputs. Normally these two inputs are 0. When the Preset input is 1, Q becomes 1 and becomes 0. When the Clear input is 1, Q becomes 0 and becomes 1. (Like the Set and Reset inputs of an R-S flip-flop, Preset and Clear shouldn't be 1 at the same time.) Otherwise, this behaves like a normal edge-triggered D-type flip-flop:

Inputs

Outputs

Pre

Clr

D

Clk

Q

1

0

X

X

1

0

0

1

X

X

0

1

0

0

0

0

1

0

0

1

1

0

0

0

X

0

Q

The diagram for the edge-triggered D-type flip-flop with preset and clear looks like this:

We have now persuaded telegraph relays to add, subtract, and count in binary numbers. This is quite an accomplishment, particularly considering that all the hardware we've been using was available more than a hundred years ago. We have still more to discover. But let's now take a short break from building things and have another look at number bases.

Chapter 15. Bytes and Hex


The two improved adding machines of the last chapter illustrate clearly the concept of data paths. Throughout the circuitry, 8-bit values move from one component to another. Eight-bit values are inputs to the adders, latches, and data selectors, and also outputs from these units. Eight-bit values are also defined by switches and displayed by lightbulbs. The data path in these circuits is thus said to be 8 bits wide. But why 8 bits? Why not 6 or 7 or 9 or 10?

The simple answer is that these improved adding machines were based on the original adding machine in Chapter 12, which worked with 8-bit values. But there's really no reason why it had to be built that way. Eight bits just seemed at the time to be a convenient amount—a nice biteful of bits, if you will. And perhaps I was being just a little bit sneaky, for I now confess that I knew all along (and perhaps you did as well) that 8 bits of data are known as a byte.

The word byte originated at IBM, probably around 1956. The word had its origins in the word bite but was spelled with a y so that nobody would mistake the word for bit. For a while, a byte meant simply the number of bits in a particular data path. But by the mid-1960s, in connection with the development of IBM's System/360 (their large complex of business computers), the word came to mean a group of 8 bits.

As an 8-bit quantity, a byte can take on values from 00000000 through 11111111. These values can represent positive integers from 0 through 255, or if two's complements are used to represent negative numbers,

Return Main Page Previous Page Next Page

®Online Book Reader