3-to-8 Decoder with Enable

Easy · Combinational Logic

Implement a 3-to-8 one-hot decoder with an active-high enable.

A decoder turns a binary number into a one-hot vector: exactly one output bit is 1, and its position is the number. Decoders drive chip selects, register-file write enables and address decoding.

Ports

PortDirWidthMeaning
eninput1Enable, active high.
selinput3Unsigned select value, 0–7.
youtput8One-hot output.

Behavior

y[i] = (i == sel).

The circuit is purely combinational (no clock, no state).

Truth table

ensely (binary)
0any0000_0000
100000_0001
110000_0010
120000_0100
130000_1000
140001_0000
150010_0000
160100_0000
171000_0000

Hint

A shift such as 8'b1 << sel produces the one-hot vector in one line. Mind the width of the constant you shift: in a plain assignment such as y = 1'b1 << sel; the expression is widened to the 8-bit target before shifting, so it happens to work, but in a self-determined context (for example inside a concatenation {...}) 1'b1 << sel is only 1 bit wide and is 0 for any sel > 0. 8'b1 << sel is safe everywhere.

Sign up free to solve 3-to-8 Decoder with Enable in your browser.

More Combinational Logic problems