Jump to content
samng

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?

 

 

Thanks,

Sam

Share this post


Link to post
Share on other sites

Hello,

It appears that you are using MS Visual C++. Please note that MS

Visual C++ has a number of restricted prefixes that cannot be used.

You would have to check the compiler manual for these.

 

Share this post


Link to post
Share on other sites

If you're using the ASI Proof of Concept simulator, have you defined the define that enables fixed point, SC_INCLUDE_FX ?

 

Alan

 

P.S. And of course you can't initialize at declaration in a class!

Edited by apfitch

Share this post


Link to post
Share on other sites

Alan,

 

I did define SC_INCLUDE_FX and sc_fixed type is working fine.

 

Dakupoto,

 

The context switch code if put in functions/methods works fine. It seems that it just don't like it in class declaration.

 

Sam

Share this post


Link to post
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;

public:
  // default constructor
  abc()
    : fxc(FIXPT)
    , fxc_context(fxc)
  {}

// ...
};
 

Greetings from Oldenburg,

  Philipp

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

×