我有一个问题,我希望有人可以给我一些解决问题的提示。
如果输入信号“in”的周期大于tmax,我需要一个verilog代码使信号“reset”立即变为高电平。
信号“复位”应在“in”的下一个上升沿再次变低(如果有下一个上升沿)
如果输入信号“in”的周期小于tmax,则信号“reset”应保持低电平。
示例1。
tmax=100ns
period(in) = 80ns
示例2。
tmax=100ns
period(in) = 130ns
我应该从哪里开始?
答案 0 :(得分:0)
How about this. You will still have to do your check to see if Tmax is exceed, but you get a 1 timescale resolution between results.
always @ (*)
begin
while(1)
begin
current_time = $realtime;
if (last_time > 0.0) freq = 1.0e9 / (current_time - last_time);
last_time = current_time;
# 1; // This allows for 1 timescale between loops. If you leave
// this out, most simulators become non-responsive in the loop.
end
end