• retagged by
1,931 views

4 Answers

Best answer
1 1 vote

A pipeline model with stages IF (Instruction Fetch), ID (Instruction Decode), OF (Operand Fetch), PD (Perform operation in ALU and store result in a register) and WB (Write Back).

  1. MOV r0, 4000 (I1): This is a memory reference operation, so it takes 5 cycles. It’s broken down into IF (1 cycle), ID (1 cycle), OF (1 cycle), PD (1 cycle) and WB (1 cycle).

  2. ADD r0, r1, r2 (I2): This is an ALU operation, so it takes 2 cycles. It’s broken down into IF (1 cycle) and ID (1 cycle). The OF, PD and WB stages are overlapped with the next instruction due to pipelining.

  3. STO r0, 5000 (I3): This is a memory reference operation, so it takes 5 cycles. It’s broken down into IF (1 cycle), ID (1 cycle), OF (1 cycle), PD (1 cycle) and WB (1 cycle).

  4. MOV r3, 6000 (I4): This is a memory reference operation, so it takes 5 cycles. It’s broken down into IF (1 cycle), ID (1 cycle), OF (1 cycle), PD (1 cycle) and WB (1 cycle).

  5. SUB r4, r3, r2 (I5): This is an ALU operation, so it takes 2 cycles. It’s broken down into IF (1 cycle) and ID (1 cycle). The OF, PD and WB stages are overlapped with the next instruction due to pipelining.

  6. STO r4, 7000 (I6): This is a memory reference operation, so it takes 5 cycles. It’s broken down into IF (1 cycle), ID (1 cycle), OF (1 cycle), PD (1 cycle) and WB (1 cycle).

The total time required to complete the program execution is calculated as follows:

Total time = Time(I1) + Time(I2) + Time(I3) + Time(I4) + Time(I5) + Time(I6)

Total time = 19 * 5 cycles for memory reference operations + 4 cycles for ALU operations

Total time = 95 cycles + 4 cycles = 99 cycles

Since each cycle corresponds to 1 ns on a 1 GHz processor, the total time required to complete the program execution is 99 ns.

This solution takes into account the pipelining of instructions which allows multiple instructions to be executed simultaneously at different stages of execution. This is why the ALU operations only take up 2 cycles in the pipeline despite technically requiring more cycles for completion.

• edited by
1 1 vote

We know there are 5 stages : IF ID OF PD WB
IF => Fetches the opcode ; No of MR = opcode size (in words)
ID=> Fetches the remaining instruction ; No of MR = Instr size – opcode size (in words)
OF=>  Identify the operands from the meaning of instruction. Here in this question , RHS side are operands
PD => Perform Operations
WB=> Here in this question , LHS side is where we are storing.


I5 : MOV @4000, r0 ; m[[4000]] ← r0 ; Size : 4 word

Opcode is of 1 word. So IF = 1MR
Remaining instruction = 3 words . So ID = 3MR
Operands are RHS ie only r0 . So OF = 1RR
PD :   -
WB: LHS is using indirect Address . So 2MR.

I3 :ADD r0,[3000] ; r0 ← r0+[3000]; 1 word

IF : opcode size : 1MR
ID : -
OF: RHS => 1RR , 1MR
PD: 1ALU
WB: LHS => 1RR

0 0 votes
here, as nothing is given about memory whether it is byte or word addressable

and size of each instruction is given in words so assume word addressable.

During Instruction Fetch , there will following memory references

I1=4

I2=2

I3=1

I4=1

I5=4

I6=1

total cycles during instruction fetch=(4+2+1+1+4+1)*5=65 ns

during Execution phase,memory references

I1=2

I2=1

I3=1

I5=2

total cycles=(2+1+1+2)*5=30 ns

during execution ALu operation,

I3=1

I4=1

total cycles for ALU operation=(2)*2=4ns

now add all the cycles to get total cycles for program execution=65+30+4=99ns
Position:
Show:

Related questions

2 2 votes
3 3 answers
2.0k
2.0k views
Shaikh727 asked Jan 24, 2024
1,990 views
Consider 16 bit CPU with 4 GB RAM supports 2 Address Instruction with Address 1 uses direct addressing mode Address2 uses indirect addressing mode. Opcode is designed as ...
3 3 votes
1 answers 1 answer
4.6k
4.6k views
sushmita asked Oct 25, 2016
4,554 views
consider an instruction of indirect addressing mode. what are the number of memory references by the processor when an instruction is a computation that requires a single...
2 2 votes
1 answers 1 answer
505
505 views
ARUN_YADAV 1 asked Jan 10
505 views
Consider a processor with a 4-byte jump instruction encountered at memory address 4096. If the jump instruction is in PC-relative mode and the instruction at memory addre...
0 0 votes
1 1 answer
1.1k
1.1k views
Chaitanya Kale asked Feb 13, 2023
1,128 views
Consider 3-word long jump instruction designed with PC-relative addressing mode, stored in the memory with a starting address of (2000)$_{10}$. Address field of an instru...