Latest Post

Ads

VLSI: Gray to Binary Dataflow Modelling with Testbench

Verilog Code for Gray to Binary Dataflow Modelling

module gray_to_binary(
    input g0,
    input g1,
    input g2,
    input g3,
    output b0,
    output b1,
    output b2,
    output b3
    );
         assign b0 = g0;buf(b0,g0);
         assign b1 = g0 ^ g1;
assign b2 = g0 ^ g1 ^ g2;
assign b3 = g0 ^ g1 ^ g2 ^ g3;
endmodule

//Testbench code for Gray to Binary Dataflow Modelling

initial begin
                             // Initialize Inputs
                             g0 = 0;g1 = 0;g2 = 0;g3 = 0;
                             // Wait 100 ns for global reset to finish
                             #100;
                             // Add stimulus here
                             #50;g0 = 0;g1 = 0;g2 = 0;g3 = 1;
                             #50;g0 = 0;g1 = 0;g2 = 1;g3 = 0;
                             #50;g0 = 0;g1 = 0;g2 = 1;g3 = 1;
                             #50;g0 = 0;g1 = 1;g2 = 0;g3 = 0;
                             #50;g0 = 0;g1 = 1;g2 = 0;g3 = 1;
                             #50;g0 = 0;g1 = 1;g2 = 1;g3 = 0;
                             #50;g0 = 0;g1 = 1;g2 = 1;g3 = 1;
                             #50;g0 = 1;g1 = 0;g2 = 0;g3 = 0;
                             #50;g0 = 1;g1 = 0;g2 = 0;g3 = 1;
                             #50;g0 = 1;g1 = 0;g2 = 1;g3 = 0;
                             #50;g0 = 1;g1 = 0;g2 = 1;g3 = 1;
                             #50;g0 = 1;g1 = 1;g2 = 0;g3 = 0;
                             #50;g0 = 1;g1 = 1;g2 = 0;g3 = 1;
                             #50;g0 = 1;g1 = 1;g2 = 1;g3 = 0;
                             #50;g0 = 1;g1 = 1;g2 = 1;g3 = 1;

 end


Output:
VLSI: Gray to Binary Dataflow Modelling with Testbench





Comments

Ads

Popular posts from this blog

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

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

VLSI: 2 Bit Magnitude Comparator Dataflow Modelling

1 to 4 DEMUX (Demultiplexer) Verilog CodeStructural/Gate Level Modelling with Testbench

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