码迷,mamicode.com
首页 > 其他好文 > 详细

事件等待(@event与wait(event.triggered))

时间:2019-12-05 21:48:19      阅读:273      评论:0      收藏:0      [点我收藏+]

标签:竞争   initial   执行   就会   输出   hello   color   class   span   

1、@event有竞争问题

program test;
    event e1;
    initial begin
        #10 ->e1;
    end
    initial begin
        #10 @e1;
        $display("hello");
    end
endpropram

在这个例子中,事件的触发(->e1)和事件的检测(@e1)都是在10ns的时候发生,这个时候就有竞争问题,看那个进程先执行(一般是上部分的代码先执行),这样就会导致有的时候能够检测到事件,输出"hello",有的时候则不能检测到。

2、wait(event.triggered)没有竞争问题

program test;
    event e1;
    initial begin
        #10 ->e1;
    end
    initial begin
        #10 wait(e1.triggered);
        $display("hello");
    end
endpropram

同样是事件的触发(->e1)和事件的检测(@e1)都是在10ns的时候发生,但是这个时候没有竞争问题,event.triggered可以检测到当前触发的事件,所以一定会输出hello。

事件等待(@event与wait(event.triggered))

标签:竞争   initial   执行   就会   输出   hello   color   class   span   

原文地址:https://www.cnblogs.com/yuandonghua/p/11991956.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!