<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to Squeeze Every Last Drop of Performance Out of SIMULINK Models with AMMCLIB   in Model-Based Design Toolbox (MBDT)</title>
    <link>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/How-to-Squeeze-Every-Last-Drop-of-Performance-Out-of-SIMULINK/m-p/719483#M1428</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;A class="jx-jive-macro-user" href="https://community.nxp.com/people/dumitru-daniel.popa"&gt;dumitru-daniel.popa&lt;/A&gt;‌,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for this example, it shows the advantages of using the math libraries for the S32K.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm trying to implement some simple floating point&amp;nbsp;operations&amp;nbsp;and trying to figure out which blocks to use is quite&amp;nbsp;the&amp;nbsp;challenge. One thing that I'd like to point out is that the name descriptions and the help provided within Simulink is almost non existent and just painful to read.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As you mention, following the link you provided in your post:&amp;nbsp;&lt;A data-content-finding="Community" href="https://community.nxp.com/external-link.jspa?url=https%3A%2F%2Fwww.nxp.com%2Fpages%2Fautomotive-math-and-motor-control-library-set%3AAUTOMATH_MCL%3F%26tid%3DvanAutoMCLib" rel="nofollow" style="color: #3d9ce7; background-color: #ffffff; border: 0px; text-decoration: none; padding: 0px calc(12px + 0.35ex) 0px 0px;" target="_blank"&gt;Automotive Math and Motor Control Library Set|NXP&lt;/A&gt;&lt;/P&gt;&lt;P&gt;gets you to the AMMCLIB site, and going to the downloads page you can download the libraries but more important the User's Manual.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_1.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/73840i613A152C13284B1F/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_1.png" alt="pastedImage_1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_2.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/73863iDCB641C4A0019AD5/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_2.png" alt="pastedImage_2.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The User's Guide SK32K14XMCLUG.pdf is a great resource (I'm not sure if I'm allowed to attach it here, that's why I pointed out how to get it), specially because each function contains the Declaration, Arguments, Implementation details and Code Example in C.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The names of the Simulink&amp;nbsp;blocks match to the function names in the User's Guide, so you can search for the block name and find the details for each function, and check the Typedefs reference for a description of the data types.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Gustavo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 09 Nov 2018 16:42:51 GMT</pubDate>
    <dc:creator>gramirezv</dc:creator>
    <dc:date>2018-11-09T16:42:51Z</dc:date>
    <item>
      <title>How to Squeeze Every Last Drop of Performance Out of SIMULINK Models with AMMCLIB</title>
      <link>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/How-to-Squeeze-Every-Last-Drop-of-Performance-Out-of-SIMULINK/m-p/719482#M1427</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="text-align: justify;"&gt;This article is about&amp;nbsp;how to&amp;nbsp;employ the powerful features of &lt;A href="https://www.nxp.com/pages/automotive-math-and-motor-control-library-set:AUTOMATH_MCL?&amp;amp;tid=vanAutoMCLib" rel="nofollow noopener noreferrer noopener noreferrer" target="_blank"&gt;Automotive Math and Motor Control Library (AMMCLIB)&lt;/A&gt; to speed up the execution of the&amp;nbsp;applications&amp;nbsp;designed to run on NXP microprocessors.&amp;nbsp;We're going to show a simple but relevant use-case that is a perfect candidate to support the usage of AMMCLIB whenever possible but if you are interested in mode details, please refer to the document attached.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 22px; color: #000080;"&gt;&lt;STRONG&gt;The Problem ...&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;During the preparation of the last 2 modules of the&amp;nbsp;&lt;A href="https://community.nxp.com/thread/464336" rel="noopener noreferrer" target="_blank"&gt;3-Phase PMSM Control Workshop with NXP's Model-Based Design Toolbox&lt;/A&gt;, I've run into a performance issue with the model I was trying to build. Basically, after adding a couple of new blocks that are needed for the sensorless observer, I noticed that the motor was not moving anymore, the FreeMASTER recorder was crashing the application and all sort of such strange behaviors.&lt;/P&gt;&lt;P style="text-align: justify;"&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;So, I went back to a previous working Simulink model and started to add one by one new Simulink blocks and check what's going on. Soon after, I found the reason&amp;nbsp;and I was a bit surprised: the time spent in processing the motor control fast loop computations was far&amp;nbsp;bigger than expected.&lt;/P&gt;&lt;P style="text-align: justify;"&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;To find the culprit I started to profile the application using the dedicated MBDT Profiler block. Soon after i had a clear picture about various subsystem processing requirements. Overall the entire FOC calculations (PI current regulators, PARK/CLARKE coordinate transformations, SVM, PWM updates,&amp;nbsp;SINE/COSINE) took about 40&amp;nbsp;micro-seconds but one simple operation took exactly 20.8 microseconds - yes - half off all the others.&lt;/P&gt;&lt;P style="text-align: justify;"&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;In the Simulink model, I'm using floating point operations based on single precision data types but at the end of the computation i need to cast these values to unsigned 32b data type since that is the input required by FTM block.&lt;/P&gt;&lt;P style="text-align: justify;"&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_9.png"&gt;&lt;IMG alt="pastedImage_9.png" src="https://community.nxp.com/t5/image/serverpage/image-id/50036i72B918B16DF50A83/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_9.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P style="text-align: justify;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;That particular cast from single to unsigned integer data types was killing the application due to the usage of fmodf() function in the generated code. The generated code look like this:&lt;/P&gt;&lt;PRE class="language-c line-numbers"&gt;&lt;CODE&gt;&lt;SPAN class="comment token"&gt;/* Product: '&amp;lt;S50&amp;gt;/TransPerMin' */&lt;/SPAN&gt;
 rtb_Sum &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;fmodf&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;truncf&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;FOC_SC_DWork&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Merge_b&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;1000.0F&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;4.2949673E+9F&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
 FOC_SC_DWork&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;TransPerMin&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; rtb_Sum &lt;SPAN class="operator token"&gt;&amp;lt;&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0.0F&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;?&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;uint32_T&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;-&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;int32_T&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;uint32_T&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
 &lt;SPAN class="operator token"&gt;-&lt;/SPAN&gt;rtb_Sum &lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;uint32_T&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;rtb_Sum&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
 rtb_Sum &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;fmodf&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;truncf&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;FOC_SC_DWork&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Merge_b&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;1000.0F&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;4.2949673E+9F&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
 FOC_SC_DWork&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;TransPerMin&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; rtb_Sum &lt;SPAN class="operator token"&gt;&amp;lt;&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0.0F&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;?&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;uint32_T&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;-&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;int32_T&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;uint32_T&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
 &lt;SPAN class="operator token"&gt;-&lt;/SPAN&gt;rtb_Sum &lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;uint32_T&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;rtb_Sum&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
 rtb_Sum &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;fmodf&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;truncf&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;FOC_SC_DWork&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Merge_b&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;2&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;1000.0F&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;4.2949673E+9F&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
 FOC_SC_DWork&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;TransPerMin&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;2&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; rtb_Sum &lt;SPAN class="operator token"&gt;&amp;lt;&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0.0F&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;?&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;uint32_T&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;-&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;int32_T&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;uint32_T&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
 &lt;SPAN class="operator token"&gt;-&lt;/SPAN&gt;rtb_Sum &lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;uint32_T&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;rtb_Sum&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P style="text-align: justify;"&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;At this point you may think ...&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P style="text-align: justify;"&gt;&lt;EM style="color: #000080; font-family: 'comic sans ms', sans-serif;"&gt;so, what? is a call to a standard floating point function and processors with FPU shall handle it just fine, right ?&lt;/EM&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P style="text-align: justify;"&gt;Well, think again! Here is a nice article about this topic:&amp;nbsp;&lt;A class="link-titled" href="http://stereopsis.com/sree/fpu2006.html" rel="nofollow noopener noreferrer noopener noreferrer" target="_blank" title="http://stereopsis.com/sree/fpu2006.html"&gt;Know Your FPU, 2006 Edition&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 22px; color: #000080;"&gt;&lt;STRONG&gt;The&amp;nbsp;Solution ...&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;In order to go further with the model development I had 2 options:&lt;/P&gt;&lt;OL&gt;&lt;LI style="text-align: justify;"&gt;change all the algorithm to fix-point implementation: that means i had to redue all the examples and skip all the FPU capabilities of the microcontroller&lt;/LI&gt;&lt;LI style="text-align: justify;"&gt;find a way to resolve the conversion issue by avoiding the fmod() function call generation&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;Personally, I consider that the days when you had to stick with the usage of fixed point to implement algorithm are gone - nowadays there are plenty of micro-controllers&amp;nbsp;capable of dealing with floating point numbers and lets not forget we are using model-based approach where we should figure on design rather than specific implementations. Therefore the only acceptable option at this point was #2.&lt;/P&gt;&lt;P style="text-align: justify;"&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;The AMMCLIB provides a specific blocks to convert between various data type formats. These block are available within the MLIB subset.&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY&gt;&lt;TR style="height: 25px;"&gt;&lt;TD style="height: 25px; text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_10.png"&gt;&lt;IMG alt="pastedImage_10.png" src="https://community.nxp.com/t5/image/serverpage/image-id/51501i7F0FEEC0FECC8221/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_10.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding: 0px;"&gt;&lt;/P&gt;&lt;P style="padding: 0px;"&gt;&lt;SPAN style="font-size: 22px; color: #000080;"&gt;&lt;STRONG&gt;The&amp;nbsp;Proof&amp;nbsp;...&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;Using these blocks, I've started to do some investigations.&lt;/P&gt;&lt;P&gt;First I've build a simple model to check verify the conversion results and the generated code. The scope of this test is to see if we can get rid of the fmod() function usage while preserving a good conversion precision.&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_12.png"&gt;&lt;IMG alt="pastedImage_12.png" src="https://community.nxp.com/t5/image/serverpage/image-id/52378iF5023A5EE489F66A/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_12.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The code generated for this model looks like this:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;STRONG&gt;C-code for SIMULINK Data Type Conversion single2int&lt;/STRONG&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;PRE class="language-c line-numbers"&gt;&lt;CODE&gt;&lt;SPAN class="comment token"&gt;/* DataTypeConversion: '&amp;lt;Root&amp;gt;/SIMULINK Data Type Conversion' */&lt;/SPAN&gt;
 tmp &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;real32_T&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;fmod&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;real32_T&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;floor&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;rtb_Add&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;4.2949673E+9F&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
 rtb_SIMULINKDataTypeConversion &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; tmp &lt;SPAN class="operator token"&gt;&amp;lt;&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0.0F&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;?&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;-&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;int32_T&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;uint32_T&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;-&lt;/SPAN&gt;tmp &lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
 &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;int32_T&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;uint32_T&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;tmp&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;/* DataStoreWrite: '&amp;lt;Root&amp;gt;/Data Store Write SIMULINK' */&lt;/SPAN&gt;
 SIMULINK_vs_AMMCLIB_DW&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;S &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; rtb_SIMULINKDataTypeConversion&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;STRONG&gt;C-code for AMMCLIB MLIB Conversion single2int&lt;/STRONG&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;PRE class="language-c line-numbers"&gt;&lt;CODE&gt;&lt;SPAN class="comment token"&gt;/* S-Function (MLIB_Convert_SF_F32FLT): '&amp;lt;S1&amp;gt;/MLIB_Convert_SF' */&lt;/SPAN&gt;
 rtb_SIMULINKDataTypeConversion &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;MLIB_Convert_F32FLT&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;rtb_Add&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;4.66E-10F&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;/* DataStoreWrite: '&amp;lt;Root&amp;gt;/Data Store Write AMMCLIB' */&lt;/SPAN&gt;
 SIMULINK_vs_AMMCLIB_DW&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;A &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; rtb_SIMULINKDataTypeConversion&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;&lt;SPAN style="color: #333333;"&gt;and .... voila!!! mission accomplished. Using the AMMCLIB MLIB block there is no expensive floating point library function call needed.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding: 0px;"&gt;&lt;/P&gt;&lt;P style="padding: 0px;"&gt;&lt;SPAN style="font-size: 22px; color: #000080;"&gt;&lt;STRONG&gt;How Fast Is It&amp;nbsp;?&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;Using MBDT Profiler we can easily check the number of ticks/time needed to execute each of the methods.&amp;nbsp;Code generated to measure the performance looks like this:&lt;/P&gt;&lt;PRE class="language-c line-numbers"&gt;&lt;CODE&gt;&lt;SPAN class="comment token"&gt;/* user code (Output function Body) */&lt;/SPAN&gt;
 &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="comment token"&gt;/* Start of Profile Code */&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uint32_t tmp1&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uint32_t tmp2&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tmp1 &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;profiler_get_cnt&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="comment token"&gt;/* Start Profiling This Function.*/&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="comment token"&gt;/* S-Function (MLIB_Convert_SF_F32FLT): '&amp;lt;S3&amp;gt;/MLIB_Convert_SF' */&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; localB&lt;SPAN class="operator token"&gt;-&amp;gt;&lt;/SPAN&gt;MLIB_Convert_SF &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;MLIB_Convert_F32FLT&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;rtu_In1&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;4.66E-10F&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="comment token"&gt;/* user code (Output function Trailer) */&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="comment token"&gt;/* Profile Code : Compute function execution time in us. */&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tmp2 &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;profiler_get_cnt&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; profile_buffer&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;gt_pf&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;tmp1&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; tmp2&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="comment token"&gt;/* End of Profile Code */&lt;/SPAN&gt;
 &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;The profiler results for both methods is shown below in this FreeMASTER scope capture.&amp;nbsp;As&amp;nbsp;can be seen the MLIB Conversion (green) is 10 times faster than the standard Simulink data type conversion conversion (red).&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; border-width: 1px; border-color: #ffffff;" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD style="text-align: center;"&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_18.png"&gt;&lt;IMG alt="pastedImage_18.png" src="https://community.nxp.com/t5/image/serverpage/image-id/54454i79F65C4543D1500B/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_18.png" /&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P style="text-align: justify;"&gt;&lt;/P&gt;&lt;PRE __default_attr="info" __jive_macro_name="alert" alert="info" class="jive_text_macro jive_macro_alert" modifiedtitle="true"&gt;&lt;P style="text-align: justify;"&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;The MBDT Profiler measures the number of LPIT counts needed to execute a particular piece of code. The source clock of the LPIT is BUS CLOCK divided by 2 which provides a clock of 40MHz.&lt;/SPAN&gt;&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;Converting the counts to seconds we get:&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6;" width="100%"&gt;&lt;THEAD&gt;&lt;TR style="background-color: #efefef; height: 25px;"&gt;&lt;TH style="width: 46%; height: 25px;"&gt;Single2Integer Conversion Method&lt;/TH&gt;&lt;TH style="width: 22.6274%; text-align: center; height: 25px;"&gt;Profiler Counts&lt;/TH&gt;&lt;TH style="width: 21.3726%; text-align: center; height: 25px;"&gt;Time (micro seconds)&lt;/TH&gt;&lt;/TR&gt;&lt;/THEAD&gt;&lt;TBODY&gt;&lt;TR style="height: 25px;"&gt;&lt;TD style="width: 46%; height: 25px;"&gt;Standard Simulink Data Type Conversion&lt;/TD&gt;&lt;TD style="width: 22.6274%; text-align: center; height: 25px;"&gt;&lt;SPAN style="color: #ff0000;"&gt;&lt;STRONG&gt;204&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD style="width: 21.3726%; text-align: center; height: 25px;"&gt;&lt;SPAN style="color: #ff0000;"&gt;&lt;STRONG&gt;5.1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD style="width: 46%; height: 25px;"&gt;AMMCLIB MLIB Conversion&lt;/TD&gt;&lt;TD style="width: 22.6274%; text-align: center; height: 25px;"&gt;&lt;SPAN style="color: #008000;"&gt;&lt;STRONG&gt;22&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD style="width: 21.3726%; text-align: center; height: 25px;"&gt;&lt;SPAN style="color: #008000;"&gt;&lt;STRONG&gt;0.55&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding: 0px;"&gt;&lt;SPAN style="font-size: 22px; color: #000080;"&gt;&lt;STRONG&gt;Conclusions&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;If you wish to speed up your computations and squeeze out the performance out of NXP microcontroller, try using AMMCLIB since it provides a set of optimized functionalities specially designed for embedded applications. For more details please visit:&amp;nbsp;&lt;A class="link-titled" href="https://www.nxp.com/pages/automotive-math-and-motor-control-library-set:AUTOMATH_MCL?&amp;amp;tid=vanAutoMCLib" rel="nofollow noopener noreferrer noopener noreferrer" target="_blank" title="https://www.nxp.com/pages/automotive-math-and-motor-control-library-set:AUTOMATH_MCL?&amp;amp;tid=vanAutoMCLib"&gt;Automotive Math and Motor Control Library Set|NXP&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Nov 2020 14:02:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/How-to-Squeeze-Every-Last-Drop-of-Performance-Out-of-SIMULINK/m-p/719482#M1427</guid>
      <dc:creator>Daniel_Popa</dc:creator>
      <dc:date>2020-11-02T14:02:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to Squeeze Every Last Drop of Performance Out of SIMULINK Models with AMMCLIB</title>
      <link>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/How-to-Squeeze-Every-Last-Drop-of-Performance-Out-of-SIMULINK/m-p/719483#M1428</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;A class="jx-jive-macro-user" href="https://community.nxp.com/people/dumitru-daniel.popa"&gt;dumitru-daniel.popa&lt;/A&gt;‌,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for this example, it shows the advantages of using the math libraries for the S32K.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm trying to implement some simple floating point&amp;nbsp;operations&amp;nbsp;and trying to figure out which blocks to use is quite&amp;nbsp;the&amp;nbsp;challenge. One thing that I'd like to point out is that the name descriptions and the help provided within Simulink is almost non existent and just painful to read.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As you mention, following the link you provided in your post:&amp;nbsp;&lt;A data-content-finding="Community" href="https://community.nxp.com/external-link.jspa?url=https%3A%2F%2Fwww.nxp.com%2Fpages%2Fautomotive-math-and-motor-control-library-set%3AAUTOMATH_MCL%3F%26tid%3DvanAutoMCLib" rel="nofollow" style="color: #3d9ce7; background-color: #ffffff; border: 0px; text-decoration: none; padding: 0px calc(12px + 0.35ex) 0px 0px;" target="_blank"&gt;Automotive Math and Motor Control Library Set|NXP&lt;/A&gt;&lt;/P&gt;&lt;P&gt;gets you to the AMMCLIB site, and going to the downloads page you can download the libraries but more important the User's Manual.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_1.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/73840i613A152C13284B1F/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_1.png" alt="pastedImage_1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_2.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/73863iDCB641C4A0019AD5/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_2.png" alt="pastedImage_2.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The User's Guide SK32K14XMCLUG.pdf is a great resource (I'm not sure if I'm allowed to attach it here, that's why I pointed out how to get it), specially because each function contains the Declaration, Arguments, Implementation details and Code Example in C.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The names of the Simulink&amp;nbsp;blocks match to the function names in the User's Guide, so you can search for the block name and find the details for each function, and check the Typedefs reference for a description of the data types.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Gustavo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Nov 2018 16:42:51 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/How-to-Squeeze-Every-Last-Drop-of-Performance-Out-of-SIMULINK/m-p/719483#M1428</guid>
      <dc:creator>gramirezv</dc:creator>
      <dc:date>2018-11-09T16:42:51Z</dc:date>
    </item>
  </channel>
</rss>

