|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
目的:用19.44M的晶振 产生10khz,每当clr的上升沿的时候要求10khz与之对齐,clr也就是秒脉冲
代码:module C10KHz(input clk,
input clr,
output reg kout);
parameter fullcnt = 1944;
parameter halfcnt = 972;
reg [12:0] cnt;
reg clrbuf;
always @ ( posedge clk)begin
if(((clrbuf == 0 ) && (clr == 1)) | (cnt + 1 >= fullcnt)) begin
cnt <= 0;
kout <= 1;
end else begin
cnt <= cnt + 1;
kout <= cnt < halfcnt;
end
clrbuf <= clr;
end
endmodule
现象: 大多数时间能对齐,有时对不齐,请大家分析下,非常感谢!!! |
|