SystemC的运行阶段

Spec中给出了SystemC程序的执行过程(在terminal下执行 编译出来的可执行文件):

a) Elaboration—Construction of the module hierarchy

b) Elaboration—Callbacks to function before_end_of_elaboration

c) Elaboration—Callbacks to function end_of_elaboration

d) Simulation—Callbacks to function start_of_simulation

e) Simulation—Initialization phase

f) Simulation—Evaluation, update, delta notification, and timed notification phases (repeated)

g) Simulation—Callbacks to function end_of_simulation

h) Simulation—Destruction of the module hierarchy

个人的理解如下:

  1. Elaboration—Construction of the module hierarchy,例化 系统的 Top Module,也就是 按照层次结构 调用 class的构造函数。此过程是非常重要的一个过程,构造函数中用SC_THREAD / SC_METHOD 标记的函数将会被 注册到SystemC Kernel中,port 绑定一般也在构造函数中完成。
  2. Elaboration—Callbacks to function before_end_of_elaboration,调用所有sc_module 实例的 before_end_of_elabration(),基类sc_module中的此函数为空,不用care。
  3. end_of_elaboration 和before_end_of_elaboration的区别暂时也没搞清楚。Spec中对两者都有分别的介绍, systemc: sc_event和sc_event_finder 中介绍了一个需要使用这两个函数的场景。end_of_elaboration 中不能调用 event的notify函数,不能调用kill, reset, or throw_it of class sc_process_handle。
  4. start_of_simulation 一般很少使用。
  5. Simulation—Initialization phase,调用一次所有的 ( SC_METHOD关联函数 & 此函数后没有加 dont_initialize() ) SC_THREAD关联函数此阶段不被执行
  6. Simulation—Evaluation, update, delta notification, and timed notification phases (repeated) 这个阶段才是真正的 SC_METHOD/SC_THREAD关联函数(在spec中统称为 processes) 开始执行的阶段,SystemC仿真时间在此阶段从0开始往前推进,SystemC Kernel开始在各个processes间进行调度执行。
  7. end_of_simulation。此函数跟before_end_of_elaboration 类似,也是在基类sc_module中定义的。对于此阶段,spec中有如下解释:If no pending timed notifications or time-outs exist, the end of simulation has been reached. So, exit the scheduler. Applications are recommended to call function sc_stop before returning control from sc_main to ensure that the end_of_simulation callbacks are called。所以,如果程序中没有显式的调用sc_stop,则所有sc_module 实例中的end_of_simulation函数不会被调用。此函数的一般用法是,做一些performance counter的统计结果输出,但其实也可以在模块的析构函数中写;故一般不建议使用此函数。
  8. Destruction of the module hierarchy

The purpose of member function before_end_of_elaboration is to allow an application to perform actions during elaboration that depend on the global properties of the module hierarchy and that also need to modify the module hierarchy. Examples include the instantiation of top-level modules to monitor events buried within the hierarchy.

operator-> and operator[] of class sc_port should not be called from the function before_end_of_elaboration because the implementation may not have completed port binding at the time of this callback and, hence, these operators may return null pointers. The member function size may return a value less than its final value.

The purpose of member function end_of_elaboration is to allow an application to perform housekeeping actions at the end of elaboration that do not need to modify the module hierarchy. Examples include design rule checking, actions that depend on the number of times a port is bound, and printing diagnostic messages concerning the module hierarchy.

  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

123axj

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

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

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

打赏作者

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

抵扣说明:

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

余额充值