Jump to content
karandeep963

Module with variable number of ports

Recommended Posts

Hello All,

 

I was wondering if I can create a module with variable number of ports.

 

In other words, pass the number of ports as a parameter for the module constructor.

 

If not, how can I try to build my component?

 

Regards,

KS

 

Share this post


Link to post
Share on other sites

The easiest solution is to use an sc_vector of ports (new in SystemC 2.3).

Here is a simple example:

SC_MODULE( module )
{
  // vector of ports
  sc_core::sc_vector< sc_core::sc_in<int> > in_vec;

  module( sc_core::sc_module_name, unsigned n_in )
    : in_vec( "in_vec" ) // set name prefix
  {
    // delayed initialisation of port vector
    in_vec.init( n_in );
  }
};

 

For some more examples and features of  sc_vector, have a look at the SystemC 2011 New Features presentation (part of SystemC 2.3.0 download archive), and/or the IEEE 1666-2011 standard, section 8.5.

 

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

×