flashman
-
Posts
3 -
Joined
-
Last visited
Content Type
Profiles
Forums
Downloads
Events
Posts posted by flashman
-
-
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!
-
Hi all,
I'm struggling to figure out the difference between peqs. I wrote my own codes but I don't see any usage case difference.
Let me to show a simple example for a Target (not a real code but some portions).
PEQ WITH GET:
In this case along fw path, transaction is inserted in the peq, triggers an event at delay_time.
struct Target : sc_module { // DEFINE A PEQ peq_with_get<tlm_generic_payload> peq_target; // DEFINE A THREAD TO TRIGGER PEQ EVENTS void target_thread(); }; tlm_sync_enum Target::nb_transport_fw(tlm_generic_payload& trans, tlm_phase& phase, sc_time& delay) { // GET TRANSACTION // ANNOTATE DELAY TIME REGARDING PROTOCOL delay_time=... // INSERT IN THE PEQ peq_target.notify(trans, delay_time); ... ... return TLM_UPDATE; }; void Target::target_thread(.....) { while(true) { wait(peq_target.get_event()); // GET TRANSACTION! trans = peq_target.get_next_transaction(); // PROCESS TRANSACTION // send response, wait........ } };
peq_with_cb_and_phase:
In this case along fw path, transaction is inserted in the peq and after a delay_time triggers a cb.
struct Target : sc_module { // DEFINE A PEQ peq_with_cb_and_phase<Target,tlm_generic_payload> peq_target; // DEFINE A THREAD TO TRIGGER PEQ EVENTS void target_cb(); }; // Constructor connect peq to cb Target::Target (......) : peq_target("peq_target", this, &Target::target_cb()) { } tlm_sync_enum Target::nb_transport_fw(tlm_generic_payload& trans, tlm_phase& phase, sc_time& delay) { // GET TRANSACTION // ANNOTATE DELAY/PHASE TIME REGARDING PROTOCOL delay_time=... // INSERT IN THE PEQ peq_target.notify(trans, phase,delay_time); ... ... return TLM_UPDATE; }; void Target::target_cb(.......) { // Triggered from peq calling target_cb at delay_time // Manage Transaction and response return TLM..... }
What is the difference ? Can you show me or indicate an example of what can be do with one and can not be do with other ?
Sincerely I don't understand.
Thank you in advance.
Accessing to a shared variable
in SystemC TLM (Transaction-level Modeling)
Posted
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.