Matlab HDL coder error: reptmat is not supported, but in the documentation it is.
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello!
I've been working on a project where I used Matlab and Simulink to generate HDL. Specifically, I have to port an existing Matlab image processing framework using the HDL Coder to an FPGA. So far I just simply did workarounds for functions that I needed but weren't supported by the HDL Coder. I tried to use the repmat function, which is according to this documentation, is supported for HDL code generation. Yet when I want to begin the generation process, it throws an error that it's not supported. Same goes for the fimath function. Does anyone know why does this happen? Again, according to the documentation I am using stuff that should be okay.
Here is the code in my custom Matlab function block that I implemented in Simulink:
function img = fcn(in)
%#codegen
F = fimath('OverflowAction','Saturate','RoundingMethod','Floor',...
'CastBeforeSum',false,'ProductMode','SpecifyPrecision', ProductWordLength=24, ProductFractionLength=16) ;
fixedIn = fi(uint8(in));
z1 = fi((-2 + 3^0.5),1,24,16);
z1 = setfimath(z1,F);
z1row = fi(zeros(1,600),1,24,16);
z1row = setfimath(z1row,F);
for i = 1:600
z1row(i) = z1^(i-1);
end
z1row = repmat(z1row,400,1);
img = sum(fixedIn.*z1row,2);
end
I am using version 2022b of Matlab and Vivado 2022.2.
0 comentarios
Respuestas (2)
Steven Lord
el 2 de Mzo. de 2023
There are different implementations of repmat for numeric arrays (the documentation to which you linked) and for fi arrays. Note that both are listed in the output of which but the first one is what will be called for that particular call to repmat.
z1 = fi((-2 + 3^0.5),1,24,16);
which -all repmat(z1, 2, 2)
I'm not sure if the implementation of repmat for fi arrays supports HDL code generation.
0 comentarios
Ryan Baird
el 2 de Mzo. de 2023
Specifying parameters with the syntax ProductWordLength=24 is not yet supported by HDL Coder. The call to fimath can be changed to:
F = fimath('OverflowAction','Saturate','RoundingMethod','Floor','CastBeforeSum',false,'ProductMode','SpecifyPrecision', 'ProductWordLength', 24, 'ProductFractionLength', 16) ;
Based on the error message you received, it sounds like the architecture is set to Matlab Datapath. Unless you're using features that are only supported by the Matlab Datapath architecture, you might also find for this model that setting the architecture to 'Matlab Function' in the Matlab Function block's HDL Block Properties compiles faster and has better error messages when a line of code is unsupported.
2 comentarios
Ryan Baird
el 6 de Mzo. de 2023
It does sound like the Matlab Datapath is required for what you're doing. I agree that you don't want to use both hdl.npufun and the Frame-to-Pixel / Pixel-to-Frame blocks for the same algorithm; hdl.npufun is intended for when you're relying on hdl coder to convert a neighborhood algorithm to a streaming algorithm, and the Frame-to-Pixel and Pixel-to-Frame blocks are intended for if you're modeling a streaming algorithm directly and writing code or a model that operates on one pixel at a time.
Ver también
Categorías
Más información sobre Speed Optimization en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!