DavidC Posted May 14 Report Share Posted May 14 Hi, I have a trivial piece of code that looks a bit like this: sc_bigint<N+1> p; // Signed sc_biguint<N> q, r; // Unsigned for(i=1; i<L; i++) { ..... /* some logic */ r = test ? p.range(i, 0) : q.range(i, 0); } However it won't compile as I get this error: Quote operands to ?: have different types 'sc_dt::sc_signed_subref' and 'sc_dt::sc_unsigned_subref' I have to say I'm a bit disconcerted because (in my mind at least), the bit-slicing operation using the .range() operator returns a bit-pattern without any clearly defined interpretation (so I don't expect concepts such as a "signed" bit-pattern and an "unsigned" bit-pattern to even exist). One question is of course the motivation for defining these concepts. Though I'm curious and interested to hear about it, I suppose there is a good reason for doing that and it is not the main point that I'm interested in. The question I'm mostly interested in, is very practical: what is the clean way to get the code to compile with the desired effect ? Thanks ! Quote Link to comment Share on other sites More sharing options...
DavidC Posted May 14 Author Report Share Posted May 14 I guess I was a bit tired when asking that question... The practical solution is as trivial as a cast it seems: r = test ? (sc_biguint<N>)p.range(i, 0) : q.range(i, 0); Having said that, I'm still curious to understand why this cast is necessary at all. In fact, the very same code based on sc_int / sc_uint rather than sc_bigint / sc_biguint works perfectly well without any cast. Why does the .range() operator return signed/unsigned patterns when applied to sc_bigint, but not when applied to sc_int ? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.