Jump to content

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?

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

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