Verilog:检测大于tmax的脉冲

时间:2016-08-31 13:33:42

标签: verilog detection pulse

我有一个问题,我希望有人可以给我一些解决问题的提示。

如果输入信号“in”的周期大于tmax,我需要一个verilog代码使信号“reset”立即变为高电平。

信号“复位”应在“in”的下一个上升沿再次变低(如果有下一个上升沿)

如果输入信号“in”的周期小于tmax,则信号“reset”应保持低电平。

示例1。

tmax=100ns
period(in) = 80ns
  • 重置始终保持低电平

示例2。

tmax=100ns
period(in) = 130ns
  • 复位在“in”
  • 的第一个上升沿后变为高电平100ns
  • 如果存在第二个脉冲
  • ,则在“in”的下一个上升沿处复位变为低电平

See attached image

我应该从哪里开始?

1 个答案:

答案 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