Testbench的模板_自用
因为建立Xilinx工程的时候,会需要联合modelsim进行仿真,同样会写Testbench,所以,这次就留一个Testbench的模板,以防止后面重复性操作。
需要有这些内容
既然是模板,就需要有时钟,复位,方便灵活可调。
这两个内容,在上次看的mig_series7的时候又样子,可以借鉴过来实用;
talk is cheap
`timescale 1ns/100ps
//
// Company:
// Engineer:
//
// Create Date: 2020/04/08 21:26:35
// Design Name:
// Module Name: sim_tb_top
// Project Name:
// Target Devices:
// Tool Versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//
module sim_tb_top ();
//***************************************************************************
// Parameters
//***************************************************************************
parameter RESET_PERIOD = 200;
parameter RST_ACT_LOW = 1;
// =1 for active low reset,
// =0 for active high.
parameter CLKIN_FREQ = 100.0; // unit MHz, according to timescale 1ns;
parameter CLKIN_PERIOD = 1000/CLKIN_FREQ; // Input Clock Period
//**************************************************************************//
// Wire Declarations
//**************************************************************************//
reg sys_rst_n;
wire sys_rst;
reg sys_clk_i;
//**************************************************************************//
//**************************************************************************//
// Reset Generation
//**************************************************************************//
initial begin
sys_rst_n = 1'b0;
#RESET_PERIOD
sys_rst_n = 1'b1;
end
assign sys_rst = RST_ACT_LOW ? sys_rst_n : ~sys_rst_n;
//**************************************************************************//
// Clock Generation
//**************************************************************************//
initial begin
sys_clk_i = 1'b0;
end
always begin
sys_clk_i = #(CLKIN_PERIOD/2.0) ~sys_clk_i;
end
//**************************************************************************//
// Others Generation
//**************************************************************************//
//**************************************************************************//
// TOP Models instantiations
//**************************************************************************//
module_top module_top_inst(
.rst_n (sys_rst),
.clk (sys_clk_i),
);
//**************************************************************************//
// Status of the Simulation. Just for reference.
//**************************************************************************//
// initial
// begin : Logging
// fork
// begin : status_1
// wait (init_calib_complete);
// $display("Calibration Done");
// #50000000.0;
// if (!tg_compare_error) begin
// $display("TEST PASSED");
// end else begin
// $display("TEST FAILED: DATA ERROR");
// end
// disable calib_not_done;
// $finish;
// end
//
// begin : status_2
// if (SIM_BYPASS_INIT_CAL == "SIM_INIT_CAL_FULL") begin
// #2500000000.0;
// end else begin
// #1000000000.0;
// end
//
// if (!init_calib_complete) begin
// $display("TEST FAILED: INITIALIZATION DID NOT COMPLETE");
// end
// disable calibration_done;
// $finish;
// end
// join
// end
endmodule // sim_tb_top
如有需求
自行复制,有问题可以留言讨论。
Update: 2020-06-01;新增加top例化;