# Calculate Number of Cycles and Average Operand Fetch Rate of the Machine

• Difficulty Level : Medium
• Last Updated : 04 Oct, 2021

In this article, we will know how to calculate the average operand fetch rate of the machine when the machine uses different operand accessing modes.

Example-1 :
Consider a hypothetical machine that uses different operand accessing mode is given below. Assume the 3 clock cycles consumed for memory access, 2 clock cycles consumed for arithmetic computation, 0 clock cycle consumed when data is present in the register or Instruction itself, What is the average operand fetch rate of the machine?

Solution :
In Indexed Addressing mode, if nothing is specified then we assume “Base Address is given directly into the instruction and Index value is stored into the Index Register“. Now, If we look at the given operand accessing mode with their number of cycle required to execute according to the given question we can see that –

Immediate Accessing Mode needs no reference or 0 Cycles.
Register Accessing Mode needs a 0-reg reference or 0 Cycles.
Direct Accessing Mode needs a 1-memory reference or 3 Cycles.
Memory Indirect Accessing Mode needs a 2-memory reference.
OR
3*2 Cycles (1-memory reference has 3 cycles so 2-mem reference has 3*2 cycles).
Indexed Accessing Mode needs 1-reg reference and 1-mem reference and 1-arithmetic calculation.
OR
5 Cycles (1-memory reference has 3 cycles and 1-arithmetic calculation has 2 cycles).

We can get the total average number of cycles required to execute one instruction by taking the sum of products of frequency and number of cycles.
The total average number of Cycle required to execute one instruction

= (0.25\times0) + (0.28\times0) + (0.18\times3) + (0.14\times6) + (0.15\times5)
= 2.13 Cycles

Now it is known that the time taken to complete one cycle is

= 1/1GHz = 1 nanosecond

Average time required to execute one instructions

= 2.13 ∗ 1 = 2.13 nanosecond

So, 2.13 nanoseconds are required for = 1 instruction.

1 second is required for

= 1 / (2.13 * 10^(-9))
= 0.469483568 * 10^9 Instructions
= 469.483568 MIPS (Million Instructions Per Second).
In general we take operation fetch rate in MIPS.

Example-2 :
Consider a hypothetical machine that uses different operand accessing mode is given below. Calculate Cycle per Instructions or CPI.

Solution :
In computer architecture, cycles per instruction are one aspect of a processor’s performance: the average number of clock cycles per instruction for a program or program fragment. It is the multiplicative inverse of instructions per cycle.
It is given that –

ALU Instruction consumes 4 cycles
Branch Instruction consumes 2 cycles
CPI = 4*0.45 + 3*0.35 + 2*0.1 + 2*0.1
= 3.25 Cycles/Instruction