cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Explorer
Explorer
914 Views
Registered: ‎08-31-2017

Is there any way to print 2's complement value in HLS C/C++ ?

Hi, dear HLS elites,

 

 I'm exploring how to print 2's complement value for variables declared as ap_fixed in HLS C/C++. Now I only can write the following HLS code to print the ap_fixed type variables as binary with signed value shown below. However, it's not straightforward for debugging. Do you know if it's possible to print the value of ap_fixed variable as 2's complement in Vivado HLS ?   Thanks

 

 

 

    ap_fixed<28,6> z0 = 3.88497;
    ap_fixed<28,6> z1 = 0.0655045;
    ap_fixed<28,6> z2 = -1.27166;
    printf("%s %s %s\n",z0.to_string(2).c_str(),z1.to_string(2).c_str(),z2.to_string(2).c_str());

 

0b011.1110001010001101011001 0b0.0001000011000100111001 -0b01.0100010110001011100001

 

All the best,

Nan-Sheng

0 Kudos
Reply
0 Replies