You are on page 1of 3

Bài 1:

Xác định tag, index, byte-offset.

Số phần tử trong 1 block = (size of block)/(size of phần tử truy xuất) = 256/1 = 2^8

Số block trong cache = (size of cache) / (size of block) = 1MB / 256B = 2^12 blocks.

Không gian địa chỉ là 32 bit.

• Direct mapped: byte-offset 8 bits, index = 12bits, tag = 32 – 8 - 12 = 12 bits

• 4-Ways set associative: byte-offset 8 bits, index = 10 bits, tag = 32 - 8 - 10 = 14 bits ( do 4 block tạo
thành 1 set mà có 2^12 blocks nên có 2^10 sets )

• Fully associcative: byte-offset 8 bits, index = 0 bits, tag = 32 – 8 = 24 bits.

Bài 2:

Xác định tag, index, half-word offset.

Số phần tử trong 1 block = (size of block)/(size of phần tử truy xuất) = 64words / 2 bytes = 2^7.

Số block trong cache = size of cache / size of block = 256KB / 64words = 256*1024/64*4 = 2^10 blocks.

Không gian địa chỉ là 256M, do đó ta dùng thanh ghi 28 bit tính theo byte-offset.

• Direct mapped: half-word offset 7 bits, index = 10 bits, tag = 28 – 7 – 10 = 11 bits.

• 4 ways set associative: half-word offset 7 bits, index = 8 bits, tag = 28 – 7 - 8 = 13 bits. (do 4 block tạo
thành 1 set mà có 2^10 blocks nên có 2^8 sets )

• Fully associcative: half-word offset 7 bits, index = 0 bits, tag = 28 – 7 = 21 bits.

Bài 3:

a. Directed map

Address Tag Index Miss/Hit Giải thích


0x00000000 0 0 M First access
0x00000004 0 0 H
0x00000001 0 0 H
0x00000005 0 0 H
0x00000041 0 4 M First access
0x00000001 0 0 H
0x00000043 0 4 M Frist access
0x0000002E 0 2 H
0x00000001 0 0 H
0x00000046 0 4 M First access
0x00000002 0 0 H
0x00000000 0 0 H

• 2 Ghz → 1 chu kỳ 0.5ns

AMAT(time) = 6*0.5 + 0.67*10 = 9.7 cyc

b. 2-way set associative.

Address Tag 0 Tag 1 Index Miss/Hit


00000000 0 0 0(1) M
00000100 0 0 1(1) M
00000001 0 0 0 H
00000101 0 0 1 H
01000001 0 1 0(2) M
00000001 0 1 0 H
01000011 0 1 0 H
00101110 1 0 3(1) M
00000001 0 1 0 H
01000110 0 1 1(2) M
00000010 0 1 0 H
00000000 0 1 0 H

• 2 Ghz → 1 chu kỳ 0.5ns

AMAT(time) = 6*0.5 + 0.58*10 = 8.8 cyc

c. Full associative.

Address Tag Miss/Hit


00000000 0(0) M
00000100 0(1) M
00000001 0 H
00000101 1 H
01000001 16(2) M
00000001 0 H
01000011 16 H
00101110 11(3) M
00000001 0 H
01000110 17(4) M
00000010 0 H
00000000 0 H

• 2 Ghz → 1 chu kỳ 0.5ns

AMAT(time) = 6*0.5 + 0.58*10 = 8.8 cyc

Bài 4:

• L2 penalty = ram access time = 100 cyc.

• L1 penalty = L2 AMAT.

• L2 AMAT = 15 + 0.05*100 = 20 cyc.

• System AMAT = L1 AMAT = 10 + 0.25*20 = 15 cyc

• 2 Ghz → 1 chu kỳ 0.5ns

• AMAT (time) = 15×0.5= 7.5 ns

Bài 5:

CPI trung bình = Base CPI + Insstall + datastall

= Base CPI + tỉ lệ miss bộ nhớ lệnh * penalty bộ nhớ lệnh + tỉ lệ miss bộ nhớ dữ liệu * penalty bộ nhớ dữ
liệu

= Base CPI + 5%*100 + (100/1000)*10%*100 = Base CPI + 6

You might also like