I want to covert MATLAB code to VHDL code using HDL coder. But I am getting following error. I have changed values many times but even also I am getting the same error .

1 次查看(过去 30 天)
### Begin TestBench generation.
Error using divide (line 169)
Division by zero detected.
Early termination due to division by zero.
Error in Float2FixedConverter>runTestBenchToLogDataNew/withScopeProtection/runSimWithTBEvalSimFcn at 567
Error in Float2FixedConverter>runTestBenchToLogDataNew at 495
Error in HDLCoderTB>computeData at 399
Error in HDLCoderTB>generateTB at 460
Error in Manager>wfa_runSimulation at 76

回答(1 个)

Tim McBrayer
Tim McBrayer 2015-9-16
编辑:Tim McBrayer 2015-9-16
If you have a data value that isn't originally zero, but becomes zero when quantized to fixed point, you could get this message. If you have a persistent variable feeding the divide, and the persistent value has an initial value of zero, that could be another possible cause.
Perhaps something like this might work:
if b ~= 0
c = a/b;
else
c = <max value for c's data type>;
end
The larger issue is that you have some source code that is resulting in a division. In general, division with an arbitrary denominator is not supported for HDL Synthesis. Even if your tool can synthesize it, it will take a lot of FPGA real estate.
  2 个评论
Maximilian Sgodda
Maximilian Sgodda 2020-3-20
Hi Tim,
I have a similiar issue. I want to implement a persistent variable that will be divided by a constant value. This constant value can be adjusted every time the script is running.
Later in the FPGA this "real" division should be implemented, since many FPGA have these Multipliers on board and can generate a division in fixed point.
How can I do this?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Code Generation 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by