The Priority Encoder will give an output which is the binary representation of the input number. If more than one input is selected, priority will be given to the lowest input. For example, if inputs P6 and P8 are high, the output will be the binary representation of 6 i.e. 0000 0110. Up to 23 inputs are available on a single encoder. If more are required they may be cascaded, see below. It also has a "Data Valid" output which is ON if any input is selected. If no input is selected then the output will be a binary representation of the highest input number (22 for a 23 input encoder) and the "Data Valid" output will be OFF.
If more than 23 priority inputs are required it is possible to cascade priority encoder objects. The output format of the last encoder is the same as for a single encoder, and will output up to the total number of priority inputs. There is no need to fill the first encoder with 23 inputs before cascading.
The cascaded sequence will still output a contiguous binary value for each of the inputs regardless of how many inputs each encoder uses. If the first encoder has no input set, it clears the Data Valid output and sets the highest possible number it can output on its output binary bus. Further cascaded encoders can detect this condition on their "Data Valid" inputs and simply add their inputs to this value. If no inputs are set on any of the cascaded encoders, the final output will have the highest possible value of all the inputs but the Data Valid not set. If the "Data Valid" output is set for any encoder then the following encoder will pass the binary value through unchanged - this way priority is always given to the to the lowest output number. Therefore, the final output will have either the binary equivalent of the first priority input and the Data Valid output set, or, the highest possible value of all the inputs but the Data Valid not set.
In the example below, there are 8 inputs on each encoder:
Range
Encoder L2: 0 to 7
Encoder L10: 8 to 15
If no input is active on the first device, the Data Valid output is clear and the binary is set to the highest value that encoder could produce. In this example the first encoder will output the value 7; the second encoder will output the value 15 if it too has no inputs active. If an input is active on the third object, it can detect that no Data Valid input is present and ADD its input value to the binary input. It then sets its Data Valid output to indicate that the binary value is valid.]
Outputs shown
Encoder 1: 7, (max possible for this encoder), data invalid
Encoder 2: 15, (max possible of first 2 encoders), data invalid
Encoder 3: 16, (input number 16 is first set input), data valid
Priority Inputs: This sets the number of priority inputs to be converted to binary. This may be set from 1 to 23. Only the lowest numbered input is converted, so P0 has the highest priority.