Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Fixed Point Toolbox: Value of Accumulator and Product wordlengths
Date: Tue, 25 Aug 2009 17:16:04 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 27
Message-ID: <h7168k$fni$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1251220564 16114 172.30.248.37 (25 Aug 2009 17:16:04 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 25 Aug 2009 17:16:04 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1639346
Xref: news.mathworks.com comp.soft-sys.matlab:565878


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.