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