Can anyone help me to create a Verilog testbench?

前端 未结 2 1673
-上瘾入骨i
-上瘾入骨i 2020-12-06 15:32

Can anyone help me create a testbench or just the input code for my following code? I\'m using XILINX.

module fsmb (input rst,clk,a,
             output reg          


        
2条回答
  •  [愿得一人]
    2020-12-06 16:23

    Testbench 101

    1. Create a new module (tb).
    2. Create a reg for each input of your DUT.
    3. Create a wire for each output of your DUT.
    4. Create an instance of your DUT.
    5. Connect your regs and wires to your DUT.
    6. Generate a clock
    7. Drive your other inputs
    8. Create checkers for your outputs (I'll leave this up to you).

    Example:

    module tb;
    
    reg rst,clk,a;
    wire x;
    
    initial begin
        clk = 0;
        forever #5 clk = ~clk;
    end
    
    initial begin
        rst = 1;
        a = 0;
        #50 rst = 0;
        #50 $finish;
    end
    
    fsmb fsmb (
        .clk    (clk),
        .rst    (rst),
        .a      (a),
        .x      (x)
    );
    
    endmodule
    

    Other simple testbench examples are provided on EDA playgound. You can sign up for a free account and look at samples such as: Published Playgounds -> D flip flop

提交回复
热议问题