Hi,
I was trying to figure out how to run SystemC simulation in a main function.
I have read LRM 4.3.2, Function sc_elab_and_sim, but still can't get it.
This is what I did:
int sc_elab_and_sim(int argc, char *argv[])
{
if (argc == 0) {
//Initialize modules and connect them
sc_core::sc_start();
return 0;
}
else{
//Initialize another set of modules and connect them
sc_core::sc_start();
return 0;
}
}
int main()
{
sc_elab_and_sim(0, argv);
sc_elab_and_sim(1, argv);
return 0;
}
I use argc to decide which set of modules I want to run, just for test.
And I got an exception when it starting second sc_start:
libc++abi.dylib: terminating with uncaught exception of type sc_core::sc_report: Error: (E529) insert module failed: simulation running
In file: ../../../../src/sysc/kernel/sc_module_registry.cpp:47
I must did something wrong, can anyone tell me?
Actually I want to do unit test. Is this the right way or there are other better solutions?
Thanks!