Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

- Community Forums
- :
- Forums
- :
- Software Development and Acceleration
- :
- HLS
- :
- error: use of overloaded operator '*' is ambiguous...

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

nanson

Explorer

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

05-15-2019 02:11 AM

1,518 Views

Registered:
08-31-2017

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

1 Solution

Accepted Solutions

u4223374

Advisor

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

05-15-2019 03:39 AM

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.

2 Replies

u4223374

Advisor

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

05-15-2019 03:39 AM

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.

nanson

Explorer

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

05-15-2019 04:28 AM

1,496 Views

Registered:
08-31-2017

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