← All exercises

Priority Encoder

medium

Encodes eight BOOL inputs into the index of the highest-priority active input.

What it teaches

When several fault or request lines are active together, report the highest-numbered one as a compact index from 0 to 7. Sts_Active distinguishes active In_0 from no request. Unlike Bit Pack, one winning input is reported instead of preserving every active bit.

Inputs and outputs

TagTypeDefaultDescription
In_0BOOL
In_1BOOL
In_2BOOL
In_3BOOL
In_4BOOL
In_5BOOL
In_6BOOL
In_7BOOL
Out_IndexDINTNumber of the highest active input
Sts_ActiveBOOL1 while at least one input is active

Required behavior