%% $RCSfile: sdspsubmtrx.tlc,v $ %% $Revision: 1.1 $ %% $Date: 1999/11/04 16:32:24 $ %% %% Steve Conahan %% Copyright (c) 1995-1999 The MathWorks, Inc. All Rights Reserved. %% %% Abstract: Submatrix %% %implements sdspsubmtrx "C" %include "dsplib.tlc" %% Function: BlockInstanceSetup =============================================== %% %% Abstract: %% Rename the S-Function parameters for easy reference. %% %function BlockInstanceSetup(block, system) void %% %% I/O PORT CONSTANTS %% %assign INPORT = 0 %assign OUTPORT = 0 %% %% INPUT PORT CHARACTERISTICS %% %assign numInDims = LibBlockInputSignalNumDimensions(INPORT) %assign inDims = LibBlockInputSignalDimensions( INPORT) %assign NUM_ROWS_INPUT = inDims[0] %assign NUM_COLS_INPUT = (numInDims == 2) ? inDims[1] : 1 %% %% This gives the real data type name, no matter if input is real or complex: %assign INPUT_DTYPE_NAME = LibBlockInputSignalDataTypeName( INPORT, "%") %assign COMPLEX_INPUT = LibBlockInputSignalIsComplex( INPORT) %% %% OUTPUT PORT CHARACTERISTICS %% %assign outDims = LibBlockOutputSignalDimensions(OUTPORT) %assign NUM_ROWS_OUTPUT = outDims[0] %assign NUM_COLS_OUTPUT = outDims[1] %% %% DERIVED CONSTANTS %% %% NOTE: The following only works for SL built-in types (i.e. not for custom types) %assign inputDtypeId = LibBlockInputSignalDataTypeId(INPORT) %assign bytesPerDataType = SLibGetDataTypeSizeFromId(inputDtypeId) %% %assign numColSampsToCopy = SFcnParamSettings.RowEndIdx - SFcnParamSettings.RowStartIdx + 1 %assign TOTAL_BYTES_PER_COL = bytesPerDataType * NUM_ROWS_INPUT %assign BYTES_PER_COLUMN_TO_COPY = bytesPerDataType * numColSampsToCopy %assign OFFSET_BYTES_PER_COL = bytesPerDataType * SFcnParamSettings.RowStartIdx %% %if COMPLEX_INPUT %assign TOTAL_BYTES_PER_COL = 2 * TOTAL_BYTES_PER_COL %assign BYTES_PER_COLUMN_TO_COPY = 2 * BYTES_PER_COLUMN_TO_COPY %assign OFFSET_BYTES_PER_COL = 2 * OFFSET_BYTES_PER_COL %endif %% %assign block = block + INPORT + OUTPORT %assign block = block + INPUT_DTYPE_NAME + COMPLEX_INPUT %assign block = block + NUM_ROWS_INPUT + NUM_COLS_INPUT %assign block = block + NUM_ROWS_OUTPUT + NUM_COLS_OUTPUT %assign block = block + TOTAL_BYTES_PER_COL + BYTES_PER_COLUMN_TO_COPY %assign block = block + OFFSET_BYTES_PER_COL %% %endfunction %% BlockInstanceSetup %% Function: Outputs ========================================================== %% %function Outputs(block, system) Output %% /* DSP Blockset Submatrix % (%) - % %if (COMPLEX_INPUT) ** Complex input, data type: % %else ** Real input, data type: % %endif */ { byte_T *u = (byte_T *) %; byte_T *y = (byte_T *) %; %if (SFcnParamSettings.ColStartIdx != SFcnParamSettings.ColEndIdx) int_T colIdx; %endif %% %assign uStartOffset = SFcnParamSettings.ColStartIdx * TOTAL_BYTES_PER_COL %% %if (uStartOffset != 0) /* Initialize u to point to beginning of first column to copy. */ /* Offset as follows: (Start col index) * (Tot bytes per col) */ u += %; %endif %if (SFcnParamSettings.ColStartIdx != SFcnParamSettings.ColEndIdx) /* Loop from starting column index through ending column index */ for (colIdx = %; colIdx <= %; colIdx++) { %endif %% %if (OFFSET_BYTES_PER_COL != 0) memcpy(y, u + %, %); %else memcpy(y, u, %); %endif %% %if (SFcnParamSettings.ColStartIdx != SFcnParamSettings.ColEndIdx) u += %; /* Adding total bytes per column */ y += %; /* Adding bytes just copied */ } %endif %% } %% %endfunction %% Outputs %% [EOF] sdspsubmtrx.tlc