计数器仿真计数有跳现象
做的就是简单计数器,打算形成电视同步信号,但是在仿真的过程中,发现计数有跳变的现象,产生的并不是连续的数值,而且数值大小已经超过设定位宽最大值,求指教附 代码。
module dianshi( clk,
rst,
ctbmc,
htbmc,
xymc,
jhmc,
sw_ctrl,
h,
hj );
input clk; //100MHz
input rst;
input sw_ctrl;//拨码开关
output ctbmc; //场同步脉冲
output htbmc; //行同步脉冲
output xymc; //消隐脉冲
output jhmc; //均衡脉冲
//output kcmc; //开槽脉冲
output h;
output hj;
regctbmc;
reghtbmc;
regxymc;
regjhmc;
regkcmc;
reg hs; //行数625
reg hjs; //行内计数器6400
always @ (posedge clk ) //行内计数,行数计数
begin
if(!rst)
hjs <= 13'b0;
else if (sw_ctrl != 4'd0)
hjs <= 13'b0;
else
hjs <= hjs+13'd1;
if( hjs == 13'd6399)
hjs <= 13'd0;
end
always @ ( posedge clk)
begin
if(!rst)
hs <= 10'b0;
else if (sw_ctrl != 4'd0)
hs <= 10'b0;
else if( hs != 10'd624)
begin
if (hjs == 13'd6399)
hs <= hs+10'd1;
end
else
hs <= 10'd0;
end
assign hj= hjs;
assign h= hs ;
endmodule
页:
[1]