Jump to content

Recommended Posts

Hi 

I am trying to understand the max_num_extension() return value. When I create a payload object and use set_extension and then call max_num_extensions(), then  it returns 2. 

I tried to debug and noticed that even if we didn't have any module, it still gives 2. The following piece of code prints 2. why it is so ?

//#include "top.hpp"
#include "tlm.h"
#include "systemc.h"
int sc_main(int argc, char** argv){
    std::cout<<tlm::max_num_extensions()<<std::endl;
    sc_start();
	return 0;
}

LRM@496 syas "The function max_num_extensions shall return the number of extension types, that is, the size of the extension array. As a consequence, the extension types shall be numbered from 0 to max_num_extensions()-1".

Thanks

Khushi

 

Share this post


Link to post
Share on other sites

Each type of extension has an automatically assigned ordinal number which is available per extension as ID in the base class tlm_extension. So in your case you have 2 tlm_extensions defined somewhere.

Under the hood this ID is used as an index into the m_extension array of the tlm::generic_payload.

Best

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.


×
×
  • Create New...