Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

std::array and sc_core::sc_fifo #58

Open
adrian-yehe opened this issue Sep 2, 2023 · 1 comment
Open

std::array and sc_core::sc_fifo #58

adrian-yehe opened this issue Sep 2, 2023 · 1 comment

Comments

@adrian-yehe
Copy link

"Define a group of FIFOs, std::array<sc_core::sc_fifostd::uint64_t, 6> mCmdFifo.", Unable to change FIFO init, So I suggest adding methods to set FIFO depth and name to sc_fifo class;

@pah
Copy link
Contributor

pah commented Dec 13, 2023

Calling the default constructor of SystemC objects is not recommended, as you lack a meaningful name for the objects.
I would recommend to use sc_vector instead of std::array:

sc_core::sc_vector<sc_core::sc_fifo<uint64_t> SC_NAMED(mCmdFifo);

SC_CTOR(...) {
  int fifo_size = 5;
  mCmdFifo.init(6, [=](const char* name, size_t) { return new sc_core::sc_fifo<uint64_t>(name, fifo_size); }); 
}

Alternatively, you can use the new emplace_back function in IEEE 1666-2023 (aka SystemC 3.0) to construct individual instances explicitly (instead of calling init with a lambda):

  for(int i = 0; i < 6; ++i)
    mCmdFifo.emplace_back(fifo_size); // name will be implicitly passed as first parameter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants