32
Dr. Prapun Suksompong [email protected] Lecture 13 1 Digital Circuits ECS 371 Office Hours: BKD 3601-7 Monday 9:00-10:30, 1:30-3:30 Tuesday 10:30-11:30

[email protected] Lecture 13 - Lecture13 - handout.pdf · Parallel Adder 19 Two categories (based on the way in which internal carries from stage to stage are handled) 1. Ripple

  • Upload
    others

  • View
    7

  • Download
    0

Embed Size (px)

Citation preview

Page 1: prapun@siit.tu.ac.th Lecture 13 - Lecture13 - handout.pdf · Parallel Adder 19 Two categories (based on the way in which internal carries from stage to stage are handled) 1. Ripple

Dr. Prapun [email protected]

Lecture 13

1

Digital CircuitsECS 371

Office Hours:

BKD 3601-7

Monday 9:00-10:30, 1:30-3:30

Tuesday 10:30-11:30

Page 2: prapun@siit.tu.ac.th Lecture 13 - Lecture13 - handout.pdf · Parallel Adder 19 Two categories (based on the way in which internal carries from stage to stage are handled) 1. Ripple

Adder

8

Half-adder: A digital

circuit that adds two

bits and produces a

sum and an output

carry. It cannot handle

input carries.

Full-adder: A digital circuit that adds two

bits and an input carry to produce a sum and

an output carry.

1+1+0 = 210 = 102

Page 3: prapun@siit.tu.ac.th Lecture 13 - Lecture13 - handout.pdf · Parallel Adder 19 Two categories (based on the way in which internal carries from stage to stage are handled) 1. Ripple

1-bit Adder: Half Adder

9

The basic difference between a full-adder and a half-

adder is that the full-adder accepts an input carry.

Half-Adder:

A

B

S

Cout

out

A B

C AB

S

Page 4: prapun@siit.tu.ac.th Lecture 13 - Lecture13 - handout.pdf · Parallel Adder 19 Two categories (based on the way in which internal carries from stage to stage are handled) 1. Ripple

1-bit Adder: Full-Adder

10

We will construct a full adder by first adding A and B using a

half-adder.

Then, we use a second half-adder to add Cin to the result of

the first half-adder.

A

B

S

Cout

S A

B

S

Cout

SA

B

S

Cout

Cin

S1

C1

S2

C2

Page 5: prapun@siit.tu.ac.th Lecture 13 - Lecture13 - handout.pdf · Parallel Adder 19 Two categories (based on the way in which internal carries from stage to stage are handled) 1. Ripple

The Output Carry of Full Adder

11

1 1 1 2

out in in

in

in

in in

in

in

C AB BC AC

AB A B C

AB A B AB C

AB A B C ABC

AB A B C

C S C C C

A

B

S

Cout

S A

B

S

Cout

SA

B

S

Cout

Cin

S1

C1

S2

C2

This is from K-map.

Page 6: prapun@siit.tu.ac.th Lecture 13 - Lecture13 - handout.pdf · Parallel Adder 19 Two categories (based on the way in which internal carries from stage to stage are handled) 1. Ripple

Multiple-bit Addition

12

When one (multiple-bit) binary number is added to another, each column generates a sum bit and a 1 or 0 carry bit to the next column to the left.

To add binary numbers with more than one bit, we must use additional full-adders.

For 2-bit numbers, two adders are needed;

for 4-bit numbers, four adders are used;

and so on.

0111 71101 13

0

1

0

1

1

1

01 20=

++A:

B:

1

Page 7: prapun@siit.tu.ac.th Lecture 13 - Lecture13 - handout.pdf · Parallel Adder 19 Two categories (based on the way in which internal carries from stage to stage are handled) 1. Ripple

Recall: Binary Addition

13

Example: Add the binary numbers 0111 and 1101 and show

the equivalent decimal addition.

4-bit adder

0111 71101 13

0

1

0

1

1

1

01 20=

++

1

A:

B:

1 1 1

0

1 0 10

00 1 1 1 0 11

1

The carry output of each

adder is connected to the

carry input of the next

higher-order adder. These

are called internal

carries.

Page 8: prapun@siit.tu.ac.th Lecture 13 - Lecture13 - handout.pdf · Parallel Adder 19 Two categories (based on the way in which internal carries from stage to stage are handled) 1. Ripple

Recall: Binary Addition

14

Example: Add the binary numbers 0111 and 1101 and show

the equivalent decimal addition.

4-bit adder

01111101

0

1

+

1

A:

B:

1 1 1

0

1 0 10

01

1+1+0 = 210 = 102

0Input Carry

If there is no input carry to the

LSB, then either a half-adder can

be used or the carry input of a full-

adder can be made 0 (grounded)

Page 9: prapun@siit.tu.ac.th Lecture 13 - Lecture13 - handout.pdf · Parallel Adder 19 Two categories (based on the way in which internal carries from stage to stage are handled) 1. Ripple

Recall: Binary Addition

15

Example: Add the binary numbers 0111 and 1101 and show

the equivalent decimal addition.

4-bit adder

01111101

0

1

0

1

+

1

A:

B:

1 1 1

0

1 0 10

01 0 1

1+0+1 = 210 = 102

Carry bit from the right column

Page 10: prapun@siit.tu.ac.th Lecture 13 - Lecture13 - handout.pdf · Parallel Adder 19 Two categories (based on the way in which internal carries from stage to stage are handled) 1. Ripple

Recall: Binary Addition

16

Example: Add the binary numbers 0111 and 1101 and show

the equivalent decimal addition.

4-bit adder

01111101

0

1

0

1

1

1

+

1

A:

B:

1 1 1

0

1 0 10

01 1 1 0 1

1+1+1 = 310 = 112

Page 11: prapun@siit.tu.ac.th Lecture 13 - Lecture13 - handout.pdf · Parallel Adder 19 Two categories (based on the way in which internal carries from stage to stage are handled) 1. Ripple

Recall: Binary Addition

17

Example: Add the binary numbers 0111 and 1101 and show

the equivalent decimal addition.

4-bit adder

01111101

0

1

0

1

1

1

0

+

1

A:

B:

1 1 1

0

1 0 10

00 1 1 1 0 11

1

0+1+1 = 210 = 102

Page 12: prapun@siit.tu.ac.th Lecture 13 - Lecture13 - handout.pdf · Parallel Adder 19 Two categories (based on the way in which internal carries from stage to stage are handled) 1. Ripple

Recall: Binary Addition

18

Example: Add the binary numbers 0111 and 1101 and show

the equivalent decimal addition.

4-bit adder

0111 71101 13

0

1

0

1

1

1

01 20=

++

1

A:

B:

1 1 1

0

1 0 10

00 1 1 1 0 11

1 The output carry from the left-

most full-adder becomes the

MSB in the sum

Page 13: prapun@siit.tu.ac.th Lecture 13 - Lecture13 - handout.pdf · Parallel Adder 19 Two categories (based on the way in which internal carries from stage to stage are handled) 1. Ripple

Parallel Adder

19

Two categories (based on the way in which internal carries from stage to stage are handled)

1. Ripple carry (The adder we have studied is a ripple-carry adder.)

2. Look-ahead carry

Externally, both types of adders are the same in terms of inputs and outputs.

The difference is the speed at which they can add numbers.

The look-ahead carry adder is much faster than the ripple-carry adder.

The speed with which an addition can be performed is limited by the time required for the carries to propagate, or ripple, through all the stages of a parallel adder.

Page 14: prapun@siit.tu.ac.th Lecture 13 - Lecture13 - handout.pdf · Parallel Adder 19 Two categories (based on the way in which internal carries from stage to stage are handled) 1. Ripple

Ripple Carry Adder

20

A ripple carry adder is one in which the carry output of each full-adder is connected to the carry input of the next higher-order stage (a stage is one full-adder).

Practical consideration: Real devices/gates have propagation time.

The sum and the output carry of any stage cannot be produced until the input carry occurs.

This causes a time delay in the addition process

Page 15: prapun@siit.tu.ac.th Lecture 13 - Lecture13 - handout.pdf · Parallel Adder 19 Two categories (based on the way in which internal carries from stage to stage are handled) 1. Ripple

Look-Ahead Carry Adder

21

Speedup the addition process by eliminating ripple carry

delay.

Anticipate the output carry of each stage.

Page 16: prapun@siit.tu.ac.th Lecture 13 - Lecture13 - handout.pdf · Parallel Adder 19 Two categories (based on the way in which internal carries from stage to stage are handled) 1. Ripple

74x283: 4-bit Parallel Adder

22

Page 17: prapun@siit.tu.ac.th Lecture 13 - Lecture13 - handout.pdf · Parallel Adder 19 Two categories (based on the way in which internal carries from stage to stage are handled) 1. Ripple

Adder Expansion

23

Page 18: prapun@siit.tu.ac.th Lecture 13 - Lecture13 - handout.pdf · Parallel Adder 19 Two categories (based on the way in which internal carries from stage to stage are handled) 1. Ripple

Arithmetic Operations with Signed

Numbers

24

Using the signed number notation with negative numbers in

2’s complement form simplifies addition and subtraction of

signed numbers.

Rules for addition: Add the two signed numbers (as if they

are unsigned number). Discard any final carries. The result is

in signed form.

00011110 = +30

00001111 = +15

00101101 = +45

00001110 = +14

11101111 = -17

11111101 = -3

11111111 = -1

11111000 = -8

11110111 = -91

Discard

carry

+ ++

Examples:

Page 19: prapun@siit.tu.ac.th Lecture 13 - Lecture13 - handout.pdf · Parallel Adder 19 Two categories (based on the way in which internal carries from stage to stage are handled) 1. Ripple

Error (Overflow)

25

Note that if the number of bits required for the answer is exceeded, error will occur. This occurs only if both numbers have the same sign.

The error will be indicated by an incorrect sign bit.

Some textbooks use the word “overflow” to denote this error.

01000000 = +128

01000001 = +129

10000001 = -126

10000001 = -127

10000001 = -127

100000010 = +2

Wrong!The answer is incorrect

and the sign bit has changed.

Discard

carry

Adding two positive numbers produces an

overflow if the sign of the result is negative.

Adding two negative numbers produces an

underflow if the sign of the result is positive

Some textbooks

denote this case by

“underflow”.

Page 20: prapun@siit.tu.ac.th Lecture 13 - Lecture13 - handout.pdf · Parallel Adder 19 Two categories (based on the way in which internal carries from stage to stage are handled) 1. Ripple

Subtraction

26

Rules for subtraction: 2’s complement the subtrahend and

add the numbers. Discard any final carries. The result is in

signed form.

00001111 = +151

Discard

carry

2’s complement subtrahend and add:

00011110 = +30

11110001 = -15

Example: Repeat the examples done previously, but subtract:

00011110

00001111-00001110

11101111

11111111

11111000- -

00011111 = +31

00001110 = +14

00010001 = +17

00000111 = +71

Discard

carry

11111111 = -1

00001000 = 8

(+30)

–(+15)

(+14)

–(-17)

(-1)

–(-8)

Page 21: prapun@siit.tu.ac.th Lecture 13 - Lecture13 - handout.pdf · Parallel Adder 19 Two categories (based on the way in which internal carries from stage to stage are handled) 1. Ripple

Comparator

27

A comparator compares two quantities and indicates whether

or not they are equal.

Page 22: prapun@siit.tu.ac.th Lecture 13 - Lecture13 - handout.pdf · Parallel Adder 19 Two categories (based on the way in which internal carries from stage to stage are handled) 1. Ripple

74x85: 4-bit Magnitude Comparator

28

Page 23: prapun@siit.tu.ac.th Lecture 13 - Lecture13 - handout.pdf · Parallel Adder 19 Two categories (based on the way in which internal carries from stage to stage are handled) 1. Ripple

Encoder

29

In general, the encoder converts information, such as a decimal

number or an alphabetic character, into some coded form.

1001

Essentially, it performs a

“reverse” decoder

function.

This encoder accepts an

active level on one of its

inputs representing a digit,

and converts it to a binary

output.

Page 24: prapun@siit.tu.ac.th Lecture 13 - Lecture13 - handout.pdf · Parallel Adder 19 Two categories (based on the way in which internal carries from stage to stage are handled) 1. Ripple

BCD

30

Binary coded decimal (BCD) is

a weighted code that is

commonly used in digital

systems when it is necessary to

show decimal numbers such as

in clock displays.

Express each of the decimal

digits with a binary code.

0

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

0000

0001

0010

0011

0100

0101

0110

0111

1000

1001

1010

1011

1100

1101

1110

1111

Decimal Binary BCD

0001

0001

0001

0001

0001

0001

0000

0001

0010

0011

0100

0101

0110

0111

1000

1001

0000

0001

0010

0011

0100

0101

Page 25: prapun@siit.tu.ac.th Lecture 13 - Lecture13 - handout.pdf · Parallel Adder 19 Two categories (based on the way in which internal carries from stage to stage are handled) 1. Ripple

Decimal-to-BCD Encoder

31

A 0-digit input is not needed because

the BCD outputs are all LOW when

there are no HIGH inputs.

The decimal-to-BCD is an encoder with an input for each of the ten decimal

digits and four outputs that represent the BCD code for the active digit.

A1

A0

A2

A3

1

2

3

4567

8

9

Page 26: prapun@siit.tu.ac.th Lecture 13 - Lecture13 - handout.pdf · Parallel Adder 19 Two categories (based on the way in which internal carries from stage to stage are handled) 1. Ripple

Example

32

Q: Show how the decimal-to-BCD encoder converts the decimal number 3 into a BCD 0011.

A: The top two OR gates have ones as indicated with the red lines. Thus the output is 0011.

A1

A0

A2

A3

1

2

3

4567

8

9

0

0

0

00

0

0

0

1

0

0

1

1

Page 27: prapun@siit.tu.ac.th Lecture 13 - Lecture13 - handout.pdf · Parallel Adder 19 Two categories (based on the way in which internal carries from stage to stage are handled) 1. Ripple

Programmable Logic Devices

33

There are two broad categories of digital ICs.

1. Fixed-function logic

2. Programmable logic

We’ve already talked

about many of these

Page 28: prapun@siit.tu.ac.th Lecture 13 - Lecture13 - handout.pdf · Parallel Adder 19 Two categories (based on the way in which internal carries from stage to stage are handled) 1. Ripple

PLD (Programmable Logic Device)

34

Historically, the first PLDs were programmable logic arrays

(PLAs)

A PLA is a combinational, two-level AND-OR device that

can be programmed to realize any SOP logic expression.

Hence, it can also be used to implement minimal sum.

Most PLDs also have a programmable inverter/buffer at the

output of the AND-OR array.

Hence, it can also be used to implemented POS expression and

minimal product.

Page 29: prapun@siit.tu.ac.th Lecture 13 - Lecture13 - handout.pdf · Parallel Adder 19 Two categories (based on the way in which internal carries from stage to stage are handled) 1. Ripple

PLA

35

A 4 3 PLA with six product terms

Potential connections in the array are

indicated by X’s; the device is

programmed by establishing only the

connections that are actually needed.

Page 30: prapun@siit.tu.ac.th Lecture 13 - Lecture13 - handout.pdf · Parallel Adder 19 Two categories (based on the way in which internal carries from stage to stage are handled) 1. Ripple

Programmable link in PLDs

36

Page 31: prapun@siit.tu.ac.th Lecture 13 - Lecture13 - handout.pdf · Parallel Adder 19 Two categories (based on the way in which internal carries from stage to stage are handled) 1. Ripple

ECS371 Exam

37

NOT to torture you.

It’s an opportunity for you to demonstrate what you have

learned from this course.

Aim for partial credit! If you know something, write that

down.

Page 32: prapun@siit.tu.ac.th Lecture 13 - Lecture13 - handout.pdf · Parallel Adder 19 Two categories (based on the way in which internal carries from stage to stage are handled) 1. Ripple

Some Important Corrections

38

These typos in the notes have already been corrected in class.

However, for those who skipped class, here are some

important ones:

Distributive law:

A+BC = (A+B)(A+C)

A(B+C) = AB+AC

Caution: AB + CD = (AB+C)(AB+D) = (A+CD)(B+CD)

NOT the same as ABC + ABD

K-Map for 4 variables

D

A

C

B

CD

AB

C

A

D

B

CD AB