Tb/and

2023. 6. 20. 01:20FPGA/HDLBits

728x90

You are given the following AND gate you wish to test:

module andgate (
    input [1:0] in,
    output out
);

Write a testbench that instantiates this AND gate and tests all 4 input combinations, by generating the following timing diagram:

module top_module();
    reg [1:0] in;
    wire out;
    
    initial begin
        in[0] = 0;
        in[1] = 0;
        
        #10
        in[0] = ~in[0];
        
        #10
        in[1] = ~in[1];
        in[0] = ~in[0];
        
        #10
        in[0] = ~in[0];
    end
    
    andgate a_gate (.in(in) , .out(out));
endmodule

 

'FPGA > HDLBits' 카테고리의 다른 글

Tb/tff  (0) 2023.06.20
Tb/tb2  (0) 2023.06.20
Tb/tb1  (0) 2023.06.20
Tb/clock  (0) 2023.06.20
Popcount255  (0) 2023.06.20