Jump to content
inspire

add template class sc_objects to sc_vector with dynamic template arguments

Recommended Posts

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

Share this post


Link to post
Share on other sites

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! smile.png

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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×