Encoders Three-State Outputs Multiplexers XOR Gates
Encoders Three-State Outputs Multiplexers XOR Gates
Three-state Outputs
Multiplexers
XOR gates
Encoders
• An encoder is a combinational logic module or a digital
circuit that performs the inverse operation of a decoder.
• It assigns a unique output code for each input signal applied
to the device.
• An encoder has 2n (or fewer) input lines and n output lines.
• The output lines generate the binary code corresponding to
the input value.
• An example of an encoder is the octal to-binary encoder,
74148.
Encoders vs. Decoders
Decoder Encoder
Decoders
• A decoder is multiple-input, multiple-output logic circuit
that converts coded inputs into coded outputs.
• Input code with fewer bits than the output bits.
– Typically n inputs, 2n outputs
• 2-to-4, 3-to-8, 4-to-16, etc.
• There is a one-to-one mapping.
Decoders
• General decoder structure
X3 X2 X1 X0 A1 A0 GS
0 0 0 0 0 0 0
0 0 0 1 0 0 1
0 0 1 d 0 1 1
0 1 d d 1 0 1
1 d d d 1 1 1
74x148 8-input priority encoder
– Active-low I/O
– Enable Input
– “Got Something”
– Enable Output
74x148
circuit
74x148 Truth Table
Cascading
priority
encoders
• 32-input
priority encoder
15-input priority encoder in ABEL
• Declarations
Constant expressions
Outputs
Alternative formulation
• 2-input multiplexer
Other multiplexer varieties
• 2-input, 4-bit-wide
– 74x157
• 4-input, 2-bit-wide
– 74x153
ABEL code for 74x153-like mux
Easier ABEL multiplexer code
Barrel shifter design example
• n data inputs, n data outputs
• Control inputs specify number of positions to rotate or shift
data inputs
• Example: n = 16
– DIN[15:0], DOUT[15:0], S[3:0] (shift amount)
• Many possible solutions, all based on multiplexers
16 16-to-
1 muxes
16-to-1 mux =
2 x 74x151
8-to-1 mux
+ NAND gate
4 16-bit 2-to-1 muxes
20 inputs
16 outputs
16 product terms
per output
2-input XOR gates
• Like an OR gate, but excludes the case where both inputs
are 1.