最近在看vivado的官方例程,顺便总结一下比较常用且优雅的testbench代码。将这些代码封装一下,以后在仿真时直接调用,非常的方便。
产生单端时钟(tb_clockgen_single .v)
//-----------------------------------------------------------------------------
//
// Copyright (c) JoeJoe.
//
// Project : Common Testbench
// Module : tb_clockgen_single .v
// Parent :
// Children : none
//
// Description:
// This is a general single clock generation module. It should be instantiated
// and connected to both the DUT
//
//
// Parameters:
// None
//
// Notes :
//
// Multicycle and False Paths
// None - this is a testbench file only, and is not intended for synthesis
//
`timescale 1ns/1ps
module tb_clockgen_single #
(
parameter PERIOD = 500 // 周期
)
(
output reg clk
);
//***************************************************************************
// Parameter definitions
//***************************************************************************
//***************************************************************************
// Register declarations
//***************************************************************************
//***************************************************************************
// Code
//***************************************************************************
initial begin
clk = 0;
forever begin
#(PERIOD/2.0)
clk = ~clk;
end // forever
end // initial
endmodule
非常常见的时钟激励编写方式。时钟通过clk端口输出,周期通过参数传入。

最低0.47元/天 解锁文章
386

被折叠的 条评论
为什么被折叠?



