Jump to content

array of sc_fifo


David Peng

Recommended Posts

Hi, 

I wonder any way to implement an array of sc_fifo with different depth.

I wrote below demo code:

sc_fifo<SomeClass> *s1;

n=4;

s1 = new sc_fifo<SomeClass>[n];

for (int i = 0; i < n; i++) {

  s1[n] = sc_fifo<SomeClass>(("FIFO_"+std::to_string(i)).c_str(), i*1024);

}

It failed that object of type sc_fifo<SomeClass> cannot be assigned because its copy assignment operator is implicitly deleted.

Any suggestion? Or I have to use sc_vector?

Thanks,

David

 

Link to comment
Share on other sites

In your case you have to use the plcaement-new as described here: https://en.cppreference.com/w/cpp/language/new

I would suggets to use C++14 constructs:

std::array<std::unique_ptr<sc_fifo<SomeClass>>, 4> s1;

for(size_t i = 0U; i < n; i++) {
  s1[i] = std::make_unique<sc_fifo<SomeClass>>("FIFO_"+std::to_string(i)).c_str(), i*1024);
}

This one manages the life time of your created objects...

Link to comment
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...