12
CS 151: Digital Design Chapter 3 3-8: Encoding

CS 151: Digital Design Chapter 3 3-8: Encoding. CS 151 Encoding Encoding - the opposite of decoding - the conversion of a maximum of 2 n input code to

Embed Size (px)

Citation preview

Page 1: CS 151: Digital Design Chapter 3 3-8: Encoding. CS 151 Encoding Encoding - the opposite of decoding - the conversion of a maximum of 2 n input code to

CS 151: Digital Design

Chapter 3

3-8: Encoding

Page 2: CS 151: Digital Design Chapter 3 3-8: Encoding. CS 151 Encoding Encoding - the opposite of decoding - the conversion of a maximum of 2 n input code to

CS 151

Encoding Encoding - the opposite of decoding - the conversion of

a maximum of 2n input code to an n-bit output code such that each valid code word produces a unique output code.

Circuits that perform encoding are called encoders. An encoder has 2n (or fewer) input lines and n output

lines which generate the binary code corresponding to the input values

Typically, an encoder converts a code containing exactly one bit that is 1 to a binary code corresponding to the position in which the 1 appears.

Page 3: CS 151: Digital Design Chapter 3 3-8: Encoding. CS 151 Encoding Encoding - the opposite of decoding - the conversion of a maximum of 2 n input code to

CS 151

Encoder Example-1 Octal-to Binary Encoder 1. Specifications:

Inputs: the 8 octal digits D0-D7

Output: the 3-bit binary code corresponding to the input octal digit. Assumptions: Only one input has a value of 1 at any time.

2. Truth table:

A2 = D4 +D5+D6+D7

A1= D2+D3+D6+D7

A0=D1+D3+D5+D7

The encoder can be implemented with 3 OR gates.

Page 4: CS 151: Digital Design Chapter 3 3-8: Encoding. CS 151 Encoding Encoding - the opposite of decoding - the conversion of a maximum of 2 n input code to

CS 151

Encoder Example-2

A decimal-to-BCD encoder Inputs: 10 bits corresponding to decimal digits 0

through 9, (D0, …, D9) Outputs: 4 bits with BCD codes Function: If input bit Di is a 1, then the output

(A3, A2, A1, A0) is the BCD code for i,

The truth table could be formed, but alternatively, the equations for each of the four outputs can be obtained directly.

Page 5: CS 151: Digital Design Chapter 3 3-8: Encoding. CS 151 Encoding Encoding - the opposite of decoding - the conversion of a maximum of 2 n input code to

CS 151

Encoder Example-2 (continued) Input Di is a term in equation Aj if bit Aj is 1 in

the binary value for i. Equations:

A3 = D8 + D9

A2 = D4 + D5 + D6 + D7

A1 = D2 + D3 + D6 + D7

A0 = D1 + D3 + D5 + D7 + D9

F1 = D6 + D7 can be extracted from A2 and A1 Is there any cost saving?

Page 6: CS 151: Digital Design Chapter 3 3-8: Encoding. CS 151 Encoding Encoding - the opposite of decoding - the conversion of a maximum of 2 n input code to

CS 151

Priority Encoder Problem 1: If more than one input value is 1, then the

encoder just designed does not work. (E.g. if D3 and D6 are both 1, what is the output?)

Solution: One encoder that can accept all possible combinations of input values and produce a meaningful result is a priority encoder.

Priority encoders establish an input priority to ensure that only one input is encoded.

Among the 1s that appear, it selects the most significant input position containing a 1 and responds with the corresponding binary code for that position.

Page 7: CS 151: Digital Design Chapter 3 3-8: Encoding. CS 151 Encoding Encoding - the opposite of decoding - the conversion of a maximum of 2 n input code to

CS 151

Priority Encoder

Problem 2: When all inputs are equal to 0, an output of all 0’s is generated- but this is the same output for D0???

Solution: Provide one more output (v) to indicate that at least one input is equal to 1.

Page 8: CS 151: Digital Design Chapter 3 3-8: Encoding. CS 151 Encoding Encoding - the opposite of decoding - the conversion of a maximum of 2 n input code to

CS 151

Priority Encoder Example Priority encoder with 4 inputs (D3, D2, D1, D0) - highest priority to most

significant 1 present - Code outputs A2, A1, A0 and V where V indicates at least one 1 present.

Xs in input part of table represent 0 or 1; thus table entries correspond to product terms instead of minterms. The column on the left shows that all 16 minterms are present in the product terms in the table.

No. of Min-terms/Row

inputsoutputs

D3D2D1D0A1A0V

10000XX0

10001001

2001X011

401XX101

81XXX111

X’s in output represent don’t cares

Condensed truth table

A1 = D3’D2 + D3

A0 = D3’D2’D1 + D3

V = D0 + D1+ D2+ D3

Page 9: CS 151: Digital Design Chapter 3 3-8: Encoding. CS 151 Encoding Encoding - the opposite of decoding - the conversion of a maximum of 2 n input code to

CS 151

What does the full truth table look like?InputsOutputs

D3D2D1D0A1A0V

0000XX0

0001001

0000110011

0000111011

001100101

001101101

001110101

001111101

11000111

11001111

11010111

11011111

11100111

11101111

11110111

11111111

D0=X

D1=X

D0 =X

D2 =X

D1 =X

D0 =X

Priority Encoder Example

Page 10: CS 151: Digital Design Chapter 3 3-8: Encoding. CS 151 Encoding Encoding - the opposite of decoding - the conversion of a maximum of 2 n input code to

CS 151

Priority Encoder ExampleA1 = D3’D2 + D3

A0 = D3’D2’D1 + D3

V = D0 + D1+ D2+ D3

Page 11: CS 151: Digital Design Chapter 3 3-8: Encoding. CS 151 Encoding Encoding - the opposite of decoding - the conversion of a maximum of 2 n input code to

CS 151

Priority Encoder ExampleA0 = D3 + D1D2’

A1 = D2 + D3

V = D0 + D1 + D2 + D3

Page 12: CS 151: Digital Design Chapter 3 3-8: Encoding. CS 151 Encoding Encoding - the opposite of decoding - the conversion of a maximum of 2 n input code to

CS 151

In Class Exercise

(Problem 4-11) Derive the truth table of a BCD-to-binary priority encoder. Where the highest priority is assigned to the least index among BCD inputs.