4 Mmi HX Eg R6 Oor TRM DY3 S

Download as pdf or txt
Download as pdf or txt
You are on page 1of 17

Chapter 2

ALU and Data Path,


CPU Control Design
LEARNING OBJECTIVES

 Arithmetic and logic unit  Control of processor


 Fixed-point arithmetic operation  Function of control unit
 Floating point arithmetic operation  Design of control unit
 BCD  Types of micro-instructions
 Data path  Micro-instruction sequencing
 CPU control design  RISC and CISC
 Instruction cycle  RISC characteristic
 Control unit  CISC characteristic

alU (arithMetiC anD logiC Unit) Unsigned numbers Only zero and positive integers can be repre-
sented. All bits represent magnitude and no need of sign.
ALU performs arithmetic and logical operations on data (see
Figure 1).
Signed numbers In signed representation, the most significant bit
Control unit Flags represents the sign. If the number is positive, the MSB is 0 and
ALU remaining bits represent magnitude. If the number is negative, we
Registers Registers have three techniques to represents that number:

Figure 1 ALU inputs and outputs 1. Signed magnitude representation: In signed magnitude
representation, the MSB represents sign and remaining bits
• Data are presented to ALU in registers and the results of an oper- represents magnitude. If the number is negative then the
ation are stored in registers. MSB is 1.
• Registers are temporary storage locations within the processor
that are connected by signal paths to ALU. Example: Signed magnitude representation of –10 =
• The control unit provides signals that control the operation of
ALU and the movement of data into and out of the ALU.
1 0 0 0 1 0 1 0
• Here we will discuss
1. Fixed-point arithmetic operations
2. Floating-point arithmetic operations Sign Magnitude
3. BCD data arithmetic operations

Fixed-point Arithmetic Operations 2. Signed 1’s complement representation: In signed 1’s com-
plement representation, the MSB bit is 1. The remaining bits
Fixed-point representation
of its signed magnitude bits are inverted i.e., convert 0’s to
The numbers may be positive, zero or negative. So we have two 1’s and 1’s to 0’s to obtain 1’s complement.
types of numbers:
Chapter 2 • ALU and Data Path, CPU Control Design | 2.17

Example: Take 2’s complement of -2 and add it to 5


Signed 1’s complement (-10) = 101
110
1 1 1 1 0 1 0 1
-----
1] 011
Sign Magnitude ↑
Discard
3. Signed 2’s complement representation: To get signed
∴ result = + 3 (A > B)
2’s complement representation, add 1 to the signed 1’s
complement of that number. (–A) + (+B) = (–5) + (+2)
= 1101 + 0010
Example: add 2’s complement of –5 to 2
Signed 2’s complement (-10) = 011
1 1 1 1 0 1 1 0 010
101
As MSB is 1 take 2’s complement to get original number
Sign Magnitude i.e., 011.
Result = 1011 = –3 (∵A > B)
Fixed-point arithmetic operations
(-A) + (-B) = (-5) + (-2)
We will discuss the following operations using signed mag-
= 1101 + 1010
nitude data and signed 2’s complement data.
101
1. Addition 010
2. Subtraction
Result = 1111 = -7
3. Multiplication
Similarly we can perform the subtractions using signed
4. Division
magnitude data.
Addition and subtraction using signed magnitude
Hardware implementation:
data Consider two numbers whose magnitude is represented
as A and B. When the signed numbers are added or subtracted,
Bs B register
there are eight different conditions to consider, depending on
the sign of the numbers and operation performed.
AVF Complementer M
Add Subtract Magnitudes
(Mode control)
Operation Magnitudes (A > B) Output carry
(+A) + (+B) +(A + B) Input carry
E Parallel adder
(+A) + (-B) +(A - B)
Sum
(-A) + (+B) -(A - B)
As A register Load sum
(-A) + (-B) -(A + B)
(+A) - (+B) +(A - B)
Figure 2 Hardware implementation for addition and subtraction.
(+A) - (-B) +(A + B)
(-A) - (+B) -(A + B) Figure 2 shows the hardware implementation for addition and
(-A) - (-B) -(A - B) subtraction operations. It consists of registers A and B and sign
flip-flops As and Bs. Subtraction is done by adding A to the 2’s
Algorithm for addition (subtraction): When the signs of complement of B. The output carry is transferred to flip-flop
A and B identical (different), add the two magnitudes and E and add overflow flip-flop AVF holds the overflow bit when
attach the sign of A to the result. When the signs of A and B A and B are added. The addition is done through the parallel
are different (identical), compare the magnitudes and sub- adder. The output of adder is sent to ‘A’ register. The comple-
tract the smaller number from the larger. Choose the sign of menter provides an output of B or complement of B depending
result based on magnitudes of A and B. on the state of mode control M. When M = 0, the output equal
to A + B, when M = 1, the output equal to A + B +1, i.e., A – B.
Example: All eight cases for the numbers A = 5, B = 2.
(+A) + (+B) = (+5) + (+2) Addition and Subtraction with signed 2’s complement data
= 0101 + 0010 = 0111= +7 Addition: In 2’s complement representation, addition pro-
(+A) + (-B) = (+5) + (-2) ceeds as if the two numbers were unsigned integers. If the
= 0101 + 1010 result of the operation is positive, we get a positive number
2.18 | Unit 2 • Computer Organization and Architecture

in 2’s complement form, which is same as in unsigned inte- Add


ger form. If the result of the operation is negative, we get a
negative number in 2’s complement form. Augend in AC
Example: Addend in BR
+5 = 0101
+2 = 0010
0111 = +7 AC ← AC + BR
V ← Overflow
+5: 0101
-2: 1110
10011 = +3
-5: 101 End
+2: 0010
Figure 4 Flowchart for addition in 2’s complement form
1101
As the result is negative, take 2’s complement of result to
Subtract
get original number, i.e., 0011 and the answer is -3.
-5: 1011 Minuend in AC
-2: 1110 subtrahend in BR
11001
As the result is negative take 2’s complement to get original
number, i.e., 0110 + 1 = 0111.
∴ Answer is -7. AC ← AC + BR + 1
V ← Overflow
Note: If two numbers are added and they are both positive
or both negative, then overflow occurs if the result has the
opposite sign.
Subtraction: To subtract subtrahend from minuend, take End
the 2’s complement of subtrahend and add it to the minuend.
Figure 5 Flowchart for subtraction of 2’s complement data
Example:
+5: 0101 Multiplication of signed magnitude data
+2: 0010
To subtract these two numbers add 2’s complement of 2 to 5. Multiply operation
+5: 0101
-2: 1110 Multiplicand in B
10011 = +3 Multiplier in Q
+5: 0101
- 2: 1110
2’s complement of -2 = 0010. A s ← Qs ⊕ Bs
+5: 0101 Q s ← Qs ⊕ Bs
A ← 0, E ← 0
+2: 0010 SC ← n − 1
0111 = +7
Similarly for the other cases we can perform the subtraction.
=0 =1
Qn
BR register
EA ← A + B

Complement and shr EAQ


V SC ← SC − 1
parallel adder
Overflow
≠0 =0
SC
AC register
END

Figure 3 Hardware implementation for signed 2’s complement


addition and subtraction: Figure 6 Flowchart for multiplication of signed magnitude data
Chapter 2 • ALU and Data Path, CPU Control Design | 2.19

Multiplication of two fixed point binary numbers in signed


Multiply
magnitude representation is a process of successive shift
and add operations (see Figure 6).
Multiplicand in BR
Example 1: Multiply the two numbers -7 and +8, using Multiplier in QR
5-bit registers.
-7 = 10111
+8 = 01000 AC ← 0
By excluding sign-bits, the multiplicand, B = 0111 and Q n +1 ← 0
SC ← n
multiplier Q = 1000. Initially A = 0000, SC is sequence
counter contains number of bits in multiplier magnitude.
Here SC = 4
Multiplicand = 10 = 01
Q n Q n +1
B = 0111 E A Q SC
Multiplier in Q 0 0000 1000 4
= 00
Last bit of Q, AC ← AC + BR + 1 AC ← AC + BR
= 11
Qn = 0 ⇒ Shr EAQ 0 0000 0100 3
Qn = 0 ⇒ Shr EAQ 0 0000 0010 2
Qn = 0 ⇒ Shr EAQ 0 0000 0001 1 Arithmatic shift
right (AC and QR)
Qn = 1 ⇒ Add B to A 0 0000 0001 SC ← SC − 1
0111
0111
Shr EAQ 0 0011 1000 0 ≠0 =0
SC
B × Q = 00111000 = 56
END
Sign = Qs ⊕ Bs = 1 ⊕ 0 = 1
∴ Result = –56
Figure 7 Booth’s multiplication algorithm
Hardware for signed magnitude data multiplication: B1,
An additional 1-bit register placed logically to the right of
A1, Q1 represent the respective signs of the registers B, A, Q.
the LSB(Qn) of Q register designated Qn+1.
Final result will be in AQ, which consist of 2n-bits. (Here
each register has n-bits). Example 2: Multiply the two numbers -7 and +8 using
booth’s algorithm, using 5 bits.
BR = -7 = 11001
B2 B3 Bn
QR = +8 = 01000
Initially AC = 00000, Qn+1 = 0, SC = 5
BR = 11001
Shift and add
n − 1 bit adder control logic Qn Qn+1 BR + 1 = 00111 AC QR Qn+1 SC

Initial 00000 01000 0 5

00 ashr(AC and QR) 00000 00100 0 4

00 ashr(AC and QR) 00000 00010 0 3

E A2 A 3 An Q2 Q3 Qn 00 ashr(AC and QR) 00000 00001 0 2

10 subtract BR 00000
ashr(AC and QR) 00111
00111
00011
Multiplication of Singed 2’s complement data The straight 10000 1 1
forward multiplication will not work if either the multipli-
cand or the multiplier is negative. There are number of ways 01 add BR 00011
ashr(AC and QR) 11001
to perform multiplication of signed 2’s complement data. 11100 10000 1 1
One such a technique is Booth’s multiplication algorithm. 11110 01000 0 0
The following flowchart depicts about Booth’s algorithm
(see figure 7).
∴ Result = 1111001000 = –56
2.20 | Unit 2 • Computer Organization and Architecture

Hardware implementation for Booth’s algorithm: Divide overflow:


•• A divide overflow condition occurs if the high-order half
BR register Sequence counter (SC ) bits of the dividend constitute a number greater than or
equal to the divisor.
•• A division by zero must be avoided.

Other algorithms for division: Two other methods are


Complementer and available for dividing numbers:
parallel adder
Qn Q n +1 Comparison method: To divide the two numbers A and B
in comparison method, they are compared prior to the sub-
traction operation. If A ≥ B, B is subtracted from A. If A < B
nothing is done. The partial remainder is shifted left and the
AC register QR register numbers are compared again.

Note: These two multiplication algorithms are sequential Non-restoring method: To divide two numbers A and B
but we can also do the operation by means of a combina- is non-restoring method, B is not added if the difference is
tional circuit that forms the product bits all at once. The negative but instead, the negative difference is shifted left
circuit consist of AND gates and adders. and then B is added.

Division algorithms
Floating-point Arithmetic Operations
Division of signed magnitude data: Division of signed
magnitude data is a process of successive compare, shift Floating-point representation
and subtract operations. Fixed-point representation allows representation of
numbers with fractional component as well. But this
Example:
approach has limitations. It is not possible to represent
Dividend = 0111000000
very large numbers and very small numbers in fixed point
Divisor = 10001
representation.
10001) 0111000000 (11010
In floating-point representation, the numbers can be rep-
­–10001
resented in the form,
010110
± S × B ±E
–10001
The three fields are
0010100
Sign: plus or minus
–10001
Significand: S
000110
Exponent: E
Hardware implementation: are stored in a binary word.
•• The hardware implementation of division is same as The base B is implicit and need not be stored because
multiplication, instead of shifting the divisor to the right, it is same for all the numbers. It is assumed that the radix
the dividend or partial remainder is shifted to the left, point is to the right of the left most or most significant bit
thus leaving the two numbers in the required relative of the significand, i.e., there is one bit to the left of the
position. radix point.
•• The divisor is stored in the B register and the double-
length dividend is stored in registers A and Q. The divi- 32-bit floating-point format: The left most bit stores the
dend is shifted to the left and the divisor is subtracted by sign of the number. The exponent value is stored in next
adding its 2’s complement value. The information about 8-bits. This is represented in biased representation.
the relative magnitude is available in E.
•• If E = 1, it signifies that A ≥ B. A quotient bit 1 is inserted
Biased exponent Significand
into Qn and the partial remainder is shifted to the left to
repeat the process. 8-bits 23-bits
•• If E = 0, it signifies that A < B so the quotient is Qn remains Sign of
a 0. The value of B is added to restore the partial remain- significand
der in A to its previous value. The partial remainder is
shifted to the left and the process is repeated again until
all quotient bits are formed. Biased representation: In biased representation, a fixed
•• Finally, the quotient is in Q and remainder is in A. This value, called the bias, is subtracted from the exponent field to
method is called restoring method. get the true exponent value.
Chapter 2 • ALU and Data Path, CPU Control Design | 2.21

Bias = (2k-1 - 1), where k = number of bits in binary • As the MSB is always one, it is unnecessary to store this
exponent. In IEEE 32-bit floating point representation, bias bit. Thus the 23-bit field is used to store a 24-bit signifi-
= 27 - 1 = 127. cand with a value in the half open internal (1, 2).
And the range of true exponents is -127 to +128. • A number may be normalized by shifting the radix point
The advantage of biased representation is that non-neg- to the right of the leftmost 1 bit and adjusting the expo-
ative floating point numbers can be treated as integers for nent accordingly.
comparison purposes.
The last portion of word is the siginificand. Example: In 32-bit floating representation of
-1.6328125 × 2 - 20,
Normalized numbers:
Sign = 1 (as the number is negative)
• To simplify operation on floating point numbers, it is
(.6328125)10 = (.1010001…)2
typically required that they must be normalized.
Exponent = -20
• A normalized number is one in which the most significant
Biased exponent = 127 - 20 = 107
digit of significand is non-zero.
= 1101011
• For base-2 representation, a normalized number is there-
∴ -1.6328125 × 2 - 20
fore one in which the MSB of the significand is one.
= 1 01101011 10100010000000000000000
• Normalized non-zero number is one in the form ±
1.bbb… b × 2 ± E, where b is either binary digit 0 or 1.
Negetive Positive
overflow underflow

Negetive Expressible negetive Zero Expressible positive Positive


overflow numbers numbers overflow

− (2 − 2 −23) × 2128 − 2 −127 0 2 −127 (2 − 2 −23) × 2128 Number line

Figure 8 Range of expressible numbers in a 32-bit floating point format

IEEE standard for binary floating-point representation Example:


(123 × 100) + (234 × 10-2)
Biased exponent Fraction =123 × 100 + 2.34 × 100 = 125.34 × 100
(ii) Multiplication: The steps to multiply two floating
8-bits 23-bits point numbers are
Sign
bit 1. Check for zeros
2. Add the exponents
Single precision format 3. Multiply the significands
4. Normalize the result
Biased exponent Fraction (iii) Division: The steps to divide two floating point
numbers are
11-bits 52-bits
1. Check for zeros
Sign
bit
2. Initialize registers and evaluate the sign
3. Align the dividend
Double precision Format 4. Subtract the exponents
5. Divide the significands
Floating-point arithmetic
(i) Addition and subtraction: The algorithm consists Binary-Coded Decimal (BCD)
the following phases: Arithmetic Operations
1. Check for zeros Computers capable of performing decimal arithmetic must
2. Align the significands/mantissas store the data in binary-coded form.
3. Add or subtract the significands
Example: BCD of 239 = 0010 0011 1001
4. Normalize the result
2.22 | Unit 2 • Computer Organization and Architecture

BCD addition Example 5: Consider the following 32-bit floating point


In BCD each digit do not exceed 9, so the sum of two BCD representation scheme as shown in the format below:
digits cannot be greater than 9 + 9 + 1 = 19, the 1 in the
sum being an input carry. When the binary sum of two BCD Sign Fraction Exponent
digits is greater than 1001, we obtain a non-valid BCD
representation. The addition of binary 6 (0110) to the binary 1 24 7
sum converts it to the correct BCD representation and also
produces an output carry as required. A value is specified by three fields:
Example: Sign field: 1 bit (0 for positive and 1 for negative values)
239 = 0010 0011 1001 Fraction: 24-bits (with binary point being at the left end of
426 = 0100 0010 0110 fraction bits)
665 0110 0101 1111 >1001 Exponent:7-bits (in excess-64 signed integer
0110 representation)
0110 0110 0101 The base of exponentiation is 16. The sign bit is in MSB.
= 665 Then the normalized floating point representation of - 6.5 is
(A) E8000042 (B) E1000012
BCD subtraction
(C) D8000841 (D) D0000042
•• Perform the subtraction by taking the 9’s or 10’s comple-
ment of the subtrahend and adding it to the minuend. Solution: (D)
•• The 9’s complement of a decimal digit represented in Here sign = 1 as the number is negative.
BCD can be obtained by complementing the bits in the (-6.5)10 = (-0110.1)2
coded representation of the digit, provided a correction
= (-1.101 × 22)
is included.
Fraction = 101000000000000000000000
There are two possible correction methods: Exponent = Excess - 64 exponent
1. Binary 1010 is added to each complemented digit and = 64 + 2 = 66 = 1000010
the carry discarded after each addition. ∴ (-6.5)10
Example: = 1 1010000000000000000000001000010
9’s complement of 7 = 2 = D0000042.
7 in BCD = 0111.
Complement of 7 = 1000
Add 1010 = 1010 Data Path
1] 0010 = 2
Data path consists of the components of the processor that

performs arithmetic operations.
Discard
Components of data path: ALU is just one data path
2. Binary 0110 is added before the digit is complemented.
building block. Other components are
Example: 1. 
Computational Components, which consist of
BCD of 7 = 0111 combinational circuits (output follow inputs)
Add 0110 = 0110 Example: ALU.
1101
Complement = 0010 = 2 2. State components, which consists of sequential circuits
(output changes on clock edge)
Example 4: Which of the following multiplier bit pattern
Example: Registers.
of Booth’s multiplication algorithm gives worst case
performance? Example: The sequence of steps for the addition of two
(A) 01010101….0101 registers content are
(B) 000000….0000 1. R1out, Xin
(C) 11111111….1111 2. R2out, Choose X, ADDITION, Yin
(D) 011110111110….01110 3. Yout, R3in
Solution: (A) (Each step executed in a single clock cycle).
Booth’s multiplication algorithm works well with
consecutive 0’s or 1’s. But it gives worst case performance •• Data path and control unit forms the processing unit of a
when the multiplier consists of alternative 0’s and 1’s. (As computer. The Data path includes ALU, multiplexers, all
01, 10 pattern leads to addition and subtractions). registers (like PC, IR) etc.
Chapter 2 • ALU and Data Path, CPU Control Design | 2.23

Example Data Path Design: Program Execution

Increment PC
+ Instruction Instruction Instruction Instruction
Cycle Cycle Cycle Cycle
IC

Fetch Decode Execute


Read address
PC fetch
of instruction
Micro Micro
memory Operation Operation

Fetch Cycle: ‘Fetch’ stage of an instruction occurs at the


CPU Control Design beginning of each instruction, which causes an instruction
Instruction Cycle to be fetched from memory. The micro-operations involved
in fetch phase are
A program residing in the memory unit of the computer
t1: MAR ← PC (move contents of PC to MAR)
consists of a sequence of instructions. The program is exe-
t2: MBR← memory; PC ← (PC) + I (move contents of
cuted in the computer by going through a cycle for each
MAR location to MBR and increment PC by I)
instruction. Each instruction cycle in turn is subdivided
t3: IR← (MBR) ⋅ (move contents of MBR to IR)
into a sequence of sub cycles. For example, the phases of
instruction cycle may be Here I is instruction length.
Each micro-operation can be performed within the time of
1. Fetch
a single time unit.
2. Decode
3. Read effective address Execute Cycle: For a machine with N different opcodes,
4. Execute, etc. there will be N different sequence of micro-operations. For
the execution of following instruction.
Next Add R1, X, the micro-operations will be
instruction t1: MAR← (IR(Address))
Fetch Execute
t2: MBR← memory
Instruction cycle t3: R1← (R1) + (MBR)

The cycle will be repeated, till all the instructions are Control of the Processor
executed.
(i) Functional requirements of control unit: Let us
Each phase is made up of more fundamental operations,
consider the following concepts to the characterization
called micro-operations.
of a CU.
Example micro-operations: Transfer between registers,
1. Define the basic elements of the processor.
simple ALU operation, etc.
2. Describe the micro-operations that the processor
performs.
Control Unit 3. Determine the functions that the control unit
must perform to cause the micro-operations to be
The control unit of a processor performs two tasks:
performed.
1. It causes the processor to execute micro-operations
(ii) Basic elements of processor:
in the proper sequence, determined by the program
•• ALU
being executed.
•• Registers
2. It generates the control signals that cause each micro-
•• Internal data path: Used to move data between reg-
operation to be executed.
isters and between register and ALU.
We now discuss the micro-operations of various phases of •• External data path: Used to link registers to mem-
instruction cycle. ory and input–output modules, often by means of a
system bus.
•• Control unit: Causes operations to happen within
Micro-operation the processor.
•• These are the functional or atomic operations of a (iii) Micro-operations of processor:
processor. •• Transfer data from one register to another.
•• Transfer data from a register to an external interface.
2.24 | Unit 2 • Computer Organization and Architecture

•• Transfer data from an external interface to a register. Totally, there are three types of control signals:
•• Perform an arithmetic or logic operation, using reg- 1. Those that activate ALU function.
isters for input and output. 2. Those that activate a data path.
(iv) Control unit tasks: 3. Those that are signals on the external system bus.
•• Sequencing: The control unit causes the proces-
sor to step through a series of micro-operations in Functions of Control Unit
the proper sequence, based on the program being •• The control unit directs the entire computer system to
executed. carry out stored program instructions.
•• Execution: The control unit causes each micro- •• The control unit must communicate with both the
operation to be executed. Arithmetic Logic Unit and Main memory.
(v) Control signals: For the control unit to perform its •• The control unit instructs the arithmetic logic unit by
function, it must have inputs that allow it to determine which, logical or arithmetic operation is to be performed.
the state of the system and outputs that allows it •• The control unit coordinate the activities of the other
to control the behaviour of the system. These are two units as well as all peripheral and auxiliary storage
external specifications of the control unit. devices linked to the computer.
  Internally, the control unit must have the logic
required to perform its sequencing and execution Design of Control Unit
functions. Control unit generates control signals using one of the two
organizations
(1) Hardwired control unit
(2) Micro-programmed control unit.
Instruction register
Hardwired control unit
Control
signals within •• It is implemented as logic circuits (gates, flip-flops,
CPU decoders, etc.) in the hardware.
Control •• It is very complicated if we have a large control unit.
Control
Control signals from •• In this organization, if the design has to be modified or
bus
Flags unit control bus changed. It requires changes in wiring among the various
Clock components. Thus the modification of all the combina-
Control tional circuits may be very difficult.
signals to
control bus Architecture of hardwired control unit An example hard-
wired control unit is shown in Figure 9.
Figure 9 Block diagram of control unit
I OP code Address

(a) Clock: This is how the control unit ‘keeps time.’


The control unit causes one micro-operation to be
performed for each clock pulse. This is referred as
processor cycle time or clock cycle time. 3 × 8 Decoder

(b) Instruction registers: The opcode of current D7 D6 D5 D4 D3 D2 D1 D0


instruction is used to determine which micro-
operations to perform during the execute cycle. Control
unit
(c) Flags: Used to determine the status of the processor
and outcome of previous ALU operations.
T1T 0
(d) Control signals from control bus: The control bus
4 × 16 Decoder
portion of system bus provides signals to the control
unit.
(e) Control signals within the processor: 4 bit sequence
1. Those that cause data to be moved from register to counter
another.
2. Those that activate specific ALU functions. Figure 10 Hardwired control unit
(f) Control signals to control bus: The above control unit consists of:
1. Control signals to memory.
2. Control signals to input–output modules. •• Instruction Register
•• Number of control logic gates
Chapter 2 • ALU and Data Path, CPU Control Design | 2.25

•• Two decoders •• Modifications in control signal are very difficult. That


•• 4-bit sequence counter. means it requires rearranging of wires in the hardware
•• An instruction read from memory is placed in the instruc- circuit.
tion register (IR) •• It is difficult to correct mistake in original design or add-
•• The instruction register is divided into three parts: the I ing new features.
bit, operation code and Address part.
•• First 12-bits (0-11) to specify an address, next 3-bits
Micro-programming control unit
specify the operation code (op code) field of the instruc- •• A micro-programmed Control unit is implemented using
tion and last left most bit specify the addressing mode I. programming approach. A sequence of micro-operations
I = 0 for direct address are carried out by executing a program consisting of
I = 1 for indirect address microinstructions.
•• First 12-bits are applied to the control logic gates. •• Micro-program, consisting of micro instructions is stored
•• The Opcode bits (12-14) are decoded with 3 × 8 decoder. in the control memory of the control unit.
•• The eight outputs (D0 through D7) from a decoder go to •• Execution of micro-instruction is responsible for genera-
the control logic gates to perform specific operation. tion of a set of control signals.
•• Last bit 15 is transferred to a I flip flop designated by A micro-instruction consists of:
symbol I. •• One or more micro-instructions to be executed.
•• The 4-bit sequence counter SC can count in binary from •• Address of next micro-instruction to be executed.
0 through15.
(a) Micro-operations: The operations performed on
•• The counter output is decoded into 16 timing pulses T0
the Data stored inside the registers are called Micro-
through T15.
operations.
•• The sequence counter can be incremented by INR input
(b) Micro-programs: Micro-programming is the concept
or clear by CLR input synchronically.
for generating control signals using programs. These
Advantages: programs are called Micro-programs.
•• Hardwired control unit is fast because control signals are (c) Micro-instructions: The instructions that make
generated by combinational circuits. Micro-programs are called micro-instructions.
•• The delay in generation of control signals depends upon (d) Micro-code: Micro-program is a group of micro-
the number of gates. instructions. Micro-program can also be termed as
micro-code.
Disadvantages: (e) Control memory: Micro-programs are stored in the
•• More is the control signal required by CPU, more com- read-only memory (ROM). That memory is called
plex will be the design of control unit. control memory.
(f) Architecture of Micro-Programmed Control Unit:

Next Control Control


Control Control
address data word
address memory
generator register register

•• The micro-programmed control unit is more flexible


•• The address of micro-instruction that is to be executed is
because design modifications, correction and enhance-
stored in the control address register (CAR).
ment is easily possible.
•• Micro-instruction corresponding to the address stored in
•• The new or modified instruction set of CPU can be easily
CAR is fetched from control memory and is stored in the
implemented by simply rewriting or modifying the con-
control data register (CDR).
tents of control memory.
•• This micro-instruction contains control word to execute
•• The fault can be easily diagnosed in the micro-program
one or more micro-operations.
control unit using diagnostic tools by maintaining the
•• After the execution of all micro-operations of micro-instruc-
contents of flags, registers and counters.
tions, the address of next micro-instructions is located.
Advantages: Disadvantages:
•• The design of micro-program control unit is less complex •• The micro-program control unit is slower than hardwired
because micro-programs are implemented using software control unit. That means to execute an instruction in
routines. micro-program control unit requires more time.
2.26 | Unit 2 • Computer Organization and Architecture

•• The micro-program control unit is expensive than hard- A desire to execute micro-instructions as fast as possible.
wired control unit in case of limited hardware resources. In executing a micro program, the address of next micro-
•• The design duration of micro-program control unit is instruction to be executed is in one of these categories.
more than hardwired control unit for smaller CPU. 1. Determined by IR
2. Next sequential address
Types of Micro-instructions 3. Branch
Micro-instructions can be classified as
Micro-instructions Execution
Horizontal micro-instruction The Micro-instruction cycle has two parts:
•• Individual bits in horizontal micro-instructions corre- 1. Fetch
spond to individual control lines. 2. Execution
•• These are long and allow maximum parallelism since
The effect of execution of a micro-instruction is to generate
each bit controls a single control line.
control signals. Some of the signals control points internal
•• No decoding needed.
to the processor. The remaining signals go to the external
control bus or other external interface.

Microinstruction Micro-instructions can be classified in a variety of ways.


address 1. Vertical/horizontal
Internal CPU Jump condition
control signals 2. Packed/unpacked
- unconditional
- zero 3. Hard/soft micro-programming
- overflow 4. Direct/indirect encoding.
- indirect bit
System bus
control signals RISC and CISC
One of the important aspects of computer architecture is the
Figure 11 Horizontal micro-instruction format
design of the instruction set for the processor. The instruc-
tion set chosen for a particular computer determines the
Vertical micro-instruction
way that machine language programs are constructed. There
•• Here, control lines are coded into specific fields are two categories of computers based on instructions:
within a micro-instruction.
•• Decoders are needed to map a field of k-bits to 2k 1. Complex instruction set computer (CISC)
possible combinations of control lines. 2. Reduced instruction set computer (RISC)
CISC: A computer with a large number of instructions is
classified as a complex instruction set computer.
Microinstruction RISC: A computer which has fewer instructions with sim-
Function codes address
ple constructs, so they can be executed much faster with in
Jump condition the CPU without having to use memory as often. This type
of computer is classified as RISC.
Figure 12 Vertical micro-instruction format

Example: A 3-bit field in a micro-instruction could be CISC characteristics


used to specify any one of eight possible lines. •• CISC provides a single machine instruction for each
•• Hence these instructions are much shorter than horizontal statement, That is written in a high level language so that
ones. compilation process is simplified and the over all com-
•• Control fields encoded in the same field cannot be acti- puter performance improved.
vated simultaneously. Therefore vertical micro-instruc- •• It has variable length instruction formats.
tions allow only limited parallelism. •• It provides direct manipulation of operands residing in
•• Decoding is necessary. memory.
•• Some instructions that perform specialized tasks and are
Micro-instruction Sequencing used infrequently.
•• A large variety of addressing modes
Two concerns are involved in the design of a micro-instruc-
tion sequencing technique: Drawback of CISC architecture As more instructions and
1. The size of micro-instruction: Minimizing size of addressing modes are incorporated into a computer, the
control memory reduces the cost of that component. more hardware logic is needed to implement and support
2. The address-generation time: them and hence this causes the computations to slow down.
Chapter 2 • ALU and Data Path, CPU Control Design | 2.27

RISC characteristics Group 3: 20 Signals


•• Reduce execution time by simplifying the instruction set Group 4: 10 Signals
of the computer. Group 5: 50 Signals
•• Fewer numbers of instructions How many bits of the control words can be saved by
•• Relatively fewer addressing modes using vertical micro-programming over horizontal
•• Memory access is limited to load and store instructions. microprogramming?
•• All operations are done with in the register of the CPU. (A) 27 (B) 173
•• Fixed - length, easily decoded instruction format. (C) 200 (D) 227
•• Single-cycle instruction execution.
Solution: Horizontal micro-programming requires 200
•• Hardwired rather than micro-programmed control.
signals. But vertical micro-programming uses encoding. So
•• Relatively large number of registers.
•• Uses overlapped register windows to speed - up proce- Group 1 requires 5-bits (∵ 25 = 32)
dure call and return. Group 2 requires 7-bits (∵ 27 = 128)
•• Efficient instruction pipeline. Group 3 requires 5-bits (∵ 25 = 32)
•• Efficient translation of high - level language programs Group 4 requires 4-bits (∵ 24 = 16)
into machine language programs by the compiler. Group 5 requires 6-bits (∵ 26 = 64)
Example 6: An instruction set of a processor has 200
signals which can be divided into 5 groups of mutually ∴ 
Total bits required using vertical micro
exclusive signals as follows. programming = 27

Group 1: 30 Signals ∴ Number of bits saved = 200 – 27 = 173



Group 2: 90 Signals

Exercise
Practice Problems 1 6. Which of the following is the correct sequence of
Directions for questions 1 to 20: Select the correct alterna- micro-operations to add a number to the AC when the
tive from the given choices. operand is a direct address operand and store the final
result to AC?
1. Using two’s complement arithmetic the resultant of
111100001111 – 110011110011 is (A) MAR←(IR(address))
(A) 0010 0001 1111 MBR ← memory
(B) 0011 0000 1100 R1 ← (AC) + (MBR)
(C) 0010 0001 1101 (B) MAR ← IR(address)
(D) 0010 0001 1100 MBR ← MAR
2. IEEE 32-bit floating point format of 384 is R1← (MBR)
(A) 0 10000111 00000000000000000000000 R2 ← (AC) + (R1)
(B) 0 10000111 10000000000000000000000 AC ← R2
(C) 0 00001000 00000000000000000000000 (C) MAR ← (IR(address))
(D) 0 00001000 10000000000000000000000 MBR ← Memory(MAR)
3. Consider the following IEEE 32-bit floating point R1 ← (MBR)
number: R2 ← (AC) + (R1)
0 01111110 10100000000000000000000. AC ← (R2)
What is the decimal value equivalent to given number? (D) MAR ← (IR (address))
(A) 0.25 (B) 3.25 MBR ← Memory(MAR)
(C) 0.8125 (D) 0.9375 AC ← (AC) + (MAR)
4. What would be the bias value for a base-8 exponent in
a 7-bit field? Statement for linked answer questions 7 to 9: Assume
(A) 8 (B) 16 that the control memory is 24 bits wide. The control portion
(C) 63 (D) 64 of the micro-instruction format is divided into two fields. A
5. The normalized value of the resultant of 8.844 × 10 -3 micro-operation field of 13-bits specifies the micro-opera-
– 2.233 × 10 -1 is tion to be performed. An address selection field specifies
(A) -2.144 × 10 - 1 (B) -0.2144 a condition, based on the flags, that will cause a micro-in-
(C) -2 × 10 - 1 (D) -0.2 struction branch. There are eight flags.
2.28 | Unit 2 • Computer Organization and Architecture

7. How many bits are there in address selection field? (A) 1110 1000 0000 0000 0000 000
(A) 1 (B) 2 (B) 1001 0000 0000 0000 0000 000
(C) 3 (D) 4 (C) 1100 0000 0000 0000 0000 000
8. How many bits are there in address field? (D) 0110 0100 0000 0000 0000 000
(A) 8 (B) 9 15. Let the total number of control signals generated are n,
(C) 13 (D) 24 then what is the number of bits allocated in control field
9. What is the size of control memory in bits? of vertical micro programming?
(A) 256 (B) 768 (A) n/2 (B) n
(C) 3328 (D) 6144 (C) 2n (D) log2n
10. A simple processor has 3 major phases to its instruc- 16. In a micro programmed control unit, a control field of one
tions cycle: address control instruction has to support two groups of
1. Fetch control signals. In group1 it is required to generate either
2. Decode one or none of the 32 control signals. In group 2 at most
3. Execute 5 from the remaining, what will be the number of bits
Two 1-bit flags are used to specify the current phase in needed for the control field?
hardwired implementation. Will these flags required in (A) 8 (B) 10
micro-programming also? (C) 35 (D) 37
(A) Yes
17. Assume that the exponent e is constrained to lie in the
(B) No
range 0 ≤ e ≤ x, with a bias of q, that the base is b and
(C) Cannot predict
that the significant is P-digits in length.
(D) Depends on clock cycle time
What is the largest positive value that can be written is
11. In a 3-bus data path, the micro instructions format will normalized floating point?
be Opcode src1, src2, desti; The number of operations (A) bx – q(1 – b – p) (B) b–q –1
supported are 8 and the src1, src2 and desti require 20, (C) b –q – p
(D) b x – q (b–p –1)
16 and 20 bits respectively.
The total number of horizontal microinstructions speci- 18. By using Booth’s Multiplication algorithm. Below two
fied will be numbers are multiplied:
(A) 264 Multiplicand: 0111 0111 1011 1101
(B) 28
Multiplier: 0101 1010 1110 1110
(C) 2 56
(D) 261
How many additions/subtractions are required for the
12. What is the smallest positive normalized number rep- multiplication of the above two numbers?
resented using IEEE single precision floating point (A) 8 (B) 10
representation? (C) 13 (D) 7
(A) 2–128 (B) 1 – 2–127
(C) 2–127 (D) 2–126 19. Let us assume, we are multiplying two positive inte-
gers 1101 and 1011. The multiplicand M is 1101 and
13. A micro program control unit is required to generate
Multiplier Q is 1011. What is partial product after sec-
a total of 30 control signals. Assume that during any
ond cycle?
micro instruction, almost two control signals are active.
(A) 0110 1101 (B) 1001 1110
Minimum number of bits required in the control word
(C) 0100 1111 (D) 1000 1111
to generate the required control signals will be
(A) 2 (B) 2.5 20. The decimal representation of the 2’s complement
(C) 10 (D) 12 number 1101011 is
14. What is the fraction field of the single-precision float- (A) 21 (B) -21
ing point representation of 6.25? (C) 219 (D) 91

Practice Problems 2 2. Micro-program is


Directions for questions 1 to 20: Select the correct alterna- (A) the name of a source program in micro computers.
tive from the given choices. (B) a primitive form of macros used in assembly lan-
guage programming.
1. A microprogrammed control unit
(C) a program of a very small size.
(A) is faster than a hard-wired control unit
(D) the set of instruction indicating the basic elemental
(B) facilitates easy implementation of new instructions.
commands which directly control the operation of a
(C) is useful when very small programs are to be run.
system.
(D) usually refers to the control unit of a micro-processor.
Chapter 2 • ALU and Data Path, CPU Control Design | 2.29

3. Programming that actually controls the path of signal 13. The sequence of events that happen during a fetch
or data within the computer is called operation is:
(A) System programming (A) PC → memory → IR
(B) Micro-programming (B) PC → MAR → memory → IR
(C) High-level language programming (C) PC → MAR → memory → MDR → IR
(D) Assembly language programming (D) PC → memory → MDR → IR
4. The instruction cycle time in a generic microprocessor 14. Micro-programming is a technique for
is (A) Programming input or output routines
(A) Longer than the machine cycle time (B) Programming the microprocessors
(B) Shorter than the machine cycle time (C) Programming the control steps of a computer
(C) Same as the machine cycle time (D) Writing small programs
(D) Double the machine cycle time
15. In a micro program ____ specifies the address of
5. Microprocessor unit or central processor unit consist of Micro-instructions to be executed.
(A) Control circuitry (B) ALU (A) AR (B) PC
(C) Memory (D) All of these (C) SP (D) CAR
6. The exponent of a floating point number is represented
16. Which one of the following statements is correct?
in excess-N code so that
(A) Micro-programmed control unit is costlier and
(A) the dynamic range is large
slow.
(B) overflow is avoided
(B) Micro-programmed control unit are cheap and
(C) the precision is high
slow.
(D) the smallest number is represented efficiently
(C) Micro-programmed control unit is costlier and
7. Using Booth’s algorithm for Multiplication, the fast.
Multiplier -14 is coded as (D) Micro-programmed control unit are fast and
(A) 11110 (B) 01110 cheaper.
(C) 10010 (D) 00010
17. Horizontal micro-instructions have
8. Data Path consists of (A) High degree parallelism, more encoding of control
(A) Registers (B) ALU information.
(C) Bus (D) All of these (B) High degree parallelism, little encoding of control
9. A floating point number that has a ‘0’ in MSB of man- information.
tissa is said to have ____ (C) Low degree parallelism, more encoding of control
(A) Overflow (B) Underflow information.
(C) Normalization (D) Positive exponent (D) Low degree parallelism, little encoding of control
information.
10. Let the Binary sum after BCD addition is stored in K,
18. A vertical micro-instruction have ____.
Z8, Z4, Z2, and Z1 Then the condition for a correction
(A) Short formats and considerable encoding of con-
and output carry can be expressed as C =
trol information
(A) K + Z8 Z4 + Z8Z2 (B) K + Z8 Z4 + Z4Z2
(B) Long formats and considerable encoding of con-
(C) K + Z8 Z2 + Z8Z1 (D) K + Z4 Z2 + Z2Z1
trol information
11. Which of the following is an advantage of biased (C) Short formats and little encoding of control infor-
exponents? mation
(A) Convenient way to represent exponents (D) Long formats and little encoding of control infor-
(B) Useful for conversion mation
(C) Convenient for comparison purposes 19. Guard bits are used to
(D) All of these (A) avoid unnecessary loss of MSB
(B) avoid unnecessary loss of LSB
12. Booth multiplication skips over runs of zeros and ones
(C) the loss of MSB
which reduces the number of add and subtract steps
(D) the loss of LSB
needed to multiply two n-bit numbers to n to a variable
number whose average value navg is less than n what 20. Which of the following is not the essential element of a
will be navg? number represented in floating-point notation?
(A) n/3 (B) n/4 (A) Exponent (B) Significand
(C) n/2 (D) n (C) Sign (D) Normalization
2.30 | Unit 2 • Computer Organization and Architecture

Previous Years’ Questions


Common data for questions 1 and 2: Consider the fol- preceding the binary (radix) point. Assume that only
lowing data path of a CPU. 0 ′s are padded in while shifting a field.
MAR MDR The normalized representation of the above number
(0.239 × 213) is: [2005]
(A) 0A 20 (B) 11 34
(C) 49 D0 (D) 4A E8
4. In the IEEE floating point representation the hexa-
decimal value 0x00000000 corresponds to [2008]
(A) The normalized value 2 - 127
S T
(B) The normalized value 2 - 126
IR PC
(C) The normalized value + 0
GPRs (D) The special value + 0
ALU 5. P is a 16-bit signed integer. The 2’s complement rep-
resentation of P is (F87B)16. The 2’s complement rep-
resentation of 8*P is [2010]
The ALU, the bus and all the registers in the data path (A) (C3D8)16 (B) (187B)16
are of identical size. All operations including incremen- (C) (F878)16 (D) (987B)16
tation of the PC and the GPRs are to be carried out in 6. The decimal value 0.5 in IEEE single precision float-
the ALU. Two clock cycles are needed for memory read ing point representation has [2012]
operation—the first one for loading address in the MAR (A) fraction bits of 000 … 000 and exponent value of 0
and the next one for loading data from the memory bus (B) fraction bits of 000…000 and exponent value of –1
into the MDR. (C) fraction bits of 100…000 and exponent value of 0
1. The instruction ‘add R0, R1’ has the register transfer (D) no exact representation
interpretation R0 ← R0 + R1. The minimum number 7. The smallest integer that can be represented by an
of clock cycles needed for execution cycle of this 8-bit number in 2’s complement form is [2013]
instruction is (A) –256 (B) –128
(A) 2 (B) 3 (C) –127 (D) 0
(C) 4 (D) 5
8. Let A = 1111 1010 and B = 0000 1010 be two 8-bit 2’s
2. The instruction ‘call Rn, sub’ is a two word instruction. complement numbers. Their product in 2’s comple-
Assuming that PC is incremented during the fetch cycle ment is [2004]
of the first word of the instruction, its register transfer (A) 1100 0100 (B) 1001 1100
interpretation is (C) 1010 0101 (D) 1101 0101
Rn ← PC + 1; 9. The microinstructions stored in the control memory
PC ← M[PC] of a processor have a width of 26 bits. Each micro-
instruction is divided into three fields, a micro-oper-
The minimum number of CPU clock cycles, needed
ation field of 13 bits, a next address field (X), and a
during the execution cycle of this instruction is
MUX select field (Y), there are 8 status bits in the
(A) 2 (B) 3
inputs of the MUX [2004]
(C) 4 (D) 5
Data for question 3: Consider the following floating-
point format.
15 14 8 7 0 Load
Control address
register

Increment

Sign bit Excess-64 Manitssa Control


exponent memory
MUX
Mantissa is a pure fraction in sign-magnitude form. Y 13
8
3. The normalized representation for the above format Micro operation
Status bits X
is specified as follows. The mantissa has an implicit 1
Chapter 2 • ALU and Data Path, CPU Control Design | 2.31

How many bits are there in the X and Y fields, and node* p = n;
what is the size of the control memory in number of while (p − >next != NULL) {
words? p = p − >next;
(A) 10, 3, 1024 (B) 8, 5, 256 }
(C) 5, 8, 2048 (D) 10, 3, 512 p − >next = m;
10. Consider the following sequence of micro-operations. }
MBR ← PC Assuming that m and n point to valid NULL-
MAR ← X terminated linked lists, invocation of join will [2017]
PC ← Y (A) append list m to the end of list n for all inputs.
(B) either cause a null pointer dereference or append
Memory ← MBR
list m to the end of list n.
Which one of the following is a possible operation (C) cause a null pointer dereference for all inputs.
performed by this sequence? [2013] (D) append list n to the end of list m for all inputs.
(A) Instruction fetch
15. The representation of the value of a 16-bit unsigned
(B) Operand fetch
integer X in hexadecimal number system is BCA9.
(C) Conditional branch
The representation of the value of X in octal number
(D) Initiation of interrupt service
system is [2017]
11. For computers based on three-address instruction for- (A) 571244 (B) 736251
mats, each address field can be used to specify which (C) 571247 (D) 136251
of the following: [2015]
16. Consider the following processor design
(S1) A memory operand characteristics.
(S2) A processor register I. Register-to-register arithmetic operations only
(S3) An implied accumulator register II. Fixed-length instruction format
III. Hardwired control unit
(A) Either S1 or S2
Which of the characteristics above are used in the
(B) Either S2 or S3
design of a RISC processor? [2018]
(C) Only S2 and S3
(A) I and II only (B) II and III only
(D) All of S1, S2 and S3 (C) I and III only (D) I, II and III
12. Let X be the number of distinct 16 - bit integers in 2’s 17. Consider the unsigned 8-bit fixed point binary num-
complement representation. Let Y be the number of ber representation below:
distinct 16 - bit integers in sign magnitude representa- b7 b6 b5 b4 b3 ⋅ b2 b1 b0
tion. They x – y is ______ . [2016] where the position of the binary point is between b3
13. The n-bit fixed-point representation of an unsigned and b2. Assume b7 is the most significant bit. Some
real number X uses f bits for the fraction part. Let i = of the decimal numbers listed below cannot be repre-
n − f. The range of decimal values for X in this repre- sented exactly in the above representation:
sentation is [2017] (i) 31.500 (ii) 0.875
(A) 2− f to 2i (B) 2− f to (2i − 2− f) (iii) 12.100 (iv) 3.001
(C) 0 to 2i (D) 0 to (2i − 2− f) Which one of the following statements is true?
14 Consider the C code fragment given below.  [2018]
typedef struct node { (A) None of (i), (ii), (iii), (iv) can be exactly repre-
int data; sented
node* next; (B) Only (ii) cannot be exactly represented
} node; (C) Only (iii) and (iv) cannot be exactly represented
void join (node* m, node* n) { (D) Only (i) and (ii) cannot be exactly represented
2.32 | Unit 2 • Computer Organization and Architecture

Answer Keys
Exercises
Practice Problems 1
1. D 2. B 3. C 4. C 5. A 6. C 7. C 8. A 9. D 10. B
11. A 12. D 13. C 14. B 15. D 16. B 17. A 18. B 19. B 20. B

Practice Problems 1
1. B 2. D 3. B 4. C 5. D 6. D 7. C 8. D 9. B 10. A
11. C 12. C 13. C 14. C 15. D 16. A 17. B 18. A 19. B 20. D

Previous Years’ Questions


1. B 2. B 3. D 4. D 5. A 6. B 7. B 8. A 9. A 10. D
11. A 12. 1 13. D 14. B 15. D 16. D 17. C

You might also like