MATLAB function block doesn't generate synthesizable HDL.
Show older comments
I developed an algorithm by using MATLAB function block and it responses properly. But, when I try to generate HDL code through HDL coder, then fail to do so with following errors.
"Signals of type double will not generate synthesizable HDL. For synthesizble code, consider enabling native floating point mode and retyping double typed signals to single".
Please help
Accepted Answer
More Answers (5)
Bharath Venkataraman
on 5 Aug 2021
0 votes
It appears that you have floating point values in your MATLAB code.
If you want to retain floating point numerics for your HDL, configure HDL Coder to generate floating point as shown in this page.
Another option is to convert these floating point variables to fixed point using the fi construct with signedness, wordlength and fraction length, and generate fixed-point HDL code.
1 Comment
Khakoo Mal
on 6 Aug 2021
Kiran Kintali
on 6 Aug 2021
0 votes
Try the attached sample model which shows how to MATLAB function block with floating point single precision code using native floating point.

1 Comment
Khakoo Mal
on 6 Aug 2021
Kiran Kintali
on 6 Aug 2021
Edited: Kiran Kintali
on 6 Aug 2021
0 votes
I am attaching R2018a version of the model for viewing the contents of the MATLAB function. I recommend upgrading to latest releases for HDL code generation. There are significant improvements in floating point code generation. Floating point code generation for MATLAB function block is available from 19b release.
https://www.mathworks.com/help/hdlcoder/release-notes.html
2 Comments
Khakoo Mal
on 12 Aug 2021
Walter Roberson
on 12 Aug 2021
"Floating point code generation for MATLAB function block is available from 19b release." implies to me that you need to upgrade to do what you want.
Kiran Kintali
on 12 Aug 2021
0 votes
R2019b
New Features, Bug Fixes
Model and Architecture Design
HDL code generation for MATLAB Function block in native floating-point mode
In R2019b, HDL Coder™ supports code generation for the MATLAB Function block by using floating-point data types in Native Floating Point mode. You can use a wider subset of MATLAB® functions to develop complex floating-point algorithms.
By default, floating-point support in HDL Coder uses a new MATLAB datapath architecture of the MATLAB Function block. This architecture treats the MATLAB Function block like a Subsystem block. The generated HDL code with the MATLAB datapath architecture is more readable.

1 Comment
Khakoo Mal
on 19 Aug 2021
Kiran Kintali
on 19 Aug 2021
0 votes
An operator or a block in Simulink can support all floating point types (for input, output and intermediate settings) that are set to same type (single, double, half). Check documentation on available floating point usage.
Consider using our automated tools to convert double to single or do manual conversion necessary to comply with supported usecases.
Please share your model for any further assistance.
Categories
Find more on Native Floating Point in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!