bennygato Posted November 29, 2013 Report Share Posted November 29, 2013 Hi all, I was asked to "Write five SystemC SC_MODULE master modules that connect to an sc_semaphore." in my project yet I found no example of doing such things. All the examples are about using sc_semaphore inside a single module, in which we can have several processes to share that semaphore. I checked asic-world instruction and example, by definition, "SystemC provides Channels for communication between two modules. " But I just don't know how. I would really appreciate it if you could share any thoughts about this. Thank you! Bingqian Quote Link to comment Share on other sites More sharing options...
apfitch Posted November 29, 2013 Report Share Posted November 29, 2013 There are no built-in ways of connecting to a semaphore (no ports or built-in channels). The easiest solution would probably be to pass a reference to the semaphore into each module via a constructor argument, regards Alan Quote Link to comment Share on other sites More sharing options...
bennygato Posted November 30, 2013 Author Report Share Posted November 30, 2013 There are no built-in ways of connecting to a semaphore (no ports or built-in channels). The easiest solution would probably be to pass a reference to the semaphore into each module via a constructor argument, regards Alan thank you very much!!! I did that and it works! Quote Link to comment Share on other sites More sharing options...
Philipp A Hartmann Posted November 30, 2013 Report Share Posted November 30, 2013 Alan, Benny, There are no built-in ways of connecting to a semaphore (no ports or built-in channels). The easiest solution would probably be to pass a reference to the semaphore into each module via a constructor argument, In general, I would not recommend to share data between modules by passing plain references or pointers around.Instead, it should be possible to use the standard semaphore interface in a plain sc_port and bind the semaphore "channel" to it, as you would do with any other channel as well. SC_MODULE(module) { sc_port< sc_semaphore_if > sem_port; // semaphore port // ... // access semaphore functions via "sem_port->", e.g. sem_port->post(); }; sc_semaphore my_sem("my_sem"); module my_module("my_module"); my_module.sem_port( my_sem ); // binding Whether or not a semaphore should be used as a channel across module boundaries is a different question. Greetings from Oldenburg, Philipp 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.