Address Decode Bits Vs Base Address - a Juggling Act

Frozen Content

When specifying the Decode Address Width, you should try to set the number of address decode bits to a value that will adequately cover the number of slave devices you wish to link to the Interconnect component. The simple approach is to take the number of slaves and consider the number of address decode bits, n, that will provide at least this number when inserted into the expression slaves = 2 n. So:

  • 2 slaves requires 1 decode bit
  • 3 -4 slaves require 2 decode bits
  • 5-8 slaves require 3 decode bits
  • 9-16 slaves require 4 decode bits, and so on.

You must also consider which base addresses to assign each slave device, in conjunction with the number of address decode bits. Certain addresses may never get selected if they are not spaced adequately in the processor's address space.

How decode bits affect memory addressing

Before looking at specific examples of specifying too few or too many address decode bits, it is worth looking at how the use of address decoding impacts on where in processor memory a device is addressed.

If a slave peripheral is connected directly to the IO port of a processor in an OpenBus System, with no Interconnect component, that device will be mapped repeatedly throughout the entire processor Peripheral I/O space. The reason is that with no decode bits, all addresses will select the device. Figure 1 illustrates this for a port peripheral, GPIO, that has a base address of 0xFF00_0000.


Figure 1. Single peripheral mapped into address
space with no Interconnect used.

Now consider the same peripheral, but this time connected to the processor via port m0 of an Interconnect component. Let's assume the same base address (0xFF00_0000) and the use of 1 decode bit. The peripheral will be selected for communications if the top bit of the address line and the top bit of the device's base address are both 0. Figure 2 illustrates how the processor's Peripheral I/O space will now look.


Figure 2. Single peripheral mapped into address
space using an Interconnect and 1 decode bit.

This time, as the device is only selected when the top address bit is 0, it is repeated only in the lower half of the address space. Notice that if you wanted to add a second slave device, you would need to give it a base address that started anywhere from 0xFF80_0000 and above. To give it a base address lower than this would result in it not being selected, as the two devices would each have an address with a top bit of 0.

If we take the number of decode bits to 2, we can see (Figure 3) that the peripheral is still repeated, but in a much more constricted area of memory. In fact, you can see the pattern – add an extra decode bit and we effectively shrink the area into which that device is mapped. With 2 decode bits, should you wish to now add a second peripheral device, you would give it a base address anywhere from 0xFF40_0000 and above.


Figure 3. Single peripheral mapped into address
space using an Interconnect and 2 decode bits.

Armed with a better understanding of how base addresses and decode bits work hand-in-hand to correctly map the physical devices in an OpenBus System, you should be able to avoid the pitfalls of using too few or too many decode bits. Let's take a look at an example of each case however, to underline the importance of setting appropriate decoder widths and device base addresses.

Specifying too few Decode Bits
Specifying too many Decode Bits

You are reporting an issue with the following selected text and/or image within the active document: