Carmichael Posted March 5, 2015 Report Share Posted March 5, 2015 Hi, I have some questions on systemC syntax. 1. sc_event_queue. I found a lot of examples for sc_event_queue on some systemC coursewares (even threads on this forum), like below, SC_MODULE(somemod){ sc_event_queue eq; ... void process1(){ while(true){ ... wait(eq); // here got a message: cannot convert from 'sc_core::sc_event_queue' to 'const sc_core::sc_event' , ... } } void process2(){ while(true){ ... eq.notify(5,SC_NS); eq.notify(8,SC_NS); ... } } SC_CTOR(somemod){ ... } }; If I change "wait(eq)" into "wait(eq.default_event())" or just use "wait()" meanwhile add eq into the sensitive list, it will work. Is it correct? 2. sc_semaphore channel. I see an example from the book systemc from the ground up like this, SC_MODULE(gas_station) { sc_semaphore pump(12); // here seems define a function which will return a sc_semaphore instance void customer1_thread { for(;; ) { // wait till tank empty … // find an available gas pump pump.wait(); // fill tank & pay } }; But this seems that it cannot work at all. Then if I use a new form like below it will work, SC_MODULE(gas_station) { sc_semaphore pump; void customer1_thread { for(;; ) { // wait till tank empty … // find an available gas pump pump.wait(); // fill tank & pay } SC_CTOR: pump(12){ ... } }; So if I want to use the form of sc_semaphore pump(12) to the module, what should I do on the constructor? Another question for the semaphore channel: does the sc_semaphore value have a upper limit or what is the size of this channel? Thanks a lot! Wayne Quote Link to comment Share on other sites More sharing options...
apfitch Posted March 5, 2015 Report Share Posted March 5, 2015 For question 1, please see Note 1 in the 1666-2011 LRM section 6.30.3. For question 2 - that looks like an error in SystemC from the Ground Up. In c++ before c++11 you can't do any initialisation of class members at declaration, so you must initialise on the constructor initialiser list (I think from memory that's been relaxed in c++ 11). When you say "So if I want to use the form of sc_semaphore pump(12) to the module, what should I do on the constructor?" the answer is you can't (pre C++11). Your second example is correct. Of course you can use a pointer to an sc_semaphore and call new in the constructor if you prefer. For your last question, please see the LRM section 6.29.3, regards Alan P.S. The LRM is free, and can be downloaded via the main Accellera website. Quote Link to comment Share on other sites More sharing options...
Carmichael Posted March 6, 2015 Author Report Share Posted March 6, 2015 Thank you so much for your help. I have downloaded the LRM. Regards, Wayne Quote Link to comment Share on other sites More sharing options...
David Black Posted March 6, 2015 Report Share Posted March 6, 2015 Wayne, which edition of SystemC: From the Ground Up are you referencing? Quote Link to comment Share on other sites More sharing options...
Carmichael Posted March 7, 2015 Author Report Share Posted March 7, 2015 2nd edition, Page 103 - Fig8.7 and Fig8.8 Quote Link to comment Share on other sites More sharing options...
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.