Fixed point converter: Ignore code part.

I am using the HDL Coder and escape an Inputparser with
if coder.target('MATLAB')
p = inputParser;
%...Inputparser Stuff
addOptional(p, 'variable', 'default', @(x)ischar(x));
%...Inputparser Stuff
else
%if nargin = ...
end
The C Coder gets through the code fine, but the fixed-point converter does not skip the coder.target('MATLAB') code.
'@(x)ischar(x)' is an anonymous function. Anonymous functions are not supported for fixed-point conversion.
Is there any possibility to tell the fixed point converter to skip these lines?

5 comentarios

Kiran Kintali
Kiran Kintali el 9 de Mzo. de 2020
Can you share the design and the project?
Thanks
Jan Siegmund
Jan Siegmund el 10 de Mzo. de 2020
Editada: Jan Siegmund el 10 de Mzo. de 2020
The Code is confidential, however here is a minimal working example:
Run hdltest.m through the HDL coder and specify input a as int32(1x1).
File: hdltest.m
function [result] = hdltest(a)
result = simple_add(a,1,2);
end
File: simple_add.m
function [result] = simple_add(a,varargin)
if coder.target('MATLAB')
p = inputParser;
addRequired(p, 'a', @(x)~isempty(x) && isscalar(x));
addOptional(p, 'b', 0, @(x)~isempty(x) && isscalar(x));
addOptional(p, 'c', 0, @(x)~isempty(x) && isscalar(x));
parse(p, a, varargin{:});
b = p.Results.b;
c = p.Results.c;
else
b = 0;
if nargin>1
b = varargin{1};
end
c = 0;
if nargin>2
c = varargin{2};
end
end
result = a + b + c;
end
Result in MATLAB 2019b:
'@(x)~isempty(x) && isscalar(x)' is an anonymous function. Anonymous functions are not supported for fixed-point conversion.
Jan Siegmund
Jan Siegmund el 10 de Mzo. de 2020
Note: in the original code, b and c are dependent on constants (configuration strings), so the minimal example represents pretty well what we are trying to achieve.
Kiran Kintali
Kiran Kintali el 31 de Mzo. de 2020
We have noted the enhancement to ignore coder.target('MATLAB') during fixed-point conversion. Thanks for the representative sample code.
Jan Siegmund
Jan Siegmund el 2 de Abr. de 2020
Thank you.

Iniciar sesión para comentar.

 Respuesta aceptada

Jan Siegmund
Jan Siegmund el 2 de Abr. de 2020

0 votos

Ignoring a code part in fixed point converter is currenty(R2019b) not supported.
Comment out the section as a temporary fix.

Más respuestas (0)

Productos

Versión

R2019b

Preguntada:

el 9 de Mzo. de 2020

Respondida:

el 2 de Abr. de 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by