flashman Posted May 6, 2016 Report Share Posted May 6, 2016 Hi all. I'm testing some codes to better understanding tlm. In this moment I have a block with this variable : std::map <tlm::tlm_generic_payload*, unsigned int> queue; Basically a place when I store my transactions using trans pointer as key. This variable is accessed by 2 threads. On as input and one as output. Input is fast, output is slow. Threads Input wait until a location (I check my max size) is free and fill it. In system C I used sc_mutex to check lock and check it every X ns (wait(X,SC_NS)). In tlm I don't want to used fixed time but wait until a location is free. Is there a simple approach to do this or I need to use sc_mutex or similar to share variable among multiple process ? Thanks for every suggestion. I need it! Quote Link to comment Share on other sites More sharing options...
kartikkg Posted May 13, 2016 Report Share Posted May 13, 2016 Hi please see sc_fifo for your requirement. sc_fifo provides both blocking & non-blocking calls . Blocking call will wait until a slot is free. Quote Link to comment Share on other sites More sharing options...
flashman Posted May 17, 2016 Author Report Share Posted May 17, 2016 Thank you Kartik for your suggestion. sc_fifo match my requirements for sharing but I need to remove every element in every order. This is why I choosed std::map with a key. I insert my elements and remove in every order. Only at start of simulation I fill my queue in order. Quote Link to comment Share on other sites More sharing options...
tjroamer Posted August 1, 2016 Report Share Posted August 1, 2016 Thank you Kartik for your suggestion. sc_fifo match my requirements for sharing but I need to remove every element in every order. This is why I choosed std::map with a key. I insert my elements and remove in every order. Only at start of simulation I fill my queue in order. for your case, I would choose to design a primitive channel to realize your requirement. This channel should be very similar to the sc_fifo, except that the element can be read/written with a given index or a specific order. I don't think using the build-in language elements to do this is a elegant way, since you may be changing the semantics of these elements. To implement it, just take a look at the sc_fifo implement. /Kenny Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.