What is Priority Encoder : Working & Its Applications

In Digital Electronics, the binary encoders are the multi-input combinational logic circuits, which consider all the input lines simultaneously and then convert them into an equivalent single encoded output. An n-bit digital encoder contains 2^n input lines and n output lines. To overcome the disadvantages of binary encoders, priority encoders were developed that work based on the highest priority input. This article gives a brief description of a priority encoder along with its applications.


What is Priority Encoder?

The priority encoder is a combinational logic circuit that contains 2^n input lines and n output lines and represents the highest priority input among all the input lines. When multiple input lines are active high at the same time, then the input that has the highest priority is considered first to generate the output.

It is used to solve the issues in binary encoders, which generate wrong output when more than one input line is active high. If more than one input line is active high(1) at the same time, then this encoder prioritizes every input level and allocates the priority level to each input.

The output of this encoder corresponds to the input that has the highest priority. To obtain the output, only the input with the highest priority is considered by ignoring all other input lines. This is a type of binary encoder or an ordinary encoder with a priority function. The input that has the larger magnitude or highest priority is encoded first rather than other input lines. Hence, the generated output is based on the priority assigned to the inputs.

In most digital applications, these encoders are used to select the inputs, which have the highest priority level. This process of selecting the input is called arbitration. For example, when multiple devices transmit the data over the computer systems, then this encoder enables the device that has the highest priority and allows access to the computer among all other devices, which have lower priority.

These encoders are designed with 4 inputs and 8-inputs. The 4-bit priority encoder contains 4 inputs and 2 outputs along with one valid output. The 8-bit priority encoder contains 8 inputs and 3 outputs. Priority encoder circuit with truth table for 8-bit and 4-bit are explained in the below section.

8 to 3 Priority Encoder

This kind of encoder is also named an 8-bit or Octal to Binary priority encoder. This type of encoder consists of 8 inputs and 3 outputs. When multiple inputs are active high at the same time, the input with the highest priority is considered to represent the output.

For example, if D1, D2, and D3 inputs are active high or logic 1 regardless of other input bits, then the encoded output of the priority encoder will be D3 i.,e 111. Here, the D1, and D2 input bits are either irrelevant or don’t care conditions.

The 8 to 3 priority encoder truth table is shown below.

D7

D6 D5 D4 D3 D2 D1 D0 A B

C

0

0 0 0 0 0 0 1 0 0 0

0

0 0 0 0 0 1 X 0 0 1
0 0 0 0 0 1 X X 0 1

0

0 0 0 0 1 X X X 0 1

1

0

0 0 1 X X X X 1 0 0
0 0 1 X X X X X 1 0

1

0

1 X X X X X X 1 1 0
1 X X X X X X X 1 1

1

From the above truth table, we can observe that D0, D1, D2, D3, D4, D5, D6, D7 are the inputs, and A, B, C are the outputs of an 8 to 3 priority encoder.


8 to 3 Priority Encoder Circuit Diagram
8 to 3 Priority Encoder Circuit Diagram

The output ‘A’ of a priority encoder is represented as active high or logic ‘1’ only when the inputs D4, D5, D6, and D7 are active high. The output ‘B’ of an encoder is at logic 1 only when the inputs D2, D3, D6, and D7 are active high. Similarly, the output ‘C’ is represented as logic ‘1’ only when the inputs D1, D3, D5, and D7 are active high.

The output expressions for A, B, and C are written either from Karnaugh map (K-map) simplification Or truth table.

The output expression are obtained as shown below,

A = D4+D5+D6+D7

B = D2+D3+D6+D7

C = D1+D3+D5+D7

From these simplified expressions, the 8 to 3 priority encoder circuit diagram is drawn as illustrated with logic gates as shown in the figure below.

8 to 3 types are available in the standard IC 74LS148, which consists of 8 active low or logic 0 inputs and 3 active high or logic 1 output bits. The different properties of this type of encoder include cascading of n bits for priority encoding, encoding of highest priority inputs, code conversions, decimal to BCD conversion, to enable output line with active low when all the input lines are active high.

4 to 2 Priority Encoder

This is also referred to as 4- bit priority, which consists of 4 inputs and 2 output lines. Since an encoder contains 2^n input lines and n output lines. The third output is ‘V’, which is considered as a valid but indicator and it is set to 1 when more than one input line is high or active (1).

If the valid bit is equal to ‘0’, then all the inputs are ‘0’. In this case, the other 2 output lines are considered as don’t care conditions denoted by ‘X

The truth table of a 4 to 2 priority encoder is shown below.

D3 D2 D1 D0 A B

V

0

0 0 0 X X 0

1

0 0 0 0 0 1

X

1 0 0 0 1

1

X X 1 0 1 0

1

X X X 1 1 1

1

From the above truth table, we can observe that D3, D2, D1, D0 are the inputs; A and B are the outputs and V is the valid bit indicator. Here D3 input is the highest priority input and D0 is the lowest priority input.

When the input D3 is active high (1), which has the highest priority irrespective of all other input lines, then the output of the 4-bit priority encoder is 11.

When the D3 input is active low and the D2 is active high that has the next highest priority irrespective of all other input lines, then the output is BA=10.

When D3, D2 inputs are active low, and the D1 is active high and has the next highest priority regardless of the remaining input line, then the output will be BA = 01

The output expression can be determined for a 4-bit encoder with the help of a karnaugh map (K-map) as shown below.

4 to 2 Priority Encoder K-map
4 to 2 Priority Encoder K-map

A = D3 + D1D2′
B= D2 + D3
V = D0 + D1 + D2 + D3

From the above K-map, the simplified expressions for the outputs A and B are obtained. From these output expressions, the 4 to 2 priority encoder circuit diagram is illustrated with logic gates as shown below.

4 to 2 Priority Encoder Circuit Diagram
4 to 2 Priority Encoder Circuit Diagram

The circuit diagram of 4 to 2 priority encoder is drawn with 2 OR gates, and the combination of AND gate and the NOT gate represent the valid bit, which is used when more than one input is logic high (1). Thus, four inputs with two outputs are encoded based on the assigned priority to the inputs. 

Verilog Code

The output of the encoder is inaccurate when more than one input line is assigned with logic 1. It works only when one of the inputs is high (1). So, the encoder doesn’t work for multiple high input lines. To overcome this drawback, the level of each input is prioritized. Hence in the case of multiple input lines, the output of the encoder corresponds to the input, which is designated with the highest priority. This is called a priority encoder.

In structural style, the priority encoder Verilog code is written as shown below.

module or_gate (C, A, B);
input A, B;
output C;
assign C= A|B;
endmodule;
module not_gate (F, E);
input E;
output F;
assign F=-E;
endmodule;
module and_gate(Z, X, Y) ;
input X, Y;
output Z;
assign Z= X&Y;
endmodule;
module priority_encoder_struct(A0, A1, Y0, Y1, Y2, Y3);
input Y0, Y1, Y2, Y3;
output A0, A1;
not_gate U1(.F(Y2bar), . e(Y2) ) ;
and_gate U2(.Z(W1) ,. X(Y2bar), . Y(Y1)) ;
or_gate (.C(A1), . A(Y3), . B(Y2)) ;
or_gate(.C(A0),. A(Y1),. B(W1)) ;
endmodule;

Difference Between Encoder and Priority Encoder

The main difference between encoder and priority encoder is- the encoder generates an error output when more than one input is high. But they are used in applications compressing data. Hence, priority encoders are introduced to overcome the issues of binary encoders.

The priority encoder generates the accurate output by considering the highest priority input among the multiple input lines. These can handle the interrupt requests of a microprocessor by detecting the highest priority interrupt.

If a circuit contains multiple inputs, then it is used to reduce the number of wires required during designing. 

Applications

Some of the applications of priority encoder are,

  • It is used to reduce the no. of wires and connections required for electronic circuit designing that have multiple input lines. Example keypads and keyboards.
  • Used in controlling the position in the ship’s navigation and robotics arm position.
  • Used in the detection of highest priority input in various applications of microprocessor interrupt controllers.
  • Used to protect the entire network from hackers by transmitting the binary code over the network.
  • Used to encode the analog to digital converter’s output.
  • Used in synchronization of the speed of motors in industries.
  • Used robotic vehicles
  • Used in applications of home automation systems with RF
  • Used in hospitals for health monitoring systems
  • Used in secure communication systems with RF technology to enable secret code.

Thus, this is all about an overview of Priority Encoder definition, 4 to 2 & 4 to 3 priority encoder circuit diagram, 8 to 3 priority encoder circuit diagram, Verilog code, and applications. Here is a question for you, “What are the differences between Encoders and Multiplexers?”

Add Comment