4 Mmi HX Eg R6 Oor TRM DY3 S
4 Mmi HX Eg R6 Oor TRM DY3 S
4 Mmi HX Eg R6 Oor TRM DY3 S
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
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
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
Increment PC
+ Instruction Instruction Instruction Instruction
Cycle Cycle Cycle Cycle
IC
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
•• 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.
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
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
Increment
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