cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
10,046 Views
Registered: ‎06-05-2013

How to use pow function in HLS with C?

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!

 

 

Tags (1)
0 Kudos
5 Replies
Highlighted
Instructor
Instructor
10,043 Views
Registered: ‎07-21-2009

Re: How to use pow function in HLS with C?

This is not a forum for technical questions.  This is the forum for discussing the forum design and usage.

 

-- Bob Elkind

SIGNATURE:
README for newbies is here: http://forums.xilinx.com/t5/New-Users-Forum/README-first-Help-for-new-users/td-p/219369

Summary:
1. Read the manual or user guide. Have you read the manual? Can you find the manual?
2. Search the forums (and search the web) for similar topics.
3. Do not post the same question on multiple forums.
4. Do not post a new topic or question on someone else's thread, start a new thread!
5. Students: Copying code is not the same as learning to design.
6 "It does not work" is not a question which can be answered. Provide useful details (with webpage, datasheet links, please).
7. You are not charged extra fees for comments in your code.
8. I am not paid for forum posts. If I write a good post, then I have been good for nothing.
0 Kudos
Highlighted
10,030 Views
Registered: ‎06-05-2013

Re: How to use pow function in HLS with C?

Oh, I'm so sorry!
0 Kudos
Highlighted
Moderator
Moderator
9,995 Views
Registered: ‎04-17-2011

Re: How to use pow function in HLS with C?

Moving to HLS forum.
Regards,
Debraj
----------------------------------------------------------------------------------------------
Kindly note- 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.
----------------------------------------------------------------------------------------------
0 Kudos
Highlighted
Moderator
Moderator
9,992 Views
Registered: ‎04-17-2011

Re: How to use pow function in HLS with C?

math.h pow is not supported.
Regards,
Debraj
----------------------------------------------------------------------------------------------
Kindly note- 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.
----------------------------------------------------------------------------------------------
0 Kudos
Highlighted
Moderator
Moderator
9,981 Views
Registered: ‎04-17-2011

Re: How to use pow function in HLS with C?

Additional Info for : The trip count and latency both are "?".

When variable loop bounds are present, Vivado HLS reports the latency as a question mark
(?) instead of using exact values.


The first problem with variable loop bounds is therefore that the performance of the design
is unknown.


The two ways to overcome this problem are:
• Use the Tripcount directive. 
• Use an assert macro in the C code.

 

Refer http://www.xilinx.com/support/documentation/sw_manuals/xilinx2013_4/ug902-vivado-high-level-synthesis.pdf on how to do those two things.

Regards,
Debraj
----------------------------------------------------------------------------------------------
Kindly note- 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.
----------------------------------------------------------------------------------------------
0 Kudos