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

error: use of overloaded operator '*' is ambiguous: Constant multiplier with ap_fixed data type

Jump to solution

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?

typedef ap_fixed<8,2> data_t;
data_t in,out;

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

0 Kudos
1 Solution

Accepted Solutions
u4223374
Advisor
Advisor
1,505 Views
Registered: ‎04-26-2015

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.

View solution in original post

2 Replies
u4223374
Advisor
Advisor
1,506 Views
Registered: ‎04-26-2015

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.

View solution in original post

nanson
Explorer
Explorer
1,496 Views
Registered: ‎08-31-2017

@u4223374 

Thanks for your comment. I've understood what mistake I made in the case.

0 Kudos