karandeep963 Posted May 14, 2013 Report Posted May 14, 2013 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 Quote
Philipp A Hartmann Posted May 14, 2013 Report Posted May 14, 2013 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 Quote
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.