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
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
No comments:
Post a Comment