| Status | Title | Difficulty | Tags |
|---|---|---|---|
A Decoder is a combinational circuit that converts n input lines into 2ⁿ unique outputs.
It activates exactly one output line corresponding to the binary code of the input.
In this tutorial, we will design a 2-to-4 decoder in Verilog and verify it using a testbench.
A 2-to-4 decoder has:
A1, A0 (2-bit binary input)D0, D1, D2, D3Decoding rules:
00 → D0 = 101 → D1 = 110 → D2 = 111 → D3 = 1All other outputs remain 0.
Boolean equations:
D0 = ~A1 & ~A0D1 = ~A1 & A0D2 = A1 & ~A0D3 = A1 & A0decoder2to4 with:
A1, A0D0, D1, D2, D3testbench module:
00, 01, 10, 11).| A1 | A0 | D0 | D1 | D2 | D3 |
|---|---|---|---|---|---|
| 0 | 0 | 1 | 0 | 0 | 0 |
| 0 | 1 | 0 | 1 | 0 | 0 |
| 1 | 0 | 0 | 0 | 1 | 0 |
| 1 | 1 | 0 | 0 | 0 | 1 |
testbench and apply all input combinations.D0 and D1.0.Submit your Verilog code using Cmd+Enter to see the simulation results and waveform visualization.