Tuesday, July 19, 2011

sc_trace for enumerated types in SystemC

I been struggling for awhile now with getting sc_trace overloading to work for enumerated types in SystemC. After finding this post and reading how sc_trace work, I worked out a solution and tested it. It works! So hopefully, this post will help others:

Here's a cut down custom object type with a working sc_trace with an enumerated type:

typedef enum { IDLE = 0, BUSY } state_t;

class MyType {
 unsigned info;
 state_t  flag;
 ...
 inline friend void sc_trace(
  sc_trace_file *tf, 
  const MyType & v,
  const std::string & NAME ) {
  int* iflag = (int*) &(v.flag);
  sc_trace(tf, v.info, NAME + ".info");
  sc_trace(tf, *iflag, NAME + ".flag");
 };
};

No comments:

Post a Comment