Hanbat Hanbat National National University University Encoder-Decoder in VerilogEncoder-Decoder in Verilog Gookyi Dennis A. N.Gookyi Dennis A. N. SoC Design Lab.SoC Design Lab. July.15.2014
ContentsContents  Objectives  Encoder  Decoder  Encoder-Decoder 2
ObjectivesObjectives  Wish to design a system that encodes at one end and decode at the other end  Design a 4 to 2 encoder  Design a 2 to 4 decoder  Design a top level module that instantiates the encoder and the decoder 3
Block diagramBlock diagram  The block diagram of the whole system is shown below: 4 4 to 2 Encoder 2 to 4 Decoder 4 Bit input 4 Bit output 2 Bit inout
EncoderEncoder  Truth table of 4 to 2 encoder is shown below:  Output equations are as follows: out[0] = ((~in[3])&(~in[2])&(in[1])&(~in[0])) | (((in[3])&(~in[2])&(~in[1])&(~in[0])))out[0] = ((~in[3])&(~in[2])&(in[1])&(~in[0])) | (((in[3])&(~in[2])&(~in[1])&(~in[0]))) out[1] = ((~in[3])&(in[2])&(~in[1])&(~in[0])) | (((in[3])&(~in[2])&(~in[1])&(~in[0])))out[1] = ((~in[3])&(in[2])&(~in[1])&(~in[0])) | (((in[3])&(~in[2])&(~in[1])&(~in[0]))) 5 In[3] In[2] In[1] In[0] Out[1] Out[0] 0 0 0 1 0 0 0 0 1 0 0 1 0 1 0 0 1 0 1 0 0 0 1 1
EncoderEncoder  Verilog code for encoder (submodule) 6
EncoderEncoder  RTL schematic 7
DecoderDecoder  Truth table for 2 to 4 decoder  Output equations are as follows: out[0] = (~in[0]) & (~in[1]) out[1] = (in[0]) & (~in[1]) out[2] = (~in[0]) & (in[1]) out[3] = (in[0]) & (in[1]) 8 In[1] In[0] Out[3] Out[2] Out[1] Out[0] 0 0 0 0 0 1 0 1 0 0 1 0 1 0 0 1 0 0 1 0 1 0 0 0
DecoderDecoder  Verilog code for decoder (submodule) 9
DecoderDecoder  RTL schematic 10
Encoder_DecoderEncoder_Decoder  Verilog code 11
Encoder_DecoderEncoder_Decoder  RTL schematic 12
Encoder_DecoderEncoder_Decoder  Full testbench 13
Encoder_DecoderEncoder_Decoder  Waveform 14

Encoder decoder