Binarios.org
Digital Logic Tools

Binary Encoder and Decoder Calculator

Convert active input lines into binary codes, expand binary addresses into one-hot decoder outputs, simulate priority encoders, and calculate BCD-to-7-segment display signals. Use the interactive controls and truth tables to explore common digital logic circuits.

1. Binary decoder calculator

A decoder converts an n-bit binary address into 2ⁿ output lines. When enabled, exactly one output is active for each address.

Valid indices: 0–7.

Decoder address

—
Choose an address and calculate.

Output lines

Output vector

—

2. Binary encoder calculator

A standard encoder converts one active input line into its binary index. For an ordinary encoder, select exactly one input. Use the priority encoder below if several inputs can be active.

Set one input to 1 and leave the other inputs at 0.

Binary output

—
Activate one input and calculate.

Decimal index and validity

—

3. Priority encoder calculator

A priority encoder accepts multiple active inputs and selects one according to the priority direction. This tool supports highest-index and lowest-index priority and includes a valid output flag.

Winning input

—
Set input lines and calculate.

Encoded binary output

—

Valid output (V)

—

4. BCD-to-7-segment decoder

Select a hexadecimal digit from 0 to F to display its conventional seven-segment pattern. For BCD decimal digits, use 0 through 9.

Seven-segment display

—
—

5. Encoder and decoder truth tables

Generate a reference truth table for a decoder, a standard encoder, or a priority encoder. Large tables can be scrolled horizontally.

Truth table information

Choose a circuit and generate the table.
The standard encoder table lists one active input at a time. The priority encoder table also includes the all-zero input and multiple-active combinations.

Your generated table will appear here.

How encoders and decoders work

Binary encoder

An encoder compresses a one-hot input into a binary index. For example, if I5 is the only active input in an 8-to-3 encoder, the output is 101, which represents decimal 5. A valid signal can distinguish an active input from the no-input condition.

Binary decoder

A decoder expands a binary address into output lines. A 3-to-8 decoder with address 101 activates output Y5 in active-HIGH mode when enabled. The other outputs remain low.

Priority encoder

When more than one input is high, a priority encoder chooses one input based on a defined priority rule. This makes it useful for interrupt controllers and systems where multiple requests may arrive at once.

Seven-segment decoder

A seven-segment decoder converts a digit code into the seven segment signals a through g. The displayed patterns for hexadecimal A–F depend on the display convention and are not the same as decimal BCD digits.

Frequently asked questions

What is the difference between an encoder and a decoder?

An encoder converts an active input line into a binary code. A decoder does the reverse: it takes a binary code and activates the corresponding output line.

How many output bits does an 8-to-3 encoder produce?

It produces three output bits because three bits can represent eight different indices, from 0 to 7.

Why does a normal encoder require only one active input?

Its binary output is intended to identify a single input. If multiple inputs are active, the OR-based output logic can produce a code that does not identify any of the active lines. A priority encoder resolves this by applying a priority rule.

What is the valid signal on a priority encoder?

The valid signal is 1 when at least one input is active and 0 when no input is active. It prevents the all-zero output code from being confused with a valid encoding of input zero.

What is an active-LOW decoder output?

In an active-LOW design, the selected output is 0 and the unselected outputs are 1. This convention is used by some integrated decoder circuits.

Is a hexadecimal seven-segment pattern the same on every display?

No. Patterns for hexadecimal values A through F can vary by design. This calculator uses common illustrative patterns; verify the truth table for your specific driver IC and display wiring before using it in hardware.

Related digital logic tools