Components / Plexers
Priority Encoder in Logisim
Outputs the S-bit binary index (Q) of the highest-numbered active input line (D0..D(2^S-1)) along with a Group Signal (GS) flag.
| Library | Plexers |
|---|---|
| Type name | Priority Encoder |
| Pins and defaults | in0..in(2^S-1) D0..Dn (-40, y), out0 Q (0, 0), any GS (0, 10), selectBits 2 (1..4) |
How the Priority Encoder Works in Logisim
A Priority Encoder monitors 2^S individual 1-bit request lines (D0 through D(2^S-1), default 4 inputs for selectBits = 2) and outputs the binary index of the highest-numbered input that is currently High (1) on its S-bit output Q.
Because input D(2^S-1) has the highest priority, lower-numbered inputs are ignored whenever a higher-numbered input is 1. When at least one input is 1, the 1-bit Group Signal output (GS, pin id "any") is asserted High (1) and Q outputs the winning binary index; when every input is 0 (or floating), GS is 0 and Q floats (Z).
Tip: Always check the GS (Group Signal) output pin to distinguish between input D0 being active (Q = 0, GS = 1) and no inputs being active (Q = Z, GS = 0).
Priority Encoder Pins & Pinout
| Pin | Direction | Width | Location & Role |
|---|---|---|---|
| in0 .. in(2^S-1) (D0..Dn) | Input (Left edge) | 1 bit each | Located at x = -40 from top (D0, lowest priority) to bottom (D(2^S-1), highest priority). |
| out0 (Q) | Output (Right edge) | 1–4 bits (selectBits) | Located at (0, 0). Binary index of the highest active input, or Z when no input is 1. |
| any (GS) | Output (Right edge, lower) | 1 bit | Located at (0, 10). Group Signal: outputs 1 if any input D_i is 1, or 0 if none are active. |
Priority Encoder Truth Table & Behavior
| D3 (Highest) | D2 | D1 | D0 (Lowest) | Q (2-bit Binary) | GS (any) |
|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | Z (floating) | 0 |
| 0 | 0 | 0 | 1 | 00 (0) | 1 |
| 0 | 0 | 1 | X | 01 (1) | 1 |
| 0 | 1 | X | X | 10 (2) | 1 |
| 1 | X | X | X | 11 (3) | 1 |