Tricky Circuit

Two-bit decoder and one-hot output

Turn an address into one chosen line

A decoder turns a binary input code into a chosen output line. One-hot means exactly one line is 1 when enabled. Enable is the control that allows these outputs to operate.

Open interactive experiment

EXPERIMENT BENCH

Change the circuit settings, predict the readings, then check a challenge. These are learning models, with the assumptions explained in each lesson.

Sign in to save progress. Guest progress stays on this device.

Open laboratory in a full window

Why it works

Ideal binary logic: 0 means low and 1 means high, not a measured voltage. Supply behavior, current, output loading and response delay are omitted; diagrams show functions, not chip pinouts. Here enable E = 1 activates high outputs; E = 0 disables them. The active-line index −1 means none, not negative voltage.

b0 and b1 are input bits; code n = b0 + 2b1 ranges from zero to three. E is enable. With E = 1 only line Qn is high; with E = 0 all four outputs are low.

Difficulty
  1. Build · Build it

    Power on with b0 = 0, b1 = 1 and E = 1. Choose code 2 and make line Q2 active.

    Need a hint?

    b0 = 0; b1 = 1; E = 1 → Q2 = 1

  2. Explore · Change the inputs

    Set b0 = 1, b1 = 1 and E = 1. Choose code 3 and make line Q3 active.

    Need a hint?

    b0 = 1; b1 = 1; E = 1 → Q3 = 1

  3. Solve it · Solve the challenge

    Keep b0 = 1 and b1 = 1; set E = 0. Disable every output.

    Need a hint?

    b0 = 1; b1 = 1; E = 0 → Q0 = Q1 = Q2 = Q3 = 0

Extra reading and circuit recipes

Turn an address into one chosen line

Two switches can choose one of four destinations. The decoder expands a compact address into a visible choice of line.

n = b0 + 2b1; E = 1 → Qn = 1; E = 0 → Q0 = Q1 = Q2 = Q3 = 0

The binary code describes which line to choose; enable says whether to make that choice active. These are independent controls.

A useful pattern

Only two address bits choose four lines: every extra binary address bit doubles the possible choices.

Beyond the model

Disabled outputs are all zero, so the disabled state is not one-hot. The input code can still be three while no output is active.

A useful trap to avoid

Line number 2 does not mean two active lines. The number identifies a destination; the active-output count remains one when enabled.

Code stays at 3, but E changes from 1 to 0. Which line is high?

  1. Q3
  2. none
  3. all four
Read more

Enable controls whether the decoded choice is allowed to appear. Disabling forces every output low.

Build it

Set b0 = 0, b1 = 1, E = 1. The weighted code is 2 and only Q2 is high.

n = 2; Q2 = 1

Change the inputs

Set b0 = 1, b1 = 1, E = 0. Code is 3, but every output remains low.

Q0 = Q1 = Q2 = Q3 = 0

Try another path

With enable on, visit codes zero through three and count the active lines each time. Then repeat with enable off.

bob.cs.sonoma.edu