Jump to content
Ganesan R

How to create an array of sc_module objects

Recommended Posts

I understand that an array of sc_module objects cannot be created even in a vector as sc_ctor requires a char* argument.

For example suppose that fifog is defined as sc_module object.

Then sc_vector<fifog>fifog("fifogarray",4) will not create an array four of fifog object as fifogarray is not a unique name.

My VS2012 throws a warning that object fifogarray already exists on subsequent loops and instead names the instances as fifogarray[0], fifogarray[1] etc.

Moreover if fifog contains sc_processe sc_method functions, how they can be invoked on each unique instances of object?

Even if I ignore that VS2012 warning, will the sc_method operate on each object instance individually?

Pl. help. Eager to go through your replies.

Simple example will help as I am newbie both to C++ and SystemC.

 

 

 

 

Share this post


Link to post
Share on other sites

Hello @Ganesan R,

It seems you are trying to achieve the vector of vector instance, something like this:

sc_vector < sc_vector < your module > >

You can find necessary discussion on this here: http://forums.accellera.org/topic/5616-initialization-of-nested-sc_vector-sc_vector/

Without sample code it is very difficult to discern the scenario you are trying to replicate.

Can you provide some minimal sample code?

Regards,

Ameya Vikram Singh

Share this post


Link to post
Share on other sites

Somehow I was able to get this work.

But I have only one difficulty right now: How to access the member of individual class object in the attached file

It is sc_vector of fifog elements of four.

fifo_pointer should be accessible in c++ like this.

What is the problem with me?

fifog32[0].fifo_pointer

Any help will be deeply appreciated as I am heavily struck up.

R. Ganesan

(Pl. ignore earlier post I was able to get new sc_vector(fifog,4) with constant size)

 

fifog_15May_end_mod.txt

Share this post


Link to post
Share on other sites

Hi,

it seems you lack a basic understanding of C/C++ visibility of variables. As fifog32 is declared a local variable in sc_main you can only access it in sc_main, it is unknow in any other function.

BR

Share this post


Link to post
Share on other sites

Thanks Eyck that helped

Suppose sc_vector<fifog>fifog32("fifog32",4) is declared in SC_main 

fifog constructor is called four times

But fifog32[0].FIFO_pointer is not working even in SC_main

How to get fifog32[0].FIFO_pointer?

Eager n thanking you

 

 

 

 

 

 

 

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

×