Motorola DSP Developer's Kit | ![]() ![]() |
Output Objects
MOTDSP_Output
objects are not used in S-functions. Instead, you create pointers to the output ports using specific Simulink macros.
// Create real versions of output port pointers // to output port 1 // Real and Complex ... creal_T *y1 = (creal_T *)ssGetOutputPortSignal(S,0); // Real only ... real_T *yr = ssGetOutputPortRealSignal(S,0);
You then "fill" these output signals with data returned from execution of the assembly or C program object file.
for (int k = 0; k < ssGetInputPortWidth(S,0); k++) { yr[k] = READ_MEM_SYM("OUT",a->GetSize(),M_FRACTYPE)[k]; }
For real and imaginary parts of a single value complex output
//real part y1[0].re = READ_REG("X1", M_FRACTYPE); //imaginary part y1[0].im = READ_REG("Y1", M_FRACTYPE);
For real and imaginary parts of a complex array output
for (int k = 0; k < ssGetInputPortWidth(S,0); k++) { y1[k].re = READ_MEM_MAP_FRAC(X_MEM, StartAddress1, a->GetSizeReal())[k]; y1[k].im = READ_MEM_MAP_FRAC(Y_MEM, StartAddress1, a->GetSizeImag())[k]; }
See Importing Data to DSP Simulator for more information on how to access the data returned from the simulator.
Validation:. Inside the try
block, a MOTDSP_FuncVar
object is instantiated with the number of input ports and output ports as arguments. Use the supplied MOTDSP_FUNCVAR(NUM_INPORTS,NUM_OUTPORTS)
macro. This class is used to validate access to input/output and create default or initial conditions.
Compared with MATLAB MEX-files, no MOTDSP_Config
class is required for S-functions, since an argument list is not parsed. Instead, arguments are obtained from a parameter dialog box.
![]() | Input Objects | S-Function Blocks | ![]() |