Latest Post

Ads

Verilog: 4 - 2 Encoder Structural/Gate Level Modelling with Testbench

Verilog Code for 4-2 Encoder Structural/Gate Level Modelling

module encode_4_to_2(
    input d0,d1,d2,d3,
    output a0,a1
    );
wire x,y,z;
not g1(x,d2);
and g2(y,x,d1);
or g3(a0,y,d3);
or g4(a1,d2,d3);
endmodule

//Testbench code for 4-2 Encoder Structural/Gate Level Modelling

initial begin
// Initialize Inputs
 d0 = 1;d1 = 0;d2 = 0;d3 = 0;
// Wait 100 ns for global reset to finish
 #100;
// Add stimulus here
 #100;d0 = 0;d1 = 1;d2 = 0;d3 = 0;
 #100;d0 = 0;d1 = 0;d2 = 1;d3 = 0;
 #100;d0 = 0;d1 = 0;d2 = 0;d3 = 1;
end

Output:
Verilog 4-2 Encoder
Verilog 4-2 Encoder Response

Other Verilog Programs:

Go to Index of Verilog Programming

Comments

Ads

Popular posts from this blog

VLSI: BCD to Excess 3 and Excess 3 to BCD Dataflow Modelling

Full Subtractor Verilog Code in Structural/Gate Level Modelling with Testbench

VLSI: 4-1 MUX Dataflow Modelling with Testbench

VLSI: Half Subtractor and Full Subtractor Gate Level Modelling

VLSI: 1-4 DEMUX (Demultiplexer) Dataflow Modelling with Testbench