Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
System verilog 等待($time>;1000);无法在系统verilog中工作?_System Verilog - Fatal编程技术网

System verilog 等待($time>;1000);无法在系统verilog中工作?

System verilog 等待($time>;1000);无法在系统verilog中工作?,system-verilog,System Verilog,我使用此代码等待特定的模拟时间 initial begin $display("A"); wait($time>1000); $display("B"); end 模拟结果为: A 我没有看到打印的B 如果我使用下面的代码,它就会工作 while($time <1000) #1; 得到以下结果 A B at 20ns 这似乎是标准中的灰色区域。在本标准第9.4节“程序定时控制”中,提到事件控制可以是隐式的(更改网络或变量)或显式的(类型为事件)$tim

我使用此代码等待特定的模拟时间

initial begin
    $display("A");
    wait($time>1000);
    $display("B");
end
模拟结果为:

A
我没有看到打印的
B

如果我使用下面的代码,它就会工作

while($time <1000) #1;
得到以下结果

A
B at 20ns

这似乎是标准中的灰色区域。在本标准第9.4节“程序定时控制”中,提到事件控制可以是隐式的(更改网络或变量)或显式的(类型为
事件
$time
是一个系统函数,而不是一个变量。我还尝试过为
wait
使用一个函数,但它也不起作用:

module top;
  int the_time = 0;

  function int the_time_f();
    return the_time;
  endfunction // the_time_f

  initial begin
    $display("A");

    // This works because 'the_time' is a variable
    //wait(the_time > 10);

    // This doesn't work because 'the_time_f' is a function
    wait(the_time_f() > 10);
    $display("B");
  end

  initial begin
    #10ns;
    the_time = 11;
    #20ns;
    $finish();
  end
endmodule // top

等待变量的更改可以正常工作,但等待函数返回值的更改不起作用。恕我直言,编译器应该将此标记为编译错误(与使用
$time
相同),因为它似乎只是忽略了该语句。

这似乎是标准中的灰色区域。在本标准第9.4节“程序定时控制”中,提到事件控制可以是隐式的(更改网络或变量)或显式的(类型为
事件
$time
是一个系统函数,而不是一个变量。我还尝试过为
wait
使用一个函数,但它也不起作用:

module top;
  int the_time = 0;

  function int the_time_f();
    return the_time;
  endfunction // the_time_f

  initial begin
    $display("A");

    // This works because 'the_time' is a variable
    //wait(the_time > 10);

    // This doesn't work because 'the_time_f' is a function
    wait(the_time_f() > 10);
    $display("B");
  end

  initial begin
    #10ns;
    the_time = 11;
    #20ns;
    $finish();
  end
endmodule // top

等待变量的更改可以正常工作,但等待函数返回值的更改不起作用。无论如何,编译器应该将其标记为编译错误(与使用
$time
相同),因为它似乎只是忽略了该语句。

在暂停进程的事件控件
@(表达式)
等待(表达式)
中,SystemVerilog调度语义需要事件来计算表达式(称为求值事件。请参阅第4.3节的事件模拟)如果表达式包含函数,则只有该函数的参数可见,才能导致事件求值(在方法调用中写入对象的任何成员时,类方法存在异常,将导致事件)。请参阅第9.4.2节事件控制

在事件驱动模拟中,time的值只是当前时隙的一个属性,它从来不是一个事件。模拟器处理队列中当前时隙的所有事件,当该队列为空时,它将时间提前到下一个时隙队列。因此,它可能模拟时隙0、5、7、10,跳过un提到的时间。使用
while
循环,将为0到1000之间的每个连续时间单位创建一个时间sot-效率极低

所以只要使用

#(1000); // wait for 1000 relative time units 

在挂起进程的事件控件
@(表达式)
等待(表达式)
中,SystemVerilog调度语义需要一个事件来评估表达式(称为评估事件。请参阅第4.3节的事件模拟)如果表达式包含函数,则只有该函数的参数可见,才能导致事件计算(在方法调用中写入对象的任何成员时,类方法存在异常,将导致事件),请参见第9.4.2节事件控制

在事件驱动模拟中,time的值只是当前时隙的一个属性,它从来不是一个事件。模拟器处理队列中当前时隙的所有事件,当该队列为空时,它将时间提前到下一个时隙队列。因此,它可能模拟时隙0、5、7、10,跳过un提到的时间。使用
while
循环,将为0到1000之间的每个连续时间单位创建一个时间sot-效率极低

所以只要使用

#(1000); // wait for 1000 relative time units 

我使用if(time_to_wait>$time)#(time_to_wait-$time);现在替换无效的while循环。:)有没有办法等到模拟到达给定时间,比如
@($time==18.5us)
?@Nazar You can
(18.5us-$realtime)
如果需要,使用$realtime而不是$time可以获得分数时间单位。我使用if(time_to_wait>$time)#(time_to_wait-$time);现在替换无效的while循环。:)有没有一种方法可以等到模拟到达给定时间,比如
@($time==18.5us)
?@Nazar您可以使用$realtime而不是$time来执行
#(18.5us-$realtime)
,如果需要的话,它可以为您提供分数时间单位。