A priority encoder is a circuit or algorithm that compresses multiple binary inputs into a smaller number of outputs. The output of a priority encoder is the binary representation of the index of the most significant activated line, starting from zero. They are often used to control interrupt requests by acting on the highest priority interrupt input.
A 4 to 2 priority encoder has 4 inputs : Y3, Y2, Y1 & Y0 and 2 outputs : A1 & A0. Here, the input, Y3 has the highest priority, whereas the input, Y0 has the lowest priority. In this case, even if more than one input is ‘1’ at the same time, the output will be the (binary) code corresponding to the input, which is having higher priority.
Inputs | Outputs | ||||
---|---|---|---|---|---|
Y3 | Y2 | Y1 | Y0 | A1 | A0 |
0 | 0 | 0 | 0 | x | x |
0 | 0 | 0 | 1 | 0 | 0 |
0 | 0 | 1 | x | 0 | 1 |
0 | 1 | x | x | 1 | 0 |
1 | x | x | x | 1 | 1 |
From the above truth table we can infer that:
- A0 is
assign A0 = Y2(bar).Y1+Y3;
- A1 is
assign A1 = Y2+Y3;
IMAGE SOURCE - GFG
IMAGE SOURCE - Wikipedia