Выбрать главу

The basic requirements are three input address lines and eight output lines each connected to one of the chip select pins on a memory chip.

To switch the chips on, the chip select must be taken to a logic 0 voltage. A logic 1 voltage level will switch the chip off. It is vital, of course, that only one chip can be switched on at the same time otherwise they will load competing data onto the data bus and are likely to be destroyed. The three addresses can result in 2³=8 different inputs to the logic gates built into the decoder chip. The internal design ensures that when the address pins are all at zero, the first output goes to a logic 0 and all the others remain high. The memory chip to which this first output is connected is switched on and all the others are on. When the next combination of inputs 0, 0, 1 is applied, the second memory chip is switched on and the others are off. The next combination switches on the next memory chip and so on until the three input wires have switched on each of the memory chips with a single combination of addresses (see Figure 7.8). With three inputs and eight outputs, it is referred to, reasonably enough, as a 3 to 8 decoder.

Figure 7.8 The operation of the address decoder

Table 7.2 looks a lot worse than it really is. It is really just a summary of the decoder chip outputs. If the microprocessor put the address C2F1H on the address bus, then in binary it would be: 1100 0010 1111 0001. It has been broken up into groups of four Table 7.2 The 3–8 decoder can control eight memory chips just to make it a little easier to read. The most significant bit, A15, is on the left-hand end.

Table 7.2 The 3–8 decoder can control eight memory chips

Inputs Outputs Results
C B A 0 1 2 3 4 5 6 7
0 0 0 0 1 1 1 1 1 1 1 Chip 0 selected
0 0 1 1 0 1 1 1 1 1 1 Chip 1 selected
0 1 0 1 1 0 1 1 1 1 1 Chip 2 selected
0 1 1 1 1 1 0 1 1 1 1 Chip 3 selected
1 0 0 1 1 1 1 0 1 1 1 Chip 4 selected
1 0 1 1 1 1 1 1 0 1 1 Chip 5 selected
1 1 0 1 1 1 1 1 1 0 1 Chip 6 selected
1 1 1 1 1 1 1 1 1 1 0 Chip 7 selected

In Table 7.3, we can see that 13 out of the 16 address lines go to the memory chip and the other three are fed to the decoder chip. The three lines going to the decoder chip carry the data 1 1 0. We can see that the values C=1, B=1 and A=0 occur near the bottom of the table. These values result in Chip 6 receiving a logic 0 value and thus being selected for use. All other chips are deselected by the logic 1.

Table 7.3 In full decoding, every address line is used A 

A15 A14 A13 A12 A11 A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 A0
1 1 0 0 0 0 1 0 1 1 1 1 0 0 0 1
←This selects chip 6→ ←This address is internally declared within the memory chip and points to single memory location→
Full and partial decoding

Full decoding

In the above example, the 8 kbyte memory chips used 13 address lines and the decoder used three. This makes a total of 16 lines used out of a 16-bit address bus. There are no unused lines and this is referred to as ‘full decoding’.

Partial decoding

Now let’s make a small change. The memory chips used are 4 kbyte each rather than 8 kbyte. What effect would this have?

The first result would be that the number of address lines going to the chips would be reduced to 12. There are still only eight chips to be selected so a 3–8 decoder is enough. So what have we got now?

Twelve address lines to the chips and three to the decoder and one left over and unused. If nothing is connected to this line, then it cannot matter what voltage it carries (see Table 7.4).

Table 7.4 One address line is unused 

A15 A14 A13 A12 A11 A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 A0
1 1 0 X 0 0 1 0 1 1 1 1 0 0 0 1
←3 lines for decoding→ This line is unused lines so it can have a value of 0 or 1 ←12 lines to the memory→

We will look at our previous address C2F1H. If it happened to go to a value of 1, the address would change from:

1 1 0 0 0 0 1 0 1 1 1 1 0 0 0 1 (C2F1H)

to

1 1 0 1 0 0 1 0 1 1 1 1 0 0 0 1 (D2F1H).

We now have two numbers that can be placed on the address bus which will result in access to the same memory location since all the bits that are actually used are identical. If we instructed the microprocessor to store some information in the address C2F1H and then to recover the information from address D2F1H, we would get the same information again. The address D2F1H is referred to as a ghost address or an image address. It is important to appreciate that ghost or image addresses have no effect at all on the operation of the microprocessor system. They are merely alternative names for a single address. Incomplete or partial decoding always gives rise to image addresses, their number and their addresses are easily worked out. In technospeak, we say that partial decoding results in more than one software addresses pointing to the same hardware address.