Jump to content

sc_semaphore problem


bennygato

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...