Cache entries – Given the following information about a cache and the addresses
accessed/referenced, what is the Hit rate of the Data cache? (15 points)
• 2-way Set Associative Data Cache.
• Least Recently Used Cache Replacement Policy.
• Cache contains 8 blocks, with each block of size 2 words.
• Array A with 6 integer elements starts from 0x1234C8
• Array B with 6 integer elements starts from 0x4231FC.
• Array C with 6 integer elements starts from 0xDCBA98.
• Program accessing these 3 arrays performs the task C[i] = A[n-i] + B[i]. n = 5, i = 0 to 5.
• In the program, for every iteration (i = 0 to 5) the CPU reads array A element first, then
reads array B element and then writes to array C element.
• Following MIPS code shows the above program details:
Start: li $s0, 0x1234C8 # Base address of array A
li $s1, 0x4231FC # Base address of array B
li $s2, 0xDCBA98 # Base address of array C
addi $s3, $0, 5 # Num elements, n+1 = 6
addi $t0, $0, 0 # Loop variable i = 0
Loop: bgt $t0, $s3, Exit # Loop runs from 0 to n(=5)
sub $t1, $s3, $t0 # Index for array B
# Addresses for array elements A[n-i]($s4), B[i]($s5),
C[i]($s6)
sll $t2, $t0, 2
sll $t3, $t1, 2
add $s4, $t3, $s0
add $s5, $t2, $s1
add $s6, $t2, $s2
lw $t4, 0($s4) # Load A[n-i]
lw $t5, 0($s5) # Load B[i]
add $t6, $t4, $t5 # A[n-i] + B[i]
sw $t6, 0($s6) # Store above sum in C[i]
addi $t0, $t0, 1 # Update Loop Variable
j Loop
Exit: addi $t0, $0, 0 # Reset Loop variable i