为什么系统Verilog$display在我预期的情况下没有执行?

为什么系统Verilog$display在我预期的情况下没有执行?,verilog,system-verilog,Verilog,System Verilog,在我的工作台程序中,我有如下内容(简化): 然后在我的index_reg模块中,我添加了以下调试代码: // index_reg.sv always @ (posedge clk) begin if (INDEX == 10) begin $display("I see the clock"); end end 我希望看到这样的结果: I see the clock 10 : BENCH I see the clock 20 : BENCH I see the clock 30

在我的工作台程序中,我有如下内容(简化):

然后在我的
index_reg
模块中,我添加了以下调试代码:

// index_reg.sv
always @ (posedge clk) begin
  if (INDEX == 10) begin
    $display("I see the clock");
  end
end
我希望看到这样的结果:

I see the clock
10 : BENCH
I see the clock
20 : BENCH
I see the clock
30 : BENCH
I see the clock
40 : BENCH
I see the clock
50 : BENCH
etc.
但有时,“我看到时钟”只每隔一段时间出现一次。我明白了

10 : BENCH
I see the clock
20 : BENCH
30 : BENCH
I see the clock
40 : BENCH
50 : BENCH
etc.

我不明白为什么会这样。有人能给我指一下正确的方向吗?非常感谢。

在没有看到更多代码的情况下,这里是我的最佳猜测

@(clk);
该代码在每个
clk
边缘触发,包括
posedge
negedge

always @ (posedge clk) begin
该代码仅在
clk
posedge
上触发,每隔一次触发一次

这可能就是为什么您看到
工作台的频率是我看到时钟的频率的两倍

如果这还不能回答您的问题,请提供一个任何人都可以编译和运行的完整代码示例

@(clk);
always @ (posedge clk) begin