Thread Subject: Generating Code from fixed-point sqrt

Subject: Generating Code from fixed-point sqrt

From: Matt

Date: 18 Nov, 2009 16:22:19

Message: 1 of 4

Hi,

I'm trying to generate code from a model that includes an Embedded M fixed-point sqrt.

If the input is sfix40_En16 the build fails but it works for sfix32_En16. It always works in Simulation.

I've created a test model that contains a single Embedded M block. The input signal is sfix40_En16. Default fimath properties.

The first error is:

eml_const: This node is not constant.
Internal Error: This error occurred inside a MathWorks function.

Function 'sqrt.m' (#179.988.1066), line 37, column 13:
"[Ty,Fy,fimathSpecified,methodName,errMsg] = eml_const(eml_fisqrt_helper(data))"

Further down the list of errors is:

sqrt(A) or sqrt(A,T) can only be calculated for FI object A and NumericType T when the scaling of A and T has a fractional slope of 1 and 0 bias (binary-point only scaling).

Function 'Embedded MATLAB Function' (#194.82.92), line 5, column 8:
"sqrt(u_fi)"

Thanks,
Matt

Subject: Generating Code from fixed-point sqrt

From: Ashok Charry

Date: 18 Nov, 2009 16:56:56

Message: 2 of 4

Hi Matt,
Could you please tell me what version of MATLAB you are using (type ver
at MATLAB prompt) and would it be possible to post a snippet of the code
that is producing this error?
Thanks,
Ashok Charry
The MathWorks

Matt wrote:
> Hi,
>
> I'm trying to generate code from a model that includes an Embedded M fixed-point sqrt.
>
> If the input is sfix40_En16 the build fails but it works for sfix32_En16. It always works in Simulation.
>
> I've created a test model that contains a single Embedded M block. The input signal is sfix40_En16. Default fimath properties.
>
> The first error is:
>
> eml_const: This node is not constant.
> Internal Error: This error occurred inside a MathWorks function.
>
> Function 'sqrt.m' (#179.988.1066), line 37, column 13:
> "[Ty,Fy,fimathSpecified,methodName,errMsg] = eml_const(eml_fisqrt_helper(data))"
>
> Further down the list of errors is:
>
> sqrt(A) or sqrt(A,T) can only be calculated for FI object A and NumericType T when the scaling of A and T has a fractional slope of 1 and 0 bias (binary-point only scaling).
>
> Function 'Embedded MATLAB Function' (#194.82.92), line 5, column 8:
> "sqrt(u_fi)"
>
> Thanks,
> Matt

Subject: Generating Code from fixed-point sqrt

From: Matt

Date: 18 Nov, 2009 16:59:23

Message: 3 of 4

I've got around the problem by reducing the precision in the main model i.e. sfix32_En8 instead of sfix40_En16.

I think using sfix40_En16 was providing more precision than is required anyway!

Subject: Generating Code from fixed-point sqrt

From: Matt

Date: 18 Nov, 2009 18:17:24

Message: 4 of 4

Ashok Charry <acharry@mathworks.com> wrote in message <4B042758.5000007@mathworks.com>...
> Hi Matt,
> Could you please tell me what version of MATLAB you are using (type ver
> at MATLAB prompt) and would it be possible to post a snippet of the code
> that is producing this error?
> Thanks,
> Ashok Charry
> The MathWorks

V7.9.0.529 (R2009b), Fixed-Point Toolbox V3.0, RTW V7.4, RTW Embedded Coder V5.4. Oh, my target is ert, I haven't tried grt.

My real model is pretty complicated but I demonstrated the same problem by creating a new model which contained a constant (type double, value 9), a conversion block (to sfix40_En16), an Embedded M block containing 'y = sqrt(u)', an output and a display block.

Do you want me to e-mail the model or something?

Thanks,
Matt

Tags for this Thread

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.

rssFeed for this Thread

Contact us at files@mathworks.com