Path: news.mathworks.com!not-for-mail
From: Ashok Charry <acharry@mathworks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: FPT : how to inherit an fi object's attributes
Date: Fri, 15 Aug 2008 16:39:51 -0400
Organization: The MathWorks, Inc.
Lines: 61
Message-ID: <C4CB61D7.12864%acharry@mathworks.com>
References: <g84mjd$hpd$1@fred.mathworks.com>
NNTP-Posting-Host: acharry-macpro.dhcp.mathworks.com
Mime-Version: 1.0
Content-Type: text/plain;
Content-Transfer-Encoding: 7bit
X-Trace: fred.mathworks.com 1218832791 26377 144.212.109.163 (15 Aug 2008 20:39:51 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 15 Aug 2008 20:39:51 +0000 (UTC)
User-Agent: Microsoft-Entourage/11.4.0.080122
Thread-Topic: FPT : how to inherit an fi object's attributes
Thread-Index: Acj/FxC5TwCcI2sKEd2jigAX8gC2Lg==
Xref: news.mathworks.com comp.soft-sys.matlab:485751



Hi Michael,

What you are doing to inherit the fi's properties is correct. My suggestion
(below) is not a huge improvement but its fewer characters to type:

aq = fi(zeros(size(atan_quantized)),...
        atan_quantized.Signed,...
        atan_quantized.WordLength+2,...
        atan_quantized.FractionLength+2,...
        atan_quantized.fimath);

Hope that helps,

Ashok Charry
The MathWorks


On 8/15/08 3:49 PM, in article g84mjd$hpd$1@fred.mathworks.com, "Michael
Hui" <myhui@yahoo.com> wrote:

> In my MATLAB workspace I do this:
> 
> cordic_p.addr_size   = 4;
> 
> cordic_p.out_size    = 23;
> 
> cordic_p.phase_size  = pow2(cordic_p.addr_size);
> 
> cordic_p.phdiff_size = cordic_p.phint_size -
> cordic_p.phase_size;
> 
> phase_size_int = cordic_p.phase_size - 2; % The RTL only
> does phase_size - 2 iterations, so we match it here
> 
> % Generate atan() ROM values
> atan_quantized = fi ( atan(pow2(0:-1:-phase_size_int+1))/pi, ...
>     'Signed', 0, 'WordLength', cordic_p.out_size-2,
> 'FractionLength', cordic_p.out_size-2, 'OverflowMode',
> 'saturate', 'RoundMode', 'round');
> 
> 
> And then I pass atan_quantized to a function as a read-only
> argument.
> 
> I want to create an fi object inside the function that
> inherits almost all attributes of that argument, except I
> want to increase its word length.
> 
> What is the proper way to do this?
> 
> I can do it like this inside the function, which is very
> tedious:
> 
> aq = fi(zeros(size(atan_quantized)),...
>    atan_quantized.fimath,...
>    atan_quantized.numerictype,...
>    'WordLength',atan_quantized.numerictype.WordLength+2,...
>   
> 'FractionLength',atan_quantized.numerictype.FractionLength+2);
>