Priority Encoder
How a priority encoder defines an output when more than one request input is active.
Updated 2026-07-09
A basic encoder assumes exactly one input is active. A priority encoder removes that ambiguity by defining which active input wins when several requests arrive together.
One common convention is highest-index wins. For a four-input encoder, test req[3] first, then req[2], req[1], and req[0] in an if / else if chain. The first true condition sets the output code, so a high req[3] takes priority over every lower request.
A separate valid output makes the no-request case clear: it stays low when every request input is 0, even though the code output still has a default value.