BES - Types of Memory
BES - Types of Memory
Types of Memory
Most embedded systems use memories in various ways. Memory is required inside
embedded systems for a variety of reasons: to store the executable code, to load the
instructions to be executed as well as the associated data, to save important information
that can be changed by the user during sessions. We will introduce these causes of
memory usage inside embedded systems in this section. Then we will deal with the
techniques used to satisfy these requirements inside embedded systems.
Let us begin this chapter by giving an introduction to the types of memory used by
embedded systems. As embedded system engineers, it is always advantageous to peek
into this domain so that we can appreciate the usage of different types of memory. We
can understand the type of memory, which should be used for a specific activity. Also,
this gives tus an understanding of the capabilities of these memories and the pros and
cons in of memory. We will discuss about ROM and its kinds,
using a specific type
RAM and its types, as well as the FLASH memory. We will necessarily keep this dis-
cussion short. The interested reader is advised to consult the exhaustive literature avail-
able for memory.
Basically embedded systems require memory to store the following classes of data:
Data related to executable code in machine instruction format: This is
usually burnt*
while the device is being manufactured. This kind of data is
typically not changed dur-
ing the lifetime of the device. This kind of data
requires a write-protected or read only
emory-that is, once filled, this memory will not be changed during the lifetime of
the product.
We will soon
see how it is "burnt".
Embedded Realtime Systems Programming
52
This data is usually the variahle
Data storing the current context ofexecution: Volalile. Since the variables
This memory
1s very
and their stacks. that the cCon
used by programs
program
is executung,
it 1s expected
when a
and stacks make
sense only turned o . However, it is also expect
is
this be lost when power
can well as writing because the
tents of memory as
access for reading
fast to
this factor. This type of mem
is
ed that this kind of m e m o r y be governed by
device will also random access mem
realtime behaviour of a in technical jargon,
and volatile-or E m b e d d e d systems use
should be fast, erasable misnomer by
the way.
ory
this n a m e is a
of device
ory. We will see later that on a m o u n t
based
ol data used, cost
random access memory
dilferent types of
and requirements on speed.
P2P to be
deterministic?
Figure 3.1 shows at a conceptual level, an example of memory access with an 8*8 row
and column grid. Note that the grid does not have to be square, and in fact in real life
it's usually a rectangle where the number of rows is less than the number of columns.
P2P
What is the advantage of using a rectangular address grid?
Column address
decoder
Row address
decoder
Data
Output/nput
signaling is required so that the memory chip and the accessing device are always syn
Table 3.1: Expla=
chronised about what they are expecting. This signaling pin is usually called probe or
chip select. One thing is for sure: everything else remaining constant, having to send The function
the address in two "chunks" slows down the addressing process, but by keeping the chip
Vcc TH
smaller and with fewer inputs we gain in terms of power consumption and space
of reduction in number of The pins). in further GND
(because reduction power consumption
leads to an increase in the speed of the chip, partially offsetting the loss in access speed.
a WE
chip with 8 address lines and two data lines.
Figure 3.2 shows a
typical memory selected f
and pins
means th
data is ag
the Dou
o RAS a
area are
thatat
When I
assume
synchro
This is not er
and a write op
same pin for o
Fig. 3.2 A memory chip
55
Types of Memorn
aid of
Let us try to understand the different parts of this memory chip with the
Table 3.1.
9 GND Ground
10 Din DATA IN
Vcc This is the pin through which the chip receives power for functioning.
GND This is the Ground pin required for any electric circuit
aWE Write Enable. When this pin is asserted, this means that the chip has been
selected for writing. This also means that the data will be sent through the Din pin
and pins A0 to A7 specify the location of this data. When the WE pin is low, this
means that the chip has been selected for reading." In this case, the location of the
data is again specified through address pins A0 to A7. The data flows out through
the Dout pin.
a RAS and CAS As we noted before, the rows and columns inside the memory
area are addressed one at a time. Hence there must be a way of telling the chip
that at this moment, the address lines specify a row number or a column number.
When RAS is set high, a row address is specified, otherwise a column address is
assumed. As we mentioned before, these are the additional pins required for
synchronisation in order to reduce the number of pins for address bus
This is not entirely true though. Some chips have other mechanisms to distinguish between a read
and a write operation. However for simplicity reasons, and to make the concept clear. let us reuse the
Same pin for our illustration.
56 Embedded Realtime Systems Programming
With the aid of Figs. 3.3 and 3.4 respectively, let us trace the steps for read and .
Tite
operations through this chip.
RAS
CAS
Don't care
A0 ROW COL
WE
Din DATA
For writing:
i. The address of the cell to be written to is placed on the address pins via the
address bus This is done by first setting the RAS and puting appropriate row
number followed by setting the CAS and putting appropriate column number
on the address bus.
ii. Set the Write Enable pin: The bit that needs to be stored in the chip is sent on
the Data In pin via the data bus.
iii. Chip select is activated to select the memory chip: When all these operations
are performed simultaneously, a bit on Din pin is written inside the chip at the
address specified by the address bus.
RAS
CAS
Don't care
A0-A7 ROW cOL
WE
Dout
tAC
DATA
Fig. 3.4 Read operation in a memory chip
Types of Memory 57
For reading:
. The address of the bit to be read is put on the address pins via the address bus.
RAS and CAS pins are used appropriately.
ii. Write Enable pin is turned low so that the chip knows it's being read from.
iv. When all these conditions are active simultaneously, data appears on the Dout
pin from the address specified by the address bus.
bit at time.
In actual practice, memory is accessed at least a byte at a time, and not a a
This is accomplished by stacking each such chip into blocks of eight and combining the
bit-data streams from these eight chips. When these chips need to be addressed, the
all address
Chip select is enabled on all of them, and the same address is specified
on
Definition
from the start of
The amount of time that it takes for the memory to produce the data required,
the access until when the valid data is available for use, is called the memory's access time,
abbreviated tAC (See Fig. 3.4).
Access time is normally measured in nanoseconds (ns). Memory available today nor-
3.2.1 RAM
Random access memory (RAM) is a read-write memory. RAM is considered "ran-
dom access" because any memory location can be accessed directly instead of a sequen-
tial operation from the beginning of the memory. Being random access does not define
this kind of memory completely. It is sufficient to distinguish it from its opposite, serial
access memory (SAM). SAM stores data as a series of memory cells that can only be
accessed sequentially (like a cassette tape). Data is searched from the beginning of the
until it is found end-of-memory is reached. SAM works very well for
memory or
Tips
Who loads this program and data inside
data and its required space inside RAM
RAM It is the job of your program to know the amount of
Memory
RAM ROM
SDRAM EPROM
ADRAM EEPROM
FLASH
DDRAM
DRAM
DRAM or the Dynamic RAM is a very volatile memory. It is not able to store iníor
mation even for a few milliseconds even if power is available to the chip. The storage
forgetting the data stored it. It periodically requires a refresh
medium keeps on on
circuit in order to prevent loss of data. Here we need to address two questions:
need to
The answer to the second question is a subtler one. To understand it, we
that sense, a capacitor is a sort of leaky bucket with a certain rate of outflow of charge
while storing the data. Therefore, we need a source of power anda 'refresh circuit' that
from discharging. The refresh
keeps on feeding energy in order to prevent the capacitor
circuit simply restores a full charge to those bits that were remembering to be Is. Hence
in order
typically several hundred times per second, the capacitors require reminding
io keep the memory intact.
This reminding process is called 'refreshing' the memory, and DRAMs use a wide
cruise through the vast
variety sophisticated refresh circuits which do nothing but
of
and re-
DRAM memory array polling each bit for its content before it fully forgets,
The disadvantage of this type of
eling the memory what it is supposed to remember.
structure. Having a mem-
ephemeral memory is offset by its very tiny size and simple
thus reducing cost
Ory cell so small allows us to put more of them on any given device,
considerably.
actual memory array and the
diagram containing the
asso-
1gure 3.6 shows a block
The lelt part ligure of the is the
cated circuitry to perform the refresh operation.
DKAM controller. Now, Reading from or writing to a DRAM cell relreshes its charge,
Embedded Realtime Systems Programming
60
on reading periodically Irom each cell. For
or that rea
so the DRAM controller just keeps
The DRAM controller
son there is a
refresh timer inside the ligure. takes
care of takes
refreshes and making sure that they
don't interfere with regula
scheduling the
the processor or some DRAM
other device.
regular reads
controlla..
and writes generated by
RAS repealedly and placing a
ically sweeps through all ofthe rows by cycling
row addresses on the address bus. The upside ol a DRAM is that since it is so s
it is small in size and less expensive. The downside is that all this refreshing tab simple,
and slows down the memory, particularly as compared to its sister-the SRAM.
Note
Earlier in the chapter, we had pointed out that a DRAM dhip is usually in theform of a rectangle
instead
of being a square. Noue is the time to explain this fact. Since DRAM uses RAS to periodical
swep through the entire RAM area, this operation will be faster ifthe number of rows is less becaue
the fewer rows the chip has, the less time il takes to refresh all the rows.
Consequently, DRAM makes
design DRAMs with fewer rows than columns thus resulting ina rectangular layout.
RAS
CAS Control clock Power
WE
Refresh
Row
Memory Din
Dout
Col
RAS
CAS
For each operation, synchronisation has to be maintained between RAS, CAS, etc.
In Fig. 3.8, a corresponding
operation for SDRAM has been illustrated. Data starts to
be read from contiguous memory locations after the bitline and
wordline have been
specified. Each clock tick initiates a read operation from the next wordline.
RAS
CAS
Dout
DATA DATA DATA
Fig. 3.8 Readoperation in SDRAM
62 Embedded Realime Systems Programming
SDRAM typically has an access time of only G-12 ns. Another variant of SDRAM
M is
called DDR RAM or a double density RAM. It is a new technology and is a cl
lock
doubled version of SDRAM, which is replacing SDRAM nowadays.
SRAM
SRAM or static RAM is so called because it retains any informaton stored in it, as lu
as
power is maintained. The data just sits there, calmly awaiting retrieval ong
by the sysite
command. Upon receiving an order to overwrite the data or to prOvide some
being retained, the SRAM is very fast to respond. That's one ol its endearing qualiti
data
lities.
SRAM uses a completely different mechanism for storage ol inlormation. An SRAM
cell is
AM
usually made up of a flip-flop gate whichfurther comprises of about 4 to 6
tran
S1stors, arranged in a configuration that traps either a binary I or a binary 0 in betw
them until that value is either written over with a new value or the tween
power goes out. This
configuration never needs refreshing unless power is switched off. This makes SRAN
much faster in response time than DRAM and
very power efficient. SRAM Can .
made with a rise time as short as 4 ns.
However, because it has more cells, each cell o
the SRAM takes more
space as compared to a DRAM cell. This means that a
not hold as
many cells as that of DRAM. This makes SRAM more
chip can.
pared to DRAM. SRAM is expensive as com.
normally
time, like for example cache.
used in places that require a
very quick response
3.2.2 ROM
ROM, or the read only
memory, as the name
suggests is
only read from. This means that ROM a
memory
can
in which we
cannot be written
ry will retain its contents even
when the power is again and again. This memo
used to store switched off. Hence this
anything
that needs to be used
after the memoryy is
on
again. What kind of information system has been switched off
and
will be executed on can this be? This is
the embedded
system. Since this
usually the actual program that
switch-ofT, it is also called nonvolatile memory." memory does not get erased at
Because of the it stores
way information (as we
compared to RAM, typically will see
having double the access time soon),
of
ROM much slower
is
One term that RAM or more. Howevel.
often confuses people is that
write and ROM is
read-only RAM is the
not random
access. This is notmemory. Hence, since RAM "opposite" of ROM because RAM
true. ROM is
also a randomstands for "random access memory15 TeROMi
can be read
in any
ories order, it is just not
introduced in the writeable. RAM gets itsaccess
memory. Inside ROM, any cation
with RAM even beginning
though it is no longer sequential, and did not allowbecause primitive read-WIToa nem
were name
relevant. random access. Ine
a
iant of SDRAM 63
y and is Types of Memory
a Mis this limitation
clock it is expected that ROM need not be accessed as
considerably cheaper as
can
to RAM per byte, definitely has its own advantage.
compared
ored in it, as
val by the long Definition
ovide somesystdatema RAMis often used to shadow parameters stored in EEPROM (RAM is mapped to
memory space) to improve performance. This technique is called 'ROM
ROM's
shadowing'.
dearing qualities, times
While the purpose of a ROM is that its contents cannot be changed, there a r e
atio. An SRAM when being able to change the contents can be very useful. Sometimes
it is desirable
bout 4 to 6 and it should be
ry O in tran that the memory remains read-only for all normal circumstances
in a mobile phone,
r between
goes out. This
possible to over-write it by specially defined processes. For example,
it will be worthwhile to store a specific type of ringer tone into such memory that cannot
makes SRAM be erased when the phone is switched off. However, it should also be possible to update
only one direction. Like all diodes, a voltage above the break over voltage (of the order
ad-writemem
name stays
of 600 mVolts) is needed so that the diode passes current. To determine whether a cell
64 Embedded Realtime Systems Programming
has a 0 or a 1, a
voltage above 600 mV is applied to a column while
grounded. If the diode is keepingng the row
connected, the current will be conducted to the groina
this method, the status of each cell can be read. d. Using
Obviously, since there is
physical presence of a diode to indicate a 1 in a coll
kind of memory cannot be changed and reused. Once the ROM is
ROM manufactured i, this
only be read. And if there are some bugs in the values, well, unfortunately, the manufactured,
chip has to be thrown. This makes the chip design process long and whole
the upside, ROM chips are cumbersome On
very cheap for mass-production, have high reliability
a
long duration and they consume very less power.
Just like regular ROM, a PROM chip has a grid of rows and columns. In order to
make it changeable once, each cell has a small fuse in it, (logically the same as we
have in our homes for checking electric malfunction). In normal circumstance when
the PROM chip is created, all cells have a value of 1. An electric charge can pass
through the fuse. To change the value of a cell to 0, a high voltage is sent to the cell
thus breaking the fuse. The electric circuit is left open and a 0 gets created at this
position.
This process makes it possible to change the PROM chip, but only once. PROM
chips are very fragile but cheap. As discussed above, they are generally used lor
prototyping data for a regular ROM before committing to the costly fabrication o
ROM chip.
Once again, it is a mesh of rows and columns and this time inside each celltne re
sistors
two transistors technically called the control gate and floating gate. The two tran
h the
are separated by a thin oxide layer. At an erased state, electricity can pass tni
Types of Memory 65
and a value
the row Oxide layer and link the two (hus linking the row and column)
transistors
PROM tric charge to return the trapped electrons to their original state. No special equipment
used for is required and the chip need not be removed. This electric charge can be targeted at
ation of any data point at any time. Operationally, EEPROM chips change data one byte at a
ime, which makes them versatile but slow.
3.2.3 Flash
process.
Flash memory is similar to EEPROM in design. The dilference is that it can be erased
here are and reprogrammed in blocks instead of one byte at a time. In-circuit wiring is used
O
ansistors apply electric charge to' an entire chip or to specilic sections called blocks, each
ugh the
usualy of size 512 bytes. Being light, compact and energy-eflicient, typical uses of
66 Embedded Realtime Systems Progrumming
FLASH are in CompactFlash, SmartMedia, Memory Stick (most often found in digitsl
cameras), PCMCIA type I and type II memory cards (used as solid-state disks igjital
in
laptops). The original intended usage of FLASH memory was to replace mass storage
devices like disk drives and tapes. Flash memory in the form ol a card or stick is verrage
versatile and can be used across devices if a standard lile system is used to represe
ery
sent
data inside it. This is the concept of so-called linear flash.
There is another kind of FLASH called the ATA flash. An ATA flash memory
nod
ule interfaces with the rest of the system using the de facto "AT Attachment" slandard.
The FLASH gives the illusion that it is made up of sectors ike on a hard disk and the
same APIs can be used as for accessing a disk drive. The main advantages of ATA lash,
from the embedded system developer's perspective, are flexibility and interchange
ability with hard disks. While linear flash modules aren'i 100%o interchangeable
between devices, ATA flash overcomes this limitation by using a standard AT interface
for accessing it. ATA flash can be accessed using an operating system's standard disk
access code and the same file system APls. This aids in cross compaibility.
For example, a memory card inside a digital camera, equipped with flash memory
uses a format to store data that is compatible with the way PC Card stores it. Hence, the
card can just be inserted into a PC card slot and can be read directly by the computer.
Not only does this promote cross compatibility, it aids in debugging as well since the lim
itation of an embedded system (lack of screen and input device) are easily surmounted.
There are additional advantages. Thebuiltin file system is robust enough to perform
some housekeeping tasks. For example, it can detect areas of memory that are defective.
It can then forbid access to these regions for read-write purposes. It can have a
mechanism by which it can create virtual sectors which point to physical sectors in
memory in such a way that read and write accesses to these sectors is evenly spread on
the chip thus preventing heavy usage and associated wear of a particular portion o
the chip. As expected, everything in this world comes with a
price. ATA Flashhasso
many advantages, but all these features make it more expensive and power-hung
Because of speed limitations, flash memories incorporate built-in SRAM buflers, dupl
cating the contents of a block of memory from the flash array for fast access.
Memory is used inside embedded systems in order to store executable code, loadthe
instructions to be executed a a t can
gives rise o
67
Types ofMemory
the
Memory chips usually arranged in
are
inside embedded systems. use the same
ypes
of memory
and columns of data. Typically, memory chips
of rectangles as r o w s
the number of lines
significantly.
form address and reduce
column
for row and
address lines and CAS pins.
read or written
based on the RAS
The data is The random a c c e s s
mem-
disconnected. It is of
two types: the dynamic static RAM
supply is from forgetting its data. The
it
times a second to prevent memory
is a
typically many its contents. The Read-Only
constant charging for storing o n c e and its
does nol need ROM can be used only
The regular
form of 'not-easily-erasable'
memory.
ROM is capable
after burning it once. The programmable
contents cannot be changed EPROM uses the Fowler
once through
electric current. The
similar to
of being recharged number of times. EEPROM is
contenls any
to erase its software control
Nordheim technique
contents can be erased through
that its
EPROM in operation except in
of EEPROM that can be reprogrammed
Flash is a type
through electric charge. Flash memory has
enhanced cross-compatibility
of
time.
blocks instead of one byte at a
standard AT interface.
through the usage of a
across
embedded devices
memory
function?
rectangles and not squares?
chips usually arranged
as
Why are memory
from SRAM?
How is DRAM different memories?
Whal are the advantages and disadvantages of FLASH over other
which memory would you
use and why?
In orderto store user preferences,
RAM?
"What is meant by an asynchronous