Jump to content

howardhsu

Members
  • Content Count

    4
  • Joined

  • Last visited

  1. howardhsu

    Problem in TLM READ command

    I think you should assign value to the variable that data pointer in the payload point to, instead to set the data pointer to point to your local variable address. if(cmd==tlm::TLM_READ_COMMAND){ bool flag=(bool)((device_rx_data[addr]>>len)& 0x1); data_ptr=reinterpret_cast<unsigned char*>(&flag); //---> *data_ptr = static_cast<unsigned char>(flag); or something } Because the lifetime of "flag" only inside the braces. You shouldn't use its address outside the if statement.
  2. howardhsu

    How to use sc_elab_and_sim?

    Alright... Thanks for reply!
  3. howardhsu

    How to use sc_elab_and_sim?

    Hello dakupoto, Thanks for the reply! I want to do unit testing in the main function. For example, I have a priority queue and I want to test whether it works as my expect. I hope I can do one test at a time, like in first one I test whether it can be written and read; and test whether the priority is as my expect in the second test. I want the queue to be "clean" or is a new one before each test starts. And each test is judged with assert statement. If I wrote this in a sequence of actions in sc_main, if one test is failed, the following tests will not be executed. So I was thinking to lunch many SystemC simulation in the main function, each of them do one test. Then I can gather the test results and make a report. The pseudo code in my original post is referenced from here: http://www.accellera.org/Discussion_Forums/helpforum/archive/msg/msg?list_name=help_forum&monthdir=200509&msg=msg00077.html Now I am trying other ways like reset my modules between every tests or create many instances and each one of them is used to run one test. I found that my question should be "How to do unit testing in SystemC" . But still I am curious about how to use sc_elab_and_sim. If anyone could give me a simple example, I'd appreciate it!
  4. howardhsu

    How to use sc_elab_and_sim?

    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!
×