Online Book Reader

Home Category

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

By Root 1601 0
a 2-to-1 Selector and a 1-to-2 Decoder, as shown on the next page.

The Select input that goes to both the Decoder and the Selector essentially selects between the two 8 x 1 RAM arrays. It's really a fourth address line. So this is actually a 16 x 1 RAM array:

This RAM array stores 16 values, each of which is 1 bit.

The number of values that a RAM array stores is directly related to the number of Address inputs. With no Address inputs (which is the case with the 1-bit latch and the 8-bit latch), only one value can be stored. With one Address input, two values are possible. With two Address inputs, four values are stored. With three Address inputs, eight values, and with four Address inputs, sixteen values. The relationship is summed up by this equation:

Number of values in RAM array = 2Number of Address inputs

I've demonstrated how small RAM arrays can be constructed, and it shouldn't be difficult to imagine much larger ones. For example

This RAM array stores a total of 8196 bits, organized as 1024 values of eight bits each. There are ten Address inputs because 210 equals 1024. There are eight Data inputs and eight Data outputs.

In other words, this RAM array stores 1024 bytes. It's like a post office with 1024 post office boxes. Each one has a different 1-byte value inside (which may or may not be better than junk mail).

One thousand twenty-four bytes is known as a kilobyte, and herein lies much confusion. The prefix kilo (from the Greek khilioi, meaning a thousand) is most often used in the metric system. For example, a kilogram is 1000 grams and a kilometer is 1000 meters. But here I'm saying that a kilobyte is 1024 bytes—not 1000 bytes.

The problem is that the metric system is based on powers of 10, and binary numbers are based on powers of 2, and never the twain shall meet. Powers of 10 are 10, 100, 1000, 10000, 100000, and so on. Powers of 2 are 2, 4, 8, 16, 32, 64, and so on. There is no integral power of 10 that equals some integral power of 2.

But every once in a while they do come close. Yes, 1000 is fairly close to 1024, or to put it more mathematically using an "approximately equal to" sign:

210 ≈ 103

Nothing is magical about this relationship. All it implies is that a particular power of 2 is approximately equal to a particular power of 10. This little quirk allows people to conveniently refer to a kilobyte of memory when they really mean 1024 bytes.

Kilobyte is abbreviated K or KB. The RAM array shown above can be said to store 1024 bytes or 1 kilobyte or 1K or 1 KB.

What you don't say is that a 1-KB RAM array stores 1000 bytes, or (in English) "one thousand bytes." It's more than a thousand—it's 1024. To sound like you know what you're talking about, you say either "1K" or "one kilobyte."

One kilobyte of memory has eight Data inputs, eight Data outputs, and ten Address inputs. Because the bytes are accessed by ten Address inputs, the RAM array stores 210 bytes. Whenever we add another address input, we double the amount of memory. Each line of the following sequence represents a doubling of memory:

1 kilobyte = 1024 bytes = 210 bytes ≈ 103 bytes

2 kilobytes = 2048 bytes = 211 bytes

4 kilobytes = 4096 bytes = 212 bytes

8 kilobytes = 8192 bytes = 213 bytes

16 kilobytes = 16,384 bytes = 214 bytes

32 kilobytes = 32,768 bytes = 215 bytes

64 kilobytes = 65,536 bytes = 216 bytes

128 kilobytes = 131,072 bytes = 217 bytes

256 kilobytes = 262,144 bytes = 218 bytes

512 kilobytes = 524,288 bytes = 219 bytes

1,024 kilobytes = 1,048,576 bytes = 220 bytes ≈ 106 bytes

Note that the numbers of kilobytes shown on the left are also powers of 2.

With the same logic that lets us call 1024 bytes a kilobyte, we can also refer to 1024 kilobytes as a megabyte. (The Greek word megas means great.) Megabyte is abbreviated MB. And the memory doubling continues:

1 megabyte = 1,048,576 bytes = 220 bytes ≈ 106 bytes

2 megabytes = 2,097,152 bytes = 221 bytes

4 megabytes = 4,194,304 bytes = 222 bytes

8 megabytes = 8,388,608 bytes = 223 bytes

16 megabytes = 16,777,216 bytes = 224 bytes

32 megabytes = 33,554,432

Return Main Page Previous Page Next Page

®Online Book Reader