SystemC中的Wait 函数

SystemC中SC_THREAD必须依靠wait 来进行仿真时间的推进;SC_METHOD中则必须保证不能出现任何显式或隐式的wait调用。

wait 有多个重载函数。

void wait() 中不加任何参数,表述wait此SC_THREAD的敏感列表事件,比如在构造函数中有这样的语句SC_THREAD( function); sensitive << evt; 这样在 SC_THREAD 的函数中 遇到wait() 就相当于wait(evt)。

void wait(int n) 简单的理解(等效)为for(int i = 0 ;i < n ; i++) {wait() ;} 也就是 等待多次 sensitive的事件。需要注意n必须是大于0的正整数。

Spec中对Wait(n)由如下表述:

A call to this function shall be equivalent to calling the function wait with an empty argument list for a number of times in immediate succession, the number of times being passed as the value of the   argument. It shall be an error to pass an argument value less than or equal to zero. The implementation is expected to optimize the execution speed of this function for clocked thread  processes. 

对这个函数的调用将等同于连续多次使用空参数列表调用函数wait,即作为参数值传递的次数。传递小于或等于零的参数值将是错误的。该实现有望优化该函数在时钟线程进程中的执行速度。

void wait(const sc_event&) 就是wait一个事件,等这个事件被notify的时候,才会跳出wait。注意notify的时候,如果调用的是notify(sc_time t),则需要等notify()语句之后,仿真时间再往前推进t 时间后,才能跳出wait;如果调用的是notify(),则相当于notify(SC_ZERO_TIME),也就是delta time。

void wait( const sc_event_or_list &) wait( evt1 | evt2 | … )是等效的,也就是说任意一个evt notify了,wait就跳出了。列表中的evtnotify的顺序是无所谓的,最终跳出wait的时刻就是最后一个被notifyevt的时刻。在最后一个evtnotify前,其他evt可以被notify多次,不影响wait的行为。可以这样认为:sc_event_and_list 初始化时,将所有的event 放到一个容器中,当一个eventnotify时,将event从容器中删除,如果event已经被删除则不处理;最终,当容器为空时,wait的条件满足,跳出waitSpec中对sc_event_and_list由如下的解释:

In order for the process to be resumed, every single one of the given events shall be notified, with no explicit constraints on the time or order of those notifications.  The process is resumed when the last such event is notified, last in the sense of being at the latest point in simulation time, not last in the list.  An event in the list may be notified more than once before the last event is notified.  If a particular event appears more than once in the list, the behavior shall be the same as if it appeared only once.

void wait( const sc_event_and_list & ); wait( evt1 & evt2 & … )是等效的,也就是说必须所有的evt都被notify一次,wait才可以跳出。

void wait( const sc_time& t); 表示wait一定的仿真时间,从当前仿真时间开始,当仿真时间再往前推进t之后跳出wait。比如 sc_time t_time = sc_time(1,SC_NS); wait(t_time);

void wait( double v , sc_time_unit tu ); 等同于void wait( sc_time( v, tu ) );

void wait( const sc_time& , const sc_event& ); 表示当时间或 事件被触发的时候,跳出wait。以下重载函数也是类似。

void wait( double , sc_time_unit , const sc_event& );

void wait( const sc_time& , const sc_event_or_list & );

void wait( double , sc_time_unit , const sc_event_or_list & );

void wait( const sc_time& , const sc_event_and_list & );

void wait( double , sc_time_unit , const sc_event_and_list & );

  • 2
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

123axj

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值