If you are trying to control memory from a CPU, then if you use two banks instead of one, you can remove the first address line. If you use four banks, then you can also remove the second as well. Why is this?

• You need some more details; are you talking about 32-bit processors? Parallel addressed RAM? 8 bits/address? – Nick T Mar 22 '11 at 1:55

I think W5VO's reply is a great description of a modern memory system but does not really describe Bank Switching.

You want bank switching when you have a narrow address bus (like 8- or 16-bit) and you want to add more memory. You can then use separate GPIO lines to switch memory chips just like W5VO wrote. You have to be careful because all your pointers are still 8-bit and the switching is manual so you can easily cause a mess.

This technique was/is popular in small micros, but also in 16-bit DOS (it was born on the 80286) and kind of in modern 32-bit processors to address more than 4GB of memory (but here the trick is done invisibly by the kernel and one program can still only see 4GB).

• But how does that reduce the number of address lines? – 200ok404notfound Mar 23 '11 at 3:16
• @2000k404notfound It does allows you to expand beyond the address bus width that is available. I think I do not fully understand your question. If you want to address 4k memory you will need 12 bits of address lines somewhere. The only question is where do you stuff them. – jpc Mar 23 '11 at 3:21
• There are two ways to reduce the number of address lines. One is to divide the memory into rows and columns and latch the row address. Truly random access then requires at least 2 clock cycles but columns inside a row can be accessed quickly. This is how DRAM works. The other method is to have a 32-bit data bus, throw away 2 low-order address bits and only access whole words at once. – jpc Mar 23 '11 at 3:45
• I think it has to do with the last bit of the address. If you have two banks, then you can assign all the even addresses to one line, and all the odd addresses to the other. The last bit tells you if the address is odd or even, but if you use the CS line to select lines, then you don't need it. Does this sound right? – 200ok404notfound Mar 23 '11 at 3:53
• @200ok404notfound: Yes, your description of interleaved memory is valid -- I hesitate to say it is "right" only because bank switching is just as valid. You are describing interleaved memory. W5VO and jpc and supercat are describing bank switching. The Sojourner Mars rover and some TRS-80 Model 100 computers use bank switching between the 16 address pins of the 80C85 and the RAM; they never used interleaved memory. Both techniques have their place. – davidcary Mar 31 '11 at 20:30

I'm going to assume that you're talking about parallel memory, and that when you say "use two banks instead of one" you are using two chips that have the same total memory, but each are half as large.

Here's the thing: you can't actually remove that address line from your CPU. It might not go directly to the memory chip, but if you remove it there is no way to distinguish between the two chips. The missing ingredient is the "chip select" function. Most memory chips will have a pin or set of pins that are used to basically tell that particular memory chip that the processor want to talk to only that chip.

Lets consider a simple example: 256 words of memory. This results in an 8-bit address bus.

• One chip with 256 words: then we are always using only one chip, and it has an 8-bit address.
• Two chips with 128 words each: Only one memory can be active at the same time, so we will be using the "chip select" pin. The MSB (Most Significant Bit) of the 8-bit address bus will go to the chip select pin on each chip, and the rest of the 7 bits will go to the 7-bit address bus on both chips.
• Four chips with 64 words each: Only one memory can be active at the same time, so we will be using the "chip select" pin. Some memory chips have multiple chip select pins, but for this example we will assume there is only one. In order to generate the chip select signals for all four chips, we will need a 2-to-4 decoder (also known as a $n\mbox{ }to\mbox{ } 2^{n}$ decoder, row decoder, address decoder - all the same things). This decoder takes the first two MSB from the address bus, and determines which chip select signal should be active. The lower 6 bits of the address go to the 6-bit address bus of all 4 memory chips.

This is a really simple example, but it scales fine. This is basically the procedure for making multiple memory chips work together to increase the address space.

• Don't you mean that the LSB is used for the chip select? – 200ok404notfound Mar 23 '11 at 4:02
• No, you use the MSB's. That way you're not switching chips every time you increment the address. This makes it much easier to use ROM chips, partially filled address spaces, and devices with a memory bus interface. – W5VO Mar 23 '11 at 9:09
• If you look at page 13 on here the LSB is being used. ece.cmu.edu/~ece548/handouts/13m_arch.pdf – 200ok404notfound Mar 23 '11 at 9:22
• If you want to switch chips every read, then you can use the LSB as CS. You can even use a combination of MSB and LSB or any bits in the address, and it will still work. If you are trying to interleave your chips to get a performance advantage, your system must be able to take advantage of that. – W5VO Mar 23 '11 at 9:36