Motorola DSP Developer's Kit | ![]() ![]() |
S-Function Blocks
Perform these three steps to link your S-function MEX-file to a Simulink block:
The parameter names that you specify here are the variable names that are
mapped to the dialog box prompts in the next step. These parameters are
treated by Simulink as MATLAB mxArray
s.
An example of accessing these parameters from your S-function MEX-file is provided in the template.
// Command File #define CMD_FILE ssGetSFcnParam(S,0) // Object File - not required in this file. #define OBJ_FILE ssGetSFcnParam(S,1) // DSP Type #define DSP_TYPE ssGetSFcnParam(S,2)
The above three string parameters (most likely to be used in the Motorola S-function MEX-files) can be accessed by using the following support functions.
int dsptype = MOTDSP_GetSFcnDspFamilyType(DSP_TYPE); char * cmdfile = MOTDSP_GetSFcnCmdFile(CMD_FILE); char * partname = MOTDSP_GetSFcnDSPName(DSP_TYPE);
Alternatively, the integer parameters may be accessed by using mx
functions.
// Number of input ports parameter specified #define NUM_INPORTS (int)mxGetPr(ssGetSFcnParam(S,3))[0] // Number of output ports parameter specified #define NUM_OUTPORTS (int)mxGetPr(ssGetSFcnParam(S,4))[0] /* Cause a 'Sample Hit' to occur at this time during the simulation - to be used as shown in the template.*/ #define DEBUG_AT_TIME_STEP (int)mxGetPr(ssGetSFcnParam(S,5))[0]
Instantiating the Simulink DSP Simulator
See Instantiating the Motorola DSP Simulator for more information on how to instantiate the DSP simulator.
Running Your Simulation
See Running the Simulation for more information on how to start execution of the simulator program.
Importing Data to DSP Simulator
See Importing Data to DSP Simulator for more information on writing data to the DSP simulator.
Exporting Data to Simulink
See Exporting Data to MATLAB for more information on how to read data out of the DSP simulator.
Terminating and Allocating Memory Cleanup
See Terminating and Allocated Memory Cleanup for more information on how to end the simulation and how to free memory allocated during the execution of the MEX-file.
![]() | Output Objects | Tutorial of Advanced Features | ![]() |