pilipovicn Posted September 14, 2022 Report Share Posted September 14, 2022 I receive an integer from an external API, that is actually a fixed point real value, disguised as int for transport compatibility. I need to convert the integer back into it's fixed point representation. I presume I can convert the int to sc_bv. Then, I would expect sc_fixed to have a constructor accepting a sc_bv, and specify the decimal point place through sc_fixed template. Looking through the source, It seem though that sc_fixed cannot be constructed from a sc_bv. The closest thing I see is the char* constructor (pass bits using sc_bv.to_string() ), but I'm pretty sure that converts a decimal string, not a binary string. In short, is there a simple enough way to convert the bits of an integer (in the form of sc_bv) into a real number (say, float) by specifying the fixed point location in the bit vector? Quote Link to comment Share on other sites More sharing options...
maehne Posted September 16, 2022 Report Share Posted September 16, 2022 How about constructing an sc_fxval from your integer, shifting then its value to the right by the amount of fractional digits and then constructing your sc_fixed variable with fixed number of bits from it? 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.