AN189
AN189REV1 3
1. INTRODUCTION
This application note explains how to interface
SRAM memory to the bus of Cirrus Logic ARM-
based microcontrollers. The bus controller on these
devices can interface to x8-, x16-, or x32-bit wide
data memory. However, when using a x16 or x32
bus configurations, it requires some external
decoding logic.
2. GENERAL DISCUSSION
The EP7xxx microcontrollers are capable of
interfacing to a wide variety of SRAM memory
devices. Extra SRAM may be required if the
internal SRAM provided in the EP7xxx is
insufficient for a particular application. SRAM can
also be used to hold program memory. Since some
SRAM devices can have fast access speeds, that
can help to improve overall system performance.
However, the ARM architecture does not support
unaligned accesses, which means that accessing
bytes on non-aligned addresses require an external
decoder to access individual "byte-lanes". In most
situations, external logic to decode the byte lanes
may be required.
Three types of SRAM configurations are shown in
Figure 2. The first configuration is for x8 memory.
In this case, no extra decoding logic is needed. For
reading and storing 8-bit data, this scheme works
well as each byte is accessed for each data access
cycle, assuming a STRB or LDRB instruction is
used (store byte or load byte). Furthermore, the
byte data can accessed on any byte-bounded
memory location. When using x8 memory for
program storage, the processor has to fetch 4 bytes
to build up an instruction word (or two bytes in the
case of a Thumb instruction) which can slow down
performance by a factor of four.
The second SRAM memory bank example in
Figure 3 is a x16 SRAM with no byte decoding
since both nUB and nLB (upper-byte and lower-
byte) signals are tied low. This limits the processor
from using byte data since it can only access data
on a half-word or on a 16-bit boundary. This means
that the programmer must take care to cast all char
data as half-word which pads the upper byte with
don’t cares thereby wasting half of available
memory space. But it can also be dangerous,
especially when using vendor provided libraries
that expect data to be on byte-boundaries. Byte
decoding of x16 SRAM may not be necessary
when using SRAM to store instructions only. The
reason is to take advantage of the faster access
times of SRAM verses the slower memory access
time of x16 Flash or EPROM. But it will still take
two memory fetches for each ARM instruction (or
one for Thumb).
It is possible to use x32 SRAM without byte
decoding, but it is not recommended. In theory, one
could use non-decoded x32 SRAM for storing
instructions (for speed improvement). But in this
case, Thumb instructions must be aligned on word
boundaries which is impractical. If using this type
of memory for data, then only 32-bit words can be
reliably accessed.
In conclusion, it is generally recommended that
when using x16 and x32 external SRAM, each byte
lane be fully decoded.
3. DESIGN OF THE BYTE DECODERS
The program in Listing 1 (See “Listing 1 Sample
Program”) is designed to write 4 bytes, 4 half-ints,
and 4 ints to a hypothetical memory device. Chip
select #5 is used which gives a default address
range starting at location 0x5000.0000 (this can be
changed by the MMU). The results were sampled
using a HP 16500B logic analyzer and is displayed
in Figure 1. The signals sampled are: A0 and A1
(address bits), nCS5 (chip select 5), nMOE (output
enable), HALFWORD and WORD. From the
waveforms, truth tables can be derived and logic
synthesized.
The first four access are byte oriented, the next four
are word (32-bit) oriented, and the last four are