05-15-2019 02:11 AM
Hi,
I wrote the following code for constant multiplier. The in and out are ap_fixed data type.
However, it fired the following error. What's the best practice to design constant multiplier in HLS?
out = (in * 0.004) + 0.984;
ERROR: [HLS 200-70] Compilation errors found:
Pragma processor failed: ../HLS_templates/const_mul/src/const_mul.cpp:23:19: error: use of overloaded operator '*' is ambiguous (with operand types 'data_t' (aka 'ap_fixed<8, 2>') and 'double')
out = (in * 0.004) + 0.984;
~~ ^ ~~~~~
/opt/Xilinx/Vivado_HLS/2017.2/include/etc/ap_fixed_sim.h:2745:1: note: candidate function [with _AP_W = 8, _AP_I = 2, _AP_S = true, _AP_Q = 5, _AP_O = 3, _AP_N = 0]
AF_OPS_WITH_INT(bool, 1, false)
Thanks
05-15-2019 03:39 AM
You have to decide what behaviour you want. Do you want HLS to:
(1) Turn "in" into a double, perform the multiplication in 64-bit double precision floating-point, and then turn the result back into fixed-point?
(2) Turn 0.004 into an ap_fixed<8,2> value and perform the multiplication there?
(3) Turn 0.004 into another fixed-point format (eg. one with more bits to improve accuracy), do the multiplication, and turn the result back into ap_fixed<8,2>?
The first is the most accurate - and by far the largest and slowest option. The second will be very fast and cheap, but the best representation of 0.004 you can get in ap_fixed<8,2> is zero - so this might not generate appropriate results. The third is a trade-off, depending on how many bits you specify.
05-15-2019 03:39 AM
You have to decide what behaviour you want. Do you want HLS to:
(1) Turn "in" into a double, perform the multiplication in 64-bit double precision floating-point, and then turn the result back into fixed-point?
(2) Turn 0.004 into an ap_fixed<8,2> value and perform the multiplication there?
(3) Turn 0.004 into another fixed-point format (eg. one with more bits to improve accuracy), do the multiplication, and turn the result back into ap_fixed<8,2>?
The first is the most accurate - and by far the largest and slowest option. The second will be very fast and cheap, but the best representation of 0.004 you can get in ap_fixed<8,2> is zero - so this might not generate appropriate results. The third is a trade-off, depending on how many bits you specify.
05-15-2019 04:28 AM
Thanks for your comment. I've understood what mistake I made in the case.