Jump to content

add template class sc_objects to sc_vector with dynamic template arguments


Recommended Posts

Posted

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

Posted

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

Posted

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.

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...