4-to-2 Encoder Circuit Diagram

4 To 2 Encoder Circuit Diagram — circuit diagram showing component connections+12V/24V SupplySensorPull-up RARDUINOUNOMCU / ReaderIndicatorSensor Circuit
4-to-2 Encoder Circuit Diagram — interactive diagram. Open it in the editor to customise components and wiring.

This is a free printable 4 to 2 encoder circuit diagram: download the diagram as SVG or open it and print to paper or PDF.

A 4-to-2 encoder converts four mutually exclusive active-high inputs into a 2-bit binary output code, implemented with two OR gates and used in digital systems to compress data lines.

A 4-to-2 encoder is a combinational logic circuit that accepts four input lines (I0–I3) and produces two output lines (A1, A0) representing the binary code of whichever single input is asserted. The fundamental assumption is that exactly one input is active at any given time — this is the basic encoder constraint.

The truth table for a basic 4-to-2 encoder is straightforward: when I0 is high, outputs are A1=0, A0=0 (binary 00); when I1 is high, outputs are A1=0, A0=1 (binary 01); when I2 is high, outputs are A1=1, A0=0 (binary 10); when I3 is high, outputs are A1=1, A0=1 (binary 11). The Boolean expressions reduce to: A1 = I2 + I3, and A0 = I1 + I3. Each output is realised with a single 2-input OR gate, so the entire circuit requires just two OR gates.

A critical limitation of the basic encoder is that it cannot handle ambiguous states — if two inputs are simultaneously active, the output is the OR of both codes, producing an incorrect and misleading result. This limitation led to the development of the priority encoder. In an 8-to-3 or 4-to-2 priority encoder (such as the 74HC148 or 74LS148 for 8-to-3), a defined hierarchy resolves conflicts: the highest-priority active input determines the output, and a GS (Group Select) output signals that at least one input is valid. For the 4-to-2 priority variant, I3 has highest priority (overrides all), followed by I2, I1, and I0.

Practical applications include keyboard encoding, interrupt priority controllers in microprocessors, and multiplexer address generation. Encoders are also cascadable — enable (EI/EO) pins on priority encoder ICs allow multiple devices to be daisy-chained to handle larger input counts. TTL and CMOS families both offer encoder ICs; CMOS operates across a wider voltage range (2V–6V for HC series) and draws far less quiescent current than TTL.

How to wire 4 to 2 encoder circuit diagram

  1. Identify your input and output requirements Confirm you have exactly four mutually exclusive input signals (I0–I3) and require a 2-bit binary output (A1, A0). Determine whether basic or priority encoding is needed based on whether simultaneous inputs are possible.
  2. Write the truth table List all four valid input states in columns I3, I2, I1, I0 and their corresponding outputs A1, A0. Verify the pattern: I0→00, I1→01, I2→10, I3→11.
  3. Derive Boolean expressions using the truth table Inspect which inputs cause each output to be high. A1 is high for I2 and I3, so A1 = I2 + I3. A0 is high for I1 and I3, so A0 = I1 + I3.
  4. Select and connect OR gates Use two 2-input OR gates. Connect I2 and I3 to the inputs of the first gate to produce A1. Connect I1 and I3 to the inputs of the second gate to produce A0. Unused gate inputs should be tied to logic low.
  5. Add supply decoupling Place a 100nF ceramic capacitor between VCC and GND as close as possible to each IC power pin to suppress switching noise and prevent false triggering.
  6. Verify operation with a truth table test Apply each of the four valid input combinations one at a time (using switches or a function generator) and confirm the output LEDs or logic probe shows the correct binary code for each.
  7. Consider invalid input handling If two inputs may be simultaneously active in your system, replace the basic encoder with a priority encoder IC or add priority logic to prevent ambiguous output codes.

Specifications

Number of inputs4 (I0, I1, I2, I3)
Number of outputs2 (A1 MSB, A0 LSB)
Logic gates required (basic)2 × 2-input OR gates
Supply voltage (CMOS HC series)2V – 6V
Supply voltage (TTL LS series)4.75V – 5.25V
Propagation delay (HC series, typical at 5V)~7 ns
Boolean expression A1I2 + I3
Boolean expression A0I1 + I3

Safety warnings

Tools needed

Common mistakes

Troubleshooting

Output remains at 00 regardless of which input is activated
Cause: OR gate inputs are not receiving the asserted signal — likely an open connection between the input switch and the gate, or the pull-down resistors are holding the signal low even when the switch is closed Fix: Use a logic probe to measure the gate input pins directly. Verify the switch wiring routes through to the correct gate input pin, and confirm pull-down resistors are connected from the input node to GND, not between the switch and the gate.
Both output bits appear always high (11)
Cause: Inputs are floating or connected directly to VCC, causing all OR gates to continuously output high Fix: Add 10kΩ pull-down resistors from each input line to GND. Re-test with a single switch active at a time.
Output code is incorrect (e.g., I2 active gives 01 instead of 10)
Cause: Gate connections are swapped — A1 and A0 gate inputs have been wired to the wrong input lines Fix: Cross-reference the wiring against the Boolean expressions: A1 gate inputs must be I2 and I3; A0 gate inputs must be I1 and I3. Rewire accordingly.
IC becomes hot and draws excess current
Cause: CMOS inputs are floating or operating in the linear region, or supply voltage exceeds the rated maximum for the logic family Fix: Immediately remove power. Tie all unused inputs to VCC or GND. Verify supply voltage is within the IC's absolute maximum rating before reapplying power.

Frequently asked questions

What is the difference between a basic encoder and a priority encoder?

A basic 4-to-2 encoder assumes only one input is ever active at a time and produces incorrect output if multiple inputs are asserted simultaneously. A priority encoder resolves conflicts by assigning a hierarchy to inputs, always encoding the highest-priority active input and ignoring lower-priority ones.

How many logic gates does a 4-to-2 encoder require?

The minimal implementation uses just two 2-input OR gates. Output A1 is driven by I2 OR I3, and output A0 is driven by I1 OR I3. No additional gates are needed for the basic (non-priority) version, making it extremely compact.

What is the Boolean expression for each output of a 4-to-2 encoder?

A1 (the most significant output bit) equals I2 OR I3. A0 (the least significant output bit) equals I1 OR I3. These expressions are derived directly from the truth table by identifying which input conditions cause each output to be logic high.

Can a 4-to-2 encoder be built from NAND gates only?

Yes. Any OR function can be realised using NAND gates via De Morgan's theorem: A OR B equals NAND(NOT A, NOT B), which simplifies to NAND(NAND(A,A), NAND(B,B)). This approach uses more gates but is useful when only NAND gates are available in a given logic family.

What does the enable output (EO) do on a priority encoder IC?

The Enable Output (EO) goes active when the Enable Input (EI) is active and all encoded inputs are inactive. It allows cascading multiple encoder ICs: the EO of a higher-priority device connects to the EI of a lower-priority device, extending the input count without additional logic.

Related diagrams

Free electrical calculators

Edit this diagram free in the online editor