Target Language Compiler    

Block Specific Records

Each block may have parameters. All parameters are written out to the model.rtw file in Parameter records that are contained with the Block records. There is one Parameter record for each block parameter (i.e., Block.Parameter[i]). A parameter in this context only refers to parameters that external mode can tune. Therefore, there may not be a one-to-one mapping between parameters in the model.rtw file and the parameter dialog for the block.

Each Simulink built-in block has an associated block record that covers all possible configurations of that block. The following table provides a complete listing of built-in blocks and their associated records. The blocks are listed in alphabetical order. The Target Language Compiler also has an associated TLC file for each block that specifies how code is generated for that block.

This table describes the block specific records written for the Simulink blocks (excluding common fields described above).

Table A-21: Model.rtw Block Specific Records  
Block Type
Properties
AbsoluteValue

No block specific records

Actuator

No block specific records.

Backlash
  • BacklashWidth parameter giving the `backlash' region for the block.
  • 1 RWorkDefine record, containing PrevY if fixed-step solver.
  • 2 RWorkDefine records, containing PrevYA and PrevYB used for `banking' the output to prevent model execution inconsistencies.
BusSelector

No block specific records.

Clock

No block specific records.

CombinatorialLogic

TruthTable parameter defining what the output should be,
y
= f(TruthTable,u).

ComplexToMagnitudeAngle

Output ParamSetting. Output is "Magnitude", "Angle", or "MagnitudeAndAngle" indicating what the output port(s) are producing.

ComplexToRealImag

Output ParamSetting. Output is one of "Real", "Imag", or "RealAndImag" indicating what the output port(s) are producing.

Constant

Value parameter indicating what the output port should produce.

DataStoreMemory

Virtual - Not written to the model.rtw file.

DataStoreRead

DataStore parameter - Region index into data stores list to get data store name, etc.

DataStoreWrite

DataStore parameter - Region index into data stores list to get data store name, etc.

DataTypeConversion

No block specific records.

DeadZone
  • LowerValue parameter - the lower value of the deadzone.
  • UpperValue parameter - the upper value of the deadzone.
  • InputContiguous ParamSetting (yes or no).
  • SaturateOnOverflow ParamSetting (NotNeed, Needed, NeededBugOff, or NeededForDiagnostics).
Demux

Virtual - Not written to the model.rtw file.

Derivative

The Derivative block computes its derivative by using the approximation:

      (input-prevInput)/deltaT
    

Two banks of history are needed to keep track of the previous input because the input history is updated prior to integrating states. To guarantee correctness when the output of the Derivative block is integrated directly or indirectly, two banks of the previous inputs are needed. This history is saved in the real-work vector (RWork). The real-work vectors are:

  • TimeStampA RWork - time values for `bank A'
  • LastUAtTimeA RWork - last input value for `bank A'
  • 'TimeStampB RWork - time values for `bank B'
  • LastUAtTimeB RWork - last input value for `bank B'
DigitalClock

No block specific records.

DiscreteFilter
See Model.rtw Linear Block Specific Records.
DiscreteIntegrator
  • Zero, one or two RWork vectors depending on the InegratorMethod. These will be SystemEnable or IcNeedsLoading or both.
  • IntegratorMethod ParamSetting - ForwardEuler, BackwardEuler, or Trapezoidal.
  • ExternalReset ParamSetting - none, rising, falling, either, level.
  • InitialConditionSource ParamSetting - internal or external.
  • LimitOutput ParamSetting - on or off.
  • ShowSaturationPort ParamSetting - on or off.
  • ShowStatePort ParamSetting - on or off.
  • ExternalX0 ParamSetting - only written when initial condition (IC) source is external.This is the initial value of the signal entering the IC port.
  • InitialCondition parameter.
  • UpperSaturationLimit parameter.
  • LowerSaturationLimit parameter.
DiscretePulseGenerator
  • PhseDelay ParamSetting, giving the numerical phase delay.
  • One IWork for ClockTicksCounter, used to manage the pulse.
  • Amplitude parameter, a numerical vector giving the pulse amplitude.
  • Period parameter, a numerical vector giving the pulse period.
  • PulseWidth parameter, a numerical vector giving the pulse width.
DiscreteStateSpace
See Model.rtw Linear Block Specific Records.
DiscreteTransferFcn
See Model.rtw Linear Block Specific Records.
DiscreteZeroPole
See Model.rtw Linear Block Specific Records.
Display
No block specific records.
ElementaryMath

Operator ParamSetting - One of sin, cos, tan, asin, acos, atan, atan2, sinh, cosh, tanh, exp, log, log10, floor, ceil, sqrt, reciprocal, pow, or hypot.

EnablePort

Only written if nonvirtual. When nonvirtual, we write the following:

  • ControlPortNumber ParamSetting - The control input port number for this block. The corresponding subsystem block control input port index is the block port number minus one.
  • SubsystemIdx ParamSetting - This is the location [systemIdx,blockIdx] of the nonvirtual subsystem which contains this nonvirtual Enable block.
From
Virtual. Not written to model.rtw file.
FromFile
  • FileName ParamSetting - Name of MAT-file to read data from
  • NumPoints ParamSetting - Number of points of data to read
  • TUData ParamSetting - Time and data points. Not present if using the Rapid Simulation Target.
  • Width ParamSetting - Number of columns in TUData structure.
  • One PWork vector, PrevTimePtr used for managing the block output.
FromWorkspace
  • VariableName ParamSetting - Name of variable in "Data" field in block parameter dialog box.
  • DataFormat ParamSetting - "Matrix" or "Structure".
  • Interpolate ParamSetting - Interpolate flag is on/off (see entry for From Workspace block in the Using Simulink manual).
  • OutputAfterFinalValue ParamSetting - How to generate output after final data value (see entry for From Workspace block in the Using Simulink manual).
  • NumPoints ParamSetting - Number of data points (rows) over which to read values from as time moves forward and write to the output port.

The following two items (Time and Data) are written as Parameters if we are generating code for the Rapid Simulation Target, otherwise they are written as ParamSettings.

  • Time - The time tracking vector. May or may not be present. If data format is Matrix, then this field is always present. If data format is Struct then this field is present only if the time field exists.
  • Data - The data to put on the output port.
  • One IWork vector for the PrevIndex used in computing the output.
  • Three PWork vectors, TimePtr, DataPtr, RSimInfoPtr used in computing the output.
Fcn
  • Expr ParamSetting - Text string containing the expression the user entered.
  • ASTNode record, containing the parsed abstract syntax tree for the expression. The general form of the ASTNode is:
    • ASTNode {
        Op            Operator (e.g. "+")
        LHS {         Left-hand side argument for Op
          ...
        }
        RHS {         Right-hand side argument for Op
          ...
        }
      }
      
Gain
  • SaturateOnOverflow ParamSetting - Only written for element gain operations. (NotNeed, Needed, NeededBugOff, or NeededForDiagnostics).
  • OperandComplexity ParamSetting - Only written for non-element gain operations. This is one of RR,RC,CR,CC where R=Real and C=Complex, depending on how the block is configured.
  • Dimensions ParamSetting - Only written for non-element gain operations. This is a vector containing the dimensions for the gain operation.
  • Complexities ParamSetting - Only written for non-element gain operations. An integer array [outputPortComplexity, <input and gain complexity pair>].
Goto
Virtual. Not written to model.rtw file.
GotoTagVisibility
Virtual. Not written to model.rtw file.
Ground
Virtual. Not written to model.rtw file.
HiddenBuffer
There are no block specific records. This block is automatically inserted into your model by the simulation engine to make the generate code more efficient by providing contiguous signals to blocks that require contiguous inputs (for example, the matrix multiply algorithm is more efficient if the inputs are contiguous).
HitCross
  • InputContiguous ParamSetting - yes, no is the input contiguous?
  • HitCrossingOffset Parameter - The hit crossing offset used in computing the output.
InitialCondition

Value parameter - This is the initial condition to output the first time the block executes. It is a parameter (as opposed to a ParamSetting) to enable loop rolling.

Inport
Virtual. Not written to model.rtw file.
Integrator
  • ExternalReset ParamSetting - one of none, rising, falling, either, level.
  • InitialConditionSource ParamSetting - internal or external.
  • LimitOutput ParamSetting - on or off.
  • ShowSaturationPort ParamSetting - on or off.
  • ShowStatePort ParamSetting - on or off.
  • ExternalX0 ParamSetting - only present for external initial conditions.
  • InputContiguous ParamSetting - is the first input port contiguous (yes or no)?
  • ResetInputContiguous ParamSetting - Only present if the reset port is present.
  • InitialCondition parameter.
  • UpperSaturationLimit parameter.
  • LowerSaturationLimit parameter.
Logic

Operator ParamSetting - one of AND, OR, NAND, NOR, XOR, or NOT.

Lookup
  • ZeroTechnique ParamSetting - The type of lookup being performed. This doesn't change during model execution. The possibilities are: NormalInterp, AverageValue, or Middle_Value.
  • InputValues parameter - The input values, x, corresponding to the function y = f(x).
  • OutputValues parameter - The output values, y, of the function
    y = f(x).
  • OutputAtZero parameter - the output when the input is zero.
Lookup2D
  • ColZeroTechnique ParamSetting - NormalInterp, AverageValue, or MiddleValue.
  • ColZeroIndex ParamSetting - Primary index when column data is zero.
  • ColZeroIndex ParamSetting - - NormalInterp, AverageValue, or MiddleValue.
  • RowIndex parameter - The row input values, x, to the function z = f(x,y).
  • ColumnIndex parameter - The column input values, y, to the function z = f(x,y).
  • OutputValues parameter - The table output values, z, for the function z = f(x,y).
MagnitudeAngleToComplex
  • Input ParamSetting - one of "Magnitude", "Angle", or "MagnitudeAndAngle"
  • ConstantPart parameter - Only written when there is one input port.
Math

Operator ParamSetting - exp, log, 10^u, log10, square, sqrt, pow, reciprocal, hypot, rem, or mod.

MATLABFcn

There is no support for the MATLAB Fcn block in the Real-Time Workshop.

Memory
  • One DWork vector, PreviousInput, used to produce the output.
  • X0 parameter - the initial condition.
Merge

InitialOutput parameter, giving the initial output for the merged signal.

MinMax

Function ParamSetting - min or max.

MultiPortSwitch

No block specific records.

Mux

Virtual. Not written to model.rtw file.

Outport

The block record for this block depends on the type of outport:

  • Root outports:
    • PortNumber ParamSetting - Port number as entered in the dialog box.
    • OutputLocation ParamSetting - Specified as Yi if root-level outport; otherwise specified as Bi.
    • OutputWhenDisabled ParamSetting - Only written when in an enabled subsystem and will be held or reset.
  • Outport in a nonvirtual subsystem:
    • InputContiguous ParamSetting - yes or no.
    • OutputWhenDisabled ParamSetting - held or reset.
    • SpecifyIC ParamSetting - yes or no was the IC specified?
    • InitialOutput parameter - Only written for virtual outport blocks in a nonvirtual subsystem.
Probe
  • ProbeWidth ParamSetting - on or off.
  • ProbeSampleTime ParamSetting - on or off.
  • ProbeComplexSignal ParamSetting - on or off.
  • ProbeSignalDimensions ParamSetting - on or off.
Product (element-wise multiply with one input port)
  • If block is configured for element-wise multiply, the block record contains:
    • One optional IWork vector to suppress warnings.
    • Multiplication ParamSetting - "Element-wise(.*)"
    • Inputs ParamSetting - string vector of the form:
      ["*", "*", "/"]
    • SaturateOnOverflow ParamSetting (NotNeed, Needed, NeededBugOff, or NeededForDiagnostics).
Product (matrix multiply with one input port)

If block is configured for matrix multiply with one input port, the block record contains:

  • Multiplication ParamSetting - "Matrix(*)"
  • Inputs ParamSetting - string vector of the form:
    ["*", "*", "/"]
  • OneInputMultipley ParamSetting - yes.
Product (matrix multiply with more than one input port).

If block is configured for matrix multiply, with one input port, the block record contains:

  • Multiplication ParamSetting - "Matrix(*)"
  • Inputs ParamSetting - string vector of the form:
    ["*", "*", "/"]
  • OneInputMultipley ParamSetting - no.
  • OperandComplexity ParamSetting - RR, RC, CR, or CC where:
    •      RR : in1 (real)    in2 (real)
           RC : in1 (real)    in2 (complex)
           CR : in1 (complex) in2 (real)
           CC : in1 (complex) in2 (complex)
      
  • Dimensions ParamSetting - [numSteps x 3] matrix. Each row of the matrix contains 3 elements. If for a specific step, e.g., i-th, operand1 is a [m x n] matrix, and operand2 is a [n x k] matrix, the i-th row contains [m n k].
  • Operands ParamSetting - [numSteps x 3] matrix. Each row contains the {result, operand1, operand2}. Where:
      zero - block output
      greater than zero - data input port number (unity-index based)
      less than zero - dwork buffer number (negative unity-index based).
  • Complexities ParamSetting - [numSteps x 3] matrix. Each row contains the {result, operand1, operand2}. Where:
      zero - real
      one - complex
  • Operators ParamSetting - LU, Pivot, X dwork indices.
  • DivisionBuffers ParamSetting - LU, Pivot, X dwork indices.
Quantizer

QuantizationInterval parameter - numerical vector giving the quantization interval points.

RandomNumber
  • One IWork vector RandSeed.
  • One RWork vector NextOutput.
  • Mean parameter - the mean of the random number generator.
  • StandardDeviation parameter - the standard deviation of the random number generator.
RateLimiter
  • If a variable step solver is being used, then this block has two RWork vectors, PrevYA and PrevYB (two banks to maintain consistent simulation results).
  • If a fixed-step solver is being used, then this block has two RWork vectors, PrevT and PrevY (used to keep track last time and output).
  • RisingSlewLimit parameter.
  • FallingSlewLimit parameter.
RealImagToComplex
  • Input ParamSetting - Real, Imag, or RealAndImag.
  • ConstantPart parameter.
Reference
Will never appear in model.rtw.
RelationalOperator
  • Operator ParamSetting - One of ==, ~=, <, <=, >=, >.
  • InputContiguous ParamSetting - yes or no.
Relay
  • InputContiguous ParamSetting - yes or no.
  • OnSwitchValue parameter.
  • OffSwitchValue parameter.
  • OnOutputValue parameter.
  • OffOutputValue parameter.
ResetIntegrator

InitialCondition parameter.

Rounding

Operator ParamSetting - floor, ceil, round, or fix

Saturate
  • InputContiguous ParamSetting - yes or no.
  • UpperLimit parameter.
  • LowerLimit parameter.
Scope
  • One PWork for LoggedData.
  • SaveToWorkspace ParamSetting - yes or no.
  • SaveName ParamSetting - name of variable to log.
  • MaxRows ParamSetting - maximum number of data points to log.
  • Decimation ParamSetting - integer giving when to log data 1 for every time step, 2 for every other time step, and so on.
  • DataFormat ParamSetting - StructureWithTime, Structure, or Matrix.
  • AxesTitles ParamSetting - record giving the axis title strings.
  • AxesLabels ParamSetting - record giving the axis label strings.
  • PlotStyles ParamSetting - what we are plotting.
Selector

Virtual. Not written to model.rtw file.

S-Function

The S-function has the following parameter settings:

  • FunctionName - Name of S-function.
  • SFunctionLevel - Level of the S-function 1 or 2.
  • FunctionType - Type of S-function: "M-File", "C-MEX", or "FORTRAN-MEX".
  • Inlined - yes, no, or skip. Skip is for case of non-C-MEX S-function sink.
  • DirectFeedthrough - For level 1 S-functions, this will be written as yes or no. For level 2 S-functions, this will be a vector of yes or no for each input port.
  • UsingUPtrs - If this is a Level 1 C MEX S-function and if it is using ssGetUPtrs (instead of ssGetU), then this ParamSetting will be "yes". If this a Level 2 S-function, then this field will be a vector of yes/no, each element corresponding to each input port. An element value of "yes" implies that the S-function has set the RequiredContiguous attribute for the corresponding input port to true. The Level 2 S-function will be using ssGetInputPortSignal (instead of ssGetInputPortSignalPtrs).
  • InputContiguous - For level 1 S-functions, this will be yes or no. For level 2 S-functions, this is a vector of yes or no for each input port.
  • SampleTimesToSet - Mx2 matrix of sample time indices indicating any sample times specified by the S-function in mdlInitializeSizes and mdlInitializeSampleTimes that get updated. The first column is the S-function sample time index, and the 2nd column is the corresponding SampleTime record of the model giving the PeriodAndOffset. For example, an inherited sample time will be assigned the appropriate sample time such as that of the driving block. In this case, the SampleTimesToSet will be [0, <i>] where <i> is the specific SampleTime record for the model.
S-Function (continued)
  • DynamicallySizedVectors - Vector containing any of:
    "U", "U0", "U1", ..., "Un",
    "Y", "Y0", "Y1", ..., "Yn",
    "Xc", "Xd", "RWork", "IWork", "PWork", "D0", ...., "Dn".

    For example ["U0", "U1", "Y0"].
    For a level 1 S-function only U or Y will be used whereas for a level 2 S-function, U0, U1, ..., Un, Y0, Y1, ..., Yn will be used. This includes dynamically typed vectors, i.e., data type and complex signals. For example, if U0 is in this list either width, data type, or complex signal of U0 is dynamically sized (or typed).

      SFcnmdlRoutines - Vector containing any of:
        ["mdlInitializeSizes",
         "mdlInitializeSampleTimes",
         "mdlInitializeConditions",
         "mdlStart",
         "mdlOutputs",
         "mdlUpdate",
         "mdlDerivatives",
         "mdlTerminate"
         "mdlRTW"]
      

    Indicating which routines need to be executed. Only written for level 2 S-functions.

  • RTWGenerated - yes or no, is this generated by the Real-Time Workshop?

The next section contains information about function-call connections:

    NumSFcnSysOutputCalls - Number of calls to subsystems of type
                             "function-call".
    SFcnSystemOutputCall {   One record for each call
      OutputElementIndex of the output element that is
                             doing the function call.
      FcnPortElementIndex of the subsystem function
                             port element that is being called.
      BlockToCall  [systemIndex, blockIndex] or
                             unconnected
    }
    
S-function (continued)
If the S-function has a mdlRTW method, then additional items can be added. See matlabroot/simulink/src/sfuntmpl.doc.
If the S-function is not inlined, i.e., sfunctionname.tlc does not exist) then

    For each S-function parameter entered in the dialog box, there is a P#Size and P# parameter giving the size and value of the parameter, where # is the index starting at 1 of the parameter in the dialog box.

If the S-function is inlined, i.e., sfunctionname.tlc does exist,

    No sizes parameter. Parameter names are derived from the run-time parameter names.

SignalGenerator
  • WaveForm ParamSetting - sine, square, or sawtooth.
  • TwoPi - 6.283185307179586.
  • Amplitude parameter.
  • Frequency parameter.
Signum

No block specific records.

Sin

This block has two very distinct forms. If the block is discrete, we use trigonometric identities to remove time from the output function, otherwise we simply compute the output as a function of time.

  • If the block is discrete,
    • We have two RWork vectors, LastSin, LastCos and one IWork, SystemEnable.
    • We have the following parameters: Amplitude, Frequency, SinH, CosH, SinPhi, CosPhi.
  • otherwise:
    • We have the following parameters: Amplitude, Frequency.
Step
  • Time parameter.
  • Before parameter.
  • After parameter.
StateSpace
See Model.rtw Linear Block Specific Records.
Sum
  • Inputs ParamSetting - A vector of the form ["+", "+", "-"] corresponding to the configuration of the block.
  • SaturateOnOverflow ParamSetting (NotNeed, Needed, NeededBugOff, or NeededForDiagnostics).
SubSystem
  • SystemIdx ParamSetting - Index of this system in the model.rtw file.
  • StatesWhenEnabling ParamSetting - held or reset. Only written if enable port is present.
  • TriggerBlock ParamSetting - Block index of TriggerPort block in system or NotPresent.
  • TriggerScope ParamSetting - Only written if we have a trigger port. It can be one of: NoScope, ScopeOnce, ScopeIndividually.
  • EnableScope ParamSetting - Only written if we have an enable port. It can be one of: NoScope, ScopeOnce, ScopeIndividually.
  • SystemContStates ParamSetting - Specified as [N,I] where N is the number of continuous states and I is the index into the state vector, X.
  • UseSystemNameForRTWFileName ParamSetting - on or off.
  • SystemFileName ParamSetting.
  • NumNonsampledZCs ParamSetting.
  • StartNonsampledZCs ParamSetting.
  • SkipIntgOnTrigEvent ParamSetting.
  • SingleRate ParamSetting.
  • MinorStepGuard ParamSetting.
Switch
  • ControlInputContiguous ParamSetting - yes or no.
  • Threshold parameter.
ToFile
  • One IWork vector, Decimation.
  • Two PWork vectors, FilePtr, and LogFilePtr.
  • Filename ParamSetting.
  • MatrixName ParamSetting.
  • Decimation ParamSetting.
ToWorkspace
  • One PWork vector, LoggedData.
  • VariableName ParamSetting - Name of variable used to save data.
  • Buffer ParamSetting- Maximum number of rows to save or 0 for no limit.
  • Decimation ParamSetting - Data logging interval
  • InputContiguous - yes or no.
  • SaveFormat ParamSetting.
  • Label ParamSetting.
Terminator

Virtual. Not written to model.rtw file.

TransferFcn

See Model.rtw Linear Block Specific Records.

TransportDelay
  • InitialInput ParamSetting.
  • BufferSize ParamSetting.
  • DiscreteInput ParamSetting.
  • One IWork vector, BufferIndices.
  • One PWork vector, TUbuffer.
  • DelayTime parameter.
TriggerPort
  • TriggerType ParamSetting - Only written if the number of output ports is one.
  • ControlPortNumber ParamSetting - The control input port number for this block. The corresponding subsystem block control input port index is PortNumber-1.
  • SubsystemIdx ParamSetting - This is the location [systemIdx, blockIdx] of the non-virtual subsystem which contains this non-virtual Trigger block.
Trigonometry
  • Operator ParamSetting - sin, cos, tan, asin, acos, atan, atan2, sinh, cosh, or tanh.
UniformRandomNumber
  • One IWork vector, RandSeed.
  • One RWork vector, NextOutput.
  • Seed ParamSetting.
  • Minimum parameter.
  • MaxMinusMin parameter.
UnitDelay
  • One DWork vector, PreviousInput, used to produce the output.
  • X0 parameter - the initial condition.
VariableTransportDelay
  • InitialInput ParamSetting.
  • BufferSize ParamSetting.
  • DiscreteInput ParamSetting.
  • One IWork vector, BufferIndices.
  • One PWork vector, TUbuffer.
  • DelayTime parameter.
Width

No block specific records.

ZeroPole
See Model.rtw Linear Block Specific Records.
ZeroOrderHold
No block specific records.


 Model Checksums Linear Block Specific Records