MIPS Number of Instructions Executed and Memory Accessed

  • Thread starter Thread starter thchao
  • Start date Start date
  • Tags Tags
    Memory Mips
Click For Summary
SUMMARY

The discussion focuses on analyzing a MIPS assembly code snippet to determine the static and dynamic instruction counts, memory accesses, and execution time. The static instruction count is established as 6, while the dynamic instruction count is calculated to be 299, accounting for the loop iterations. Instruction memory is accessed 299 times, and data memory is accessed 99 times. The execution time for the code on a single cycle processor with a CPI of 1 at a clock rate of 100 KHz is computed to be approximately 2.99 milliseconds.

PREREQUISITES
  • MIPS assembly language programming
  • Understanding of static vs. dynamic instruction counts
  • Knowledge of memory access patterns in assembly
  • Familiarity with execution time calculations using CPI and clock rate
NEXT STEPS
  • Study MIPS assembly language control flow instructions
  • Learn about performance optimization techniques in MIPS
  • Explore the impact of instruction pipelining on execution time
  • Investigate memory hierarchy and access patterns in MIPS architecture
USEFUL FOR

Students studying computer architecture, MIPS assembly programmers, and anyone interested in performance analysis of assembly code execution.

thchao
Messages
2
Reaction score
0

Homework Statement


The number of instructions a program has is the static instruction count. The number of instructions actually executed (e.g. due to some instructions being repeated, as in a loop) is called the dynamic instruction count. Consider the following code:
li $t0, 99
li $t1, 44
loop: addi $t0, $t0, -1
lw $t1, 0($t1)
bne $t0, $zero, loop
add $v0, $t0, $zero

a. What is the static instruction count of this code? What is the dynamic instruction count? (Assume any pseudoinstructions are counted as 1 instruction).
b. How many times is the instruction memory accessed? How many times is the data memory accessed?
c. Assuming this runs on a single cycle processor (with CPI = 1) running at 100 KHz, how long will the code take to execute?

Homework Equations


[/B]
Execution Time = (CPI * IC) / Clock Rate

The Attempt at a Solution



a. Static Instruction Count: 6 (Since there are only 6 instructions in the code.)
Dynamic Instruction Count: (99 * 3) - 1 + 3 = 299 (The two li instructions and the add instruction only executed once. The loop itself executes 99 times but bne instructions executes only 98 times since at the 99th iteration, $t0 = 0 and bne instruction won't executed.)

b. Instruction Memory Accessed: 299 (Number of times program counter updated)
Data Memory Accessed: 99 (Number of times lw or load instruction was executed)

c. Given CPI = 1, IC = 299 (from part a), Clock Rate = 100000 (Converted KHz to Hz)
Execution Time = (1 * 299) / 100000 = 2.99 x 10-3 milliseconds

I am not sure if I calculated the Dynamic Instruction Count correctly and if the Instruction Memory Accessed is correct or not. Any input would greatly appreicated.
 
Last edited:
Physics news on Phys.org
thchao said:
... but bne instructions executes only 98 times since at the 99th iteration, $t0 = 0 and bne instruction won't executed.)
BNE executes every time. The duration may vary, but I think here you are not asked to consider that.

Perhaps you could say what processor this is, so that we can look up details.
 
It's the MIPS processor.
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 4 ·
Replies
4
Views
5K
  • · Replies 2 ·
Replies
2
Views
5K
  • · Replies 4 ·
Replies
4
Views
6K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
Replies
1
Views
2K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 4 ·
Replies
4
Views
3K