banner

Design the the sequential logic circut D flip flop and simulate it on iverilog and GTKWave open simulator.

Design and test bench:

    //***** design under test******
    // design module
    module dffwar(
    input clk,d,rst,
    output reg q);

    //design logic
    //loop on positive edge of clk and rst
    always@(posedge clk or posedge rst)
    begin
        // if reset q=0
        if(rst)
            begin
                q<=0;
            end
        
        //if no reset q=d
        else
            begin
                q<=d;
            end
    end
    endmodule

    //******* test bench*********
    // test bench module
    module tb();
    reg clk,d,rst;
    wire q;

    //instance of the desing in  test bench
    dffwar i(clk,d,rst,q);

    //dumping the variable
    initial begin
        $dumpfile("dff.vcd");
        $dumpvars(-1,i);
    end

    // clock generation
    always begin
        #10 clk=~clk;
    end

    //generating test signals
    initial begin
        clk <= 0;
        d<=1;rst<=0; #15;
        d<=1;rst<=1; #15;
        d<=1;rst<=0; #15;
        d<=1;rst<=0; #15;
        d<=1;rst<=0; #15;
        rst <= 1;#15;
        $finish;
    end
    endmodule

Waveform:


No comments:

Post a Comment

Design verilog code for the combinational circuit MUX4x1 in structural style modelling by taking instance of MUX2X1 and simulate it on iverilog and GTKWave open simulator.

Design and test bench: //***** design under test****** // design top module module mux4( //input interface input [3:0]i, input[1:0]s, input ...