Jump to content

Tracing for a class which inherits sc_object


sumit_tuwien

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

Link to comment
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

Link to comment
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

Link to comment
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

Link to comment
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

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