Indian Institute of Technology Jodhpur, Year 28 29 Digital Logic and Design (Course Code: EE222) Lecture 4: Combinational Contd.. Decoders/Encoders Course Instructor: Shree Prakash Tiwari Email: sptiwari@iitj.ac.in Webpage: http://home.iitj.ac.in/~sptiwari/ / / Course related documents will be uploaded on http://home.iitj.ac.in/~sptiwari/dld/ Note: The information provided in the slides are taken form text books Digital Electronics (including Mano & Ciletti), and various other resources from internet, for teaching/academic use only Decoders/Encoders Binary decoders Converts an n-bit code to a single active output Can be developed using AND/OR gates Can be used to implement logic circuits. Binary encoders Converts one of 2 n inputs to an n-bit output Useful for compressing data Can be developed using AND/OR gates Both encoders and decoders are extensively used in digital systems
Binary Decoder Black box with n input lines and 2 n output lines Only one output is a for any given input n inputs Binary Decoder 2 n outputs 2-to-4 Binary Decoder Truth Table: X Y F F F 2 F 3 F = X'Y' F = X'Y From truth table, circuit for 2x4 decoder is: Note: Each output is a 2- variable minterm (X'Y', X'Y, XY' or XY) F 2 = XY' F 3 = XY X Y 2-to-4 Decoder F F F2 F3 X Y 2
3-to-8 Binary Decoder Truth Table: x y z F F F 2 F 3 F 4 F 5 F 6 F 7 F = x'y'z' F = x'y'z F 2 =x'yz' xyz F 3 = x'yz F 4 = xy'z' F 5 = xy'z F 6 = xyz' X Y Z 3-to-8 Decoder F F F2 F3 F4 F5 F6 x y z F 7 =xyz F7 Implementing Functions Using Decoders Any n-variable logic function can be implemented using a single n-to-2 n decoder to generate the minterms OR gate forms the sum. The output lines of the decoder corresponding to the minterms of the function are used as inputs to the or gate. Any combinational circuit with n inputs and m outputs can be implemented with an n-to-2 n decoder with m OR gates. Suitable when a circuit has many outputs, and each output function is expressed with few minterms. 3
Implementing Functions Using Decoders F = m(,2) Implementing Functions Using Decoders Exercise: Design a circuit, using a 3-to-8 Decoder to realize the Boolean expression given below. F X,Y,Z = m(,2,5,7) 4
Implementing Functions Using Decoders Exercise: Design a Full Adder using a 3-to-8 Decoder. Implementing Functions Using Decoders Example: Full adder S(x, y, z) = (,2,4,7) C(x, y, z) = (3,5,6,7) x y z C S x y z 3-to-8 Decoder S 2 S S 2 3 4 5 6 7 S C 5
Building a Binary Decoder with NAND Gates Start with a 2-bit decoder Add an enable signal (E) Note: use of NANDs only one active! if E = Use two 3 to 8 decoders to make 4 to 6 decoder Enable can also be active high In this example, only one decoder can be active at a time. x, y, z effectively select output line for w 6
Encoders If the a decoder's output code has fewer bits than the input code, the device is usually called an encoder. e.g. 2 n -to-n The simplest encoder is a 2 n -to-n binary encoder One of 2 n inputs = Output is an n-bit binary number 2 n inputs... Binary encoder... n outputs 4-to-2 Binary Encoder At any one time, only one input line has a value of. w 3 w 2 w w y y w w y w 2 w 3 y 7
8-to-3 Binary Encoder At any one time, only one input line has a value of. I Inputs Outputs I I I 2 I 3 I 4 I 5 I 6 I 7 y 2 y y I I 2 y 2 = I 4 + I 5 + I 6 + I 7 I 3 y = I 2 + I 3 + I 6 + I 7 I 4 I 5 I 6 I 7 y = I + I 3 + I 5 + I 7 Priority Encoder Higher-order input has priority of lower-order input Order of the input determined by its binary value I has binary value () I has binary value () I2 has binary value (2) I3 has binary value (3) etc. So, I selected over I I2 selected over I and I I3 selected over I2, I, and I Etc. 8
Priority Encoder Valid indicator Output signal of the (priority) encoder that indicates the validity of the encoded output Encoded output is invalid when no inputs are selected or when the encoder is disabled V = (indicates invalid encoded output; active high) Encoded output when one, or more, input(s) is (are) selected, and encoder is enabled V = (indicates valid encoded output; active high) 4-to-2 Priority Encoder Valid indicator invalid valid 9
Priority Encoder 4-to-2 Priority Encoder
8-to-3 Priority Encoder What if more than one input line has a value of? Ignore lower priority inputs. Idle indicates that no input is a. Note that polarity of Idle is opposite from Table 4-8 in Mano Inputs Outputs I I I 2 I 3 I 4 I 5 I 6 I 7 y 2 y y Idle x x x X X X X X X X X X X X X X X X X X X X X X X X X X X X X Encoder Application (Monitoring Unit) Encoder identifies the requester and encodes the value Controller accepts digital inputs. Alarm Signal Contoller Response Machine Machine 2 Encoder Machine Code Controller Action Machine n
Multiplexers A multiplexer switches (or routes) data from 2 N inputs to one output, where N is the number of select (or control) inputs. A multiplexer (mux) is a digital switch. Multiplexers What next 24 2