Testbench的模板_自用

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例化;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

ShareWow丶

前人栽树,分享知识,传播快乐。

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值