哦 因为400m频率比74m快相当于在74m为高的时候扫描了高信号几次所以在此期间都被值0 了 用另外这个看看能不能达到要求:
always@(posedge clk_400m)
begin
if(ret)
begin
count <= 3'd0;
state_74m_pg <= 0;
end
else
begin
case(state_74m_pg)
0:begin
if(clk_74m)
begin
count <= 3'd0;
state_74m_pg <= 1;
end
else
begin
count <= count + 3'd1;
state_74m_pg <= 0;
end
end
1:begin
if(!clk_74m)
begin
count <= count + 3'd1;
state_74m_pg <= 0;
end
else
begin
count <= count + 3'd1;
state_74m_pg <= 1;
end
end
default:begin
count <= 3'd0;
state_74m_pg <= 0;
end
endcase
end
end
因为是用400m扫描74m所以在clk_400m上升沿来之前如果74m的上升沿来了那么count值0 要等到clk_400m的上升沿来的时候 不知道能不能用 希望对你有所帮助
reg clk_74m_bak = 0;
always @(posedge clk_400m)
begin
clk_74m_bak <= clk_74m;
if ((clk_74m_bak == 0) && (clk_74m == 1))
counter <= 0;
else
counter <= counter + 1;
end
always@(posedge clk_400m)
begin
if(ret)
begin
count <= 3'd0;
state_74m_pg <= 0;
end
else
begin
case(state_74m_pg)
0:begin
if(clk_74m)
begin
count <= 3'd0;
state_74m_pg <= 1;
end
else
begin
count <= count + 3'd1;
state_74m_pg <= 0;
end
end
1:begin
if(!clk_74m)
begin
count <= count + 3'd1;
state_74m_pg <= 0;
end
else
begin
count <= count + 3'd1;
state_74m_pg <= 1;
end
end
default:begin
count <= 3'd0;
state_74m_pg <= 0;
end
endcase
end
end
因为是用400m扫描74m所以在clk_400m上升沿来之前如果74m的上升沿来了那么count值0 要等到clk_400m的上升沿来的时候 不知道能不能用 希望对你有所帮助
一周热门 更多>