enchanter Posted May 28, 2014 Report Share Posted May 28, 2014 I try to define a sc_vector like this in SC_MODULE sc_vector<sc_signal<sc_uint<C_WIDTH> > > sDin("sDin", C_SIZE); Then I got this error: expected identifier before string constant sc_vector<sc_signal<sc_uint<C_WIDTH> > > sDin("sDin", C_SIZE); ^ I am not sure what is missing from there. Quote Link to comment Share on other sites More sharing options...
dakupoto Posted May 29, 2014 Report Share Posted May 29, 2014 I try to define a sc_vector like this in SC_MODULE sc_vector<sc_signal<sc_uint<C_WIDTH> > > sDin("sDin", C_SIZE); Then I got this error: expected identifier before string constant sc_vector<sc_signal<sc_uint<C_WIDTH> > > sDin("sDin", C_SIZE); ^ I am not sure what is missing from there. Hello Sir, SystemC vectors are derived from ANSI C++ STL vectors. The following are how some STL vectors might be declared, defined and initialized. std::vector<int> first; /* empty vector of intwgwrs */std::vector<int> second (4,100); /* four integers with value 100 */std::vector<int> third (second.begin(),second.end()); /* iterating through second */std::vector<int> fourth (third); /* a copy of third *//* the iterator constructor can also be used to construct from arrays: */int myints[] = {16,2,77,29};std::vector<int> fifth (myints, myints + sizeof(myints) / sizeof(int) ); Hope this helps. Quote Link to comment Share on other sites More sharing options...
Philipp A Hartmann Posted May 29, 2014 Report Share Posted May 29, 2014 I try to define a sc_vector like this in SC_MODULE sc_vector<sc_signal<sc_uint<C_WIDTH> > > sDin("sDin", C_SIZE); Your problem is not specific to sc_vector, but to C++ in general: You can't initialize a member of an SC_MODULE (or any other C++ class) in the body of the class itself. You need to do it in the constructor, using an initializer list: SC_MODULE(mod) { sc_vector<sc_signal<sc_uint<C_WIDTH> > > sDin; SC_CTOR(mod) : sDin("sDin", C_SIZE) // C++ initializer list { // ... } }; Greetings from Oldenburg, Philipp Quote Link to comment Share on other sites More sharing options...
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.