Simulink Design Verifier does not accept 64bits
Mostra commenti meno recenti
Hello,
I am encountering some issues in running Simulink Checks on my Simulink project, that includes s-functions.
In particular I have an s-function used to compute the time (see below) that is causing the fail of the Simulink Design Verifier analysis, for Check usage of Reciprocal Sqrt blocks. The error is the following:
Building model representation failed: Code cannot be generated for this model because block '.../GET_TIME1/sfun_GET_TIME' is using the data type 'int64' which requires 64 bits, but the maximum supported by the block for code generation is 32.
Considering that I have to use 64 bits, is there a way to make the SDV compatible with numbers in 64 bits or to pass this check in any case?
Thanks for the support!
#define S_FUNCTION_LEVEL 2
#define S_FUNCTION_NAME sfun_GET_TIME
/*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
/* %%%-SFUNWIZ_defines_Changes_BEGIN --- EDIT HERE TO _END */
#define NUM_INPUTS 0
#define NUM_OUTPUTS 2
/* Output Port 0 */
#define OUT_PORT_0_NAME SYSTEM_TIME
#define OUTPUT_0_WIDTH 1
#define OUTPUT_DIMS_0_COL 1
#define OUTPUT_0_COMPLEX COMPLEX_NO
#define OUT_0_FRAME_BASED FRAME_NO
#define OUT_0_BUS_BASED 0
#define OUT_0_BUS_NAME
#define OUT_0_DIMS 1-D
#define OUT_0_ISSIGNED 1
#define OUT_0_WORDLENGTH 64
#define OUT_0_FIXPOINTSCALING 0
#define OUT_0_FRACTIONLENGTH -1
#define OUT_0_BIAS 0
#define OUT_0_SLOPE 0
/* Output Port 1 */
#define OUT_PORT_1_NAME RET_CODE
#define OUTPUT_1_WIDTH 1
#define OUTPUT_DIMS_1_COL 1
#define OUTPUT_1_COMPLEX COMPLEX_NO
#define OUT_1_FRAME_BASED FRAME_NO
#define OUT_1_BUS_BASED 0
#define OUT_1_BUS_NAME
#define OUT_1_DIMS 1-D
#define OUT_1_ISSIGNED 1
#define OUT_1_WORDLENGTH 8
#define OUT_1_FIXPOINTSCALING 1
#define OUT_1_FRACTIONLENGTH 3
#define OUT_1_BIAS 0
#define OUT_1_SLOPE 0.125
#define NPARAMS 0
#define SAMPLE_TIME_0 INHERITED_SAMPLE_TIME
#define NUM_DISC_STATES 0
#define DISC_STATES_IC [0]
#define NUM_CONT_STATES 0
#define CONT_STATES_IC [0]
#define SFUNWIZ_GENERATE_TLC 1
#define SOURCEFILES "__SFB__"
#define PANELINDEX 6
#define USE_SIMSTRUCT 0
#define SHOW_COMPILE_STEPS 0
#define CREATE_DEBUG_MEXFILE 0
#define SAVE_CODE_ONLY 1
#define SFUNWIZ_REVISION 3.0
/* %%%-SFUNWIZ_defines_Changes_END --- EDIT HERE TO _BEGIN */
/*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
#include "simstruc.h"
#include "fixedpoint.h"
#include "time.h"
typedef
enum {
NO_ERROR = 0, /* request valid and operation performed */
NO_ACTION = 1, /* status of system unaffected by request */
NOT_AVAILABLE = 2, /* resource required by request unavailable */
INVALID_PARAM = 3, /* invalid parameter specified in request */
INVALID_CONFIG = 4, /* parameter incompatible with configuration */
INVALID_MODE = 5, /* request incompatible with current mode */
TIMED_OUT = 6 /* time-out tied up with request has expired */
} RETURN_CODE_TYPE;
typedef long long APEX_LONG_INTEGER; /* 64-bit signed.*/
typedef APEX_LONG_INTEGER SYSTEM_TIME_TYPE; /* 64-bit signed integer with a 1 nanosecond LSB */
/*====================*
* S-function methods *
*====================*/
/* Function: mdlInitializeSizes ===============================================
* Abstract:
* Setup sizes of the various vectors.
*/
static void mdlInitializeSizes(SimStruct *S)
{
int id;
DECL_AND_INIT_DIMSINFO(outputDimsInfo);
ssSetNumSFcnParams(S, NPARAMS);
if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) {
return; /* Parameter mismatch will be reported by Simulink */
}
ssSetNumContStates(S, NUM_CONT_STATES);
ssSetNumDiscStates(S, NUM_DISC_STATES);
ssFxpSetU32BitRegionCompliant(S, 1);
if (!ssSetNumInputPorts(S, NUM_INPUTS)) return;
if (!ssSetNumOutputPorts(S, NUM_OUTPUTS)) return;
/* Output Port 0 */
ssSetOutputPortWidth(S, 0, OUTPUT_0_WIDTH);
ssRegisterTypeFromNamedObject(S, "SYSTEM_TIME_TYPE", &id);
ssSetOutputPortDataType(S, 0, id);
ssSetOutputPortComplexSignal(S, 0, OUTPUT_0_COMPLEX);
/* Output Port 1 */
ssSetOutputPortWidth(S, 1, OUTPUT_1_WIDTH);
ssRegisterTypeFromNamedObject(S, "RETURN_CODE_TYPE", &id);
ssSetOutputPortDataType(S, 1, id);
ssSetOutputPortComplexSignal(S, 1, OUTPUT_1_COMPLEX);
ssSetNumSampleTimes(S, 1);
ssSetNumRWork(S, 0);
ssSetNumIWork(S, 0);
ssSetNumPWork(S, 0);
ssSetNumModes(S, 0);
ssSetNumNonsampledZCs(S, 0);
ssSetSimulinkVersionGeneratedIn(S, "8.8");
/* Take care when specifying exception free code - see sfuntmpl_doc.c */
ssSetOptions(S, (SS_OPTION_EXCEPTION_FREE_CODE |
SS_OPTION_USE_TLC_WITH_ACCELERATOR |
SS_OPTION_WORKS_WITH_CODE_REUSE));
}
/* Function: mdlInitializeSampleTimes =========================================
* Abstract:
* Specifiy the sample time.
*/
static void mdlInitializeSampleTimes(SimStruct *S)
{
ssSetSampleTime(S, 0, SAMPLE_TIME_0);
ssSetModelReferenceSampleTimeDefaultInheritance(S);
ssSetOffsetTime(S, 0, 0.0);
}
#define MDL_SET_OUTPUT_PORT_DATA_TYPE
static void mdlSetOutputPortDataType(SimStruct *S, int port, DTypeId dType)
{
ssSetOutputPortDataType(S, 0, dType);
}
#define MDL_SET_DEFAULT_PORT_DATA_TYPES
static void mdlSetDefaultPortDataTypes(SimStruct *S)
{
ssSetOutputPortDataType(S, 0, SS_DOUBLE);
}
/* Function: mdlOutputs =======================================================
*
*/
static void mdlOutputs(SimStruct *S, int_T tid)
{
SYSTEM_TIME_TYPE *SYSTEM_TIME = (SYSTEM_TIME_TYPE *) ssGetOutputPortRealSignal(S,0);
RETURN_CODE_TYPE *RET_CODE = (RETURN_CODE_TYPE *)ssGetOutputPortRealSignal(S,1);
real_T time = ssGetT(S);
*SYSTEM_TIME = (SYSTEM_TIME_TYPE)(time*1000000000);
*RET_CODE = NO_ERROR;
}
/* Function: mdlTerminate =====================================================
* Abstract:
* In this function, you should perform any actions that are necessary
* at the termination of a simulation. For example, if memory was
* allocated in mdlStart, this is the place to free it.
*/
static void mdlTerminate(SimStruct *S)
{
}
#ifdef MATLAB_MEX_FILE /* Is this file being compiled as a MEX-file? */
#include "simulink.c" /* MEX-file interface mechanism */
#include "fixedpoint.c"
#else
#include "cg_sfun.h" /* Code generation registration function */
#endif
Risposte (0)
Categorie
Scopri di più su Block Authoring and Simulation Integration in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!