Organization - Unit 5 - CO
Organization - Unit 5 - CO
Contents
• Basic concept and hierarchy
• semiconductor RAM memories and types,
ROM memories and types.
• Cache memories: concept and design issues (
performance, address mapping and
replacement)
• Virtual memory: concept implementation
Memory
• The memory unit is an essential component in any digital computer
since it is needed for storing programs and data.
• Not all accumulated information is needed by the processor at the
same time.
• So it is more economical to use low cost storage devices as a
backup for storing the information which is not currently used by
the CPU.
• The execution speed of programs is highly dependant on the speed
with which instruction and data can be transferred between the
processor and memory.
• There are 3 basic parameters of memory:--
• Capacity
• Speed
• Cost per bit
Capacity
• Memory can be viewed as a storage unit
containing m number of locations (addresses),
each of which stores n number of bits..
• Each word is addressed uniquely by log2m
number of bits.
• The total capacity of a memory is expressed as
mXn bit or m word memory.
• Ex. A 16 bit computer that generates 16-bit
address is capable of addressing up to 216=64K
memory locations.
Speed
• A useful parameter of the memory is its speed of
operation which is the time that elapses between the
initiation of an operation and the completion of that
operation.
• This is measured in terms of two parameter:
access time tA
cycle time tC
Access time is the time taken by the memory to complete
a read operation.
Cycle time is the min time delay required between the
initiations of two successive memory operation.
Types of Memory
• Memory is the main component of a computer system. It stores
instructions and data in binary form that is used by the central
processing unit. Memories are divided into 2 types such as
1) Primary memory
2) Secondary memory
• Primary memory is the memory that can be directly accessed by
the CPU which constantly interacts with it, retrieves data stored
therein, goes through instructions and execute them as per the
requirement.
• Secondary memory:The maximum capacity of primary memory is
limited. So to handle more data than allowed by primary memory,
secondary memory is used. And it is non-volatile i.e. data is not lost
due to current failure. Magnetic tape, Floppy disk and Hard disk are
some examples of secondary memory.
Types of Memory
Memory
Primary
Secondary
Magnetic
RAM ROM tape
PROM Magnetic
SRAM Disk
EPROM
DRAM CD ROM
EEPROM
• RAM( Random access memory/ Read write memory):--
The most familiar form of system memory, Random Access Memory
(RAM) derives its name from the fact that any of its memory cells
can be accessed directly if you are aware of the row and column
that intersect at that cell. The columns are referred to as bit lines
while the rows are referred to as word lines. The intersection of a
word line and bit line is the address of the memory cell onto a
silicon wafer.
This is volatile in nature, it means contents stored in it are not
permanent.
Some common types of RAM are as follows
(1) SRAM: Used primarily to create CPU’s speed-sensitive cache,
Static Random Access memory (SRAM) uses multiple
transistors for each memory cell. It does not have a capacitor
in each cell.
Each bit of memory is held by a flip-flop memory which takes
four to six transistors besides some wiring. SRAM is not
required to be refreshed which makes it significantly fast. As
compared to DRAM, SRAM has more parts and therefore it
consumes a lot more space on a chip.
(2) DRAM: Dynamic Random Access Memory needs to be refreshed
consistently and contains memory cells with a paired transistor. In order to
activate the transistor at each bit in the column, DRAM sends a charge
through the appropriate column .
The level of charge is determined by the sense-amplifier while reading. If
the level of charge exceeds fifty percent, it is read as a 1 whereas if the
charge is below fifty percent it is read as a 0. For dynamic memory to work,
Either the CPU or the memory controller recharges all the capacitors before
they are discharged to zero.
To ensure this the memory is read and written back which if referred to as
refresh operation. DRAM is required to be refreshed dynamically all the
time otherwise it will lose the information. This refreshing operation
consumes a lot of time and causes the memory to slow down.
Memory cells have a support infrastructure of other specialized circuits so
that information can be put in and retrieved from them. These circuits
identify each and column, keep track of the refresh sequence, read and
restore the signal from a cell and tell a cell whether it should take a charge
or not)
ROM
• Read Only Memory (ROM) is an integrated circuit programmed with
data that holds instructions for starting up the computer. Data
stored in ROM is non volatile and is not lost when powered off.
These data cannot be changed or a special operation is needed to
be performed to change it.
ROM chips also comprise of columns and rows but it is different
from RAM in terms of intersection of these. These chips use diodes
instead of transistors to connect the lines if the value is 1 whereas if
the value is 0 the lines are not connected.
A ROM chip cannot be reprogrammed or rewritten therefore when
the chip is created it requires the programming of perfect and
complete information. ROM chips are cost effective and use very
little power.
(1) PROM
Programmable read only memory (PROM) is a
type of ROM. These chips are non volatile and
cannot be purged to store something else once it
has been used. Blank PROM chips can be coded
with the help of a tool known as a programmer.
CPU
Register
Cache
RAM
Access time
capacity
Cost per bit
RAM ROM
Flash Memory
Hard disk
CD and DVD
Magnetic tape
Bootstrap loader
• The bootstrap loader is a program whose
function is to start the computer software
operating when power is turned on.
• When power is turned on the hardware of
computer sets the program counter to the first
address of bootstrap loader.
• The bootstrap program loads a portion of the
operating system from disk to main memory and
control is then transferred to the operating
system, which prepares the computer for general
use.
RAM chips
RAM
• The block diagram of a RAM chip has been
shown.
• The capacity of memory is 128 words of eight bits
each.
• This require a 7 bit address and an 8 bit
bidirectional data bus which is constructed with
three state buffer gate.
• The read write inputs specify the memory
operation and the two chip select CS control
inputs are for enabling the chip only when it is
selected by the microprocessor.
RAM
• The unit is in operation only when CS1=1 and CS2 =0.
• If the chip select inputs are not enabled or if they are
enabled but the read write inputs are not enabled the
memory is inhibited and its data bus is in high
impedance state.
• When CS1=1 and CS2=0 the memory can be read or
write mode.
• When WR input is enabled the memory stores a byte
from the data bus into a location specified by the
address input line
• When RD input is enabled the content of selected
bytes are placed into the bus.
ROM chip
Memory address map
• The designer of a system must calculate the
amount of memory required for the particular
application and assign it to either RAM or ROM.
• The addressing of the memory can be established
by means of a table that specifies the memory
address assigned to each chip.
• The table called a memory address map is a
pictorial representation of assigned address
space for each chip in the system.
Example 1
• Assume that a computer system needs 512
bytes of RAM and 512 bytes of ROM.
• RAM chip is of 128 X 8
• And ROM chip is of 512 X 8
Ex 1Calculation of no. of chips.
•
Size=512 bytes
= 512 X 8
128 X 8 RAM 1
128 X 8 RAM 2
512 X 8 RAM
128 X 8 RAM 3
128 X 8 RAM 4
• The hexadecimal address assigns a range of
hexadecimal equivalent address for each chip
128 X 8
• As there are 2048 addresses
• So log2(2048)= 211
• So 11 bits for addressing
• Common lines will be 7 as RAM is of 128 bytes
• 4 lines for chip select.
• Size of decoder 4 X 16.
•
RAM 10
RAM 16
RAM 11
RAM 13
RAM 14
RAM 15
RAM 12
RAM 1
RAM 9
RAM 7
RAM 8
RAM 5
RAM 3
RAM 4
RAM 2
RAM 6
CS 1
CS1
CS1
CS1
CS1
CS1
CS1
CS1
CS1
CS1
CS1
CS1
CS1
CS1
CS1
CS1
16 out put lines each will be
connected to CS 1of RAM chip
0 1 2 3 4 --------------16
Decoder
4 X 16 7 address lines to access 128
words.
11 10 9 8 7654321
Cache memory
• Principle of Locality:-
Programs access a small proportion of their address
space at any time
Temporal locality
– Items accessed recently are likely to be accessed again
soon
– e.g., instructions in a loop, induction variables
Spatial locality
– - Items near those accessed recently are likely
to be accessed soon
– E.g., sequential instruction access, array data
Cache memory
• If the active portion of the program and data
are placed in a fast memory, the average
access time can be reduced, thus reducing the
total execution time of program. Such a fast
memory is referred to as a cache memory.
The working of cache
• When the cpu needs to access the memory,
the cache is examined. If the word is found in
the cache, it is read from there. If it is not
found in the cache, the main memory is
accessed to read the word. A block of word
containing the one just accessed is then
transferred from main memory to cache..
Hit Ratio
The performance of cache memory
When the CPU refers to memory and finds the word in the cache its is
said to produce a hit.
If the word is not found in cache it is in main memory and it counts as
miss.
CPU
Main Memory Cache
32 K X 12 memory
512 X 12
Associative mapping
Direct mapping
Set-associative mapping
Associative Mapping
- Any block location in Cache can store any block in memory
-> Most flexible
- Mapping Table is implemented in an associative memory
-> Fast, very Expensive
- Mapping Table
Stores both address and the content of the memory word
address (15 bits)
Argument register
Address Data
01000 3450
CAM 02777 6710
22235 1234
40
Associative mapping
• The associative memory stores the address and data of
memory word.
• Here the address is of 15 bits and data is of 12 bits.
• A cpu address of 15 bit is placed in argument register and
the associative memory is searched for the matching
address.
• If the address is found the corresponding 12 bit data is read
from the memory.
• If no match occurs, main memory is accessed for the word.
• The address data pair is than transferred to the associative
cache memory.
• If the cache is full then a pair of address of data is replaced
from the memory.
Direct mapping
• Associated memories are expansive compared to RAM
because of the address logic associated with each cell.
• In direct mapping address is divided in two fields (1)
index (2) tag
• The number of bits in the index field is equal to the no.
of address bits required to access the cache memory.
• In general if there are 2K words in cache memory and n
words in main memory. The n bit memory address is
divided into two fields
• K bits for index and n-k bits for tag.
MEMORY AND CACHE MAPPING - DIRECT MAPPING -
01777 4560
02000 5670
777 02 6710
02777 6710
44
DIRECT MAPPING
Operation
Block 63 770 02
777 02 6710
45
Direct mapping
Direct mapping
Direct Mapping
• Each word in cache consist of the data word and
its associated tag. When a new word is first
brought into the cache the tag bits are stored
alongside the data bits.
• The index field is used to access the cache.
• The tag field is compared.
• If the two tag match, there is a hit and desired
data is in cache.
• If there is a miss the required word is read from
main memory, and stored in the cache together
with the new tag replacing the previous value.
Direct mapping
CPU address= 02777
777 is the index and 02 is
the tag bits.
As the two tag matches
there is a hit
777 01 4560
• The disadvantage of direct mapping is that the
hit ratio can drop if two or more words whose
address have the same index but different
tags are accessed repeatedly.
• Ex 01000, 02000, 03000
• This possibility is minimized by the fact that
they will be far apart in the address range.
Direct mapping
• If the cache uses block size of 8 words. Then
the index is divided into two fields.
• (1) block (2) word
• 512/ 8 =64 blocks 6 bits for block
• 9-6=3 bits for word
•
Tag Block Word
6 6 3
Question
• A digital computer has a memory unit of 64K X
16 and a cache memory of 1K words. The
cache can use direct mapping with a block size
of four words.
• (a) how many bits are there in the tag, index,
block and word fields of the address format?
• (b) how many block can the cache
accommodate?
Solution
• Cache size 1K= 210
• So 10 bits are required to address the cache
memory. Index=10bits
• Total memory capacity=64K= 216
• Tag=16-10=6bits
• No. of blocks=1024/4=256=28
• 8 bits for block
• 2 bits for words
Set-Associative mapping
• This organization shows an improvement over
the direct mapping technique.
• Each data word is store two or more words of
memory under the same index addresses.
• Each data word is stored together with its tag.
• The number of tag-data items in one word of
cache is said to form a set.
MEMORY AND CACHE MAPPING - SET ASSOCIATIVE MAPPING -
Operation
- CPU generates a memory address(TAG; INDEX)
- Access Cache with INDEX, (Cache word = (tag 0, data 0); (tag 1, data 1))
- Compare TAG and tag 0 and then tag 1
- If tag i = TAG -> Hit, CPU <- data i
- If tag i TAG -> Miss,
Replace either (tag 0, data 0) or (tag 1, data 1),
Assume (tag 0, data 0) is selected for replacement,
(Why (tag 0, data 0) instead of (tag 1, data 1) ?)
M[tag 0, INDEX] <- Cache[INDEX](data 0)
Cache[INDEX](tag 0, data 0) <- (TAG, M[TAG,INDEX]),
CPU <- Cache[INDEX](data 0)
56
Set associative mapping
Set associative mapping
• Here each index address refers to two data
words and their associated tags.
• Each tag require 6 bits and each data word is
of 12 bits.
• So the word length is 2(6+12)=36 bits.
• An index address of 9 bits can accommodate
512 words.
• Thus the size of cache memory is 512X36 bits.
Set associative mapping
• When the cpu generates a memory request,
the index value of the address is used to
access the cache.
• The tag field of the address is then compared
with both tags in the cache to determine if a
match occurs.
• The comparison logic is done by an associative
search of the tags.
CACHE WRITE
Write Through
When writing into memory
If Hit, both Cache and memory is written in parallel
If Miss, Memory is written
For a read miss, missing block may be
overloaded onto a cache block
Memory is always updated
-> Important when CPU and DMA I/O are both executing
Slow, due to the memory access time
Write-Back (Copy-Back)
When writing into memory
If Hit, only Cache is written
If Miss, missing block is brought to Cache and write into Cache
For a read miss, candidate block must be
written back to the memory
Memory is not up-to-date, i.e., the same item in
Cache and memory may have different value
60
Questions