How to resolve unsupported functions in MATLAB HDL Coder?
9 ビュー (過去 30 日間)
古いコメントを表示
Hello,
We have some simulation code written in MATLAB that we are trying to simulate and deploy on an FPGA, and so we are trying to use the HDL Coder tool for this task. However, we are receiving code generation issues indicating that the following functions are not supported:
- diff
- fft
- exp
- angle
- ifft
- filter
Is there perhaps a toolkit or package that replicates these functions with support for HDL coding? I tried referencing the list of supported functions found here:
But the links for supported functions don't seem to be working (at least for me).
Otherwise, is there a recommended way of resolving this?
Thank you,
James
P.S. I have successfully used the MATLAB Coder to generate C code for this project, if this helps.
2 件のコメント
Walter Roberson
2025 年 1 月 30 日
fft is handled by dsphdl.FFT
angle is handled by cordicangle
ifft is handled by dsphdl.IFFT
filter() itself is not handled, but there are a variety of filters handled, such as dsphdl.BiquadFilter and dsp.HighpassFilter and dsp.FIRFilter
回答 (1 件)
Kiran Kintali
2025 年 1 月 30 日
編集済み: Kiran Kintali
2025 年 1 月 31 日
Happy to assist you with your MATLAB to HDL workflow. Attached is a sample zip file with the code for the attached functions (using R2025a pre-release)
Many customers use HDL Coder to create custom MATLAB algorithms to generate HDL IP. To tailor our assistance to your application needs, could you provide me some details on the following?
- Development Approach: Are you planning to develop your MATLAB code in floating-point and utilize HDL Coder's integrated float2fixed workflow for fixed-point conversion before generating HDL? If so, what are your typical wordlength and fractionlength requirements?
- Floating-Point Hardware: Do you need to generate floating-point hardware directly from your MATLAB code for any functions within the HDL Coder workflow?
- Target Platform: Are you working with FPGA/SoC or ASIC? If it's FPGA/SoC, what is your target platform? For ASIC development, note that HDL Coder supports an HLS (SystemC) workflow compatible with the StratusHLS tool integrated into the Cadence Genus environment.
- Performance Requirements: What are your frequency and area requirements? MATLAB to HDL supports VHDL, Verilog, and SystemVerilog, as well as SystemC and Synthesizable C++ for HLS workflows.
Thanks
3 件のコメント
Kiran Kintali
2025 年 1 月 31 日
MathWorks provides a comprehensive suite of predefined IP modules for various functions:
- FFT: Use dsphdl.FFT. Learn more here.
- Exponential: Refer to the CORDIC Exponential documentation.
- Angle Calculation: Use cordicangle. Further details.
- IFFT: Utilize dsphdl.IFFT. Read more here.
Unsupported Functions
- Filter: The filter() function is not yet supported. Consider alternatives like dsphdl.BiquadFilter and dsp.FIRFilter.
- Differences and Approximate Derivatives: The diff() function is not supported; you may need to create a custom function.
Custom MATLAB Code
You can also implement all the above functions as custom MATLAB code. Refer to the mathfcns.m example in this folder, which defines these operators from first principles.
Project Configuration
The attached .prj file is configured for Verilog. If you set up Vivado in your path, you can perform synthesis and P&R steps directly within the viewer. A test bench is automatically generated based on the testbench. You can also write runme.m files and run the entire workflow (float2fixed + hdlcodegen + testbench + synthesis steps) from command line. See command line workflow
Mixed Code Support
You can mix floating-point and fixed-point code. By enabling the integrated fixed-point conversion step in HDL Coder, you can convert floating-point code to fixed-point. If the code is already in fixed-point, you can instruct the float2fixed step to skip certain functions. Additionally, the MATLAB to HDL product includes automatic function replacement and lookup table generation features.
Additional Steps
- Try the code generation and synthesis steps.
- For further assistance, do not hesitate to reach out to MathWorks support.
Useful Resources
- HDL Code Generation from MATLAB
- HDL Coder Examples
- Fixed-Point Conversion: Learn more about working with fixed-point code.
Examples and Demos
Several FFT-based examples are located in the design patterns folder (<matlabroot>/toolbox\hdlcoder\hdldesignpatterns\matlabhdl).
Use the following command to see fft based examples:
>> mlhdlc_demo_setup('fft')
To see the complete list of available sample code, try:
>> mlhdlc_demo_setup('list')
参考
カテゴリ
Help Center および File Exchange で Fixed Point Conversion Basics and Type Specification についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!