Thread Subject: Fixed Point Toolbox: Value of Accumulator and Product wordlengths

Subject: Fixed Point Toolbox: Value of Accumulator and Product wordlengths

From: Anindya G

Date: 25 Aug, 2009 17:16:04

Message: 1 of 2

Hello,

1. I am trying to simulate a fixed-point bit-true model of my FPGA/VHDL design in MATLAB. The design consists of a series of FIR filters.

2. The input is 16-bit and filter coefficients are also 16-bit signed integers. While using the fixed-point toolbox in MATLAB, it asked me to specify the bit-lengths of the Accumulator and Product integer and fractional parts. I chose the defaults - (31,30) and (32,30) for the Product and the accumulator respectively. I kept output bit lengths as (16,15).

3. After running the qreport on the logged output of the first filter, I fished for the the actual lengths of the integer parts in the qreport and calculated the fractional parts of the Output, Accumulator and the Product. Here, to calculate the fractional part of fixedpoint object, say the Product, of the fixed-point filter hf, I used the following formula which I found in one of the fixed-point webinars on the Mathworks website:

R = qreport(hf)
A = max(abs(double(R.Product.Min)), abs(double(R.Product.Max)));
integer_part = ceil(log2(A));
ProductFracLength = hf.ProductWordLength - integer_part - 1;

4. Through this process, I got the new values of lengths of the Product, Accumulator and the Output as follows:
Product: 32, 32
Accumulator: 32, 31
Output: 16, 16

5. The integer lengths were derived after looking the range of values in the qreport.

6. Now when I re-ran the program using the bit-length values obtained in 4, I didn't see any overflows, but when I re-calculated my fractional wordlengths for the Product, Accumulator and the Output, all of them were same as specified except the Product fractional length which was 1-bit more. So I increased it by 1-bit and re-ran the filter, but again in the end the fractional length so obtained was increased by 1-bit (though no overflows). I am unable to understand what is going on. When I specify the Product fractional length by calculating the actual values why in the end it increases by 1 bit.

7. A general question is how exactly should I choose the Product and Accumulator wordlengths?

Regards,

Anindya.

Subject: Fixed Point Toolbox: Value of Accumulator and Product wordlengths

From: Tom Bryan

Date: 26 Aug, 2009 12:57:19

Message: 2 of 2

Hello Anindya,

Could you share how you created hf and ran the simulation? It would be
very helpful for us to see how to answer your question.

For example, if you could fill in the question marks here:

hf = ?
x = ?
y = filter(hf, x)

%% Then, if you modified hf again,

hf.ProductFracLength = ?
etc.

Thanks,
Tom Bryan
tom.bryan@mathworks.com

Anindya G wrote:
> Hello,
>
> 1. I am trying to simulate a fixed-point bit-true model of my FPGA/VHDL design in MATLAB. The design consists of a series of FIR filters.
>
> 2. The input is 16-bit and filter coefficients are also 16-bit signed integers. While using the fixed-point toolbox in MATLAB, it asked me to specify the bit-lengths of the Accumulator and Product integer and fractional parts. I chose the defaults - (31,30) and (32,30) for the Product and the accumulator respectively. I kept output bit lengths as (16,15).
>
> 3. After running the qreport on the logged output of the first filter, I fished for the the actual lengths of the integer parts in the qreport and calculated the fractional parts of the Output, Accumulator and the Product. Here, to calculate the fractional part of fixedpoint object, say the Product, of the fixed-point filter hf, I used the following formula which I found in one of the fixed-point webinars on the Mathworks website:
>
> R = qreport(hf)
> A = max(abs(double(R.Product.Min)), abs(double(R.Product.Max)));
> integer_part = ceil(log2(A));
> ProductFracLength = hf.ProductWordLength - integer_part - 1;
>
> 4. Through this process, I got the new values of lengths of the Product, Accumulator and the Output as follows:
> Product: 32, 32
> Accumulator: 32, 31
> Output: 16, 16
>
> 5. The integer lengths were derived after looking the range of values in the qreport.
>
> 6. Now when I re-ran the program using the bit-length values obtained in 4, I didn't see any overflows, but when I re-calculated my fractional wordlengths for the Product, Accumulator and the Output, all of them were same as specified except the Product fractional length which was 1-bit more. So I increased it by 1-bit and re-ran the filter, but again in the end the fractional length so obtained was increased by 1-bit (though no overflows). I am unable to understand what is going on. When I specify the Product fractional length by calculating the actual values why in the end it increases by 1 bit.
>
> 7. A general question is how exactly should I choose the Product and Accumulator wordlengths?
>
> Regards,
>
> Anindya.

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
fixed point too... Anindya G 25 Aug, 2009 13:19:05
qreport Anindya G 25 Aug, 2009 13:19:05
accumulator Anindya G 25 Aug, 2009 13:19:05
product Anindya G 25 Aug, 2009 13:19:05
filter Anindya G 25 Aug, 2009 13:19:05
bittrue model Anindya G 25 Aug, 2009 13:19:05
vhdl Anindya G 25 Aug, 2009 13:19:05
rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com