Wednesday, October 27, 2021

Decoders in Verilog


  Decoders in Verilog

The decoder has N inputs and 2N outputs to cover all input combinations

consider 2:4 decoders with two inputs and four outputs. The output corresponding to a given input will be at logic level 1 all other outputs will be at logic  0 as shown in functional table


The decoder can be constructed by AND and NOT gates. The circuit diagram of the two-to-four decoder as shown below
Circuit diagram of two-to-four decoder

Verilog Description of Two-to-Four Decoder:



Verilog Description of Three-to-Eight Decoder Using case Keyword



Additional example: 3:8 decoder with enable input:

if en= 1 then decoder will works

 

test bench:

module decoder_tb;
wire [7:0] out;
reg en;
reg [2:0] in;
integer i;
 
decoder3_to_8 dut(in,out,en);
 
initial begin  
$monitor( "en=%b, in=%d, out=%b ", en, in, out);
   for ( i=0; i<8; i=i+1)
        begin
           {en,in}  = i;
            #1;
        end
end

endmodule





👉 back to combination blocks

No comments:

Post a Comment

COMPARISON TREE

  Difference between Full and Complete Binary Tree A   binary tree  is a type of data structure where each node can only have  two offspring...