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
Did you mean:
Highlighted
Explorer
3,488 Views
Registered: ‎04-23-2014

## Convert Decimal to fixed point

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?

1 Solution

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

## Re: Convert Decimal to fixed point

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.

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

## Re: Convert Decimal to fixed point

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
3,420 Views
Registered: ‎04-23-2014

## Re: Convert Decimal to fixed point

@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.

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