in CO and Architecture edited by
24,300 views
47 votes
47 votes

Consider the following data path of a $\text{CPU}.$

The $\text{ALU},$ the bus and all the registers in the data path are of identical size. All operations including incrementation of the $\text{PC}$ and the $\text{GPRs}$ are to be carried out in the $\text{ALU}.$ Two clock cycles are needed for memory read operation – the first one for loading address in the $\text{MAR}$ and the next one for loading data from the memory bus into the $\text{MDR}.$

The instruction $``\text{add R0, R1}”$ has the register transfer interpretation $\text{R0} \Leftarrow \text{R0 + R1}.$ The minimum number of clock cycles needed for execution cycle of this instruction is:

  1. $2$
  2. $3$
  3. $4$
  4. $5$
in CO and Architecture edited by
24.3k views

4 Comments

edited by

Carl Hamacher and William Stallings describes Fetch phase to be completed in 3 cycles. So according to these books your sequence in correct. But in Morris Mano, Fetch phase takes 2 clock cycle,

  1.  PC -->MAR
  2. [MAR]-->IR

So, it depends. that’s why they asked for execution phase only.

1
1
i just wanna know why alu cycle is not take here. why directly add and store in register
0
0

@manikantsharma

But, here it is mentioned that value of $PC$ is incremented in the ALU.

Doubt:

There is not need to copy the $PC$ value in the $MDR$ right? as it is just for data, and $MAR$ value can be directly transffered into $IR$, which means that the instruction fetch is completed.

am i correct?

0
0

6 Answers

72 votes
72 votes
Best answer

Instruction fetch requires two cycles but the question asks for the execution part only!

Now for execution:

  1. $R1_{out}, S_{in}\qquad S \leftarrow R0 \quad -1^{st}$ cycle
  2. $R2_{out}, T_{in}\qquad T \leftarrow R1 \quad - 2^{nd}$ cycle
  3. $S_{out}, T_{out}, \text{Add } R0_{in} \quad R0 \leftarrow R0 + R1  \quad -  3^{rd}$ cycle

So, $3$ cycles for execution.

As it is asked for only execution cycles, no of cycles required $=3.$

Had it been asked for instruction cycles, then the answer will be $5.$

Hence, option B is correct.

edited by

4 Comments

why is not a cycle from ALU → R0 not considered, or maybe ALU gives output back to S but then we need to supply back S to R0 ( Write back stage) ?? shouldn’t it be 4 cycles.
0
0
An instruction cycle is consisting of

1) Fetch Cycle

2)Decode cycle

3)Execution cycle

and in this question, they have asked for Execution Cycle Only.
1
1
execution cycle = OF + compute + WB.

2 cycle for OF, 1 cycle for WB but why we not taking 1 cycle for computation(addition)
0
0
13 votes
13 votes
S <- R0 ...... 1cycle ( Since the buses are of same size as the

T <- R1 ...... 2nd cycle

R0 <- R0 + R1  ..... 3rd cycle

therefore we need 3 cycles.

3 Comments

will operand fetch not be the part of execution ?
0
0

If One wonders why S <- R0 is one cycle. 

It is given,

"Two clock cycles are needed for memory read operation – the first one for loading address in the MAR...."

Means PC to MAR one cyle, and it is given all registers are same size. so  R0 to S also one cycle.

22
22
because its register to register operation which doesnt involve memory read operation. We are assuming that operands are present in R0 and R1 already.
6
6
8 votes
8 votes

All the answers here are a tad confusing, I want to share my solution with evidences from the book "Computer Organisation and Embedded System" by Hamacher et al

In the book it is clearly mentioned that

Instruction processing consists of two phases: the fetch phase and the execution phase. It is convenient to divide the processor hardware into two corresponding sections. One section fetches instructions and the other executes them.

The section that fetches instructions is also responsible for decoding them and for generating the control signals that cause appropriate actions to take place in the execution section. The execution section reads the data operands specified in an instruction, performs the required computations, and stores the results.

Considering this in mind we can approach this question with each stage in the Execution cycle to be taking 1 clock cycle each, that is :

Execution Cycle : OF + Compute + WB

OF : 1 clock cycle for Sin←R0 and Tin←R1 both (as both can be done parellely)

Compute : 1 clock cycle for ALUout←S+T

WB : 1 clock cycle for writing the result R0in←ALUout

So in total 3 clock cycles are needed for the Execution cycle.

P.S - We don't have to assume anything at our end until and unless it is explicitly stated in the question, and the statement 

The instruction “add R0, R1” has the register transfer interpretation

doesn't mean that only register operations are to be considered for the clock cycle but it is providing the interpretation for the instruction to be R0 <= R0 + R1 and nothing else, please don't misinterpret it.

4 Comments

How Sin←R0 and Tin←R1  can run in parallel...when the bus is in control of S then how it can be given to T at the same time.

1
1
Loading S and T parallely ? How?
1
1
It means for addition it doesn't require one cycle  ALU operation doesn't require any cycle but for storing the result in register it requires one cycle.
0
0

Sin←R0 and Tin←R1   cannot be done parallely.

2
2
6 votes
6 votes

R0  <= R+R1

The sequence of instruction take place 

I Cycle : R1 out  , Sin

II Cycle: Ro out  , Tin

III Cycle: Sout  ,   Tout , ALU , Rin therefore 3 cycle required 

3 Comments

whats the diff btw execution cycle and instruction cycle??
0
0
@akriti sood, Instruction Cycle for fetching of instruction and execution cycle is for execution of instructions. Also, at the same time instructions/operands may be fetched. :). Hope you get it.
0
0

Instruction cyle means

  1. Fetch cycle
  2. Execution cycle 
  • PC to MAR
  • M[MAR] to MBR,PC+STEPSIZE
  • MBR to IR
0
0
Answer:

Related questions