Memory Organisation 2
Memory Organisation 2
Memory Organisation 2
C ache
CPU
m e m o ry
Multiprogramming
enable the CPU to process a number of independent program concurrently
Memory Management System : sec. 12-7
supervise the flow of information between auxiliary memory and main memory
( a ) B lo c k d ia g r a m C h i p s e le c t 1 CS1
( b ) F u n c tio n ta b le
16 - 11 10 9 8 7 - 1 RD W R D a ta b u s
Address line 9 8
D ecoder
Address line 10
C S2
128 8 D a ta
RD
RAM 2
W R
ROM 1 : 0200 - 03FF AD7
Address line 10 C S1
C S1
C S2
RD : ROM CS1 1- 7 128 8
RO M
D a ta
8
OE(Output Enable)
AD 9
9
T ra c k s
K e y re g is te r ( K )
Memory In p u t
M = 1 O u tp u t
In p u t
A 1 A j A n
W rite
K 1 K j K n
W o rd 1 C 11 C 1j C 1n M 1 R S M a tc h
To M i
F ij lo g ic
Read
W o rd i C i1 C ij C in M i
W o rd m C m 1 C m j C m n M m
B it 1 B it j B it n
O u tp u t
Match Logic
One cell of associative memory : Fig. 12-8
Input = 1 or 0 Write F/F
A K Match Logic M=1 (M READ )
Read F/F
j 1 bit match
xj = Aj Fij (1 AND 1)+ Aj Fij (0 AND 0)
1 - n n bits match Mi = x1x2..xn
Key bit Kj : xj + Kj
Kj = 0 : Aj Fij no comparison ( Kj : xj + 1 = 1 )
Kj = 1 : Aj Fij comparison ( Kj : xj + 0 = xj )
Match Logic for word I : M i
= j 1
n
(xj + Kj)
= j 1
(Aj Fij + Aj Fij + Kj)
Mapping
The transformation of data from main memory to cache memory
1) Associative mapping
2) Direct mapping
3) Set-associative mapping
Example of cache memory : Fig. 12-10
main memory : 32 K x 12 bit word (15 bit address lines)
cache memory : 512 x 12 bit word M a in m e m o r y
32K 12 C a c h e m e m o ry
CPU
512 12
CPU sends a 15-bit address to cache
Hit : CPU accepts the 12-bit data from cache
Miss : CPU reads the data from main memory (then data is written to cache)
Associative mapping : Fig. 12-11 Cache Coherence (Sec. 13-5)
Cache memory associative memory C P U a d d r e s s ( 1 5 b its )
0 1 0 0 0 3 4 5 0
6 b its 9 b its
Tag In d e x
Tag (6 bit)
00 - 63
00 000 000
512 12
32K 12
C a c h e m e m o ry
Index (9 bit) O c ta l
H ex M a in m e m o r y a d d re s s
000 - 511 A d d re s s
A d d r e s s = 9 b its
D a ta = 1 2 b its
1FF
A d d r e s s = 1 5 b its
3F 1FF D a ta = 1 2 b its
M e m o ry In d e x
a d d re s s M e m o ry d a ta a d d re s s Tag D a ta
Direct mapping cache organization : Fig. 12-13 000000 1 2 2 0 000 00 1 2 2 0
: 02000 00777 2 3 4 0
1) Index 000 cache 01000 3 4 5 0
2) Tag cache
3) 000 Index cache tag 00
01777 4 5 6 0 777 02 6 7 1 0
(02 )
02000 5 6 7 0
4) miss (b ) C a c h e m e m o ry
5) main memory data read
02777 6 7 1 0
(address 02000 = 5670 read)
( a ) M a in m e m o ry
In d e x Tag D a ta 6 6 3
In d e x Tag D a ta Tag D a ta
000 0 1 3 4 5 0 Tag B lo c k W o rd
B lo c k 0 000 0 1 3 4 5 0 0 2 5 6 7 0
007 0 1 6 5 7 8
In d e x
010
B lo c k 1
017
770 0 2
B lo c k 6 3 777 0 2 6 7 1 0 0 0 2 3 4 0
777 0 2 6 7 1 0
Cache Initialization
Cache is initialized : cache empty invalid data .
1) when power is applied to the computer
2) when main memory is loaded with a complete set of programs from auxiliary memory
valid bit
indicate whether or not the word contains valid data
V ir tu a l M a in m e m o r y
a d d re s s M e m o ry a d d re s s M a in
r e g is te r m a p in g r e g is te r m e m o ry
( 2 0 b its ) ta b le ( 1 5 b its )
M e m o r y ta b le M a in m e m o r y
b u f f e r r e g is te r b u f f e r r e g is te r
Page no.
L in e n u m b e r
1 0 1 0 1 0 1 0 1 0 0 1 1 V ir tu a l a d d r e s s
T a b le P re s e n c e
a d d re s s b it
000 0 M a in m e m o r y
001 11 1 B lo c k 0
010 00 1 B lo c k 1
011 10 01 0101010011 B lo c k 2
100 0 M a in m e m o r y B lo c k 3
101 01 1 a d d r e s s r e g is te r
110 10 1
MBR
111 10
01 1
M e m o r y p a g e ta b le
V ir tu a l m e m o r y
P age no .
1 0 1 L in e n u m b e r A r g u m e n t r e g is te r
1 1 1 0 0 K e y r e g is te r
0 0 1 1 1
0 1 0 0 0
A s s o c ia tiv e m e m o r y
1 0 1 0 1
1 1 0 1 0
P ag e no . B lo c k n o .
Page(Block) Replacement
Page Fault : the page referenced by the CPU is not in main memory
a new page should be transferred from auxiliary memory to main memory
Replacement algorithm : FIFO LRU
MMU : OS
1) CPU
2) memory controller
Segment
A set of logically related instruction or data elements associated with a given
name
: a subroutine, an array of data, a table of symbol, users program
Logical Address
the address generated by a segmented program
similar to virtual address
Virtual Address : fixed-length page
Logical Address : variable-length segment
Segmented-page MMU
Fig. 12-21(a) : 2 table(segment, page)
2 table
Fig. 12-21(b) : Associative memory 1 table
TLB (Translation Look-a-side Buffer)
associative memory most recently reference table
Numerical Example
: Logical address & Physical address (Fig. 12-22)
Logical Address : 4 8 8
4 bit segment : 16 segments Segm ent Page W o rd
( b ) P h y s ic a l a d d r e s s f o r m a t : 4 0 9 6 b lo c k s o f 2 5 6 w o r d each,
e a c h w o r d h a s 3 2 b its
H e x a d e c im a l Page Table
a d d re s s Page num ber
6 00 00
6 00 FF Page 0 Segm ent Page B lo c k
6 01 00
6 01 FF
Page 1 6 00 012
6 02 00 6 01 000
Page 2
6 02 FF 6 02 019
6 03 00
6 03 FF
Page 3 6 03 053
6 04 00 6 04 A61
Segment 6 04 FF
Page 4
Page ( a ) L o g ic a l a d d r e s s a s s ig n m e n t ( b ) S e g m e n t- p a g e v e r s u s
Word m e m o r y b lo c k a s s ig n m e n t
L o g ic a l a d d r e s s
L o g ic a l a d d r e s s ( in h a x a d e c im a l)
Segm ent Page W o rd 6 02 7E
S e g m e n t ta b le P h y s ic a l m e m o r y
P a g e ta b le
S e g m e n t ta b le P a g e ta b le 0 00
000 00
B lo c k 0
000 FF
6 35
35 012
36 000
+ + 012 00
37 019
B lo c k 1 2
38 053 012 FF
39 A61
F A3
B lo c k W o rd
P h y s ic a l a d d r e s s 019 00
3 2 b it w o r d
019 7E
( a ) L o g ic a l to p h y s ic a l a d d r e s s m a p p in g A3 012 019 FF
( a ) S e g m e n t a n d p a g e ta b le m a p p in g
A r g u m e n t r e g is te r
Segm ent Page B lo c k
Segm ent Page B lo c k
6 02 019
6 04 A61
( b ) A s s o c i a t i v e m e m o r y t r a n s l a t i o n lo o k - a s i d e b u f f e r ( T L B ) ( b ) A s s o c ia tiv e m e m o r y ( T L B )
Memory Protection
Typical segment descriptor : Fig. 12-25
segment Length
B a s e a d d re s s L e n g th P r o te c tio n
Base address
A d d re s s b u s CPU
16 - 11 10 9 8 7 - 1 RD W R D a ta b u s
Decoder
3 2 1 0
CS1
CS2
128 8 D a ta
RD
RAM 1
W R
AD7
CS1
CS2
128 8 D a ta
RD
RAM 2
W R
AD7
CS1
CS2
128 8 D a ta
RD
RAM 3
W R
AD7
CS1
CS2
128 8 D a ta
RD
RAM 4
W R
AD7
CS1
CS2
1- 7 128 8 D a ta
RO M
8
AD9
9