cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
smileworker2012
Visitor
Visitor
3,638 Views
Registered: ‎06-05-2013

How to use pow function in HLS with C?

Jump to solution

Hello,

      I dad write "#include <math.h>" in my code. However there's still the error " math function 'pow' is not supported for synthesis".Which C library shoud I choose or whice function shoude I use to get number's power?

     I tried to write the pow function myself to get the power of 2 ,codes like:

     

            int power_func(int n)
            {
                   int power=1,k;

                   for(k=0;k<=n-1;k++)

                   {
                          power=power*2;

                   }
                  return power;
             }

      The trip count and lentancy both are "?". Maybe because n is an variable.

   

      What can I do for the power?

 

      Thanks a lot!

0 Kudos
1 Solution

Accepted Solutions
muzaffer
Teacher
Teacher
4,470 Views
Registered: ‎03-31-2012
Do some algebra:
By definition pow(x,y) = exp(y*log(x)).

Both exp and log are available for synthesis.
- Please mark the Answer as "Accept as solution" if information provided is helpful.
Give Kudos to a post which you think is helpful and reply oriented.

View solution in original post

0 Kudos
2 Replies
muzaffer
Teacher
Teacher
4,471 Views
Registered: ‎03-31-2012
Do some algebra:
By definition pow(x,y) = exp(y*log(x)).

Both exp and log are available for synthesis.
- Please mark the Answer as "Accept as solution" if information provided is helpful.
Give Kudos to a post which you think is helpful and reply oriented.

View solution in original post

0 Kudos
smileworker2012
Visitor
Visitor
3,624 Views
Registered: ‎06-05-2013

Thank you!

0 Kudos