CENG 241 Digital Design 1 Lecture 6 Amirali

  • Slides: 27
Download presentation
CENG 241 Digital Design 1 Lecture 6 Amirali Baniasadi amirali@ece. uvic. ca

CENG 241 Digital Design 1 Lecture 6 Amirali Baniasadi amirali@ece. uvic. ca

Decimal adder z When dealing with decimal numbers BCD code is used. z A

Decimal adder z When dealing with decimal numbers BCD code is used. z A decimal adders requires at least 9 inputs and 5 outputs. z BCD adder: each input does not exceed 9, the output can not exceed 19 z How are decimal numbers presented in BCD? z Decimal z 9 z 19 z Binary 10011 BCD 1001 (0001)(1001) 1 9 2

Decimal Adder z Decimal numbers should be represented in binary code number. z Example:

Decimal Adder z Decimal numbers should be represented in binary code number. z Example: BCD adder z Suppose we apply two BCD numbers to a binary adder then: z The result will be in binary and ranges from 0 through 19. z Binary sum: K(carry) Z 8 Z 4 Z 2 Z 1 z BCD sum : C(carry) S 8 S 4 S 2 S 1 z z For numbers equal or less than 1001 binary and BCD are identical. For numbers more than 1001, we should add 6(0110) to binary to get BCD. example: 10011(binary) = 11001(BCD) =19 ADD 6 to correct. 3

BCD adder Numbers that need correction (add 6) are: 01010 (10) 01011 (11) 01100

BCD adder Numbers that need correction (add 6) are: 01010 (10) 01011 (11) 01100 (12) 01101 (13) 01110 (14) 01111 (15) 10000 (16) 10001 (17) 10010 (18) 10011 (19) Decides to add 6? Adds 6 4

BCD adder Numbers that need correction (add 6) are: K Z 8 Z 4

BCD adder Numbers that need correction (add 6) are: K Z 8 Z 4 Z 2 Z 1 0 1 0 (10) 0 1 1 (11) 0 1 1 0 0 (12) 0 1 1 0 1 (13) 0 1 1 1 0 (14) 0 1 1 (15) 1 0 0 (16) 1 0 0 0 1 (17) 1 0 0 1 0 (18) 1 0 0 1 1 (19) C = K + Z 8 Z 4 +Z 8 Z 2 5

Magnitude Comparators z Compares two numbers, determines their relative magnitude. z We look at

Magnitude Comparators z Compares two numbers, determines their relative magnitude. z We look at a 4 -bit magnitude comparator; z A=A 3 A 2 A 1 A 0, B=B 3 B 2 B 1 B 0 z Two numbers are equal if all bits are equal. z A=B if A 3=B 3 AND A 2=B 2 AND A 1=B 1 AND A 0=B 0 z Xi= Ai. Bi + Ai’Bi’ ; Ai=Bi Xi=1 (remember exclusive NOR? ) 6

Magnitude Comparators z How do we know if A>B? z z 1. Compare bits

Magnitude Comparators z How do we know if A>B? z z 1. Compare bits starting from the most significant pair of digits 2. If the two are equal, compare the next lower significant bits 3. Continue until a pair of unequal digits are reached 4. Once the unequal digits are reached, A>B if Ai=1 and Bi=0, A<B if Ai=0 and Bi = 1 z A>B = A 3 B 3’+X 3 A 2 B 2’+X 3 X 2 A 1 B 1’+X 3 X 2 X 1 A 0 B 0’ z A<B = A 3’B 3+X 3 A 2’B 2+X 3 X 2 A 1’B 1+X 3 X 2 X 1 A 0’B 0 z Xi=1 if Ai=Bi 7

Magnitude Comparators A 3=B 3 ? X 3 A 2’B 2 8

Magnitude Comparators A 3=B 3 ? X 3 A 2’B 2 8

Decoders z A decoder converts binary information from n input lines to a maximum

Decoders z A decoder converts binary information from n input lines to a maximum of 2 n output lines z Also known as n-to-m line decoders where m< 2 n z Example 3 -to-8 decoders. 9

Decoders: Truth Table z z z z z X 0 0 1 1 Y

Decoders: Truth Table z z z z z X 0 0 1 1 Y 0 0 1 1 Z 0 1 0 1 D 0 1 0 0 0 0 D 2 0 0 1 0 0 0 D 3 0 0 0 1 0 0 D 4 0 0 1 0 0 0 D 5 0 0 0 1 0 0 D 6 0 0 0 1 0 D 7 0 0 0 0 1 10

Decoders: AND implementation 11

Decoders: AND implementation 11

2 -to-4 Decoder: NAND implementation Decoder is enabled when E=0 12

2 -to-4 Decoder: NAND implementation Decoder is enabled when E=0 12

How to build bigger decoders? We can combine two 3 -to-8 decoders to build

How to build bigger decoders? We can combine two 3 -to-8 decoders to build a 4 -to-16 decoder. Generates from 0000 to 0111 Generates from 1000 to 1111 13

Combinational Logic implementation z A decoder provides the 2 n minterms of n input

Combinational Logic implementation z A decoder provides the 2 n minterms of n input variables. z Any function is can be expressed in sum of minterms. z Use a decoder to make the minterms and an external OR gate to make the sum. z Example: consider a full adder. z S(x, y, z) = Σ(1, 2, 4, 7) z C(x, y, z) = Σ (3, 5, 6, 7) 14

Combinational Logic implementation 15

Combinational Logic implementation 15

Encoders z Encoders perform the inverse operation of a decoder: z Encoders have 2

Encoders z Encoders perform the inverse operation of a decoder: z Encoders have 2 n input lines and n output line. z Output lines generate the binary code corresponding to the input value. 16

Encoders: Truth Table Outputs z z z z z X 0 0 1 1

Encoders: Truth Table Outputs z z z z z X 0 0 1 1 Y 0 0 1 1 Z 0 1 0 1 z z=D 1+D 3+D 5+D 7 Inputs D 0 1 0 0 0 0 D 2 0 0 1 0 0 0 D 3 0 0 0 1 0 0 y=D 2+D 3+D 6+D 7 D 4 0 0 1 0 0 0 D 5 0 0 0 1 0 0 D 6 0 0 0 1 0 D 7 0 0 0 0 1 x=D 4+D 5+D 6+D 7 17

Priority Encoders z z z Encoder limitations: If two inputs are active, the output

Priority Encoders z z z Encoder limitations: If two inputs are active, the output is undefined. Solution: we need to take into account priority. What if all inputs are 0? Solution: we need a valid bit z z z z Input D 0 D 1 D 2 0 0 0 1 0 0 X 1 0 X X 1 X X X D 3 0 0 1 x X 0 0 1 1 Output y X 0 1 v 0 1 1 18

Priority Encoders: Map 19

Priority Encoders: Map 19

Priority Encoders: Circuit 20

Priority Encoders: Circuit 20

Multiplexers z Multiplexer: selects one binary input from many selections z example: 2 -to-1

Multiplexers z Multiplexer: selects one binary input from many selections z example: 2 -to-1 MUX 21

4 -to-1 MUX Directs 1 of the 4 inputs to the output 22

4 -to-1 MUX Directs 1 of the 4 inputs to the output 22

Multi-bit selection logic z Multiplexers can be combined with common selection inputs to support

Multi-bit selection logic z Multiplexers can be combined with common selection inputs to support multi-bit selection logic 23

Implementing Boolean functions w/ MUX z General rules for implementing any Boolean function with

Implementing Boolean functions w/ MUX z General rules for implementing any Boolean function with n variables: z z z Use a multiplexer with n-1 selection inputs and 2 n-1 data inputs List the truth tabel Apply the first n-1 variables to the selection inputs of multiplexer For each combination evaluate the output as a function of the last variable. The function can be 0, 1 the variable or the complement of the variable. 24

Implementing Boolean functions w/ MUX 25

Implementing Boolean functions w/ MUX 25

Implementing Boolean functions w/ MUX 26

Implementing Boolean functions w/ MUX 26

Summary z Reading up to page 154 27

Summary z Reading up to page 154 27