3.3.7 · D5Combinational Circuits

Question bank — Encoders and priority encoders

1,498 words7 min readBack to topic

True or false — justify

Every valid line of a plain -to- encoder's truth table is "one-hot" (exactly one input HIGH).
True. The plain encoder is only defined for exactly-one-active inputs; all other rows (zero or many HIGH) are outside its promise, which is precisely why it misbehaves there.
A plain encoder and a plain decoder are exact inverses on all input combinations.
False. They are inverses only on the legal domain (one-hot in, single number out). A decoder always produces one-hot, but an encoder fed a non-one-hot pattern has no meaningful inverse — that's the whole flaw.
For the 4-to-2 plain encoder, needs no AND gate.
True. Because only one input is ever HIGH by assumption, no input can "cancel" another, so a bare OR of the bit-1 indices suffices — no suppression logic is needed.
The priority-encoder equation is identical to the plain encoder's, so priority adds nothing to bit 1.
False verdict on "nothing" — it's identical for this bit only because both indices 2 and 3 have bit-1 set, so dominating never changes . Bit 0 is where priority actually does work (the term).
If you swap the priority order to (lowest wins), the equations stay the same.
False. Lowest-priority-wins requires suppressing higher indices, so the bar-terms move: e.g. would need -style suppression. Priority direction changes which inputs get masked.
A valid bit is only useful for the all-zero case.
False. is the only thing distinguishing "no input" ( with ) from " active" ( with ). It resolves the fundamental ambiguity of index 0, not merely the empty case — those are the same event described two ways.
can be simplified using 's don't-care rows.
False. must go HIGH for any active input including , so every input appears in the OR; there is nothing to remove without breaking the "at least one active" meaning.
For a plain 4-to-2 encoder, feeding alone gives output , which is correct.
True. Index 0 in binary is , so is the right answer — the problem is only that also appears when nothing is pressed, not that 's code is wrong.

Spot the error

" for the priority encoder, same as the plain one."
Wrong. Priority requires . The bare would let index 1 leak into even when the higher is active, giving output instead of 's .
"With and into a plain encoder we get output , which is a rounding of the average of 1 and 2."
Wrong reasoning. is an accident of OR-ing bits ( from , from ), not any average. The number is meaningless garbage, and no arithmetic interpretation is intended.
"Priority encoders need AND gates only because they have more inputs."
Wrong. The AND/NOT terms come from suppression (masking lower inputs when a higher one is active), not from input count. Even a 4-input priority encoder needs the term; a plain 4-input encoder needs none.
"A priority encoder's means the output bits are ."
Wrong. When the output bits are don't-care / undefined — they may be anything and must be ignored. is a "don't trust the number" flag, not a guarantee of .
"For into the priority encoder, output is because wins."
Wrong — wins (highest index). , , giving . Priority is highest-index, and .
" means whenever , input is definitely active."
Wrong. could come from alone. An output bit being 1 tells you the index has that bit set, not which specific input is on — that's exactly why individual outputs aren't reversible without priority.

Why questions

Why does OR-ing (not AND-ing) the indices give the encoder equations?
Because under the one-hot assumption exactly one input is 1; "is bit set for the active index?" becomes "is any index with bit set currently active?", which is an OR.
Why does the plain encoder produce a wrong number for two simultaneous inputs rather than just picking one?
Each output bit independently ORs its own indices, so bits from two different indices merge into a code belonging to neither — there is no shared logic forcing a single consistent index.
Why is the highest index (not lowest) the conventional priority winner?
It's a design convention that maps naturally to "most significant / most urgent" numbering; the math works either way, but you must then choose which inputs to suppress accordingly.
Why does need the term but does not?
When is active it must produce code — bit 0 must be forced off even if is also on. Bit 1 is already 1 for both indices 2 and 3, so nothing needs masking there.
Why can't we just tell "nothing pressed" from the number itself?
Because index 0 legitimately encodes to , and "empty" also produces from all-zero OR gates. The number line has no spare code for "none", so a separate signal is required.
Why is an encoder called the "inverse of a decoder"?
A decoder maps a binary number to one active line (number → position); an encoder maps one active line back to its binary number (position → number). They undo each other on legal inputs.

Edge cases

Plain 4-to-2 encoder, all inputs 0: what is the output and is it trustworthy?
Output , untrustworthy — it collides with " active." Without a bit you cannot tell empty from index 0.
Priority encoder, all inputs 0: what do and read?
; are don't-care and must be ignored. The valid bit is the only reliable signal here.
Priority encoder, all four inputs HIGH simultaneously: what wins?
(highest index): , , , output . Every lower input is masked by the priority logic.
Priority encoder with (but ): output?
wins: , , so . The term kills 's contribution.
Only active in the priority encoder — does the term change anything?
No harm: so , giving , output . The mask only bites when a higher input is present.
Can a -to- encoder ever output every one of its codes?
Yes for a priority encoder (all -bit codes are reachable, index 0 via ). A plain encoder also can, but only legally under strict one-hot input.
What happens to if exactly one input is HIGH?
, since ORs all inputs and at least one is active — confirming the number on is meaningful. for one or more active inputs.


Connections

  • Parent topic — the full derivations these traps probe.
  • Karnaugh maps — where the don't-care rows and suppression terms come from.
  • Boolean algebra simplification — why the OR/mask equations take their minimal form.
  • Interrupt controllers — real hardware where "highest priority wins" is the whole point.
  • Decoders — the inverse device; contrast its one-hot output with the encoder's ambiguity.
  • Combinational circuits — the memoryless family these belong to.