<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/174418</link>
    <title>MATLAB Central Newsreader - FPT : how to inherit an fi object's attributes</title>
    <description>Feed for thread: FPT : how to inherit an fi object's attributes</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Fri, 15 Aug 2008 19:49:01 -0400</pubDate>
      <title>FPT : how to inherit an fi object's attributes</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/174418#449389</link>
      <author>Michael Hui</author>
      <description>In my MATLAB workspace I do this:&lt;br&gt;
&lt;br&gt;
cordic_p.addr_size   = 4;&lt;br&gt;
&lt;br&gt;
cordic_p.out_size    = 23;&lt;br&gt;
&lt;br&gt;
cordic_p.phase_size  = pow2(cordic_p.addr_size);&lt;br&gt;
&lt;br&gt;
cordic_p.phdiff_size = cordic_p.phint_size -&lt;br&gt;
cordic_p.phase_size;&lt;br&gt;
&lt;br&gt;
phase_size_int = cordic_p.phase_size - 2; % The RTL only&lt;br&gt;
does phase_size - 2 iterations, so we match it here&lt;br&gt;
&lt;br&gt;
% Generate atan() ROM values&lt;br&gt;
atan_quantized = fi ( atan(pow2(0:-1:-phase_size_int+1))/pi, ...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'Signed', 0, 'WordLength', cordic_p.out_size-2,&lt;br&gt;
'FractionLength', cordic_p.out_size-2, 'OverflowMode',&lt;br&gt;
'saturate', 'RoundMode', 'round');&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
And then I pass atan_quantized to a function as a read-only&lt;br&gt;
argument.&lt;br&gt;
&lt;br&gt;
I want to create an fi object inside the function that&lt;br&gt;
inherits almost all attributes of that argument, except I&lt;br&gt;
want to increase its word length.&lt;br&gt;
&lt;br&gt;
What is the proper way to do this?&lt;br&gt;
&lt;br&gt;
I can do it like this inside the function, which is very&lt;br&gt;
tedious:&lt;br&gt;
&lt;br&gt;
aq = fi(zeros(size(atan_quantized)),...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;atan_quantized.fimath,...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;atan_quantized.numerictype,...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;'WordLength',atan_quantized.numerictype.WordLength+2,...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&lt;br&gt;
'FractionLength',atan_quantized.numerictype.FractionLength+2);</description>
    </item>
    <item>
      <pubDate>Fri, 15 Aug 2008 20:39:51 -0400</pubDate>
      <title>Re: FPT : how to inherit an fi object's attributes</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/174418#449395</link>
      <author>Ashok Charry</author>
      <description>Hi Michael,&lt;br&gt;
&lt;br&gt;
What you are doing to inherit the fi's properties is correct. My suggestion&lt;br&gt;
(below) is not a huge improvement but its fewer characters to type:&lt;br&gt;
&lt;br&gt;
aq = fi(zeros(size(atan_quantized)),...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;atan_quantized.Signed,...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;atan_quantized.WordLength+2,...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;atan_quantized.FractionLength+2,...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;atan_quantized.fimath);&lt;br&gt;
&lt;br&gt;
Hope that helps,&lt;br&gt;
&lt;br&gt;
Ashok Charry&lt;br&gt;
The MathWorks&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
On 8/15/08 3:49 PM, in article g84mjd$hpd$1@fred.mathworks.com, &quot;Michael&lt;br&gt;
Hui&quot; &amp;lt;myhui@yahoo.com&amp;gt; wrote:&lt;br&gt;
&lt;br&gt;
&amp;gt; In my MATLAB workspace I do this:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; cordic_p.addr_size   = 4;&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; cordic_p.out_size    = 23;&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; cordic_p.phase_size  = pow2(cordic_p.addr_size);&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; cordic_p.phdiff_size = cordic_p.phint_size -&lt;br&gt;
&amp;gt; cordic_p.phase_size;&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; phase_size_int = cordic_p.phase_size - 2; % The RTL only&lt;br&gt;
&amp;gt; does phase_size - 2 iterations, so we match it here&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; % Generate atan() ROM values&lt;br&gt;
&amp;gt; atan_quantized = fi ( atan(pow2(0:-1:-phase_size_int+1))/pi, ...&lt;br&gt;
&amp;gt;     'Signed', 0, 'WordLength', cordic_p.out_size-2,&lt;br&gt;
&amp;gt; 'FractionLength', cordic_p.out_size-2, 'OverflowMode',&lt;br&gt;
&amp;gt; 'saturate', 'RoundMode', 'round');&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; And then I pass atan_quantized to a function as a read-only&lt;br&gt;
&amp;gt; argument.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I want to create an fi object inside the function that&lt;br&gt;
&amp;gt; inherits almost all attributes of that argument, except I&lt;br&gt;
&amp;gt; want to increase its word length.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; What is the proper way to do this?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I can do it like this inside the function, which is very&lt;br&gt;
&amp;gt; tedious:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; aq = fi(zeros(size(atan_quantized)),...&lt;br&gt;
&amp;gt;    atan_quantized.fimath,...&lt;br&gt;
&amp;gt;    atan_quantized.numerictype,...&lt;br&gt;
&amp;gt;    'WordLength',atan_quantized.numerictype.WordLength+2,...&lt;br&gt;
&amp;gt;   &lt;br&gt;
&amp;gt; 'FractionLength',atan_quantized.numerictype.FractionLength+2);&lt;br&gt;
&amp;gt; </description>
    </item>
    <item>
      <pubDate>Sun, 17 Aug 2008 05:35:03 -0400</pubDate>
      <title>Re: FPT : how to inherit an fi object's attributes</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/174418#510953</link>
      <author>Donn Shull</author>
      <description>The way you are doing this now is the &quot;proper way&quot; to do &lt;br&gt;
it. If you are looking for alternatives then you could &lt;br&gt;
create methods in the @embedded/@fi directory to give you &lt;br&gt;
more flexibility. For instance you could create a file &lt;br&gt;
setWordLength.m with this code:&lt;br&gt;
&lt;br&gt;
function this = setWordLength(this, wordLength)&lt;br&gt;
&lt;br&gt;
this.WordLength = wordLength;&lt;br&gt;
&lt;br&gt;
in that directory. Then after restarting MATLAB you could &lt;br&gt;
do the following&lt;br&gt;
&lt;br&gt;
aq = atan_quantized.copy;&lt;br&gt;
aq.setWordLength(23);&lt;br&gt;
&lt;br&gt;
But this would be an &quot;improper way&quot; to do this.</description>
    </item>
    <item>
      <pubDate>Sun, 17 Aug 2008 16:20:17 -0400</pubDate>
      <title>Re: FPT : how to inherit an fi object's attributes</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/174418#510983</link>
      <author>Michael Hui</author>
      <description>I thank you both for sharing your thoughts.&lt;br&gt;
&lt;br&gt;
The difference between the following:&lt;br&gt;
&lt;br&gt;
aq = fi(zeros(size(atan_quantized)),...&lt;br&gt;
atan_quantized.fimath,...&lt;br&gt;
atan_quantized.numerictype,...&lt;br&gt;
'WordLength',atan_quantized.numerictype.WordLength+2,...&lt;br&gt;
'FractionLength',atan_quantized.numerictype.FractionLength+2);&lt;br&gt;
&lt;br&gt;
aq = fi(zeros(size(atan_quantized)),...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;atan_quantized.Signed,...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;atan_quantized.WordLength+2,...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;atan_quantized.FractionLength+2,...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;atan_quantized.fimath);&lt;br&gt;
&lt;br&gt;
is that the first one takes in all properties of numerictype&lt;br&gt;
without listing them out, and the second one lists them&lt;br&gt;
explicitly.&lt;br&gt;
&lt;br&gt;
I suppose the two will work differently if one adds more&lt;br&gt;
properties to numerictype. The first method will continue to&lt;br&gt;
inherit all properties and the second one might miss the new&lt;br&gt;
properties.&lt;br&gt;
&lt;br&gt;
So that's why both of you said the first method is the&lt;br&gt;
proper method. Thanks for that!</description>
    </item>
  </channel>
</rss>

