Quantcast
Channel: SystemC Language Forum RSS Feed
Viewing all articles
Browse latest Browse all 595

How to achieve concurrency through SC_THREAD

$
0
0

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;
}
 
 
 
 

Viewing all articles
Browse latest Browse all 595

Trending Articles