ArticleslgStudy

engineering

Priority encoder

Priority encoder is a engineering topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Priority encoder rather than just read about it. In short: A priority encoder is a circuit or algorithm that compresses multiple binary inputs into a smaller number of outputs, similar to a simple encoder. The output of a priority encoder is the binary representation of the index of the most significant activated line.

Priority encoder — main illustration
Priority encoder — illustration

Key takeaways

  • Priority encoder belongs to engineering; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Priority encoder to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Priority encoder from memory before moving on to harder problems.

Reference excerpt

A priority encoder is a circuit or algorithm that compresses multiple binary inputs into a smaller number of outputs, similar to a simple encoder. The output of a priority encoder is the binary representation of the index of the most significant activated line. In contrast to the simple encoder, if two or more inputs to the priority encoder are active at the same time, the input having the highest priority will take precedence. It is an improvement on a simple encoder because it can handle all possible input combinations, but at the cost of extra logic. Applications of priority encoders include their use in interrupt controllers (to allow some interrupt requests to have higher priority than others), decimal or binary encoding, and analog-to-digital / digital to-analog conversion.

Implementation A truth table of a single bit 4-to-2 priority encoder is shown, where the inputs are shown in decreasing order of priority left-to-right, and "x" indicates a don't care term - i.e. any input value there yields the same output since it is superseded by a higher-priority input. The (usually-included) "v" output indicates if the input is valid.

Priority encoders can be easily connected in arrays to make larger encoders, such as one 16-to-4 encoder made from six 4-to-2 priority encoders – four 4-to-2 encoders having the signal source connected to their inputs, and the two remaining encoders take the output of the first four as input.

Recursive construction of priority encoders Sources: A priority-encoder, also called leading zero detector (LZD) or leading zero counter (LZC), receives an n {\displaystyle n} -bit input vector and detects the index of the first binary ‘1’ in the input vector. A valid signal indicates if any binary ‘1’ was detected in the input vector, hence the index is valid. Priority-encoders can be efficiently constructed by recursion. The input vector is split into k {\displaystyle k} equal fragments with n / k {\displaystyle n/k} bits. A priority encoder PE n / k {\displaystyle {\textrm {PE}}_{n/k}} with a narrower width of 𝑛/𝑘 is applied for each fragment. The valid bit of each of the k {\displaystyle k} PE n / k {\displaystyle {\textrm {PE}}_{n/k}} ‘s goes to a k {\displaystyle k} bit PE n / k {\displaystyle {\textrm {PE}}_{n/k}} to detect the first valid fragment. The location of this fragment is the higher part of the overall index, and steers the exact location within the fragment itself to produce the lower part of the overall index. The depth of the proposed structure is ⌈ log k ⁡ n ⌉ {\displaystyle \lceil \log _{k}n\rceil } , while the hardware area complexity is O ( n ) {\displaystyle {\mathcal {O}}(n)} . If Altera's Stratix V or equivalent device is used, k = 4 {\displaystyle k=4} is recommended to achieve higher performance and area compression, since the mux can be implemented using 6-LUT, hence an entire ALM. An open-source Verilog generator for the recursive priority-encoder is available online.

A behavioral description of priority encoder in Verilog is as follows. In this case, the LSB has the highest priority.

Simple encoder

A simple encoder circuit is a one-hot to binary converter. That is, if there are 2n input lines, and at most only one of them will ever be high, the binary code of this 'hot' line is produced on the n-bit output lines.

Notes

References

Illustrations

Priority encoder: Priority-encoder (left) symbol (right) recursive definition.
Priority-encoder (left) symbol (right) recursive definition.
Priority encoder: A simple 4:2 Encoder using OR gate.
A simple 4:2 Encoder using OR gate.

Worked examples

Example 1 — a first encounter with Priority encoder

Start with the simplest possible case. Write down what Priority encoder claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In engineering, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Priority encoder before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Priority encoder ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Priority encoder

In research
Priority encoder appears in engineering research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Priority encoder in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Priority encoder is common in secondary-school and first-year university syllabi. It links to neighbouring topics Digital circuits, so understanding it makes those chapters shorter.
In everyday life
Look for Priority encoder outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Priority encoder in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Priority encoder means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Priority encoder out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Priority encoder in simple terms?

A priority encoder is a circuit or algorithm that compresses multiple binary inputs into a smaller number of outputs, similar to a simple encoder. The output of a priority encoder is the binary representation of the index of the most significant activated line.

Why does Priority encoder matter?

Because it connects several engineering ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Priority encoder?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Priority encoder.

Tags

  • Digital circuits

Keep exploring