engin 112 intro to electrical and computer engineering · intro to electrical and computer...

18
ENGIN112 L15: Magnitude Comparator and Multiplexers October 6, 2003 ENGIN 112 Intro to Electrical and Computer Engineering Lecture 15 Magnitude Comparators and Multiplexers

Upload: others

Post on 03-Jun-2020

6 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: ENGIN 112 Intro to Electrical and Computer Engineering · Intro to Electrical and Computer Engineering Lecture 15 Magnitude Comparators and Multiplexers. ENGIN112 L15: Magnitude Comparator

ENGIN112 L15: Magnitude Comparator and Multiplexers October 6, 2003

ENGIN 112

Intro to Electrical and Computer Engineering

Lecture 15Magnitude Comparators and Multiplexers

Page 2: ENGIN 112 Intro to Electrical and Computer Engineering · Intro to Electrical and Computer Engineering Lecture 15 Magnitude Comparators and Multiplexers. ENGIN112 L15: Magnitude Comparator

ENGIN112 L15: Magnitude Comparator and Multiplexers October 6, 2003

Overview

° Discussion of two digital building blocks

° Magnitude comparators• Compare two multi-bit binary numbers• Create a single bit comparator• Use repetitive pattern

° Multiplexers• Select one out of several bits• Some inputs used for selection• Also can be used to implement logic

Page 3: ENGIN 112 Intro to Electrical and Computer Engineering · Intro to Electrical and Computer Engineering Lecture 15 Magnitude Comparators and Multiplexers. ENGIN112 L15: Magnitude Comparator

ENGIN112 L15: Magnitude Comparator and Multiplexers October 6, 2003

Magnitude Comparator

° The comparison of two numbers• outputs: A>B, A=B, A<B

° Design Approaches• the truth table

- 22n

entries - too cumbersome for large n• use inherent regularity of the problem

- reduce design efforts- reduce human errors

MagnitudeCompare

A[3..0]

B[3..0]A = B

A < B

A > B

Page 4: ENGIN 112 Intro to Electrical and Computer Engineering · Intro to Electrical and Computer Engineering Lecture 15 Magnitude Comparators and Multiplexers. ENGIN112 L15: Magnitude Comparator

ENGIN112 L15: Magnitude Comparator and Multiplexers October 6, 2003

Magnitude Comparator

A0

A1

A2

A3

B0

B1

B2

B3

A_EQ_B

C0

C1

C3

C2

D01

D23

How can we find A > B?

How many rows would a truth table have?

28 = 256

Page 5: ENGIN 112 Intro to Electrical and Computer Engineering · Intro to Electrical and Computer Engineering Lecture 15 Magnitude Comparators and Multiplexers. ENGIN112 L15: Magnitude Comparator

ENGIN112 L15: Magnitude Comparator and Multiplexers October 6, 2003

Magnitude Comparator

A0

A1

A2

A3

B0

B1

B2

B3

A_EQ_B

C0

C1

C3

C2

D01

D23

If A = 1001 andB = 0111

is A > B?Why?

Because A3 > B3i.e. A3 . B3’ = 1

Therefore, one term in thelogic equation for A > B isA3 . B3’

Find A > B

Page 6: ENGIN 112 Intro to Electrical and Computer Engineering · Intro to Electrical and Computer Engineering Lecture 15 Magnitude Comparators and Multiplexers. ENGIN112 L15: Magnitude Comparator

ENGIN112 L15: Magnitude Comparator and Multiplexers October 6, 2003

Magnitude Comparator

If A = 1010 andB = 1001

is A > B?Why? Because A3 = B3 and

A2 = B2 andA1 > B1

i.e. C3 = 1 and C2 = 1 andA1 . B1’ = 1

Therefore, the next term in thelogic equation for A > B isC3 . C2 . A1 . B1’

A > B = A3 . B3’+ C3 . A2 . B2’+ …..

Page 7: ENGIN 112 Intro to Electrical and Computer Engineering · Intro to Electrical and Computer Engineering Lecture 15 Magnitude Comparators and Multiplexers. ENGIN112 L15: Magnitude Comparator

ENGIN112 L15: Magnitude Comparator and Multiplexers October 6, 2003

Magnitude Comparison

° Algorithm -> logic• A = A3A2A1A0 ; B = B3B2B1B0

• A=B if A3=B3, A2=B2, A1=B1and A1=B1

° Test each bit:- equality: xi= AiBi+Ai'Bi'- (A=B) = x3x2x1x0

° More difficult to test less than/greater than• (A>B) = A3B3'+x3A2B2'+x3x2A1B1'+x3x2x1 A0B0'• (A<B) = A3'B3+x3A2'B2+x3x2A1'B1+x3x2x1 A0'B0

• Start comparisons from high-order bits

° Implementation• xi = (AiBi'+Ai'Bi)’

Page 8: ENGIN 112 Intro to Electrical and Computer Engineering · Intro to Electrical and Computer Engineering Lecture 15 Magnitude Comparators and Multiplexers. ENGIN112 L15: Magnitude Comparator

ENGIN112 L15: Magnitude Comparator and Multiplexers October 6, 2003

Magnitude Comparison

° Hardware chips

Page 9: ENGIN 112 Intro to Electrical and Computer Engineering · Intro to Electrical and Computer Engineering Lecture 15 Magnitude Comparators and Multiplexers. ENGIN112 L15: Magnitude Comparator

ENGIN112 L15: Magnitude Comparator and Multiplexers October 6, 2003

Magnitude Comparator

° Real-world application• Thermostat controller

Page 10: ENGIN 112 Intro to Electrical and Computer Engineering · Intro to Electrical and Computer Engineering Lecture 15 Magnitude Comparators and Multiplexers. ENGIN112 L15: Magnitude Comparator

ENGIN112 L15: Magnitude Comparator and Multiplexers October 6, 2003

Multiplexers

° Select an input value with one or more select bits

° Use for transmitting data

° Allows for conditional transfer of data

° Sometimes called a mux

Page 11: ENGIN 112 Intro to Electrical and Computer Engineering · Intro to Electrical and Computer Engineering Lecture 15 Magnitude Comparators and Multiplexers. ENGIN112 L15: Magnitude Comparator

ENGIN112 L15: Magnitude Comparator and Multiplexers October 6, 2003

4– to– 1- Line Multiplexer

Page 12: ENGIN 112 Intro to Electrical and Computer Engineering · Intro to Electrical and Computer Engineering Lecture 15 Magnitude Comparators and Multiplexers. ENGIN112 L15: Magnitude Comparator

ENGIN112 L15: Magnitude Comparator and Multiplexers October 6, 2003

Quadruple 2–to–1-Line Multiplexer

° Notice enable bit

° Notice select bit

° 4 bit inputs

Page 13: ENGIN 112 Intro to Electrical and Computer Engineering · Intro to Electrical and Computer Engineering Lecture 15 Magnitude Comparators and Multiplexers. ENGIN112 L15: Magnitude Comparator

ENGIN112 L15: Magnitude Comparator and Multiplexers October 6, 2003

Multiplexer as combinational modules

° Connect input variables to select inputs of multiplexer (n-1 for n variables)

° Set data inputs to multiplexer equal to values of function for corresponding assignment of select variables

° Using a variable at data inputs reduces size of the multiplexer

Page 14: ENGIN 112 Intro to Electrical and Computer Engineering · Intro to Electrical and Computer Engineering Lecture 15 Magnitude Comparators and Multiplexers. ENGIN112 L15: Magnitude Comparator

ENGIN112 L15: Magnitude Comparator and Multiplexers October 6, 2003

Implementing a Four- Input Function with a Multiplexer

Page 15: ENGIN 112 Intro to Electrical and Computer Engineering · Intro to Electrical and Computer Engineering Lecture 15 Magnitude Comparators and Multiplexers. ENGIN112 L15: Magnitude Comparator

ENGIN112 L15: Magnitude Comparator and Multiplexers October 6, 2003

Typical multiplexer uses

Page 16: ENGIN 112 Intro to Electrical and Computer Engineering · Intro to Electrical and Computer Engineering Lecture 15 Magnitude Comparators and Multiplexers. ENGIN112 L15: Magnitude Comparator

ENGIN112 L15: Magnitude Comparator and Multiplexers October 6, 2003

Three-state gates

• A multiplexer can be constructed with three-state gates• Output state: 0, 1, and high-impedance (open ckts)• If the select input (E) is 0, the three-state gate has no

output

Opposite true here,

No output if E is 1

Page 17: ENGIN 112 Intro to Electrical and Computer Engineering · Intro to Electrical and Computer Engineering Lecture 15 Magnitude Comparators and Multiplexers. ENGIN112 L15: Magnitude Comparator

ENGIN112 L15: Magnitude Comparator and Multiplexers October 6, 2003

Three-state gates

• A multiplexer can be constructed with three-state gates• Output state: 0, 1, and high-impedance (open ckts)• If the select input is low, the three-state gate has no output

Page 18: ENGIN 112 Intro to Electrical and Computer Engineering · Intro to Electrical and Computer Engineering Lecture 15 Magnitude Comparators and Multiplexers. ENGIN112 L15: Magnitude Comparator

ENGIN112 L15: Magnitude Comparator and Multiplexers October 6, 2003

Summary

° Magnitude comparators allow for data comparison• Can be built using and-or gates

° Greater/less than requires more hardware than equality

° Multiplexers are fundamental digital components• Can be used for logic• Useful for datapaths• Scalable

° Tristate buffers have three types of outputs• 0, 1, high-impedence (Z)• Useful for datapaths