Jump to content

Recommended Posts

Posted

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

 

Posted

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

 

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...