[HDL Coder] Bug: Fixed point converter does not descend into System Objects

1 回表示 (過去 30 日間)
Jan Siegmund
Jan Siegmund 2020 年 4 月 6 日
編集済み: Jan Siegmund 2020 年 4 月 22 日
Can I somehow tell the fixed point converter to explicitly convert a certain function? This would temporarily fix the following bug.
The Bug I found can be reproduced with these files:
dut_tb.m
a = dut(1);
dut.m
function out = dut(in)
persistent system;
if isempty(system)
system = dutSystem(1.1);
end
out = system.step(in);
end
dutSystem.m
classdef dutSystem < matlab.System
properties (Nontunable)
number
end
methods (Access = public)
function obj = dutSystem(number)
obj.number = number;
end
end
methods (Access = protected)
function out = stepImpl(obj,in)
out = buggy_function(in,obj.number);
end
end
end
buggy_function.m
function out = buggy_function(in1, in2)
out = round(in1 + in2);
end
convert.m
function [] = convert()
exArgs = {1};
fc = coder.config('fixpt');
fc.TestBenchName = 'dut_tb';
hc = coder.config('hdl');
codegen -float2fixed fc -args exArgs -config hc dut
end
Execute convert. The HDL coder will stop, because round is supposedly not supported by the HDL coder. But it is supported. The fixed-point converter just did not convert buggy_function.m

回答 (1 件)

Kiran Kintali
Kiran Kintali 2020 年 4 月 20 日
Unfortunately the development team cannot reproduce the issue. Is it possible the attached reproduction steps are not sufficient? Can you share a zip file with the code and a snapshot of the error message when running the convert() function? Thanks
  1 件のコメント
Jan Siegmund
Jan Siegmund 2020 年 4 月 22 日
編集済み: Jan Siegmund 2020 年 4 月 22 日
Sorry, somehow, MATLAB 2020a in contrast to 2019b accepts double inputs in round.
But this does not mean, that the error is not reproduceable. The problematic extract from my dutSystem_fixpt.m:
...
function out = stepImpl(obj,in)
fm = get_fimath();
out = fi(buggy_function(in,obj.number), 0, 14, 15, fm);
end
...
It uses the standard buggy_function and not buggy_function_fixpt.
Use this buggy_function.m instead and you will see an error pop up.
function out = buggy_function(in1, in2)
out = in1/(2^in2);
end

サインインしてコメントする。

タグ

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by