2.1 Addition and Subtraction
2.1 Addition and Subtraction
UNIT NO 2
II IV
CS 8491
Computer Architecture
(Common to CSE & IT)
CS 8491
COMPUTER ARCHITECTURE (Common to CSE & IT )
Addition
The add instruction adds two registers and places the result
in another register. The format is
The value that was in Rd before the add is replaced with the
sum Rs + Rt. Rs and Rt are unchanged. For example:
The value that was in Rd before the add is replaced with the
sum Rs + immed. Rs is unchanged. For example:
Subtraction
The sub instruction subtracts two registers and places the result in
another register. The format is:
The value that was in Rd before the sub is replaced with the difference
Rs - Rt. Rs and Rt are unchanged. For example:
The value that was in $t3 before the sub is replaced with the difference
$t1 - $t2. $t1 and $t2 are unchanged. Note that there is no subi
instruction; to subtract a constant, use addi with a negative constant.
CS 8491
COMPUTER ARCHITECTURE (Common to CSE & IT )
Boolean Addition
CS 8491
COMPUTER ARCHITECTURE (Common to CSE & IT )
Boolean Subtraction
CS8351
Half-Adder:
•A half-adder is a combinational circuit that can be used to add two binary bits.
• It has two inputs that represent the two bits to be added and two outputs, with one producing the
SUM output and the other producing the CARRY.
0 0 0 0
0 1 0 1
1 0 0 1
1 1 1 0
CS8351
Full-Adder:
• The third input represents the carry from previous lower significant
position. The block diagram of full adder is given by,
CS8351
Truth Table:
Inputs Outputs
0 0 0 0 0
0 0 1 1 0
0 1 0 1 0
0 1 1 0 1
1 0 0 1 0
1 0 1 0 1
1 1 0 0 1
1 1 1 1 1
CS8351
,
CS8351
The Boolean expressions for the SUM and CARRY outputs are given by the equations,
• The logic diagram of the full adder can also be implemented with two half- adders and one OR
gate.
• The S output from the second half adder is the exclusive-OR of Cin and the output of the first
half-adder, giving
Sum = Cin Å (A Å B)
[xÅy = x‘y+ xy‘]
= Cin Å (A‘B+AB‘)
The 4-bit words to be added be represented by, A3A2A1A0= 1111 and B3B2B1B0= 0011.
CS8351
• The bits are added with full adders, starting from the least significant position, to form the
sum it and carry bit.
• The carry output of the lower order stage is connected to the carry input of the
next higher order stage. Hence this type of adder is called ripple-carry adder.
• In the least significant stage, A0, B0 and C0 (which is 0) are added resulting in sum S0 and
carry C1.
• Similarly in the second stage, A1, B1 and C1 are added resulting in sum S1 and carry C2, in
the third stage, A2, B2 and C2 are added resulting in sum S2 and carry C3, in the third stage,
A3, B3 and C3 are added resulting in sum S3 and C4, which is the output carry.
• Thus the circuit results in a sum (S3S2S1S0) and a carry output (Cout).
CS8351
• In Parallel adder, all the bits of the augend and the addend are available for computation at
the same time
.
• The carry output of each full-adder stage is connected to the carry input of the next high-
order
stage.
• Since each bit of the sum output depends on the value of the input carry, time delay occurs in
the addition process. This time delay is called as carry propagation delay.
Full-Adder circuit
Carry propagate, Pi = Ai Å Bi
Si = Pi Å Ci Ci+1 = Gi Å PiCi
CS8351
•Gi (carry generate), it produces a carry 1 when both Ai and Bi are 1, regardless of the input carry
Ci
•Pi (carry propagate) because it is the term associated with the propagation of the carry from Ci to
Ci+1.
•The Boolean functions for the carry outputs of each stage and substitute for each Ci its value from
C1= G0 + P0C0
= G1 + P1G0 + P1P0C0
vIDEO lINK
https://www.youtube.com/watch?v=03fhijH6e2w