Professional Documents
Culture Documents
TYPES OF MEMORY
R
D
AS
R
D
M
A D
R
M D
A
R
M
A
M
R
O
M
2
MEMORY: BASIC CONCEPTS
Stores large number of bits
m x n: m words of n bits each
k = Log2(m) address input
signals
or m = 2^k words
e.g., 4,096 x 8 memory:
32,768 bits
12 address input signals
8 input/output data signals
Memory access
r/w: selects read or write
enable: read or write only when
asserted
Nonvolatile memory
Can be read from but not written
to, by a processor
in an embedded system
Traditionally written to,
programmed, before
inserting to embedded system
2k n ROM
enable
External view
Uses
Store software program for
general-purpose processor
program instructions can be one
or more ROM words
Example: 8 x 4 ROM
m
w
or
d
s
n
n
r/ me
2
bit
ewA mo
n
m
A
read
s
Q
n Qry
and
e
write
pe
a ext
m
mem
r
ory
bl or
er
wo
e nal
y
rd
vie
w
P
E
E
R
P
E
O
F
R
P
M
L
O
R
A
M
O
S
M
H
Ext
e ern
2k
A
n aln
A
a0 vie
RO
Q
Q
kbl
wM
e1 n-1 0
M
e
m
o
S
Rr
y
A
M
0
k1
n-1 0
TermS
Traditional ROM/RAM
distinctions
ROM
read only, bits stored without
power
RAM
read and write, lose stored
bits without power
Traditional distinctions
blurred
4
Advanced ROMs can be written
to
e.g., EEPROM
Advanced RAMs can hold bits
without power
e.g., NVRAM
Write ability
Manner and speed a memory
can be written
Storage permanence
ability of memory to hold
stored bits after they are written
ROM: Read-Only Memory
6
7
Horizontal lines = words
Vertical lines = data
Lines connected only at circles
Decoder sets word 2s line to 1 if
address input is 010
Data lines Q3 and Q1 are set to 1
because there is a programmed
connection with word 2s line
Word 2 is not connected with
data lines Q2 and Q0
Output is 1010
Inte
8rnal
4
3
vie
ROMw
e
w
A
w
A
w
w
A
o
n
o
0 8
1
od
2
d
rro
ap
e QQQQra
r
d
bro
d
c 3 21 0w
dd
t
o
l g 0
1
ir
2a
d
li
era
e
e
n
li
r
m
m
a
bl
e
c
o
n
d
e
n
e
O
R
Mask-programmed ROM
Connections programmed at
fabrication
set of masks
Lowest write ability
only once
Highest storage permanence
9bits never change unless
damaged
voltage
built-in memory controller
commonly used to hide details from
memory user
writes very slow due to erasing
and programming
busy pin indicates to processor
EEPROM still writing
can be erased and programmed
tens of thousands of times
Similar storage permanence to
EPROM (about 10 years)
Far more convenient than
EPROMs, but more expensive
Flash Memory
Extension of EEPROM
Same floating gate principle
Same write ability and storage
permanence
Fast erase
Large blocks of memory erased
at once, rather than one word at a
time
13
Blocks typically several thousand
bytes large
Writes to single words may be
slower
Used with embedded systems
storing large data items in
nonvolatile
memory
e.g., digital cameras, TV set-top
boxes, cell phones
RAM: Random-access memory
Typically volatile memory
bits are not held without power
supply
Read and written to easily by
embedded system
during execution
Internal structure more
complex than ROM
a word consists of several
memory cells, each storing 1 bit
enable
2k n read and write
memory
A0
r/w
Qn-1 Q0
Ak-1
external view
14
each input and output data line
connects to each cell in its
column
rd/wr connected to every cell
when row is enabled by decoder,
each cell has logic that
stores input data bit when rd/wr
indicates write or outputs
stored bit when rd/wr indicates read
44 RAM
24
deco
der
Q3 Q0
A0
enab
le
A1
Q2 Q1
Memo
ry cell
I3 I2 I1 I0
rd/wr To every cell
internal
view
Basic types of RAM
SRAM: Static RAM
Memory cell uses flip-flop to
store bit
Requires 6 transistors
e
ct
io
n
Cache mapping
is the method for assigning main
memory addresses to the far
fewer number of available cache
addresses, and for
determining whether a particular
main memory address
contents are in the cache.
38
Direct mapping:
A particular block of main
memory can be brought to a
particular
block of cache memory. So, it is not
flexible.
Associative mapping:
In this mapping function, any
block of Main memory can
potentially reside in any cache
block position. This is much more
39
flexible mapping method.
Block-set-associative
mapping:
In this method, blocks of cache
are grouped into sets, and the
mapping allows a block of main
memory to reside in any block of
a specific set. From the flexibility
point of view, it is in between to
the other two methods.
All these three mapping methods
are explained with the
help of an example.
Consider a cache of 4096 (4K)
words with a block size of 32
words.
How many blocks are there in
the cache?
4K cache size require 12 bit
address lines
Since the cache is divided into
blocks.
40
Calculate the number of address
lines required to select and
block
Calculate the numbers of
address lines required to select one
word from each block
Cache Memory
Therefore, the cache is organized
as 128 blocks.
For 4K words, required address
lines are 12 bits.
To select one of the block out of
128 blocks, we need 7 bits
of address lines and to select one
word out of 32 words, we
need 5 bits of address lines.
41
So the total 12 bits of address is
divided for two groups,
lower 5 bits are used to select a
word within a block, and
higher 7 bits of address are used to
select any block of cache
memory.
Main Memory
Let us consider a main memory
system consisting 64K
words.
The size of address bus is 16
bits.
Since the block size of cache is
32 words, so the main
memory is also organized as block
size of 32 words.
42
Calculate the total number of
blocks in the main memory
and the bits required to address the
blocks and also to select
a word within a block.
48
The TAG field of that block is
compared to the TAG field of
the address.
If they match, the desired word
specified by the low-order 5
bits of the address is in that block
of the cache.
If there is no match, the required
word must be accessed
from the main memory, that is, the
contents of that block of
the cache is replaced by the new
block that is specified by the
new address generated by the CPU
and correspondingly the
TAG bit will also be changed by the
high order 4 bits of the
49
address
Associated Mapping Technique:
In the associative mapping
technique, a main memory block
can
potentially reside in any cache
block position.
In this case, the main memory
address is divided into two groups,
low-order bits identifies the location
of a word within a block and
high-order bits identifies the block.
In the example here,
50
11 bits are required to identify a
main memory block when it is
resident in the cache , high-order
11 bits are used as TAG bits and
low-order 5 bits are used to identify
a word within a block.
The TAG bits of an address
received from the CPU must be
compared to the TAG bits of each
block of the cache to see if the
desired block is present.
51
In the associative mapping, any
block of main memory can go
to any block of cache, so it has got
the complete flexibility
and we have to use proper
replacement policy to replace a
block from cache if the currently
accessed block of main
memory is not present in cache.
52
It might not be practical to use
this complete flexibility of
associative mapping technique due
to searching overhead,
because the TAG field of main
memory address has to be
compared with the TAG field of all
the cache block.
Block-Set-Associative Mapping
Technique
This mapping technique is
intermediate to the previous two
techniques.
Blocks of the cache are grouped
into sets, and the mapping
allows a block of main memory to
reside in any block of a
specific set.
Therefore, the flexibity of
associative mapping is reduced
53
from full freedom to a SET of
specific blocks.
This also reduces the searching
overhead, because the search
is restricted to number of SETS,
instead of number of blocks.
Also the contention problem of
the direct mapping is eased
76