CS2100 Exam Questions Analysis and Cache Mapping Scenarios

cs2100 n.w
1 / 7
Embed
Share

Explore past year exam questions from CS2100, including code analysis, instruction execution, data forwarding scenarios, and cache mapping examples. Understand concepts like rotating array elements, instruction sequences, data caching, and more.

  • Exam Analysis
  • CS2100
  • Cache Mapping
  • Instruction Execution
  • Data Forwarding

Uploaded on | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. CS2100 Past Year Exam Questions (Prepared by Aaron Tan)

  2. AY2015/16 Semester 1 Q11 addi $t1, $a0, 12 # I1 lw $t0, 12($a0) # I2 Loop: lw $t2, -4($t1) # I3 sw $t2, 0($t1) # I4 addi $t1, $t1, -4 # I5 bne $t1, $a0, Loop # I6 sw $t0, 0($t1) # I7 (a) $a0 stores the base addr of integer array A. What does the code do? Rotates A[0], A[1], A[2], A[3] one element to the right. A[0] A[1] A[2] A[3] (b) If first instruction executed is I1, which is the seventh instruction executed? Instruction I3. 2

  3. AY2015/16 Semester 1 Q11 addi $t1, $a0, 12 # I1 lw $t0, 12($a0) # I2 Loop: lw $t2, -4($t1) # I3 sw $t2, 0($t1) # I4 addi $t1, $t1, -4 # I5 bne $t1, $a0, Loop # I6 sw $t0, 0($t1) # I7 (c) No data forwarding. Branch resolved at stage 4. Total number of cycles = 41 1 2 D F 3 E D 4 M W E F 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 I1 F I2 I3 I4 I5 I6 I3 M W D E M W F D F E D M W E M W F D E M W F D E M W 3

  4. AY2015/16 Semester 1 Q11 addi $t1, $a0, 12 # I1 lw $t0, 12($a0) # I2 Loop: lw $t2, -4($t1) # I3 sw $t2, 0($t1) # I4 addi $t1, $t1, -4 # I5 bne $t1, $a0, Loop # I6 sw $t0, 0($t1) # I7 (d) With data forwarding. Branch resolved at stage 2, predicted taken. Total number of cycles = 23 1 2 D F 3 E D F 4 M W E D F 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 I1 F I2 I3 I4 I5 I6 I3 M W E D F M W E D M W E F M W D F E D M W E M W 4

  5. AY2015/16 Semester 1 Q12 Base addresses: A = 0x00000080 B = 0xFFFF0040 C = 0x12345688 int sum = 0; for (int i=0; i<32; i++) { sum = sum + (A[i]*B[i]) C[i]; } Direct-mapped cache, 8 blocks, 4 words per block. First four iterations: A[0]..A[3] mapped to block 0. B[0]..B[3] mapped to block 4. C[0], C[1] mapped to block 0, C[2], C[3] mapped to block 1. 0x00000080 = 0000 00001 000 0000 0xFFFF0040 = 0000 00000 100 0000 0x12345688 = 0101 01101 000 1000 A[0] (miss), A[1] (miss), A[2] (miss), A[3] (hit). B[0] (miss), B[1]..B[3] (hits) C[0] (miss), C[1] (miss), C[2] (miss), C[3] (hit). Hit rate = 5/12 5

  6. AY2015/16 Semester 1 Q12 int sum = 0; for (int i=0; i<32; i++) { sum = sum + (A[i]*B[i]) C[i]; } A: 0000 00001 000 0000 B: 0000 00000 100 0000 C: 0101 01101 000 1000 Block 0 C[30] C[31] unknown unknown Block 1 B[20] B[21] B[22] B[23] Block 2 B[24] B[25] B[26] B[27] Block 3 B[28] B[29] B[30] B[31] Block 4 A[16] A[17] A[18] A[19] Block 5 A[20] A[21] A[22] A[23] Block 6 A[24] A[25] A[26] A[27] Block 7 A[28] A[29] A[30] A[31] 6

  7. END OF FILE

Related


More Related Content