Target Language Compiler    

Data Type Work (DWork) Information

Certain blocks require persistent memory to store values between consecutive time intervals. When these blocks require the data to be stored in a data type other than real_T (the default data type), then instead of using an RWork element, a DWork element is used. DWork contains block identifier, name, width, datatype index, and a flag that tells whether it is used to retain data typed state information. Blocks that use data types but do not require persistence (e.g., Gain blocks) do not require DWork entries.

Data Store Read and Write blocks access a Data Store Memory block. The memory associated with a Data Store Memory block is placed within a DWork record.

Note, all RWork, IWork, PWork, ModeVector, DiscStates code elements are captured in the DWork records. Think of the real (RWork), integer (IWork), and pointer (PWork), etc. as well-defined data type (DWork) vectors.

Table A-12: Model.rtw Data Type (DWork) Information 
Variable/Record Name
Description
DWorks {

List of all data type work vectors in the model. There is one DWork record for each data type work vector in the model. The source of a data type work vector is a block. A block can have zero or more data type work vectors.

  DWorkDefaults {

Default values for the following DWork records.

    RecordType

DWork

    Width

1: Length of data type work vector.

    MemoryMapIdx

[-1,-1,-1]: used to populate global data map record (GlobalMemoryMap) during code generation. The TLC functions that are required to generate and access the global data map record are contained in
matlabroot/rtw/c/tlc/mw/globalmaplib.tlc.

    StorageClass

Auto: Real-Time Workshop declares memory for this DWork.

    CustomStorageClassVersion

0

    StorageTypeQualifier

"": No type qualifier.

    HasObject

0: if HasObject = 1, this DWork is a Simulink Data Object. See "Object Information in the model.rtw File" in the Real-Time Workshop User's Guide.

    DataTypeIdx

0: Default vector of a DWork record is a real_T vector.

    ComplexSignal

no: Default vector of a DWork record is a non-complex vector.

    Origin

DWORK: This datatype work vector originated as a DWork.

    UsedAs

DWORK: This data type work vector is used as a DWork.

    InitialValue

[ ]

    AcceleratorPadding

0

  }

  NumDWorks

Number of data type work vectors in the model. Each block can register 0 or more data type work vectors. This include discrete states, RWork, IWork, PWork and ModeVector. Each record contains a vector as well as information describing the vector. For example, the model may contain two data type work records where one record contains a vector of length 3 and the other contains a vector of length 9 where each vector is of a different data type. In this case, NumDWorks is 2.

  DWork {

One DWork record for each data type work vector.

    Identifier

Identifier provides a unique variable name across all data type work vectors, can also be used to reference Simulink State objects.

    Width

Length of the data type work vector.

    DataTypeIdx

Index into the CompiledModel.DataTypes.DataType record list (i.e., the data type table used to identify the data type for this DWork). Only written if data type is a non-real_T (i.e., not a 0).

    ComplexSignal

yes: Only written if this data type work vector is complex.

    Origin

Only written if not default (DWORK); it can be one of MODE, RWORK, IWORK, PWORK or DSTATE.

    UsedAs

Only written if not default (DWORK); it can be either DSTATE or SCRATCH.

    SigSrc

[systemIdx, callSiteIdx, blockIdex, dworkIdx].

    StorageClass

Specifies where to declare/place this parameter value in memory (Auto, ExportedGlobal, ImportedExtern, ImportedExternPointer). Default value is Auto in which case this field is not written to the model.rtw file.

    StorageTypeQualifier

Only written if non-empty (e.g., const or something similar).

    HasObject

HasObject = 1 if this DWork is associated with a Simulink Data Object. In this case, an Object record is written. If HasObject = 0, no Object record will be written.

    HasObject

1: Indicates whether the output signal has an associated Simulink.State object. This only occurs when there is one source of this signal (i.e., not merged or reused).

    Object{

Contents of Simulink.State; only written if HasObject=1, (a Unified Data Repository object is attached to the output signal) and the output signal is not being reused.

       ...

Fields in the Object record depend upon the contents of the object.

    }

  }

}


  Using BlockOutput[i].SigSrc Continuous States