inspire Posted January 12, 2016 Report Posted January 12, 2016 Hi, is it possible to add sc_modules with template arguments to a sc_vector where the template argument is dynamic? What I mean is this: sc_vector<Shift_register_nBit<?, ?>> shift; SC_HAS_PROCESS(myModule); myModule(sc_module_name) : shift("shift") { for (int i = 0; i < 5; ++i) shift.add(Shift_register_nBit<i, 2>); } I also tried to use sc_vector<Shift_register_nBit*> shift; but this didn't work. Do you have an idea? Thanks! inspire Quote
ralph.goergen Posted January 14, 2016 Report Posted January 14, 2016 Hi, template arguments are required to be compile time constant in C++. So: you will not be able to instantiate template objects with template arguments depending on a loop counter, not with sc_vector and not without it. Greetings Ralph Quote
dakupoto Posted January 17, 2016 Report Posted January 17, 2016 Hi, is it possible to add sc_modules with template arguments to a sc_vector where the template argument is dynamic? What I mean is this: sc_vector<Shift_register_nBit<?, ?>> shift; SC_HAS_PROCESS(myModule); myModule(sc_module_name) : shift("shift") { for (int i = 0; i < 5; ++i) shift.add(Shift_register_nBit<i, 2>); } I also tried to use sc_vector<Shift_register_nBit*> shift; but this didn't work. Do you have an idea? Thanks! inspire Hello Sir, First of all, what is the benefit of using a complicated data structure as a vector of vectors ? Since any design would involve a fixed number of shift registers(bit vectors anyway), maybe the wisest option would be to have a fixed number of shift registers and manipulate them separately, How would one deal with the case when some data is to be written to, e.g., shift register number 3. With separate shit registers, shift register 3 is identified right away, whereas with a vector of vectors, one has to first locate shift 3 inside the container vector, and then write to it. Secondly, as SystemC is a C++ library, and the STL library does support the vector of vectors data structure -- but initializing and reading/writing data from/to is a messy operation. I personally would not get into that mess, and focus more on solving the design problem at hand. Hope that helps. 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.