UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Explorer
Explorer
3,488 Views
Registered: ‎04-23-2014

Convert Decimal to fixed point

Jump to solution

I have coefficients to use for filtering and I would like to convert them into fixed point (hoping that it will decrease the implementation resources):

const ap_ufixed<125,1,AP_TRN_ZERO,AP_SAT> H[256] = {
... 0.00000000000000000000091449017339064687, 0.00000000000000000000062116230274780313, 0.00000000000000000000042127263672158805, 0.00000000000000000000028526830531801544, 0.00000000000000000000019287498479639181
...
};

Is this an acceptable way to define an array, or I have to explicitly convert the coefficients to fixed point numbers. If conversion is necessary, then how to do that?

0 Kudos
1 Solution

Accepted Solutions
Scholar jprice
Scholar
6,134 Views
Registered: ‎01-28-2014

Re: Convert Decimal to fixed point

Jump to solution

Given that, that should work but you'll find pretty heavy DSP usage though overall less logic resources (I think, I never tried arithmetic with coefficients that large that weren't floating point). Your syntax is correct, I do that with smaller bit widths frequently. 

View solution in original post

0 Kudos
4 Replies
Scholar jprice
Scholar
3,456 Views
Registered: ‎01-28-2014

Re: Convert Decimal to fixed point

Jump to solution

To answer your actual question, that should work fine. However looking at your bit widths (125) I suspect you'll end up using way more resources than you care to. However looking at your examples I don't know if you need that many bits. I'd normalize your coefficients and try a few different bit widths and pick smaller ones that still perform acceptably. What kind of a filter is this? 

Explorer
Explorer
3,420 Views
Registered: ‎04-23-2014

Re: Convert Decimal to fixed point

Jump to solution

@jprice I am trying to implement a bilateral filter. The coefficients that you saw are the smallest five: they are normalized and the range is 10^-22 : 1. I may be able to decrease the precision, but first I want to succeed with full precision.

0 Kudos
Scholar jprice
Scholar
6,135 Views
Registered: ‎01-28-2014

Re: Convert Decimal to fixed point

Jump to solution

Given that, that should work but you'll find pretty heavy DSP usage though overall less logic resources (I think, I never tried arithmetic with coefficients that large that weren't floating point). Your syntax is correct, I do that with smaller bit widths frequently. 

View solution in original post

0 Kudos
Explorer
Explorer
3,406 Views
Registered: ‎04-23-2014

Re: Convert Decimal to fixed point

Jump to solution
Yep, I decreased width from 125 to 24 bit and it has a similar effect. At least, now the implementation fits on the device.
0 Kudos