Encoders

Binary encoding circuits - convert one-hot or priority inputs into compact binary codes.

An encoder converts a set of inputs into a compact binary code. In a simple encoder, exactly one input is active at a time, and the output is the binary representation of that input's position. Priority encoders handle the case where multiple inputs may be active simultaneously by encoding the highest-priority input.

Objectives

  • Design simple 4-to-2 and 8-to-3 encoders from truth tables
  • Understand the problem with simple encoders when multiple inputs are active
  • Design and use priority encoders
  • Identify the 74HC148 (8-to-3 priority encoder) and its cascading features

Key Takeaways

  • Encoders convert one-hot (or priority) inputs to compact binary codes
  • Simple encoders only work when exactly one input is active
  • Priority encoders handle multiple active inputs by encoding the highest-priority one
  • Valid/group-select flag indicates whether any input is active
  • 74HC148 is the standard 8-to-3 priority encoder with cascading capability
  • Encoders are the functional complement of decoders

Applications

  • Keyboard Encoding: Converting key presses to scan codes.
  • Interrupt Priority: Encoding the highest-priority interrupt request for the CPU.
  • Position Encoding: Converting switch positions or sensor outputs to binary.
  • Data Compression: Reducing the number of lines needed to represent data.

Practice Problems

Problem 1: Write the output expressions for a 4-to-2 simple encoder.

Problem 2: An 8-to-3 priority encoder has inputs D7=0, D6=1, D5=1, D4=0, D3=1, D2=0, D1=0, D0=1. What is the output?

Problem 3: Why does a simple encoder fail when D2 and D5 are both active?

Problem 4: How many 74HC148 (8-to-3 priority encoder) ICs are needed for a 32-input priority encoder?