Vhdl Verilog等效于;等到。。。为了;?
在Verilog测试台中,我尝试编写以下行为:Vhdl Verilog等效于;等到。。。为了;?,vhdl,verilog,Vhdl,Verilog,在Verilog测试台中,我尝试编写以下行为: 等待事件发生(上升/下降沿)的最长时间,即等效于VHDL指令: wait until <event> for <duration>; 等待; 具有以下行为(提醒): 要么事件发生 或者期限到期 除非我弄错了,否则我在Verilog中找不到这个函数的任何直接等价物。。。因此,我尝试了以下代码: reg watchdog; // ... // Set a signal 'watchdog' in backgroun
- 等待事件发生(上升/下降沿)的最长时间,即等效于VHDL指令:
wait until <event> for <duration>;
等待;
- 要么事件发生李>
- 或者期限到期
reg watchdog;
// ...
// Set a signal 'watchdog' in background which will be triggered in 10 us.
fork
watchdog <= #10_000 1'b1;
join
// Wait until SIGNAL is set to '1' *OR* watchdog event occurs.
@(posedge SIGNAL or posedge watchdog);
// Reset the watchdog
watchdog <= 1'b0;
reg看门狗;
// ...
//在后台设置一个信号“看门狗”,该信号将在10秒后触发。
叉
watchdog您的fork-join
只有一个进程,因此您没有并行执行任何操作
这应该满足您的要求:
fork : wait_or_timeout
begin
#10_000; //#10ms
disable wait_or_timeout;
end
begin
@(posedge SIGNAL);
disable wait_or_timeout;
end
join
要在Verilog中执行此操作,您需要使用禁用
。我建议完全去掉watchdog
信号,只使用fork
的两个分支
下面是一个工作示例。注意,如果分支成功,fork的每个分支都调用禁用f
。禁用fork将终止未成功的分支
module top;
reg signal;
task test();
fork : f
begin
// Timeout check
#10
$display("%t : timeout", $time);
disable f;
end
begin
// Wait on signal
@(posedge signal);
$display("%t : posedge signal", $time);
disable f;
end
join
endtask
initial begin
// test signal before timeout
fork
test;
begin
signal = 0;
#5;
signal = 1;
#5;
signal = 0;
#10;
end
join
// test signal after timeout
fork
test;
begin
signal = 0;
#15;
signal = 1;
#5;
end
join
end
伟大的这正是工作。还是Verilog的年轻学徒,我还没有完全理解fork的行为。。。加入
。谢谢