Jump to content
bennygato

sc_semaphore problem

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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!

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×