ENCODER Digital Logic Simulator

Priority Encoder Simulator

Simulate 4-to-2 and 8-to-3 priority encoders online. Toggle multiple digital inputs, choose highest-input or lowest-input priority, and calculate the encoded binary output, decimal input index and valid signal.

✓ 4-to-2 Encoder ✓ 8-to-3 Encoder ✓ Priority Resolution ✓ Valid Output ✓ Binary Code ✓ Truth Table
PRI
Priority Encoder Simulation
● Ready
Digital Inputs
Encoder Configuration
Priority rule: If several inputs are high simultaneously, only the input with the configured priority is encoded. With the standard highest-priority mode, I3 overrides I2, I1 and I0 in a 4-to-2 encoder, while I7 has the highest priority in an 8-to-3 encoder.
Priority Encoder Result Valid Input
Encoded Output
Encoder
Priority
Winning Input
Encoded Binary
Decimal Index
Valid V
Active Inputs
Ignored Inputs
4:2
PRIORITY
ENCODER
CODE = —
VALID = —
Priority Resolution
Encoding Analysis

Priority Encoder Simulator

The Priority Encoder Simulator models digital priority encoders that convert one active input line into a shorter binary code. Unlike an ordinary encoder, a priority encoder can handle multiple active inputs by assigning one input higher priority than another.

This simulator supports both the common 4-to-2 priority encoder and an 8-to-3 priority encoder. You can activate several inputs simultaneously and see which input wins according to the configured priority direction.

The simulator also provides a valid output V. The valid signal indicates whether at least one encoder input is active, which removes the ambiguity between a genuine encoded zero and the state where no input is present.

How to Use the Priority Encoder Simulator

Choose either a 4-to-2 or 8-to-3 priority encoder. Click the individual input buttons to toggle them between 0 and 1, choose the priority direction and then press Simulate Priority Encoder.

4-to-2 encoder Inputs: I3 = 0 I2 = 1 I1 = 1 I0 = 0 Priority: Highest index I2 overrides I1. Winning input: I2 Encoded output: 10 Valid: 1

What Is a Priority Encoder?

A priority encoder is a combinational digital circuit that detects the highest-priority active input and outputs a binary number identifying that input.

For example, a four-input priority encoder needs only two output bits because two binary bits can represent four input indices from zero through three.

Input index → binary code I0 → 00 I1 → 01 I2 → 10 I3 → 11

4-to-2 Priority Encoder

A 4-to-2 priority encoder contains four data inputs and two encoded output bits. In the common highest-index-priority convention, I3 has the highest priority and I0 the lowest.

Priority order: I3 ↓ I2 ↓ I1 ↓ I0

If I3 and I1 are both active, the output represents I3 because the higher-priority input suppresses the lower one.

4-to-2 Priority Encoder Truth Table

X represents a don’t-care input because once a higher-priority input is active, lower-priority inputs no longer affect the encoded result.

I3 I2 I1 I0 Y1 Y0 V Winning Input
1XXX 111I3
01XX 101I2
001X 011I1
0001 001I0
0000 000None

Why Does a Priority Encoder Need Priority?

An ordinary encoder assumes that only one input is active at a time. If several ordinary encoder inputs become active simultaneously, the result may be ambiguous or invalid.

A priority encoder removes this ambiguity by defining which input wins. Therefore multiple high inputs still produce one deterministic encoded output.

Inputs: I3 = 0 I2 = 1 I1 = 1 I0 = 1 Highest-priority mode: Winner: I2 Output: 10

Valid Output in a Priority Encoder

A valid output is commonly included because encoded zero can otherwise mean two different things.

Case 1: I0 = 1 All others = 0 Encoded output: 00 V = 1 Case 2: All inputs = 0 Encoded output: 00 V = 0

The valid bit distinguishes those two situations.

4-to-2 Encoder Example: I3 Active

I3 = 1 I2 = 1 I1 = 0 I0 = 1 Highest-priority input: I3 Lower active inputs: I2, I0 Ignored because I3 wins. Output: 11 Decimal index: 3 Valid: 1

4-to-2 Encoder Example: I2 Active

I3 = 0 I2 = 1 I1 = 1 I0 = 1 Highest active input: I2 Output: 10 Valid: 1

I1 and I0 are don’t-care conditions once I2 is active and I3 is zero.

8-to-3 Priority Encoder

An 8-to-3 priority encoder accepts eight input lines and produces a three-bit output. Three output bits are sufficient because they can encode decimal input indices zero through seven.

I0 → 000 I1 → 001 I2 → 010 I3 → 011 I4 → 100 I5 → 101 I6 → 110 I7 → 111

8-to-3 Priority Encoder Example

Inputs: I7 = 0 I6 = 0 I5 = 1 I4 = 0 I3 = 1 I2 = 0 I1 = 1 I0 = 0 Highest-priority mode: Winner: I5 Encoded output: 101 Decimal: 5 Valid: 1

Highest-Priority vs Lowest-Priority Encoding

Most priority encoder examples assign the highest numbered input the greatest priority. This simulator also includes lowest-index priority so you can study the opposite convention.

Active inputs: I3, I1 Highest-index priority: I3 wins Output = 11 Lowest-index priority: I1 wins Output = 01

The encoded number always represents the winning input; only the rule used to choose that winner changes.

Priority Encoder vs Ordinary Encoder

Feature Ordinary Encoder Priority Encoder
Multiple active inputs Usually invalid or ambiguous Resolved by priority
Encoded output Active input index Highest-priority active input
Priority logic No Yes
Valid signal Optional Common

Priority Encoder vs Decoder

An encoder performs the opposite conceptual transformation of a decoder. An encoder converts one of many input lines into a compact binary code, while a decoder expands a compact binary code into one of many output lines.

Encoder: 8 input lines ↓ 3-bit code Decoder: 3-bit code ↓ 8 output lines

Priority Encoder Boolean Logic

For a standard active-high 4-to-2 priority encoder where I3 has the highest priority, the winning conditions can be written as:

I3 wins when: I3 = 1 I2 wins when: NOT I3 AND I2 I1 wins when: NOT I3 AND NOT I2 AND I1 I0 wins when: NOT I3 AND NOT I2 AND NOT I1 AND I0

These conditions show how each higher-priority input suppresses every lower-priority input.

Encoded Output of a 4-to-2 Priority Encoder

Once the winning input has been identified, the encoder outputs its binary index.

Winner I0: index 0 binary 00 Winner I1: index 1 binary 01 Winner I2: index 2 binary 10 Winner I3: index 3 binary 11

What Happens When No Input Is Active?

If every input is zero, there is no valid input to encode. The encoded bits are normally shown as zero by this simulator, while the valid signal V becomes zero.

I3 I2 I1 I0 0 0 0 0 Code: 00 Valid: 0 Meaning: No active input

Always inspect the valid output instead of assuming code 00 means I0.

Why Input Index Is Converted to Binary

An encoder reduces the number of signal lines by representing the active input number as a binary value.

4 possible inputs: requires log2(4) = 2 output bits 8 possible inputs: requires log2(8) = 3 output bits 16 possible inputs: requires log2(16) = 4 output bits

This makes encoders useful whenever many mutually related signals need to be represented efficiently.

Priority Encoders in Interrupt Systems

One common conceptual use of priority encoding is interrupt handling. Several devices may request processor attention simultaneously, but the system may need to service the most important request first.

Requests: IRQ7 = 0 IRQ6 = 1 IRQ5 = 1 IRQ4 = 0 If higher index means higher priority: IRQ6 wins. Encoded interrupt number: 110

Real interrupt controllers may include additional masking, nesting and control logic, but priority encoding captures the central selection idea.

Priority Encoders in Digital Systems

Priority encoders appear in interrupt controllers, arbitration circuits, keyboard encoding, request handling, event selection and digital control systems.

Whenever several signals can become active at the same time but only one must be represented or serviced, priority encoding provides a deterministic selection rule.

Priority Encoder in Keyboard Encoding

An encoder can convert one of several key lines into a smaller binary code. Priority logic becomes useful when multiple key signals occur simultaneously and the circuit must decide which key receives precedence.

8 possible input keys ↓ 8-to-3 encoder ↓ 3-bit key number

Priority Encoder and Arbitration

Arbitration circuits decide which request gains access to a shared resource. A fixed-priority encoder can select the highest-ranked active request.

Requests: R3 = 1 R2 = 0 R1 = 1 R0 = 1 Fixed highest priority: R3 wins.

More advanced arbiters may rotate priority for fairness, but a fixed priority encoder is a basic building block.

Active-High Priority Encoder

This simulator uses active-high logic. An input value of 1 means that the corresponding request is active.

Active-high: 1 = active 0 = inactive

Some physical encoder ICs use active-low inputs or outputs. Their truth tables look inverted and should not be confused with the active-high model used here.

Active-High vs Active-Low Priority Encoders

Logic Type Active State Inactive State
Active High 1 0
Active Low 0 1

Always check the logic convention when comparing a simulator with a particular hardware data sheet.

Common Priority Encoder Mistakes

A common mistake is treating a priority encoder like an ordinary encoder and assuming only one input may be active. Multiple active inputs are specifically what priority logic is designed to resolve.

Another mistake is reading the encoded output without checking the valid bit. Code 00 can represent I0 when I0 is active, but it can also appear when no input is active if V is zero.

It is also important to know which direction has priority. In the standard configuration used by default here, the highest numbered active input wins.

Priority Encoder Simulator Limitations and Notes

This simulator models ideal active-high combinational logic. It supports 4-to-2 and 8-to-3 priority encoders with either highest-index or lowest-index fixed priority.

The simulator does not model propagation delay, active-low IC behavior, tri-state outputs, enable pins, cascading signals or hardware-specific electrical characteristics.

If multiple inputs are active, exactly one winning input is selected according to the configured priority rule.

Priority Encoder Simulator FAQs

What is a priority encoder?
A priority encoder converts the highest-priority active input into a binary code.
What is a 4-to-2 priority encoder?
It has four input lines and produces a two-bit binary code identifying the winning active input.
What is an 8-to-3 priority encoder?
It has eight input lines and produces a three-bit binary code from 000 through 111.
Why is it called a priority encoder?
When several inputs are active simultaneously, a priority rule decides which one controls the output.
Which input has highest priority in a 4-to-2 encoder?
In the default convention used here, I3 has the highest priority, followed by I2, I1 and I0.
What is the output when I2 is the winning input?
The binary output is 10 because decimal input index 2 equals binary 10.
What is the output when I3 wins?
The 4-to-2 encoded output is 11.
What is the output when I7 wins?
An 8-to-3 priority encoder outputs 111 for input index 7.
What is the valid signal?
The valid signal V equals 1 when at least one input is active and 0 when all inputs are inactive.
Why can output 00 be ambiguous?
00 can encode I0, but the same code may also be present when no input is active. The valid bit resolves this ambiguity.
Can several inputs be 1 at the same time?
Yes. The priority encoder chooses only the highest-priority active input.
What does X mean in a priority encoder truth table?
X means don’t care. Once a higher-priority input is active, lower inputs do not affect the output.
What is the difference between an encoder and priority encoder?
An ordinary encoder generally assumes one active input. A priority encoder can resolve several simultaneous active inputs.
What is the difference between an encoder and decoder?
An encoder compresses one of many input lines into a binary code, while a decoder expands a binary code into one of many output lines.
Does this simulator use active-high inputs?
Yes. A value of 1 means the corresponding encoder input is active.
Can I reverse the priority direction?
Yes. The simulator supports both highest-index and lowest-index priority for comparison.
Scroll to Top