verilog中testbench仿真时钟的生成
作者:互联网
一、普通时钟信号:
1、基于initial语句的方法:
parameter clk_period = 10;
reg clk;
initial begin
clk = 0;
forever
#(clk_period/2) clk = ~clk;
end
2、基于always语句的方法:
parameter clk_period = 10;
reg clk;
initial
clk = 0;
always #(clk_period/2) clk = ~clk;
二、自定义占空比的时钟信号:
parameter High_time = 5,Low_time = 20;
// 占空比为High_time/(High_time+Low_time)
reg clk;
always begin
clk = 1;
#High_time;
clk = 0;
#Low_time;
end
三、相位偏移的时钟信号:
parameter High_time = 5,Low_time = 20,pshift_time = 2;
// 相位偏移为360*pshift_time/(High_time+Low_time)
reg clk_a;
wire clk_b;
always begin
clk_a = 1;
#High_time;
clk_a = 0;
#Low_time;
end
assign #pshift_time clk_b = clk_a;
四、固定数目的时钟信号:
parameter clk_cnt = 5, clk_period = 2;
reg clk;
initial begin
clk = 0;
repeat(clk_cnt)
#(clk_period/2) clk = ~clk;
end
参考链接:https://www.cnblogs.com/Edam-IC/p/9054278.html
标签:Low,clk,testbench,period,High,verilog,time,parameter,时钟 来源: https://www.cnblogs.com/amxiang/p/16529733.html