How to make block description of a simulink function block displayed above function header?

2 views (last 30 days)
Hi everyone,
I'm using simulink function block to generate C code. For simulink function block, I add a brief function description to the block as shown below on the left side.
After code generation, the function description is inserted inside the function body.
So, I want to know if there is a way to display this description above the function header instead of inside the function body?
Thanks!

Accepted Answer

zhichuan wang
zhichuan wang on 24 Oct 2018
I think I get you point. You can modify the CODE TEMPLATES FILE in Configuration Parameters(Code Generation->Templates-Code templates-Source file template) to do what you want.
  5 Comments
zhichuan wang
zhichuan wang on 26 Oct 2018
Hi, qxj
I've saved your model with previous version in 2017b with the help of others. After running your model in 2017b , I found that the generated code is different from yours in 2018a, which makes me confused.
1 /*
2 * File: test_2017b_timestwo.c
3 *
4 * Code generated for Simulink model 'test_2017b'.
5 *
6 * Model version : 1.23
7 * Simulink Coder version : 8.13 (R2017b) 24-Jul-2017
8 * C/C++ source code generated on : Fri Oct 26 08:51:02 2018
9 *
10 * Target selection: ert.tlc
11 * Embedded hardware selection: Intel->x86-64 (Windows64)
12 * Code generation objectives: Unspecified
13 * Validation result: Not run
14 *
15 *
16 * TLC version : 8.13 (Jul 25 2017)
17 */
18
19 #include "test_2017b_timestwo.h"
20
21 /* Include model header file for global data */
22 #include "test_2017b.h"
23 #include "test_2017b_private.h"
24
25 /*!
26 * Function Name : test_2017b_timestwo
27 * Block Description : Block description for: '<Root>/timestwo'
28 * This function multiplies the input with two and then outputs the result as return value.
29 *
30 * Input:
31 * u: uint32
32 *
33 * Return:
34 * y: uint32
35 * Arguments : uint32_T rtu_u
36 * Return Type of Function : uint32_T
37 */
38 uint32_T test_2017b_timestwo(uint32_T rtu_u)
39 {
40 return rtu_u << 1;
41 }
42
43 /*
44 * File trailer for generated code.
45 *
46 * [EOF]
47 */
48
Xiaojie Qiu
Xiaojie Qiu on 29 Oct 2018
Hi Zhichuan,
after code generation by using MATLAB R2017b, I also got the same result as you.
So, I have to draw a conclusion, that this problem is a side effect due to MATLAB version.
If you have any idea in the future, please tell me how to solve it. Thanks for your help again!
qxj

Sign in to comment.

More Answers (0)

Categories

Find more on Simulink Functions in Help Center and File Exchange

Products


Release

R2018a

Community Treasure Hunt

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

Start Hunting!