我是靠谱客的博主 呆萌店员,最近开发中收集的这篇文章主要介绍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.

最后

以上就是呆萌店员为你收集整理的SystemC的运行阶段的全部内容,希望文章能够帮你解决SystemC的运行阶段所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(57)

评论列表共有 0 条评论

立即
投稿
返回
顶部