LogisimRevisited

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.

PRID0D1D2D3QGS
Default settings, facing east. Pins are the dots.
LibraryPlexers
Type namePriority Encoder
Pins and defaultsin0..in(2^S-1) D0..Dn (-40, y), out0 Q (0, 0), any GS (0, 10), selectBits 2 (1..4)

Try it in the app

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

PinDirectionWidthLocation & Role
in0 .. in(2^S-1) (D0..Dn)Input (Left edge)1 bit eachLocated 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 bitLocated 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

4-to-2 Priority Encoder truth table (selectBits = 2, X = 0 or 1)
D3 (Highest)D2D1D0 (Lowest)Q (2-bit Binary)GS (any)
0000Z (floating)0
000100 (0)1
001X01 (1)1
01XX10 (2)1
1XXX11 (3)1

Related Circuits & Components