Jump to content

kaushalyjain

Members
  • Content Count

    4
  • Joined

  • Last visited

  1. That clarifies a lot of my doubts. Thank you again Philip. I realize that the best/quickest way to clarify doubts is indeed posting on the forum! Also really appreciate the veterans giving prompt replies
  2. Thanks again Philip. That really helped. So, if we are using a sc_vector of sc_vectors, we compulsorily need to create a custom creator function/lambda function for initializing such sc_vector of sc_vectors ? A naive question, but where do we need custom creator functions in general? Also, do they have to be static (like in this case). Also, in the LRM, page 405 (8.5.5) the following example uses a custom creator function and does it using Boost bind. How is it different from this case? While using the custom creator function for initialization as in your answer, can we pass the arguments to the function (char* , size_t) ? I tried doing it but it threw an error. // Case 2: creator is a member function my_module* my_module_creator_func( const char* name, size_t i ) { return new my_module( name, "value_of_extra_arg" ); } Top(sc_module_name _name, int N) { // Initialize vector passing through constructor arguments to my_module // Case 1: construct and pass in a function object vector1.init(N, my_module_creator("value_of_extra_arg")); // Case 2: pass in a member function using Boost bind vector2.init(N, sc_bind( &M::my_module_creator_func, this, sc_unnamed::_1, sc_unnamed::_2 ) );
  3. Thank you Philip for the prompt answer/suggestions: Appending my requirements through a sample code written/edited by you only (taken from OFFIS website): Desired topology: Each of the in[3] ports in the 4 submodules need to be bound with the corresponding in_vec[3] vector Hence, binding looks something like this module.in_vec_0[0:2] <bound to> sub_module.in[0:2] This is also shown in the code below in for loop commented out and works fine 1) So, in my design: my submodule has a multi-port (currently defined here as in[3] array) Now, if I define input ports as sc_vector (as seen in commented portion of submodule), how do I bind the vector of vectors? Could you please show with this example? 2) Also, is there a better way to bind these ports using sc_assemble_vector? #include "systemc.h" SC_MODULE( sub_module ) { sc_in <sc_uint <16> > > in[3]; SC_CTOR(sub_module) {} //possible alternative: but how do i bind this using sc_assemble_vector // sc_vector<sc_in<sc_uint <16> > > in; // SC_CTOR(sub_module):in(3) {} }; SC_MODULE( module ) { // vector of sub-modules sc_vector< sub_module > m_sub_vec; // vector of ports sc_vector < sc_in<sc_uint<16> > > in_vec[3]; module( sc_core::sc_module_name, unsigned n_sub ) : m_sub_vec( "sub_modules", n_sub ) // set name prefix, and create sub-modules // , in_vec() // use default constructor // , in_vec( "in_vec" ) // set name prefix { // delayed initialisation of port vector // here with default prefix sc_core::sc_gen_unique_name("vector") // bind ports of sub-modules -- sc_assemble_vector for(unsigned i=0;i<3;i++){ in_vec[i].init( n_sub ); cout << "Size of vector " << m_sub_vec.size()<<endl; //can I use sc_assemble_vector in this case? //sc_assemble_vector( m_sub_vec, &sub_module::in).bind( in_vec ); //the following element by element binding works, but is there a neater way? /* for(unsigned j=0;j<m_sub_vec.size();j++){ m_sub_vec[j].in[i](in_vec[i][j]); } */ } } }; int sc_main(int , char* []) { module m("dut", 4); std::vector<sc_object*> children = m.get_child_objects(); for (size_t i=0; i<children.size(); ++i ) cout << children[i]->name() << " - " << children[i]->kind() << endl; cout << "Program completed" << endl; return 0; }
  4. Hi, So I have a submodule having an array of boolean input ports. Now in the top module, I define an sc_vector of the submodule type. Also, I define an array of sc_vector signals to be bound to. Questions: Can I use an array of sc_vectors? Any conventions on using them? eg: can I write sc_vector < sc_signal <bool> > operand_vec[max_operands]; If no, then is there any work around for this? Also, I now need to assemble and bind these ports: The code below doesn't seem to work. Both the stack_cnt_vec and operand_vec are initialized properly. for(int i=0;i<max_operands;i++){ operand_vec[i].init(10); } for(int i=0; i<10; i++) { sc_assemble_vector( stack_cnt_vec, &StackController::operands[i]).bind( operand_vec[i] ); } Thanks a lot for your time.
×
×
  • Create New...