[Matlab Coder] Generate C code with hierarchy

3 views (last 30 days)
Hi,
I'm using Matlab coder to generate C code for my project so that I can put it through HLS. As I know, Matlab has an HDL coder toolbox to implement algorithm in Matlab and Simulink for HDL programming. However, my project requires to add some other modification in the HDL level with the use of Vivado HLS. Thus, I need to manually modify and redefine the C code generated by Matlab Coder. Right now, I have some trouble with the hierachy of the generated C code, and causes my a lot of troubles in debugging. Below is my Matlab code hierachy:
------Rk_4.m
|<------------------------------ IS_dynamics.m
It means that I have a file named as Rk_4.m that is calling a lower level file (IS_dynamics.m) mutiple times during the execution. After using Matlab coder for Rk_4.m file, I noticed that the generated C code in Rk_4.c didn't make any call to the function IS_dynamics as it did in Matlab. Instead, it generates C code for IS_dynamics.m file and places inside the Rk_4.c, which creates a complicated and hard to keep track c code file. Hopefully, the picture below can explain more what my problem is:
Thus, I want to ask, If there is an option in Matlab coder that I can generate my RK_4.c file so that It will call the function IS_dynamics (maybe from the file IS_dynamics.c) instead of extracting IS_dynamic.m directly inside RK_4.c.

Accepted Answer

Darshan Ramakant Bhat
Darshan Ramakant Bhat on 5 Oct 2021
The function "Is_dynamics" is getting inlined by compiler optimization while generating code from MATLAB. Please try coder.inline('never') option on the called function :

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by