Jump to content
sumit_tuwien

Tracing for a class which inherits sc_object

Recommended Posts

Hello All,

I wrote a class as follows:


# ifndef ALLESGUTE_H_
# define ALLESGUTE_H_

# include <cstdint>
# include <systemc>

template <
            typename T
         >
class allesGute final 
   :   public sc_core::sc_object
{
private :
   T                 vData          ;
   T                 someOtherVData ;

public :

   explicit
   allesGute(const char* name_)
      :   sc_core::sc_object { name_ }
      ,   vData              { 0     }
   {}

   const char* kind() const override 
   {
      return  "allesGute" ;
   }

// Helpers :
   T read() const
   {
      return vData ;
   }

   void write(const T& var_)
   {
      vData = var_ ;
   }


  ~allesGute() final                            =   default ; 
   allesGute(const allesGute& other)            =   delete  ;
   allesGute& operator=(const allesGute& other) =   delete  ; 
   allesGute(allesGute&& other)                 =   delete  ;
   allesGute&& operator=(allesGute&& other)     =   delete  ; 


};


# endif

How shall I register vData with tracing system ?

Thanks in advance,

Regards,

Sumit

Share this post


Link to post
Share on other sites

Hello @sumit_tuwien,

You can declare the sc_trace method as a friend function.

Here is a small sample of what it might look like:

# ifndef ALLESGUTE_H_
# define ALLESGUTE_H_

# include <cstdint>
# include <systemc>

template <
            typename T
         >
class allesGute final 
   :   public sc_core::sc_object
{
private :
   T                 vData          ;
   T                 someOtherVData ;

public :

   explicit
   allesGute(const char* name_)
      :   sc_core::sc_object { name_ }
      ,   vData              { 0     }
   {}

   const char* kind() const override 
   {
      return  "allesGute" ;
   }

// Helpers :
   T read() const
   {
      return vData ;
   }

   void write(const T& var_)
   {
      vData = var_ ;
   }


  ~allesGute() final                            =   default ; 
   allesGute(const allesGute& other)            =   delete  ;
   allesGute& operator=(const allesGute& other) =   delete  ; 
   allesGute(allesGute&& other)                 =   delete  ;
   allesGute&& operator=(allesGute&& other)     =   delete  ; 
  
  // Friend function declaration.
  // Don't inline the definition since you might face issues later due to aggressive compiler optimizations.
  friend void sc_trace(sc_core::sc_trace_file *tf, const allesGute<T>& tObj, const std::string& name);
};

// Friend function definition.
template<typename T>
void sc_trace(sc_core::sc_trace_file *tf, const allesGute<T>& tObj, const std::string& name)
{
  // Assuming the type T is traceable type.
  // If not then you'll have to implement the sc_trace friend function for type T.
  sc_trace(tf, tObj.vData, name + "_vData");
  sc_trace(tf, tObj.someOtherVData, name + "_someOtherVData");
}

# endif

 

Let me know if this helps.

Regards,

Ameya Vikram Singh

Share this post


Link to post
Share on other sites

Hello Ameya,

 

I tried earlier this way and it did not work. In fact I need to register this with any kind of tracing (for EDA vendor specific too).

With your solution it does not work too.

Share this post


Link to post
Share on other sites

Hello @sumit_tuwien,

If you can elaborate the use-case more, it would be better.

It seems you are trying to implement your own channel interface, if my assumptions are right.

If you are just looking for custom datatype which you need to push through the sc_in/out interface then this might not be required at all.

Let us know.

Regards,

Ameya Vikram Singh

Share this post


Link to post
Share on other sites

Actually not.

I am trying to create my own custom data types which can be used in a module (for some particular reason) or channel or anywhere else. I want to benefit maximally from these data types by making them visible to tracing mechanism.

 

The detail implementation of these datatypes has not been shown for confidentiality reasons.

 

Regards,

Sumit

Share this post


Link to post
Share on other sites

Dear Sumit,

I fear that there's no universal solution to register your datatype for any kind of tracing mechanism. You will have to implement the interfaces of each tracing mechanism separately (i.e., SystemC's sc_trace() and SystemC AMS's sca_trace() + all the vendor tools, which don't use the standard mechanism) for your datatype. Be aware that the semantics of tracing may differ from the context, where you use your data type.

Regards,

Torsten

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

×