leimli Posted July 1, 2014 Report Posted July 1, 2014 Hi, everyone, I am a starter of SystemC. I wrote a simple example with using SC_THREAD following the example in systemc source. I have two classes which boot two threads, bootMAC and respondDrv. However, when I simulate this program, I observed that only bootMAC is running, respondDrv did not print anything. Are there anything I still need to add? Thanks so much for you guys' help. The code is follows. class SYSCMAC : public sc_core::sc_module { public: SC_HAS_PROCESS(SYSCMAC); SYSCMAC(sc_module_name name) : sc_core::sc_module(name) { SC_THREAD(bootMAC); } void bootMAC() { while(true) printf("in bootMAC\n"); } }; class SYSCNETDEV : public sc_module { public: SC_HAS_PROCESS(SYSCNETDEV); SYSCNETDEV(sc_module_name name) : sc_core::sc_module(name) { SC_THREAD(respondDrv); } void respondDrv() { while(true) printf("in respondDrv\n"); } }; int sc_main(int argc, char **argv) { printf("hello world\n"); SYSCMAC *q = new SYSCMAC("mac"); SYSCNETDEV *sn = new SYSCNETDEV("qemu"); sc_start(); printf("start simulation now\n"); return 0; } Quote
dakupoto Posted July 1, 2014 Report Posted July 1, 2014 Hi, everyone, I am a starter of SystemC. I wrote a simple example with using SC_THREAD following the example in systemc source. I have two classes which boot two threads, bootMAC and respondDrv. However, when I simulate this program, I observed that only bootMAC is running, respondDrv did not print anything. Are there anything I still need to add? Thanks so much for you guys' help. The code is follows. class SYSCMAC : public sc_core::sc_module { public: SC_HAS_PROCESS(SYSCMAC); SYSCMAC(sc_module_name name) : sc_core::sc_module(name) { SC_THREAD(bootMAC); } void bootMAC() { while(true) printf("in bootMAC\n"); } }; class SYSCNETDEV : public sc_module { public: SC_HAS_PROCESS(SYSCNETDEV); SYSCNETDEV(sc_module_name name) : sc_core::sc_module(name) { SC_THREAD(respondDrv); } void respondDrv() { while(true) printf("in respondDrv\n"); } }; int sc_main(int argc, char **argv) { printf("hello world\n"); SYSCMAC *q = new SYSCMAC("mac"); SYSCNETDEV *sn = new SYSCNETDEV("qemu"); sc_start(); printf("start simulation now\n"); return 0; } Hello, Please get hold of a good reference on SystemC and read through it. Both your modules have threads, but NONE of them are "sensitized" to any events. That is why you just have one module running, when both should be running. Please find out how you would use the SystemC keyword "sensitive". Quote
David Black Posted July 2, 2014 Report Posted July 2, 2014 Actually, you don't need a sensitive statement. You can simply insert: wait(1,SC_NS); into each of the loops to observe the behavior. In fact, I rarely use static sensitivity in my SystemC code. I prefer dynamic because it results in easier to understand code. Mind you, I don't write RTL when writing SystemC. RTL more or less requires static sensitivity. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.