SourceRTL Design Directory

Decoder: An Overview

The functionality of a decoder is the opposite of an Encoder. A decoder is a combinational circuit that converts a binary coder to a set of output signals with only one bit of the being high at any given time. It consists of N input lines and 2^N output lines.

Design: 2-to-4 Decoder

A 2-to-4 decoder consists of two input lines and four output lines. The truth table of the decoder is shown below:

in[1]in[0]out[3]out[2]out[1]out[0]
000001
010010
100100
111000

Boolean equation for the decoder from the truth table is as follows:

out = in[1]’ * in[0]’ + in[1]’ * in[0] + in[1] * in[0]’ + in[1] * in[0]

Design: 3-to-8 Decoder

A 3-to-8 decoder consists of three input lines and eight output lines. The truth table for the decoder is as follows:

in[2]in[1]in[0]out[7]out[6]out[5]out[4]out[3]out[2]out[1]out[0]
00000000001
00100000010
01000000100
01100001000
10000010000
10100100000
11001000000
11110000000

From the truth table, the boolean equation can be written as:

out = in[2]’ * in[1]’ * in[0]’ + in[2]’ * in[1]’ * in[0] + in[2]’ * in[1] * in[0]’ + in[2]’ * in[1] * in[0] + in[2] * in[1]’ * in[0]’ + in[2] * in[1]’ * in[0] + in[2] * in[1] * in[0]’ + in[2] * in[1] * in[0]

Verilog Code: Parameterized Decoder

always_comb
  out = 1 << in;