Jump to content

Recommended Posts

Posted

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.

 

 

  • 6 months later...
Posted

peq_with_cb_and_phase - has a call back attached. (ie) When the time has expired, a call back function is triggered. You can then process the transaction in the call back function.

The call back function also gives the phase. say, the current call back has a phase AR_READY --> you can then do the processing of the state machine for AR_READY.

 

From the LRM:

"Transactions emerge in different ways from the two PEQ variants. In the case of peq_with_get, the method

get_event returns an event that is notified whenever a transaction is ready to be retrieved. The method
get_next_transaction should be called repeatedly to retrieve any available transactions one at a time.
 
In the case of peq_with_cb_and_phase, a callback method is registered as a constructor argument, and that
method is called as each transaction emerges. This particular PEQ carries both a transaction object and a phase
object with each notification, and both are passed as arguments to the callback method."
 
 
For example on how this is to be used - you can refer;

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