Jump to content

How to share data(a vector) between two modules who can read and write


Prepo

Recommended Posts

I know that sc_fifo allows for one way communication from one module to another. We can also use sc_signal. But I am essentially trying to create a vector of data (like a shared memory) that can be read and written by multiple modules.I can just declare it as a global but looking for some other way so that I can write modular code for testing. Ideally I just want a sc_signal<std:vector<T>> data. But i think that is not supported. Is the option to inherit own class and implement? I just don't want to overlook some inbuilt systemc construct . Isn't it a common requirement?

Link to comment
Share on other sites

Sorry, I thought sc_signal<std::vector<T>> was not supported. I cannot compile it so maybe in newer version? Also sc_vector unfortunately is not suitable for  as my vector is changing in size and dynamic binding will be an issue correct?

Link to comment
Share on other sites

On 3/3/2023 at 11:27 PM, Prepo said:

Sorry, I thought sc_signal<std::vector<T>> was not supported. I cannot compile it so maybe in newer version? Also sc_vector unfortunately is not suitable for  as my vector is changing in size and dynamic binding will be an issue correct?

@Eycksuggestion was sc_core::sc_vector<sc_signal<T>>, there's no std::vector in there and the order is reversed. SystemC objects have special construction requirements that std::vector does not meet. His solution is clean.

Alternately, you could probably specify std::vector's allocator, but that would be much messier. See https://en.cppreference.com/w/cpp/container/vector/vector for details on this approach.

 

Or develop a simple Vector_channel with a simple API (i.e., sc_interface) with methods similar to std::vector<T>. But this too would be slightly messy compared to @Eyck's solution.

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