简体   繁体   English

如何从CTHREAD停止SystemC仿真,并使用特定的退出代码终止仿真?

[英]How do I stop a SystemC simulation, from a CTHREAD, and terminate the simulation with a specific exit code?

I've got a SystemC testbench (for a VHDL DUT but that's irrelevant right now). 我有一个SystemC测试平台(对于VHDL DUT,但现在这是无关紧要的)。 I'd like to be able to cause the test to terminate, with a specific exit code, from within an SC_CTHREAD. 我希望能够使用SC_CTHREAD中的特定退出代码终止测试。 I am pretty new to SystemC (I'm mostly a verilog/sv guy). 我对SystemC很新(我主要是一个verilog / sv人)。

I've tried simply including "exit(error_code)" but while that terminates the simulation, the final exit code comes from my sc_main's return statement. 我试过简单地包括“exit(error_code)”,但是当终止模拟时,最终的退出代码来自我的sc_main的return语句。 I guess this makes sense since the "exit" probably terminates the separate thread with that exit code, but not the sc_main thread. 我想这是有道理的,因为“exit”可能会终止带有退出代码的单独线程,但不会终止sc_main线程。

I've tried calling sc_stop before that exit, and usually get an error about calling a pure virtual method (I believe that's end_of_simulation, which I have not defined....but that should be optional, right?). 我试过在退出之前调用sc_stop,并且通常会遇到关于调用纯虚方法的错误(我相信这是我没有定义的end_of_simulation ......但是这应该是可选的,对吧?)。

The only way I see to affect the exit code of the process is to change the return statement of sc_main, but that doesn't quite work when all my action is happening in an SC_THREAD created by a constructor of an object somewhere (if it's not obvious I truly don't understand how SystemC works very well, probably because there's a lot of hidden action with secret classes that we can't see, as opposed to verilog where simulation ordering is all there is, assuming you understand blocking/non-blocking). 我看到影响进程退出代码的唯一方法是更改​​sc_main的return语句,但是当我的所有操作都发生在由某个对象的构造函数创建的SC_THREAD中时(如果它不是很明显我真的不明白SystemC是如何工作得很好的,可能是因为我们看不到有很多秘密类的隐藏动作,而不是verilog模拟排序就是这样,假设你理解阻塞/非阻塞)。

Is there a way for the SC_THREAD to pass some failure information up to sc_main? 有没有办法让SC_THREAD将一些失败信息传递给sc_main?

Note: I am running with a commercial simulation tool, and not pure C++. 注意:我使用的是商业模拟工具,而不是纯C ++。 It's possible that there's an implementation bug there. 那里可能存在实施错误。 I'm trying to get our pure C++ compile running but it seems to have broken a while ago (I'm not responsible for the SystemC model). 我试图让我们的纯C ++编译运行,但它似乎已经破坏了一段时间(我不负责SystemC模型)。

The answer, of course, is to have sc_main get its return value by reaching directly into the module that it instantiates to get at a member variable: 当然,答案是让sc_main通过直接访问它实例化的模块获取其返回值来获取成员变量:

return(test_module.exit_code);

I need to remember that we're still running C++ and basic C++ rules apply, so this is possible. 我需要记住,我们仍在运行C ++并且应用了基本的C ++规则,所以这是可能的。 In my hardware-design mind, I was spinning off modules and threads that had no connection to the classes that they actually are. 在我的硬件设计思想中,我正在分离与他们实际上没有连接的模块和线程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM