直接上代码
/*
pulse_gen #(.CNTR(1000*1000*100))pulse_gen (
.clk(),
.rst(),
.pulse()
);
*/
module pulse_gen (
input clk,
input rst,
output reg pulse
);
parameter CNTR = 100*1000*1000 ;
reg [31:0] c ; always @ (posedge clk ) if ( c >= CNTR ) c<=1;else c<=c+1;
always @ (posedge clk ) pulse <= c >= CNTR ;
endmodule
如果clk时钟是100M,CNTR参数设置为100*1000*1000时候,每秒产生一个脉冲。