Unit 6 Memory Organization
Unit 6 Memory Organization
Unit 6 Memory Organization
Organization
• Main Memory: memory unit that communicates directly with the CPU
• RAM, ROM
I/O Processor
Magnetic
Tapes
Main Memory CPU
Cache
Memory
© Ronak Patel, Computer Engineering Department , CSPIT, CHARUSAT
Memory Hierarchy
Smaller
Faster Registers
Costlier
(per byte storage) Cache
(SRAM)
Main memory
(DRAM)
2. DRAM(Dynamic RAM)
• Stores the Binary information in the form of electric charges that are applied
to capacitors
• Refreshing is required
• Reduced power consumption and Larger storage capacity
© Ronak Patel, Computer Engineering Department , CSPIT, CHARUSAT
ROM (Read Only Memory)
• Non volatile
• Store programs and data that are permanently reside in the computer
that do not change in value.
• Store Bootstrap Loader
• When power is turned on, the hardware of the computer sets the
program counter to the first address of the bootstrap loader.
Function Table
CS1 CS2 RD WR Memory Function State of the Data Bus
0 0 × Inhibit High Impedance
×
0 1 × × Inhibit High Impedance
1 1 × × Inhibit High Impedance
1 0 0 0 Inhibit High Impedance
1 0 0 1 Write Input data to RAM
1 0 1 × Read Output data from RAM
© Ronak Patel, Computer Engineering Department , CSPIT, CHARUSAT
ROM Chip
Block Diagram
• Available chip
• RAM: 128 × 8
• ROM: 512 × 8
8 bit data
128 × 8 128 × 8 128 × 8 128 × 8 512 × 8
RAM 1 RAM 2 RAM 3 RAM 4 ROM
CS1 CS2 RD WR AD7 CS1 CS2 RD WR AD7 CS1 CS2 RD WR AD7 CS1 CS2 RD WR AD7 CS1 CS2 AD
9
WR
RD
1
1-7 8 9
1-7
0
8
1
Decoder
Address bus
2
9
3
10
11-16
Component
Binary Hexa Binary Hexa
Decimal Decimal
10 9 8 7 6 5 4 3 2 1 10 9 8 7 6 5 4 3 2 1
0 0 0 0 0 0 0 0 0 0 0000 0 0 0 1 1 1 1 1 1 1 007F
RAM-1
0 0 1 0 0 0 0 0 0 0 0080 0 0 1 1 1 1 1 1 1 1 00FF
RAM-2
0 1 0 0 0 0 0 0 0 0 0100 0 1 0 1 1 1 1 1 1 1 017F
RAM-3
0 1 1 0 0 0 0 0 0 0 0180 0 1 1 1 1 1 1 1 1 1 01FF
RAM-4
1 0 0 0 0 0 0 0 0 0 0200 1 1 1 1 1 1 1 1 1 1 03FF
ROM
• The memory is capable of finding an empty unused location to store the word.
• When a word is to be read from the memory, the content of the word, or part of the word,
is specified.
• The memory locates all words which match the specified content and marks them for
reading.
• Expensive
© Ronak Patel, Computer Engineering Department , CSPIT, CHARUSAT
Cache Memory
• Locality of reference: few localized areas of memory are repeatedly
referred.
• If the active program and data are placed in a fast small memory, the
average memory access time can be reduced, thus reducing total
execution time of the program. Such a fast small memory is referred
to as a cache memory.
0
2 2 mod 4 = 2
3
Tag 1
2
4 4 mod 4 = 0
5
3 1 Bit of Tag is required
Cache Memory 01 6
No of Block(N)=4 7
MM Blocks That Can be Placed in Block 0 of CM are {0,4} Main Memory
MM Blocks That Can be Placed in Block 1 of CM are {1,5} No of Block(M)=8
MM Blocks That Can be Placed in Block 2 of CM are {2,6}
MM Blocks That Can be Placed in Block 3 of CM are {3,7}
© Ronak Patel, Computer Engineering Department , CSPIT, CHARUSAT
Direct Mapping
1 bit 2 bits 2 bits
TAG Physical
Cache Blockaddress
Offset Word Offset
0 1 0 0 1
0 0 mod 4 = 0
Compare
1
01 0
2 2 mod 4 = 2
3
Tag 1
0 2
4 4 mod 4 = 0
1 5
3
Tag bits are same. Cache Memory 6
So word is present. No of Block(N)=4
It is at location 1.
7 7 mod 4 = 3
Check word no 9 is present in cache or not? Main Memory
No of Block(M)=8
Physical Address 0 1 0 0 1
© Ronak Patel, Computer Engineering Department , CSPIT, CHARUSAT
Example
• MM= 512 words
• CM = 64 words
• Block size= 16 words
1. How many Bits for Physical Address?
2. How many TAG Bits are required?
3. How many Bits are required for cache offset?
4. How many Bits are required for word offset?
5. If MM blocks 16, 9, 26, 7 are present in CM than show Tag of each
cache.
6. Now Check on above cache representation that word 237 and 400 is
Present? and How?
© Ronak Patel, Computer Engineering Department , CSPIT, CHARUSAT
Direct Mapping
3 bit 2 bits 4 bits
PA= 9 Bits TAG Physical
Cache Blockaddress
Offset Word Offset
1
10000 16
100 2
00 16
01001 9
010 3
Tag 01 9
11010 26 4
110 26
10 00111
001 7 :
11 7
30
Cache Memory
No of Block(N)=4 31
Check word is present in cache or not?
word no 237 word no 400 word no 145
PA: 010 01 0001 Main Memory
PA: 011 10 1101 PA: 110 01 0000 No of Block(M)=32
TAG is Different in 10 TAG is Different in 01 TAG is same in 01 word is at 0001 in that block
© Ronak Patel, Computer Engineering Department , CSPIT, CHARUSAT
Limitation of Direct Mapping
• Conflict penalties:
• Present of one block abstracting the incoming block inspite of the cache is
free
• MM Block ref: 0, 4, 0, 4, 8, 0, 4, 12, 4, 12
1
000 2
0
010 3
Tag 1
111 4
2
5
3
Cache Memory 6
No of Block(N)=4 7
Main Memory
No of Block(M)=8
© Ronak Patel, Computer Engineering Department , CSPIT, CHARUSAT
Example
• MM= 512 words
• CM = 64 words
• Block size= 16 words
1. How many Bits for Physical Address?
2. How many TAG Bits are required?
3. How many Bits are required for cache offset?
4. How many Bits are required for word offset?
5. If MM blocks 16, 9, 26, 7 are present in CM than show Tag of each
cache.
6. Now Check on above cache representation that word 237 and 400 is
Present? and How?
© Ronak Patel, Computer Engineering Department , CSPIT, CHARUSAT
Set Associative Mapping
• Advantage of Direct Mapping and Associative Mapping.
• Jth Block of MM has to be placed in ( Jth mod S )th Set. Within the set it
can be placed anywhere.
TAG Physical
Set Offsetaddress Word Offset
2 bits 1 bit 2 bits 0 0 mod 2 = 0
1
00 0
2 2 mod 2 = 0
01 3
1
11 4
2
5
3
Cache Memory 6
No of Block(N)=4 7 7 mod 2 = 1
Main Memory
No of Block(M)=8
© Ronak Patel, Computer Engineering Department , CSPIT, CHARUSAT
Example
• MM= 512 words
• CM = 64 words
• Block size= 16 words
• 2-way Set Associative
1. How many Bits for Physical Address?
2. How many TAG Bits are required?
3. How many Bits are required for set offset?
4. How many Bits are required for word offset?
5. If MM blocks 16, 9, 26, 7 are present in CM than show Tag of each cache.
6. Now Check on above cache representation that word 237 and 400 is
Present? and How?
© Ronak Patel, Computer Engineering Department , CSPIT, CHARUSAT
Question
• Consider 1MB cache and 4 GB MM are partitioned into 64KB blocks.
1. How many bits are required for Physical address if word size is 1B?
4. How many TAG memory in Bytes are required for each case?
8-Way Set Associative: TAG Set Offset Word Offset 8 – 15 bits 16 × 15 = 240 bits = 30 B
15 bits 1 bit 16 bits
• Write-back
Cache Initialization
• Valid bit
• Why it is required?
• Paging overview
?
© Ronak Patel, Computer Engineering Department , CSPIT, CHARUSAT