Ca Unit 2
Ca Unit 2
Unit – II
Arithmetic for computers
Addition and subtraction – Multiplication – Division – Floating Point operations –
Subword parallelism.
Representing numbers in such data types is commonly known as fixed point representation
and floating point representation .
Based on the complexity of operation done by ALU its design has classified into two types:
Simple ALU perform fixed point addition and subtraction as well as word logical operations, can be
realized by COMBINATIONAL CIRCUI TS .
Complex ALU perform multiplication and division as well as floating point operation. It can be
performed using SEQUENTIAL LOGIC CI R CU ITS based ALU.
1. AND gates
2. OR gates
3. Inverters
4. Multiplexers
0110 Subtract
0111 Set on less than
1100 NOR
The MIPS word is 32 bits wide so we need a 32 bit wide ALU. It is constructed by connecting 32 1 bit
ALU's in series.
1.2.1. OR OPERATION
A B Out
0 0 0
0 1 1
1 0 1
1 1 1
Half adder
Full adder
Generally adder must have two inputs for operands arid a single
output for the sum. In some cases we have second output called as
C ARRY O UT . The carry out from the neighbour adder must be included
as an input, so we need a third input. This input is called C ARRY I N .
1-bit adder is also called as full adder because it has 3 inputs and 2 outputs.
1.4. SUBTRACTION
The subtraction consists of four possible elementary operations,
S.NO OPERATIONS
1. 0-0=0
2. 0-1=1 with 1 borrow
3. 1-0=1
4. 1-1=0
4. If carry is not generated then the result is negative and in the 2’s complement form.
Example:
1. Perform (28)- (15) using 6 bit 2’s complement representation.
Inputs Outputs
Carry Carry Comments
A B Sum
in out
0 0 0 0 0 0 + 0 + 0 = 00two
0 0 1 0 1 0 + 0+ 1 = 01two
0 1 0 0 1 0 + 1 + 0 = 01 two
o 1 1 1 0 0 + 1 + 1 = 10 two
1 0 0 0 1 1 + 0 + 0 = 01 two
1 o 1 1 0 1 + 0 + 1 = 10 two
1 1 0 1 0 1 + 1 + 0 = 10 two
1 1 1 1 1 l + 1 + l = 11 two
Each full adder inputs a Cin, which is the Cout of the previous adder.
This kind of adder is a Ripple Carry Adder, since each carry bit "ripples" to the next full adder. The
first full adder may be replaced by a half adder.
The block diagram of 4-bit Ripple Carry Adder is shown here below
The layout of ripple carry adder is simple, which allows for fast design time; however, the ripple carry
adder is relatively slow, since each full adder must wait for the carry bit to be calculated from the
previous full adder.
The gate delay can easily be calculated by inspection of the full adder circuit. Each full adder requires
three levels of logic.
In a 32-bit ripple carry adder, there are 32 full adders, so the critical path delay is 31 * 2(for carry
propagation) + 3(for sum) = 65 gate delays.
𝑷𝒓𝒐𝒄𝒑𝒂𝒈𝒂𝒕𝒊𝒐𝒏𝒂𝒍 𝑫𝒆𝒍𝒂𝒚 = 𝒏𝒅
Where,
While using parallel connected full adders, unlike serial adders the amount of hardware needed gets
increasing as the number of bits becomes higher.
The sum and carry outputs of any stage cannot be produced until the input carry occurs; this leads to a
time delay in the addition process. This delay is known as carry propagation delay, consider the
following addition.
0101
+ 0011
1000
Addition of the LSB position produces a carry into the second position. This carry, when added to the
bits of the second position (stage), produces a carry into the third position. The latter carry, when
added to the bits of the third position, produces a carry into the last position.
The key thing to notice in this example is that the sum bit generated in the last position (MSB)
depends on the carry that was generated by the addition in the previous positions.
This means that, adder will not produce correct result until LSB carry has propagated through the
intermediate full-adders. This represents a time delay that depends on the P ROPAGATIO N D ELAY
produced in each full-adder.
Full-adder requires two gate delays and sum requires only one gate delay. When we connect full adder
circuits in cascade to generate n-bit ripple adder. Cn-1 is available in 2(n-l) gate delays. The final
carry-out, Cn is available after 2n gate delays.
Thus for 4-bit ripple adder C4 is available after 8(2x4) gate delays, C3 is available in 6[2(4—1)] gate
delays and S3 is available in 7 gate delays.
One method of speeding up this process by eliminating inter stage carry delay is called look ahead-
carry addition. This method utilizes logic gates to look at the lower-order bits of the augend and
addend to see if a higher-order carry is to be generated. It uses two functions: carry generate and carry
propagate.
Carry generate
Carry propagate.
𝑷𝒊 = 𝑿𝒊 ⨁ 𝒀𝒊
𝑮𝒊 = 𝑿𝒊 𝒀𝒊
Gi is called a carry generate and it produces on carry when both Xi and Yi are one, regardless of the
input carry.
Pi is called a carry propagate because it is term associated with the propagation of the carry from Gi to
Ci+1. Now Ci+1 can be expressed as a sum of products function of the P and G outputs of all the
preceding stages.
For example, the carriers in a four stage carry-look ahead adder are defined as follows:
𝑪𝟏 = 𝑮𝟎 + 𝑷𝟎 𝑪𝒊𝒏
The Carry for the bit position i can be calculated by using the following formula,
𝑪𝒊 = 𝒈𝒊 + 𝒑𝒊 𝑪𝒊−𝟏 (1)
𝑪𝒊−𝟏 = 𝒈𝒊−𝟏 + 𝒑𝒊−𝟏 𝑪𝒊−𝟐 (2)
Substituting equation (2) in (1)
𝑺𝒊 = 𝒑𝒊 ⨁𝒈𝒊 ⨁𝑪𝒊−𝟏
Sum 0 0 0 0 1 1 1 1 : 15
𝑮𝒊 = 𝑿𝒊 𝒀𝒊
𝑺𝒊 = 𝒑𝒊 ⨁𝒈𝒊 ⨁𝑪𝒊−𝟏
Sum 0 0 0 1 0 1 0 1 : 21
𝑮𝒊 = 𝑿𝒊 𝒀𝒊
𝑺𝒊 = 𝒑𝒊 ⨁𝒈𝒊 ⨁𝑪𝒊−𝟏
8. SEQUENTIAL MULTIPLICATION
The multiplication of binary number is done in the same way as decimal numbers are multiplied.
Consider the example, Multiplying 1010 by 1000
Multiplicand 1 0 1 0
Multiplier X 1 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
1 0 1 0
Product 1 0 1 0 0 0 0
The first operand is called the M ULTIPLICAND and second operand is called the M ULTIPLIER , the final
result is called the P RODUCT
Take the digits of the multiplier one at the time from right to left, multiplying the multiplicand by the
single digit of the multiplier.
Shifting the intermediate product one digit to the left of the earlier intermediate products.
The numbers of digits in the product is larger than the number of digits in either the multiplicand or
the multiplier.
The multiplier
is shifted in the opposite direction at each step.
The multiplication algorithm starts with the product initialized to 0. Control decides when to shift the
multiplicand and multiplier registers and when to write new values into the product register .
S TEP 2: The left shift has the effect of moving the intermediate operands to the left.
S TEP 3: The shift right gives the next bit of the multiplier to examine in the following iteration.
S TEP 4: These three steps are repeated 32 times to obtain the product.
We can increase the speed of process by performing the operations in parallel manner. That means,
the multiplier and multiplicand are shifted while the multiplicand is added to the product if the
multiplier bit is a 1
The product register only has 64 bits. The product is shifted right. The separate multiplier register also
disappeared and the multiplier is placed instead in the right half of the product register.
8.4. EXAMPLE
Multiply 210 by 310
A 0000110 1 13
X x0000011 0 6
Y 0 0 0 0 1 0 -1 0 recoded multiplier
1111001 10
Shift 1111100 110
0000100 1110
Shift 0000010 01110
Shift Only 0000001 001110
Shift Only 0000000 1001110
Shift Only 0000000 01001110
Shift Only 0 0 0 0 0 0 0 0 0 1 0 0 1 1 1 0 78
Example:
Multiply 01110(+14) and 11011(-5)
Example: Multiply (-7) and (3) by using booth’s multiplication. Give the flow table of
multiplication.
To speed up the multiplication process in the booth’s algorithm a technique called bit pair
recoding is used. It is also called modified booth’s algorithm.
Bit-Pair recoded
Multiplier bit on
Multiplier bit Pair multiplier bit at
the right
position i
i+1 i i-1
0 0 0 0
0 0 1 +1
0 1 0 +1
0 1 1 +2
1 0 0 -2
1 0 1 -1
1 1 0 -1
1 1 1 0
Multiplicand=01111(15)
Multiplier=10110 (-10)
10. DIVISION
The division process for binary numbers is similar to the decimal numbers. In the division process,
first the bits of the dividend are examined from left to right, until the set of bits examined represents a
number greater than or equal to the divisor.
Until this condition occurs, 0's are placed in the quotient from left to right.
When the condition is satisfied, a 1 is placed in the quotient and the divisor is subtracted from the
partial dividend. The result is referred to as a PARTIAL REMAINDER .
From this point onwards, the division process is required. In each repetition cycle, additional bits from
the dividend are brought down to the partial remainder until the result is greater than or equal to the
divisor and the divisor is subtracted from the result to produce a new partial remainder.
The process continues until all the bits of the dividend are brought down and result is still less than the
divisor.
Divisor and dividend are loaded into register B and register Q, respectively. Register A is
initially set to zero. The division operation is then carried out.
After the division is complete, the n-bit quotient is in register Q and the remainder is in register A.
3. If the sign bit of A is 1, set Q0 to 0 and add divisor back to A (that is, restore A); Otherwise, set
Q0 to 1.
4. Repeat steps 1, 2, and 3 n times.
10.1.2. EXAMPLE
Dividend: 1000
Divisor: 0011
3.14159265 (Pi)
2.71828(e)
The last two numbers are bigger than 32 bit signed integer. These numbers is called scientific
notation.
Binary number also can be represented in the normalized form. To keep a binary number in
normalized form, we need a base value that can increase or decrease by exactly the .number of bits the
number must be shifted to have one non zero digit to the left of the decimal point Computer arithmetic
supports such number is called F LOATING P OINT
Fraction is the value generally between 0 and 1 it is called the mantissa. Exponent is the
numerical representation system of floating point arithmetic.
Increasing the size of the fraction enhances the precision of the fraction. Increasing the size of the
exponent increases the range numbers that can be represented.
Floating point numbers are usually a multiple of the size of a word. The representation of a MIPS
floating point number is shown below.
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
S Exponent Fraction
1
8 bits 23 bits
bit
where S is the sign of the floating point number (1 – Negative & 0 – Positive)
Exponent is the value of the 8-bit exponent field. Fraction is the 23bit number. In general floating
point numbers are of the form
(1)sF2E
Thus cause the overflow interrupts in floating point arithmetic as well as in integer arithmetic.
Overflow means the exponent is too large to be represented in the exponent field.
Underflow occurs when the negative exponent is too large to fit in the exponent field.
Both underflow and overflow condition will occur in floating point arithmetic. One way to reduce
chances of underflow or overflow is to offer another format that has a larger exponent
The representation of a double precision floating point number take two MIPS words as shown below:
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
S Exponent Fraction
1
11 bits 20 bits
bit
where
Assume that we can store only four decimal digits of the significand and two decimal digits of the
exponent.
Step 1:
To add these numbers we must align the decimal point of the number that has the smaller
exponent. We need to convert the smaller number, 𝟏. 𝟔𝟏𝟎𝒕𝒆𝒏 × 𝟏𝟎−𝟏 to match the larger
exponent.
Step 2:
9.999ten
+ 0.016ten
10.015ten
The sum is 𝟏𝟎. 𝟎𝟏𝟓𝒕𝒆𝒏 × 𝟏𝟎𝟏
Step 3:
Whenever the exponent is increased or decreased, we must check for overflow or underflow.
Step 4:
Since we assumed that the significand can be only four digits long (excluding the sign), we
must round the number. If the digit to the right of the desired point is between 0 and 4 and add
1 to the digit if the number to the right is between 5 and 9. The number
𝟏. 𝟎𝟎𝟏𝟓𝒕𝒆𝒏 × 𝟏𝟎𝟐
𝟏. 𝟎𝟎𝟐𝒕𝒆𝒏 × 𝟏𝟎𝟐
Step 3 normalizes the results, forcing a check for overflow or underflow. The test for overflow and
underflow in step 3 depends on the precision of the operands.
The pattern of all 0 bits in the exponent is reserved and used for the floating-point representation of
zero.
The pattern of all 1 bits in the exponent is reserved for indicating values and situations outside the
scope of normal floating-point numbers
Assume that we can store only four digits of the significand and two digits of the exponent
Step 1
The exponent of the product is calculated by simply adding the exponents of the operands
together
Step 2
There are three digits to the right of the decimal point for each operand, so the decimal point
is placed six digits from the right in the product significand
𝟏𝟎. 𝟐𝟏𝟐𝟎𝟎𝒕𝒆𝒏
Assuming that we can keep only three digits to the right of the decimal point, the product is
Step 3
After the multiplication, the product can be shifted right one digit to put it in normalized form
by adding 1 to the exponent.
At this point, we can check for overflow and underflow. Underflow may occur if both
operands are small that is, if both have large negative exponents.
Step 4
We assumed that the significand is only four digits long (excluding the sign), so we must
round the number. The number
𝟏. 𝟎𝟐𝟏𝟐 × 𝟏𝟎𝟔
𝟏. 𝟎𝟐𝟏𝒕𝒆𝒏 × 𝟏𝟎𝟔
Step 5
The sign of the product depends on the signs of the original operands. If they are both the same, the
sign is positive; otherwise, it’s negative.
The addition of speakers and microphones for teleconferencing and video games suggested
support of sound as well.
Audio samples need more than 8 bits of precision, but 16 bits are sufficient.
Every microprocessor has special support so that bytes and halfwords take up less space
when stored in memory (see Section 2.9), but due to the infrequency of arithmetic operations
on these data sizes in typical integer programs, there was little support beyond data transfers.
Architects recognized that many graphics and audio applications would perform the same
operation on vectors of this data.
By partitioning the carry chains within a 128-bit adder, a processor could use parallelism to
perform simultaneous operations on short vectors of sixteen 8-bit operands, eight 16-bit
operands, four 32-bit operands, or two 64-bit operands.
The cost of such partitioned adders was small. Given that the parallelism occurs within a
wide word, the extensions are classified as subword parallelism.
It is also classified under the more general name of data level parallelism. They have been
also called vector or SIMD, for single instruction, multiple data (see Section 6.6). The rising
popularity of multimedia applications led to arithmetic instructions that support narrower
operations thcan easily operate in parallel.
For example, ARM added more than 100 instructions in the NEON multimedia instruction
extension to support subword parallelism, which can be used eithwith ARMv7 or ARMv8.
It added 256 bytes of new registers for NEON that can bviewed as 32 registers 8 bytes wide
or 16 registers 16 bytes wide. NEON supporall the subword data types you can imagine
except 64-bit fl oating point numbers:
8-bit, 16-bit, 32-bit, and 64-bit signed and unsigned integers.
32-bit fl oating point numbers.
PART – A
ARITHMETIC LOGIC UNIT
1. What is ALU?[May/june-2016]
An arithmetic logic unit (ALU) is a digital electronic circuit that performs arithmetic and bitwise
logical operations on integer binary numbers. It is a fundamental building block of the central
processing unit (CPU)
2. State two basic data types implemented in the computer system.
Based on the number system two basic data types are implemented in the computer system:
Fixed point numbers
Floating point numbers.
Representing numbers in such data types is commonly known as fixed point representation and
floating point representation.
3. Write a note on scalar data types.
All of the commonly used data types such as, char, int, short long, float, and double are called
scalar or base data types because they hold a single data item.
4. What is signed magnitude representation?
Signed magnitude representation is a scheme for representing negative integers. It uses one bit to
indicate the sign. "0" indicates a positive integer, and "1" indicates a negative integer. The rest of
the bits are used for the magnitude of the number. So -2410 is represented as:
1001 1000
The l's complement of a binary number is the number that results when we change all 1/s to zeros and
the zeros to ones.
The 2's complement is the binary number that results when we add 1 to the l's complement. It is given
as 2's complement = l's complement +1.
We can relate addition and subtraction operations of numbers by the following relationship:
(± 𝑨) − (+𝑩) = (± 𝑨) + (−𝑩)
(± 𝑨) − (−𝑩) = (± 𝑨) + (+𝑩)
The logic circuit which performs addition of two binary bits is called a half-adder.
The circuit which performs addition of three bits (two significant bits and a previous carry) is a
full-adder.
The n-bit parallel adder using n number of full-adder circuits connected in cascade, i.e. the carry
output of each adder is connected to the carry input of the next higher-order adder is called ripple
carry adder.
11. Define overflow rule in addition.[Nov/Dec-2015][Nov/Dec-2016]
When both operands a and b have the same sign, an overflow occurs when the sign of result does
not agree with the signs of a and b.
(+A)+(+B)= -C
(-A)+(-B)= +C
12. How overflow occur in subtraction? [May/June 2015]
Overflow in subtraction occurs when the subtrahend is larger than the minuend.
(+A)-(-B)= -C
(-A)-(+B)= +C
Example:
0010 0011
(-) 0110 1110
Will cause overflow
13. Subtract (11011)2 - (100011)2 using 2’s complement.[Nov/Dec-2017].
14. What is guard bit? What are the ways to truncate guard bit?[Nov/Dec-2016].
The first two extra bits kept on the right during intermediate calculations of floating point format.
Several ways,
1. Chopping
2. Rounding.
3. Von-Neumann rounding.
15. Subtract (11010)2 – (10000)2 using 1’s complement and 2’s complement
method.[May/June-2017]
MULTIPLICATION
16. Discuss the principle behind the Booth's multiplier.
Booth's algorithm generates a 2n-bit product and treats both positive and negative numbers
uniformly. This algorithm suggest that we can reduce the number of actions required for
multiplication by representing multiplier as a difference between two numbers.
17. Discuss the role of Booth's algorithm in the design of fast multipliers.
To speed-up the multiplication process in the Booth's algorithm a technique called bit-pair
recoding is used. It is also called modified Booth's algorithm. It halves the maximum number of
summands. In this technique, the Booth-recoded multiplier bits are grouped in pairs. Then each
pair is represented by its equivalent single bit multiplier reducing total number of multiplier bits to
half.
18. What is combinational multiplier or array multiplier?
The multiplier which uses n shifts and adds operations to multiply n-bit binary number is
called combinational multiplier or array multiplier.
19. How bit pair recoding of multiplier speeds up the multiplication process?
It guarantees that the maximum number of summands that must be added is n/2 for n-bit
operands.
20. How CSA speeds up multiplication?
It reduces the time needed to add the summands. Instead of letting the carries ripple along the
rows, they can be saved and introduced into the next row, at the correct waited position.
DIVISION
21. Write down the steps for restoring division.
Non restoring division avoids the need for restoring the contents of register after successful
subtraction.
24. Divide (1001010)2 / (1000)2 . [Nov/Dec-2017].
The 32-bit standard representation (single-precision representation) occupies a single 32-bit word.
The 32-bits are divided into three fields as shown below:
(field 1) Sign - 1 - bit
(field 2) Exponent - 8 - bits
(field 3) Mantissa - 23 - bits
The 64-bit standard representation (double-precision representation) occupies two 32-bit words.
The 64-bits are divided into three fields as shown below:
(field 1) Sign - 1 - bit
(field 2) Exponent - 1 - bit
(field 3) Mantissa - 52 – bits
26. Mention the situations under which a processor sets exception flag.
Underflow
Overflow
Divide by zero
Inexact Invalid
27. State the representation of double Precision floating Point number.[Nov/Dec-
2015]
28. Define underflow and overflow
U NDERFLOW : In a single precision, if the number requires an exponent less than -126 or in a
double precision, if the number requires an exponent less than - 1022 to represent its normalized
form the underflow occurs.
O VERFLOW : In a single precision, if the number requires an exponent greater than + 127; or in a
double precision, if the number requires an exponent greater than + 1023 to represent its
normalized form the overflow occurs.
1. Add the exponents and subtract bias. (127 in case of single precision numbers and 1023 in
case of double precision numbers).
2. Multiply the mantissas and determine the sign of the result. I .
3. Normalize the result.
30. State the rules of floating point division.
1. Subtract exponents and add bias (127 in case of single precision numbers and 1023 in
case of double precision numbers).
The mantissas of initial operands and final results are limited to 24-bits, including the implicit
leading 1. But if we provide extra bits in the intermediate steps if calculations we can get
maximum accuracy in the final result. These extra bits used in the intermediate calculations are
called guard bits.
32. State the commonly used methods of truncation.
SUBWORD PARALLELISM
33. What do you mean by subword parallelism? [May/June 2015] ?[May/June-2016]
Subword Parallelism is a technique that enables the full use of word-oriented datapaths when
dealing with lower-precision data. It is a form of low-cost, small-scale SIMD parallelism.
PART – B
ARITHMETIC LOGIC UNIT
1. Explain in detail how a simple Arithmetic Logic Unit can be constructed.
MULTIPLICATION
6. Explain the sequential version of multiplication and its hardware. [May/June 2015
– 16M]. [Refer Page No:2.9]
7. Explain in detail about multiplication algorithm with suitable example and
diagram.[Nov/Dec-2015] [May-17] [Refer Page No:2.9]
8. Define booth multiplication algorithm with suitable example.[May-16]
9. Explain Booth’s algorithm for the multiplication of signed two’s complement
numbers. [Dec-16]
10. Multiply the following pair of signed numbers using Booth`s bit-pair recording of
the multiplier. A=+13(Multiplicand) and B=-6 (Multiplier) [Nov/Dec 2014 - 10M]
11. Explain Booth`s Algorithm for multiplication and multiply the following pair using
the same A=10, B=4. ?[May/june-2016]
12. Explain Booth`s Algorithm for multiplication and multiply the following pair using
the same A=16, B=4.
13. Explain Booth`s Algorithm for multiplication and multiply the following pair using
the same A=20, B=16.
DIVISION
14. Explain in detail the process of restoring and non-restoring division. [Refer Page
No:2.15]
15. Explain in detail about division algorithm with suitable example and diagram.
[Nov/Dec-2015] [Nov/Dec-2016] [Refer Page No:2.15]