James_Parsons wrote:
I know garth has an article on this in his 6502 primer, however to help me I would like to learn the actual mechanics/mathematics of address decoding. I suppose it wont be to different for related processors like the 8085 and 6800
No, it would all be the same. This is basic boolean logic, well actually boolean algebra.
The basic question is, given a 16-Bit address, which chip gets turned on for each individual address.
Let's take a contrived case of a 4K RAM chip, assuming something existed.
To get 64K of RAM, you need 16 chips, right? 16 x 4 = 64.
Now, each chip itself would need 12 bits for addressing, since 2^12 is 4096 (4K).
So, each chip, in this case, will have 12 pins for addressing. But there is also another pin.
This is the Chip Select pin (or similarly named).
So, since you need 16 chips, how do you select which chip gets the data?
Well, since 12 bits of the address are needed by the chip itself, and the CPU only has 16 bits, you have 4 more bits to represent which actual chip you want to select.
Note that 2^4 is 16.
So, in this simple case, you would need logic that take in the 4 upper bits of the address, and fans those out in to 16 distinct lines, one to the Chip Select pins on each of the 16 RAMs. This circuit is sometime known as a demultiplexer, or a decoder.
The 74138 is an example of such a decoder on a chip, it takes 3 inputs, and had 8 output (2^3 == 8). Each unique combination of input signals lights up 1, and only 1, of the output signals.
Now as things get finer grained, smaller blocks of memory (like devices that only need, say, 8 bytes of memory space), the logic gets more complicated.
On the other side of the coin, you can see if you had 32K of RAM and 32K of ROM, the top bit can be used. You could wire the bit straight to the 32K ROM (which is the top half of memory), and the other directly to a 32K RAM chip, but through an inverter. Simple logic.
Garth laughs when I mention Karnaugh maps, but these were the technique I was taught for trying to simplify logic like this. You create effectively truth tables of what goes in, and what you want out, and then apply some techniques to simplify it, and in the end you get the collection of logic operations (AND, OR, NAND, NOR, EOR) to get the desired outputs for the desired inputs.
Not necessary for simply logic.