Decoder = device which takes an input and translate it to another format
Decoders are one output hot, so only one output is HIGH at a given time(*Note that the input as as a decimal number corresponds with the bit number on the output)
Commonly used as selector
The decoder module can take N inputs and will output 2N outputs with one of the outputs having a value of 1.
For the user side only the number of inputs needs to be declared for the module to work.
Implementation:
Image to the left shows the implementation of the decoder 2 parameters were declared in order to create 2 constants for the body of the decoder. These constants are the number of inputs and the number of outputs, note a decoder has 2^N outputs in the code N=m.
The body of the code consists of an always block which will run if anything changes. An if-else statement is used to meet the enable conditions such that if the enable is LOW then the output will be 0 regardless of the input values, and if enable is HIGH then the output will change depending on the value of the input. A shift operator was used in order to compute the output since there is a pattern between the input and the output as seen in the truth table.
Testing:
Testing was done for 2 different decoders a 2x4 and a 3x8 decoder. In order to test the module vector testing was completed in PyMTL. The body of each of the tests defines the inputs(enable, x) and the output(y) for different scenarios.
Physical Design:
Characterization:
Area: 38μm2
Energy: 1.54e^-06 nW
Cycle Time: 2.80 ns