Module-2 - Lecture 2: Alu - Signed Addition/Subtraction
Module-2 - Lecture 2: Alu - Signed Addition/Subtraction
The rules governing addition and subtraction of n-bit signed numbers using the 2’scomplement
representation system may be stated as follows:
To add two numbers, add their n-bit representations, ignoring the carry-out bit from the most significant
bit (MSB) position. The sum will be the algebraically correct value in 2’s-complement representation if the
actual result is in the range -2n-1 through +2n-1-1
To subtract two numbers X and Y , to perform X − Y , form the 2’s-complement of Y , then add it to X
using the add rule. Again, the result will be the algebraically correct value in 2’s-complement representation
if the actual result is in the range -2n-1 through +2n-1-1
Addition and subtraction using 2’s complement
Overflow in integer arithmetic
When adding unsigned numbers, a carry-out of 1 from the most significant bit
position indicates that an overflow has occurred.
If two numbers are added, and they are both positive or both negative, then
overflow occurs if and only if the result has the opposite sign.
MODULE- 2- LECTURE 3
MULTIPLICATION
REPRESENTATION OF NUMBER
Fixed-point representation
Floating-point representation
FIXED-POINT REPRESENTATION
This is known as fixed-point representation where the position of decimal point is fixed
and number of bits before and after decimal point are also predefined.
If we use 16 bits before decimal point and 8 bits after decimal point, in signed magnitude
form, the range is 216 1 to 216 1 and the precision is 2 8
One bit is required for sign information, so the total size of the number is 25 bits
In this representation, numbers are represented by a mantissa comprising the significant digits
and an exponent part of Radix R. The format is:
Numbers are often normalized, such that the decimal point is placed to the right of the first non
zero digit.
To store this number in floating point representation, we store 5236 in mantissa part and 3 in
exponent part
IEEE standard floating point format:
E ' 127
1.M 2 E '1023
1.M 2
Arithmetic operations with Floating point numbers are more complicated
than arithmetic operations with fixed point numbers
Process involves generation of partial products, one for each digit in the
Multiplier and each successive partial product is shifted one position to the
left.
When the multiplier bit is 0, the partial product is 0. When the multiplier is 1,
the partial product is the multiplicand
Multiplicand
Multiplier
A register, is also needed and is initially set to 0.
SIGNED MULTIPLICATION
BOOTH’S ALGORITHM
Algorithm used for signed number multiplication is called Booth’s algorithm
which generates 2n-bit product .
N bit adder
-N bit adder add two inputs, A register and M(multiplicand)
Shift, add and subtract control logic : scans Q0 and Q-1 bits one at a time
-If (Q0 and Q-1 =1-1 or 0-0 ), shift operations occur from (A to Q-1) registers, no add/subtract(Enable=0)
-If (Q0 and Q-1 =0-1), addition operation , A=A+M (Add/subtract enable=1)
-If (Q0 and Q-1 =1-0), subtraction operation , A=A-M (Add/subtract enable=1)
-After addtion and subtraction, right shift occurs from Left most bit of A(An-1) and also it keeps An-1 bit
in A register.
ARRAY MULTIPLIER
ARRAY MULTIPLIER
AND gate in each cell determines whether a multiplicand bit, mj , is added to the incoming partial-
product bit, based on the value of the multiplier bit, qi =0 ≤ i ≤ 3,
if qi=1 ,adds the multiplicand (appropriately shifted) to the incoming partial product, PPi, to generate the
outgoing partial product, PP(i + 1),.
Row by row addition in array circuit differ from manual addition (column by column )
Critical path and performance is identified by two gate delays from the inputs to the outputs of a full-
adder block, FA.
Total of 6(n − 1) − 1 gate delays, including the initial AND gate delay in all cells, for an n × n array.
MODULE- 2- LECTURE 6
A
Shift A and Q left one binary position
-If sign bit of A is 1, shift A and Q left one position and add divisor to A,
Set Q0 =0.
-If sign bit of A is 0, shift A and Q left one position and subtract divisor from A, Set Q0 =1
If a pc is working with high speed normally we will compare that with other PC by
speed ,cost and operation etc.
Computer user expects to reduce the start and execution time of process.
Hence, the execution time on B is longer than A. Therefore you say A is faster than Y
Performance A ExecutiontimeB
n
PerfromanceB Executiontime A
EXAMPLES
CPU execution time or CPU time, is the time the CPU spends computing for this task and does not
include time spent waiting for I/O or running other programs.
the CPU time spent in the program, called user CPU time
CPU time spent in the operating system performing tasks on behalf of the program, called
System CPU time
All computers are constructed in such a way that events in hardware synchronized using
clocks
The clock cycle time is the amount of time for one clock period to elapse
clock cycle time in seconds is the inverse of clock rate (in HZ)
For example if a computer have a clock cycle time of 5 ns then the clock rate will be 200
MHz.
CPU PERFORMANCE AND ITS FACTORS
Simple formula relate most basic metrics (clock cycles and clock cycles time)
CPU execution time for program = CPU clock cycles for a program x clock
cycle time
CPI (clock cycles per instruction) is average number of clock cycles required for each instruction
takes to execute
Performance equation in terms of instruction count, CPI and clock cycle time:
Therefore these formulas have three key factors that affect CPU performance and it will be useful to
compare different implementations
OTHER PERFORMANCE MEASURES
MIPS is inversely proportional to execution time. Hence faster computers have higher
MIPS rating
Instructioncount Clockrate
MIPS
Instructioncount CPI CPI 10 6
10 6
Clockrate
THANK YOU