Computer Architecture 3rd Edition by Moris Mano CH 12
Computer Architecture 3rd Edition by Moris Mano CH 12
Cache
CPU
memory
Multiprogramming
enable the CPU to process a number of independent program concurrently
CS1 CS2 RD W R Memory function State of data bus Chip select 2 CS2
0 0 × × Inhibit High-impedance
512×8
8 bit data bus
0 1 × × Inhibit High-impedance ROM
1 0 0 0 Inhibit High-impedance
1 0 0 1 W rite Input data to RAM
1 0 1 × Read Output data from RAM 9 bit address AD9
1 1 × × Inhibit High-impedance
16 - 11 10 9 8 7 - 1 RD W R Data bus
» Address line 9 8
Decoder
RAM 1 0 0 : 0000 - 007F 3 2 1 0
CS1
» 참고 CS1
Tracks
12-3 Auxiliary Memory
Magnetic Disk : Fig. 12-5, FDD, HDD
to r
Magnetic Tape : Backup or Program 저장
S ec
Optical Disk : CDR, ODD, DVD text
이름 주소
Key register (K)
Memory 내용 Input
M = 1 일때 출력 Output
Input
A1 A j An
W rite
K1 K j Kn
W ord 1 C 11 C 1j C 1n M1 R S Match
To M i
F ij logic
Read
W ord i C i1 C ij C in Mi
W ord m C m1 C mj C mn Mm
Output
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 : Mi
j 1
= (xj + Kj’)
n
j 1
Hit Ratio
the ratio of the number of hits divided by the total CPU references (hits + misses)
to memory
» hit : the CPU finds the word in the cache ( 보통 0.9 이상 )
» miss : the word is not found in cache (CPU must read main memory)
예제 : cache memory access time = 100 ns, main memory access time = 1000
총 10 회 ns, hit ratio = 0.9
Memory 참조
» 1 회 miss : 1 x 1000 ns Cache 가 없으면 1000 ns,
1900 ns / 10 회 = 190 ns 따라서 약 5 배 성능 향상
» 9 회 hit : 9 x 100 ns
Computer System Architecture Chap. 12 Memory Organization Dept. of Info. Of Computer.
12-8
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 Main memory
32K×12 Cache memory
CPU
0 1 0 0 0 3 4 5 0
Cache memory 로 저가의 일반 memory 사용 0 2 7 7 7 6 7 1 0
6 bits 9 bits
Tag Index
Tag (6 bit)
00 - 63
00 000 000
512×12
32K×12
Cache memory
Index (9 bit) Octal
Hex Main memory address
000 - 511 Address
Address = 9 bits
Data = 12 bits
1FF
Address = 15 bits
3F 1FF Data = 12 bits
Memory Index
address Memory data address Tag Data
Direct mapping cache organization : Fig. 12-13 000000 1 2 2 0 000 00 1 2 2 0
770 02
Block 63 777 0 2 6 7 1 0 0 0 2 3 4 0
777 02 6710
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
Computer System Architecture Chap. 12 Memory Organization Dept. of Info. Of Computer.
12-12
Page no.
Line number
1 0 1 0 1 0 1 0 1 0 0 1 1 Virtual address
Table Presence
address bit
000 0 Main memory
001 11 1 Block 0
010 00 1 Block 1
011 0
1 01 0101010011 Block 2
100 0 Main memory Block 3
101 01 1 address register
110 10 1
MBR
111 0
1
01 1
Virtual m em ory
Page no.
1 1 1 0 0 Key register
0 0 1 1 1
0 1 0 0 0
Associative m em ory
1 0 1 0 1
1 1 0 1 0
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, user’s 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 Segment Page W ord
8 bit page : 256 pages (a) Logical address format : 16 segments of 256 pages each,
8 bit word : 256 address field each page has 256 words
Address
» Physical Address : or Index
12 bit block : 4096 blocks 12 8
8 bit word : 256 address field Block W ord
2 20 × 32
Physical memory
Logical address
Logical address (in haxadecim al)
Segment Page W ord 6 02 7E
6 35
35 012
36 000
+ + 012 00
37 019
Block 12
38 053 012 FF
39 A61
F A3
Block W ord
Physical address 019 00
32 bit word
019 7E
(a) Logical to physical address mapping A3 012 019 FF
Argument register
Segment Page Block
Segment Page Block
6 02 019
6 04 A61
(b) Associative memory translation look-aside buffer (TLB) (b) Associative m emory (TLB)
Memory Protection
Typical segment descriptor : Fig. 12-25
segment Length
Base address Length Protection
Base address
16 - 11 10 9 8 7 - 1 RD WR Data bus
Decoder
3 2 1 0
CS1
CS2
128×8 Data
RD
RAM 1
WR
AD7
CS1
CS2
128×8 Data
RD
RAM 2
WR
AD7
CS1
CS2
128×8 Data
RD
RAM 3
WR
AD7
CS1
CS2
128×8 Data
RD
RAM 4
WR
AD7
CS1
CS2
1-7 128×8 Data
ROM
8
AD9
9