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
- :
- Re: Why 'pow' cannot be synthesized?

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

nurulhuda

Adventurer

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

12-22-2019 10:40 AM - edited 12-23-2019 12:29 PM

1,589 Views

Registered:
03-30-2018

Hello,

I tried to synthesize my project in HLS using C++ codes. However, the function of 'pow' cannot be synthesized. I tried to synthesize my algorithm using Vivado HLS 2019.2 version, unfortunately, it still gives me the same error as below:

Please, can someone give me any idea how to solve this problem?

1 Solution

Accepted Solutions

jonbho

Observer

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

01-28-2020 08:22 AM

1,247 Views

Registered:
10-23-2019

Hello @nurulhuda,

I can't help you with getting pow() to synthesize, I guess you would need to research into the HLS accelerated math library, but I don't know the details. On the other hand, I have had a look at your code, and there is one very simple thing you can certainly do: in all cases were your code uses pow(), the second argument (the exponent) is 2. That means that you are using pow() to square the first argument, and you can do that without calling pow(), just by multiplying the argument by itself, which HLS will undoubtedly be able to synthesize using one to a few DSP48Es (multiplying double-precision floating point values may require more than one DSP48E).

Here is a version of your code modified in the way I am describing, I haven't tested it but it should compile, synthesize, and run correctly:

//Function to divide void divideComplex(complex<double> J[8], complex<double> fft_G1[8], complex<double> fft_E1[8], int row) { loop7:for (int i = 0; i < row; i++) { double a, b; double re, im, re2, im2, re2im2, inv_re2im2; re = real(fft_E1[i]); im = imag(fft_E1[i]); re2 = re * re; im2 = im * im; re2im2 = re2 + im2; inv_re2im2 = 1.0 / re2im2; a = (((real(fft_G1[i])) * (real(fft_E1[i]))) + ((imag(fft_G1[i])) * (imag(fft_E1[i])))) * inv_re2im2 b = (((real(fft_E1[i]))*(imag(fft_G1[i]))) - ((real(fft_G1[i]))*(imag(fft_E1[i])))) * inv_re2im2; J[i] = complex<double>(a, b); } }

Also notice how I have optimized it in several ways, by calculating repeated values only once, and by doing only one division, since both divisions are by the same denominator, and pre-computing the inverse and multiplying twice is probably going to go faster (but you should always test yourself to verify it, it may be that I am introducing one more delay cycle and that the only savings is in using less area since it's just one division).

Best luck,

-- Jon

8 Replies

drjohnsmith

Teacher

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

12-22-2019 12:37 PM

1,567 Views

Registered:
07-09-2009

https://forums.xilinx.com/t5/High-Level-Synthesis-HLS/hls-pow-function/td-p/791341

<== If this was helpful, please feel free to give Kudos, and close if it answers your question ==>

nurulhuda

Adventurer

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

12-23-2019 12:30 PM

1,500 Views

Registered:
03-30-2018

Dear @drjohnsmith ,

May I know, do you use LINUX?...or is anybody here use LINUX to run Vivado HLS?

drjohnsmith

Teacher

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

12-24-2019 04:07 AM

1,451 Views

Registered:
07-09-2009

but from what I see, the few people that are using HLS are based on Linux,

Its evident from the support answers one sees, that Xilinx are heavily use Linux.

<== If this was helpful, please feel free to give Kudos, and close if it answers your question ==>

nurulhuda

Adventurer

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

01-16-2020 10:09 AM - edited 01-18-2020 01:47 PM

1,339 Views

Registered:
03-30-2018

Hello @drjohnsmith,

I still could not solve the problem with 'pow'. I have tried to run my synthesize in a different version of Vivado such as Vivado version 2018.3, 2019.1, and 2019.2. Unfortunately, it failed.

Then, I tried to synthesize with Linux, and again it failed. Vivado gave me the same error which mentioned that '

Please, do you have any idea what is wrong with my 'pow' function? How am I going to fix it?

//Function to divide void divideComplex(complex<double> J[8], complex<double> fft_G1[8], complex<double> fft_E1[8], int row) { loop7:for (int i = 0; i < row; i++) { double a, b; a = (((real(fft_G1[i])) * (real(fft_E1[i]))) + ((imag(fft_G1[i])) * (imag(fft_E1[i])))) / (pow(real(fft_E1[i]), 2) + pow(imag(fft_E1[i]), 2)); b = (((real(fft_E1[i]))*(imag(fft_G1[i]))) - ((real(fft_G1[i]))*(imag(fft_E1[i])))) / (pow(real(fft_E1[i]), 2) + pow(imag(fft_E1[i]), 2)); J[i] = complex<double>(a, b); } }

Thank you.

jonbho

Observer

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

01-28-2020 08:22 AM

1,248 Views

Registered:
10-23-2019

Hello @nurulhuda,

I can't help you with getting pow() to synthesize, I guess you would need to research into the HLS accelerated math library, but I don't know the details. On the other hand, I have had a look at your code, and there is one very simple thing you can certainly do: in all cases were your code uses pow(), the second argument (the exponent) is 2. That means that you are using pow() to square the first argument, and you can do that without calling pow(), just by multiplying the argument by itself, which HLS will undoubtedly be able to synthesize using one to a few DSP48Es (multiplying double-precision floating point values may require more than one DSP48E).

Here is a version of your code modified in the way I am describing, I haven't tested it but it should compile, synthesize, and run correctly:

//Function to divide void divideComplex(complex<double> J[8], complex<double> fft_G1[8], complex<double> fft_E1[8], int row) { loop7:for (int i = 0; i < row; i++) { double a, b; double re, im, re2, im2, re2im2, inv_re2im2; re = real(fft_E1[i]); im = imag(fft_E1[i]); re2 = re * re; im2 = im * im; re2im2 = re2 + im2; inv_re2im2 = 1.0 / re2im2; a = (((real(fft_G1[i])) * (real(fft_E1[i]))) + ((imag(fft_G1[i])) * (imag(fft_E1[i])))) * inv_re2im2 b = (((real(fft_E1[i]))*(imag(fft_G1[i]))) - ((real(fft_G1[i]))*(imag(fft_E1[i])))) * inv_re2im2; J[i] = complex<double>(a, b); } }

Also notice how I have optimized it in several ways, by calculating repeated values only once, and by doing only one division, since both divisions are by the same denominator, and pre-computing the inverse and multiplying twice is probably going to go faster (but you should always test yourself to verify it, it may be that I am introducing one more delay cycle and that the only savings is in using less area since it's just one division).

Best luck,

-- Jon

nurulhuda

Adventurer

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

02-11-2020 03:42 AM

1,110 Views

Registered:
03-30-2018

nurulhuda

Adventurer

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

02-11-2020 11:12 PM

1,069 Views

Registered:
03-30-2018

jonbho

Observer

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

02-12-2020 03:32 AM

1,048 Views

Registered:
10-23-2019

@nurulhuda great to hear, thanks for letting me know. Very happy to have helped! :)