Thread Subject: Signal processing blockset and the IQMath library

Subject: Signal processing blockset and the IQMath library

From: Kevin

Date: 28 Feb, 2008 15:29:06

Message: 1 of 3

Hello everyone,

I've been toying with the Target for C2000 toolbox, just to
see what can be done with.

I'm quite disapointed by the fact that Simulink forces the
use of floating point numbers in many blocks.
I'm sure there's a way to force Simulink to do everything in
fixed point numbers, but I just can't see how.

For example, I've created a filter using the signal
processing toolbox. The results are stored as fixed point
variables, but every multiplication is made using floating
point operations.
So in the C Code, I get something like

tmp = floor(ldexp(DMC_P.b3_Gain *
ldexp((real_T)rtb_BodyDelay3, (int16_T)
      -16L), (int16_T)16L) + 0.5);
    rtb_b3 = (int32_T)(tmp <= 2.147483647E+009 ? tmp >=
-2.147483648E+009 ? tmp :
                       -2.147483648E+009 : 2.147483647E+009);

Which is quite complicated, especially when you know that
the IQMath library is way faster.

So, can I force Simulink to do fixed point operations?
Better yet: is there a way to use Iqmath in conjunction with
the signal processing toolbox without manually replacing
every "Gain" block with by an Iqmath equivalent?

Subject: Signal processing blockset and the IQMath library

From: Praetorian

Date: 29 Feb, 2008 22:06:38

Message: 2 of 3

On Feb 28, 8:29 am, "Kevin " <kedec...@mathworks.com> wrote:
> Hello everyone,
>
> I've been toying with the Target for C2000 toolbox, just to
> see what can be done with.
>
> I'm quite disapointed by the fact that Simulink forces the
> use of floating point numbers in many blocks.
> I'm sure there's a way to force Simulink to do everything in
> fixed point numbers, but I just can't see how.
>
> For example, I've created a filter using the signal
> processing toolbox. The results are stored as fixed point
> variables, but every multiplication is made using floating
> point operations.
> So in the C Code, I get something like
>
> tmp = floor(ldexp(DMC_P.b3_Gain *
> ldexp((real_T)rtb_BodyDelay3, (int16_T)
> -16L), (int16_T)16L) + 0.5);
> rtb_b3 = (int32_T)(tmp <= 2.147483647E+009 ? tmp >=
> -2.147483648E+009 ? tmp :
> -2.147483648E+009 : 2.147483647E+009);
>
> Which is quite complicated, especially when you know that
> theIQMathlibrary is way faster.
>
> So, can I force Simulink to do fixed point operations?
> Better yet: is there a way to useIqmathin conjunction with
> the signal processing toolbox without manually replacing
> every "Gain" block with by anIqmathequivalent?

Kevin,
The reason Simulink is generating float math is because you haven't
set the port data types for the blocks. Also, if you're using ERT you
should pick the fixed point specific flavor of ert.tlc (the same may
exist even in case of GRT). I work on a very large scale model
generating code for the TI 2812 and all of our code is in fixed point,
including that generated by default Simulink blocks such as the gain
block. Also, if you have the TI C2000 toolbox there are blocks in
there that make use of IQ math. And a new feature of R2007b (I haven't
used it yet) is Target Function Replacement where apparently there is
an API for specifying hardware specific instructions in place of
generic math operations. So using that you should be able to have the
Gain block generate IQ math code instead of Simulink's fixed point
math multiplication.

HTH,
Ashish.

Subject: Signal processing blockset and the IQMath library

From: Antonin Ancelle

Date: 4 Mar, 2008 14:11:23

Message: 3 of 3

Hi Kevin,

You can enable TFL (Target Function Library) if you open the configset of
your model (Ctrl+E) and go to:
Real-Time Workshop -> Interface -> Target Function Library. (requires RTW
Embedded Coder)
Pick "TI C28x", this should replace most of the basic fixed-point operations
with IQMath calls, even inside Signal Processing blocks.
TFL was introduced for C2000 in R2007b, more replacement are available in
the brand new R2008a release available since the 1st of march 2008.

I hope it helps,

Antonin.


"Praetorian" <ashish.sadanandan@gmail.com> wrote in message
news:d7287b5d-f1a3-41ec-a645-3e8d35231b5f@u10g2000prn.googlegroups.com...
> On Feb 28, 8:29 am, "Kevin " <kedec...@mathworks.com> wrote:
>> Hello everyone,
>>
>> I've been toying with the Target for C2000 toolbox, just to
>> see what can be done with.
>>
>> I'm quite disapointed by the fact that Simulink forces the
>> use of floating point numbers in many blocks.
>> I'm sure there's a way to force Simulink to do everything in
>> fixed point numbers, but I just can't see how.
>>
>> For example, I've created a filter using the signal
>> processing toolbox. The results are stored as fixed point
>> variables, but every multiplication is made using floating
>> point operations.
>> So in the C Code, I get something like
>>
>> tmp = floor(ldexp(DMC_P.b3_Gain *
>> ldexp((real_T)rtb_BodyDelay3, (int16_T)
>> -16L), (int16_T)16L) + 0.5);
>> rtb_b3 = (int32_T)(tmp <= 2.147483647E+009 ? tmp >=
>> -2.147483648E+009 ? tmp :
>> -2.147483648E+009 : 2.147483647E+009);
>>
>> Which is quite complicated, especially when you know that
>> theIQMathlibrary is way faster.
>>
>> So, can I force Simulink to do fixed point operations?
>> Better yet: is there a way to useIqmathin conjunction with
>> the signal processing toolbox without manually replacing
>> every "Gain" block with by anIqmathequivalent?
>
> Kevin,
> The reason Simulink is generating float math is because you haven't
> set the port data types for the blocks. Also, if you're using ERT you
> should pick the fixed point specific flavor of ert.tlc (the same may
> exist even in case of GRT). I work on a very large scale model
> generating code for the TI 2812 and all of our code is in fixed point,
> including that generated by default Simulink blocks such as the gain
> block. Also, if you have the TI C2000 toolbox there are blocks in
> there that make use of IQ math. And a new feature of R2007b (I haven't
> used it yet) is Target Function Replacement where apparently there is
> an API for specifying hardware specific instructions in place of
> generic math operations. So using that you should be able to have the
> Gain block generate IQ math code instead of Simulink's fixed point
> math multiplication.
>
> HTH,
> Ashish.


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
f2812 Bahaa Hafez 12 Mar, 2008 12:02:32
ti c2000 Bahaa Hafez 12 Mar, 2008 12:02:32
fixed point Kevin 28 Feb, 2008 10:30:49
signal processing Kevin 28 Feb, 2008 10:30:49
iqmath Kevin 28 Feb, 2008 10:30:49
c2000 Kevin 28 Feb, 2008 10:30:49
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