• edited by
7,259 views
11 11 votes

A non-pipelined CPU has $12$ general purpose registers $(R0,R1,R2, \dots ,R12)$. Following operations are supported

  • $\begin{array}{ll} \text{ADD Ra, Rb, Rr} & \text{Add Ra to Rb and store the result in Rr} \end{array}$
  • $\begin{array}{ll} \text{MUL Ra, Rb, Rr} & \text{Multiply Ra to Rb and store the result in Rr} \end{array}$

$\text{MUL}$ operation takes two clock cycles, $\text{ADD}$ takes one clock cycle.

Calculate minimum number of clock cycles required to compute the value of the expression $XY+XYZ+YZ$. The variable $X,Y,Z$ are initially available in registers $R0,R1$ and $R2$ and contents of these registers must not be modified.

  1. $5$
  2. $6$
  3. $7$
  4. $8$

3 Answers

Best answer
16 16 votes
Let's first rewrite the expression as: y*(x + z + x*z)

the instructions are:
ADD R0, R1, R3

MUL R0, R1, R4

ADD R3, R4, R3

MUL R2, R3, R3

Since it is a non-pipelined processor it will take 2*2 + 2*1 = 6 cycles
• selected by
3 3 votes
Given expression is : XY + XYZ + YZ  now rewrite it as  X( Y+ YZ) +YZ;

Take required general purpose registers R0, R1, R2, R3;

from the expression X*( Y+ Y*Z) +Y*Z

1) MUL Y, Z, R0;  multiply y and z and store in R0 ; op(Y*Z)

2) ADD Y, R0, R1    store in R1 : op( Y+YZ)

3) MUL X, R1, R2    multiply X*(Y+Y*Z) and store in R2;

now add R2 with R0 and store in R3 ;

4) ADD R2, R0, R3;

Operation 1) and 3) take 2 clock cycles each and operation 2) and 4) take 1 each

Total  2+1+2+1= 6

 
Answer:
Position:
Show:

Related questions

12 12 votes
5 5 answers
13.7k
13.7k views
Satbir asked Jan 13, 2020
13,717 views
Consider a $5$- segment pipeline with a clock cycle time $20$ ns in each sub operation. Find out the approximate speed-up ratio between pipelined and non-pipelined system...
78 78 votes
11 answers 11 answers
33.7k
33.7k views
go_editor asked Sep 28, 2014
33,715 views
Consider a $6$-stage instruction pipeline, where all stages are perfectly balanced. Assume that there is no cycle-time overhead of pipelining. When an application is exec...
197 197 votes
9 answers 9 answers
78.1k
78.1k views
Kathleen asked Sep 22, 2014
78,050 views
A $5$ stage pipelined CPU has the following sequence of stages:IF – instruction fetch from instruction memoryRD – Instruction decode and register readEX – Execute: ALU op...
74 74 votes
4 answers 4 answers
35.6k
35.6k views
Kathleen asked Sep 12, 2014
35,643 views
Which of the following are NOT true in a pipelined processor?Bypassing can handle all RAW hazardsRegister renaming can eliminate all register carried WAR hazardsControl h...