Jump to content
Sign in to follow this  

Recommended Posts

Dear all, 

I am new to payload extensions and I would appreciate a feedback on whether I am doing things right.. 

I need to declare a simple payload extension, including two additional fields: 

  • a reset value 
  • a 16 bit bit vector representing the value of a register

In the header, I simply declare the clone/copy from functions, plus my additional fields:

class reg_extension : public tlm::tlm_extension<reg_extension>{
  
  public:
  
  reg_extension();   

  tlm::tlm_extension_base* clone() const ; 
  
  void copy_from(tlm::tlm_extension_base const &); 
  
  bool reset; 
  sc_bv<16> value; 
 
};

And then I implemented the functions, by taking care of the additional reset and value fields: 

reg_extension::reg_extension(){
  reset = false; 
  value = sc_bv<16>(0); 
}

tlm::tlm_extension_base * reg_extension::clone() const{
  
  cout<<"Executing clone!"<<endl;
  
  reg_extension * ext = new reg_extension();
  ext->reset = this->reset; 
  ext->value = this->value; 
  return ext;
  }

void reg_extension::copy_from(tlm::tlm_extension_base const & ext){
  reset = static_cast<reg_extension const &>(ext).reset;  
  value = static_cast<reg_extension const &>(ext).value;  
}

Is this enough for the extension to work?
Best regards,
S. 

 

Share this post


Link to post
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.

Sign in to follow this  

×
×
  • Create New...