VHDL与VerilogHDL的Testbench模板
一般而言,一个testbench需要包含的部分如下:
(1)VHDL:entity 和 architecture的声明;Verilog:module declaration
(2)信号声明
(3)实例化待测试文件
(4)提供仿真激励
其中第(4)步是关键所在,需要完成产生时钟信号,以及提供激励信号两个任务。
VHDL Testbench中产生时钟信号的两种方法
首先要在信号声明部分,定义一个constant如下:
constant clk_period:TIME:=10ns;
- 方法一
clk<= not clk after clk_period/2;
- 方法二
process
begin
wait for clk_period/2;
clk<='1';
wait for clk_period/2;
clk<='0';
end process;
其次激励信号生成语法也利用wait for语句产生即可
process
begin
rst_n<='0';
en<='0';
wait for(clk_period*30);
rst_n<='1';
wait for(clk_period*30);
en