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

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...