Target Language Compiler    

Using BlockOutput[i].SigSrc

SigSrc enables us to generate a reference to the block I/O "slot" for this record. The block I/O is a hierarchical structure definition.

Consider a model that has two references (sysA1,sysA2) to a nonvirtual subsystem named sysA. Within sysA, there are three references (sysB1,sysB2,sysB3) to sysB. Within sysB, there are five references (sysC1,sysC2,sysC3,sysC4,sysC5) to sysC. The total number of system instances:

A model similar to this example is located at matlabroot/toolbox/rtw/rtwdemos/tlctutorial/biohstruct/biohstruct_a2b3c5_ex.mdl. Some examples based on this model:

A simple TLC function that lets us generate these references is shown below. This function is located in matlabroot/toolbox/rtw/rtwdemos/tlctutorial/biohstruct/biohstruct.tlc.

This function lets us generate an observer reference to a particular slot in the block I/O (similar to ex1) by passing the desired BlockOutput record index, stopAtSystemIdx == the root system index, accessPrefix == "rtB->", and accessBlockIoStructOnly==0.

This function lets us generate internal references to the Block I/O structure (similar to ex2) where we are in a System record and need a portion of the fully qualified signal access. This is achieved by passing the desired BlockOutput record index, stopAtSystemIdx == DeclSystemIdx (a field within the system record), accessPrefix == "p->", and accessBlockIoStructOnly==0.

This function lets us generate references similar to ex3 by calling by passing the first BlockOutput record index corresponding to the start of the desired structure, stopAtSystemIdx == DeclSystemIdx, accessPrefix = "&p->", and accessBlockIoStructOnly==1.

This function lets us generate references similar to ex4 by passing the BlockOutput record index corresponding stopAtSystemIdx == DeclSystemIdx, accessPrefix == "&p->", and accessBlockIoStructOnly==0. The string "[1]" must then be appended to the return value of GetBlockIoHStructAccess. This example occurs when processing the canonical inputs to a system.

CallSites and their Interaction with SigSrc's.

We will now explore the CallSites matrix in a little more detail. Consider the model, which is located at: matlabroot/toolbox/rtw/rtwdemos/tlctutorial/biohstruct/biohstruct_fcncall_ex.mdl. The overall model is configured as shown below.

The model contains three function call subsystems, A, B, and C:

From Model.rtw System Record, the System[i].CallSites field contains

  [[callerSysIdx, callersCallSiteIdx, graphicalSysIdx,     ssBlkIdxInGraphicalSys]; ...]

and from Model.rtw Block I/O Information BlockOuptuts.BlockOutput[i].SigSrc field contains:

  [systemIdx, callSiteIdx, blockIdx, outputPortIdx]

Looking at the model.rtw for this example, we see:

Consider a call to GetBlockIoHStructAccess(6, 4, "rtB.", 0) this will use the SigSrc record above to get at sysIdx = 0 to access System with Name "<Root>/C" and callSiteIdx = 0. Then we enter the %foreach loop where we we access the System[sysIdx].CallSites[callSiteIdx] row. Notice that in System `C' the callSysIdx (1 = System B) is not equal to the graphicalSysIdx (3 = System Root). This is because C is called by B, but resides in the Root System. This process continues and the function produces:

Looking at the CallSites matrix, we see that the first two elements (callerSysIdx, callersCallSiteIdx) are used to construct the order in which the identifier path is created. The second two elements (graphicalSysIdx, ssBlkIdxInGraphicalSys) are used to obtain the specific name for each section of the identifier path.


  Signal Connections Data Type Work (DWork) Information