in CO and Architecture retagged by
783 views
1 vote
1 vote

( Numerical Answer Type Questionm )

in CO and Architecture retagged by
783 views

4 Answers

1 vote
1 vote
Best answer

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

3 Comments

How come u got 19*5 MR ops?
0
0
edited by

@Rohit Chakraborty bro refer this question 

here in quesiton it is mentioned that for each memory reference there we need 5 memory cylces so toatal memory cycle that will be neeeded will be equals to it s multiply with no of m/o refernce and 4 is added for alu opeatations.

0
0

@Ray Tomlinson you have nowhere explained how you got 19 Memory References and I don’t think we even care about pipelining in this question.

0
0
1 vote
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 votes
0 votes

99.

2 Comments

Can u explain the answer please
0
0
0 votes
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

Related questions