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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×