- As you mentioned, Simulink doesn't support int64 or uint64 as built-in data types for S-functions and you have to register them for using them as outports, inports or states. You can use the following commands to register int64 or uint64:
S-Function uint64_T input/output for simulink code generation error
14 ビュー (過去 30 日間)
古いコメントを表示
I am attempting to generate C code with simulink coder for a model with an S-Function on Matlab 2020b. The S-Function contains an int64 input and an int64 output. The update diagram and simulink simulation work fine, therefore my s-function is valid. But C code generation with simulink coder indicates an error stating the maximum supported by the block for code generation is 32 bits, and in my tlc file i have the correct types in my function prototypes. In my S-Function i have also registered the 64 bits data types since SS_UINT64 and SS_INT64 does not exist.
What am i missing something? How can i generate the code using a 64 bit data type?



0 件のコメント
回答 (1 件)
Aiswarya
2023 年 10 月 20 日
Hi,
I understand that you are trying to generate C code with Simulink coder for a S-function with int64 input and output, but you are getting an error regarding data type while doing so. The steps below can help you solve the error:
DTypeId dtId_Int64 = ssRegisterDataTypeInteger(S,1,64,0);
DTypeId dtId_Uint64 = ssRegisterDataTypeInteger(S,0,64,0);
And then use themto specify inport and outport:
ssSetInputPortDataType( S,0,dtId_Int64); // 1st input port uses int64
ssSetOutputPortDataType(S,1,dtId_int64); // 1st output port uses int64
Refer to the following link on more information on data type IDs: https://www.mathworks.com/help/fixedpoint/ug/data-type-ids.html
2. In addition to that, you have to also include the header files mentioned below for using 64 bit integers:
#include "simstruc.h"
#include "fixedpoint.h"
The following link will help you create the structure of a S-function which uses fixed point data types:
3. While mexing you have to pass an extra argument :
mex('your_sfun_file.c','-lfixedpoint')
In case of any issues while doing this set up, you may refer to the following answer:
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!