Jump to content
Frank Poppen

This is not an option: "scv_smart_ptr<sc_fix>" ?

Recommended Posts

I found a bug in my legacy code that I needed to fix. Even though the bug was easily found the fix troubles me due to limitations of SCV. I have a (template) function "randomRangeEval"() which uses an scv_smart_ptr to choose a random value from a range ...

template<typename T>       // T expected to be double, sc_fix or sc_ufix
  std::string randomRangeEval(T rangeStart, T rangeEnd) {
  ...
  scv_smart_ptr< int > randomRangeValue;
  ...
  randomRangeValue->keep_only(rangeStart, rangeEnd);
  randomRangeValue->next();

... using the "int" does of course only work for sc_fix/sc_ufix with limited bit width. The bug became apparent when working with bitwidth greater than that of "int". So what would fix the problem is the use of ...

  scv_smart_ptr< T > randomRangeValue;   // where T is either the same sc_fix or sc_ufix as the range defined

... unfortunately I receive the problem at "randomRangeValue->keep_only" which is ...
 
  error: 'class scv_extensions<sc_dt::sc_fix>' has no member named 'keep_only'
 
As I see from the code of SCV it seems that only allowed is ...

  bool
  char
  unsigned char
  short
  unsigned short
  int
  unsigned int
  long
  unsigned long
  long long
  unsigned long long
  float
  double
  string

... not ...
  sc_fix
  sc_ufix
 
... but even "long long" is not enough as I could have an sc_fix with let's say 96 bits. Any ideas?

Share this post


Link to post
Share on other sites

This is a known limitation, we ran into this issue last year too. If you look closely you will find commented macros in the scv_extensions mentioning sc_fixed and sc_ufixed. However, uncommenting these entry will not work as these seem to be leftovers from the early implementation dating back to around 2000 when first commits were publicly recorded. You will probably have to find a workaround for that at the moment. Adapting the scv_extensions does not look too trivial.

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

×