Data type conversion out of matlab function block with HDL Coder

5 views (last 30 days)
I am receiving the following errors:
Error due to multiple causes.
Error using slhdlcoder.SimulinkConnection/initModel (line 11)
Inferred type ('embedded.fi (uint16)') for data 'Ref_level' (#356)
does not match back propagated type ('uint16') from Simulink.
Error using slhdlcoder.SimulinkConnection/initModel (line 11)
An error occurred while propagating data type 'uint16' through
system/port_name'.
These errors are related to a Matlab Function Blocks output and input respectively. I just changed the code by setting all the internal signals to fi data types. If I don't do this the VHDL generated creates real type variables that wont synthesize.
How should I correct these issues?

Answers (1)

Tim McBrayer
Tim McBrayer on 4 Jun 2014
The error message is saying in essence that uint16 is different from fixdt(0, 16, 0) , which it is. Do you have uint16 data somewhere, perhaps feeding into the MATLAB Function block? If so, you should be able to fix this error by changing all the data types, both in- and outside the function block, to one or the other of the data types, as your needs require.
If you don't need fimath, Simulink will simulate faster if you use uint16. You can do this in the Function block with e.g. uint16(0) wherever yo need to specify the type, as opposed to fi(0, 0, 16, 0). The choice of data type will have no real effect on the generated HDL code.

Community Treasure Hunt

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

Start Hunting!