Jump to content

passing size value of sc_fifo in sc_vector


Recommended Posts

I created vector of fifos:

sc_vector<sc_fifo>  fifos;

and in my constructor:
 

template <unsigned S>
class my_chnl : public my_chnl_if, public sc_channel {
  
  sc_vector<sc_fifo> fifos;  //vectors of fifos
  
  
//-----------------------------------------------------------
public:

  //-----------------------------------------------------------
  //constructor
  //-----------------------------------------------------------
  explicit my_chnl(sc_module_name nm, unsigned _size = 4)
    : sc_channel(nm),
      fifos("FIFO")
  {
    fifos.init(S, _size);
  }
  .....

I am getting compile error saying that 

include/sysc/utils/sc_vector.h:634: error: \u2018c\u2019 cannot be used as a function

 

If I do fifos.init(S), it works, but I get default size of 16.  How do I set custom size? Any help?

 

Thanks

Link to post
Share on other sites

It seems you are using the sc_vector<>.init method incorrectly.

As per the source from sc_vector.h you are trying to pass _size as a function pointer (Creator function).

Can you make modifications from:

explicit my_chnl(sc_module_name nm, unsigned _size = 4)
    : sc_channel(nm),
      fifos("FIFO")

to:

explicit my_chnl(sc_module_name nm, unsigned _size = 4)
    : sc_channel(nm),
      fifos("FIFO", _size)

Also sc_fifo is template class what type are you specializing it to?

If you are creating to a vector of sc_fifo of int datatype your declaration should be:

sc_vector<sc_fifo<unsigned int> > fifos;  //vectors of fifos

Regards,

Ameya Vikram Singh

Link to post
Share on other sites

Hi.

If you want to pass arguments to the constructor of the elements of an sc_vector, you need a custom creator. See SystemC LRM IEEE:1666 Section 8.5.5 for details and examples.

A very easy way to realize custom creator by using a Lambda function is presented here:

https://www.researchgate.net/publication/284731273_Automated_SystemC_Model_Instantiation_with_Modern_C_Features_and_sc_vector

 

Greetings

Ralph

Link to post
Share on other sites
  • 3 weeks later...

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