Jump to content

sc_fxcast_switch in class


Recommended Posts

I am trying to implement float and fixed and point computation using the same code using sc_fixed<> and type casting sc_fxcast_switch().


For this, I created a class template and added the type casting code:



template <sc_switch FIXPT> class abc {

  sc_fxcast_switch  fxc(FIXPT);

  sc_fxcast_context fxc_context(fxc);


  // members

  sc_fixed<....> a, b, c;





However, the compiler does not seem to like having the type casting code in class declaration, error in VS2010:


error C2061: syntax error : identifier 'fxc'



Can sc_fxcast_context/switch be members of a class? If not, how do you control the cast switch sc_fixed<> members?





Link to comment
Share on other sites

As Alan said, you can't initialize a class member within the body of the class definition in C++ (not SystemC specific).  You need to write a constructor instead.  Something like:


template <sc_switch FIXPT>
class abc
  sc_fxcast_switch  fxc;
  sc_fxcast_context fxc_context;

  // members
  sc_fixed<....> a, b, c;

  // default constructor
    : fxc(FIXPT)
    , fxc_context(fxc)

// ...

Greetings from Oldenburg,


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.

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...