adder substracter

25
KL 2164 DIGITAL ELECTRONICS ADDER / SUBSTRACTER Pn. Wan Nurdiana Wan Ibrahim [email protected]

Upload: wannurdiana

Post on 24-May-2015

1.166 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Adder substracter

KL 2164DIGITAL ELECTRONICS

ADDER / SUBSTRACTER

Pn. Wan Nurdiana Wan Ibrahim

[email protected]

Page 2: Adder substracter

2

Contents

Half Adder

Full Adder

Subtracter

Page 3: Adder substracter

3

AdderThe result of adding two binary digits could produce a carry valueRecall that 1 + 1 = 10 in base two

Half adderA circuit that computes the sum of two bits and produces the correct carry bit

Full AdderA circuit that takes the carry-in value into account

Page 4: Adder substracter

4

Contents

Half Adder

Full Adder

Subtracter

Page 5: Adder substracter

5

Example of 1-bit Adder

Design a simple binary adder that adds two 1-bit binary numbers, a and b, to give a 2-bit sum. The numeric values for the adder inputs and outputs are as follows:

Page 6: Adder substracter

6

Represent inputs to the adder by the logic variables A and B and the 2-bit sum by the logic variables X and Y, and the truth table:

Because a numeric value of 0 is represented by a logic 0 and a numeric value of 1 by a logic 1, the 0’s and 1’s in the truth table are exactly the same as in the previous table.

Boolean expression :

Page 7: Adder substracter

7

Half Adder

Circuit diagram representing a half adder

Boolean expressionssum = A Bcarry = AB

Page 8: Adder substracter

8

2-bits Binary Adder

Design an adder which adds two 2-bit binary numbers to give a 3-bit binary sum. Find the truth table for the circuit. The circuit has four inputs and three outputs as shown:

Page 9: Adder substracter

9

Page 10: Adder substracter

10

Contents

Half Adder

Full Adder

Subtracter

Page 11: Adder substracter

11

Full Adder

The logic equations for the full adder derived from the truth table are:

(X=A & Y = B)

Page 12: Adder substracter

12

Implementation of Full Adder

Page 13: Adder substracter

13

Design of Binary Adders and Subtracters

Design a parallel adder that adds two 4-bit unsigned binary numbers and a carry input to give a 4-bit sum and a carry output.

Page 14: Adder substracter

14

Parallel Adder for 4-Bit Binary Numbers

Page 15: Adder substracter

15

One approach would be to construct a truth table with nine inputs and five outputs and then derive and simplify the five output equations.

A better method is to design a logic module that adds two bits and a carry, and then connect four of these modules together to form a 4-bit adder.

Page 16: Adder substracter

16

Parallel Adder Composed of Four Full Adders

Example : 1011+ 1011 = ?

Page 17: Adder substracter

17

One’s complement addition To add one’s complement numbers:

◦ First do unsigned addition on the numbers, including the sign bits.

◦ Then take the carry out and add it to the sum. Two examples:

This is simpler and more uniform than signed magnitude addition.

0111 (+7)+ 1011 + (-4)

1 0010

0010+ 1

0011 (+3)

0011 (+3)+ 0010 + (+2)

0 0101

0101+ 0

0101 (+5)

Page 18: Adder substracter

18

Two’s complement addition Negating a two’s complement number takes a bit

of work, but addition is much easier than with the other two systems.

To find A + B, you just have to:◦ Do unsigned addition on A and B, including their sign

bits. ◦ Ignore any carry out.

For example, to find 0111 + 1100, or (+7) + (-4): ◦ First add 0111 + 1100 as unsigned numbers:

◦ Discard the carry out (1).◦ The answer is 0011 (+3).

0111+ 1100

10011

Page 19: Adder substracter

19

Unsigned numbers overflowCarry-out can be used to detect overflowThe largest number that we can represent with

4-bits using unsigned numbers is 15 Suppose that we are adding 4-bit numbers: 9

(1001) and 10 (1010).

The value 19 cannot be represented with 4-bitsWhen operating with unsigned numbers, a

carry-out of 1 can be used to indicate overflow

1 0 01(9)+ 1 0 1 0 (10)10011 (19)

Page 20: Adder substracter

20

An overflow has occurred if adding two numbers gives a negative result or adding two negative numbers gives a positive result.

• Negative number in compliment form

define an overflow signal, V = 1 if an overflow occurs. V = A3′B3′S3 + A3B3S3′

Overflow for Signed Binary Numbers

Page 21: Adder substracter

21

Contents

Half Adder

Full Adder

Subtracter

Page 22: Adder substracter

22

Binary Subtracter Using Full Adders

Full Adders may be used to form A – B using the 2’s complement representation for negative numbers. The 2’s complement of B can be formed by first finding the 1’s complement and then adding 1.

Page 23: Adder substracter

23

Parallel SubtracterAlternatively, direct subtraction can be accomplished by employing a full subtracter in a manner analogous to a full adder.

d = differencebi = borrow

Page 24: Adder substracter

24

Consider xi = 0, yi = 1, and bi = 1:

Step 1 : (if b=1) X= Xi – 1= 0 – 1 Need to borrow from column i+1 bi+1 =1 & adding 10 (210) to XiStep 2 : X = 10 – 1 = 1Step 3 : X -Y = 1 – 1 d = 0

Page 25: Adder substracter

25

Truth Table for Binary Full Subtracter