| xPC Target | ![]() |
www.kxcad.net Home > CAE Software Index > MATLAB Index >
| On this page… |
|---|
xPC Target uses a model for reflective memory (also known as shared memory) that includes Simulink blocks, for the shared memory drivers, and MATLAB structures for defining shared memory and node initialization partitions. The topics in this section are
To use the xPC Target SCRAMNet+ SC150 shared memory blocks to read, write, pack, or unpack data, you must define a partition structure. SCRAMNet+ SC150 shared memory drivers use MATLAB structures to define shared memory partitions. A partition structure describes how you want to allocate (or partition) the shared memory. xPC Target allocates shared memory with bundles of data that are packed into memory partitions. The following SCRAMNet+ SC150 blocks use shared memory partition structures:
After you define the shared memory partitions, you can add SCRAMNet+ SC150 shared memory driver blocks to your Simulink model. Create a shared memory structure in one of the following ways. See Shared Memory Partition Structure for the complete list of fields for the structure.
The following description refers to the completepartitionstruct command. Type
help completepartitionstruct
for a description of the command.
Using the completepartitionstruct command at the MATLAB Command Window, create a default partition structure. For example, type
completepartitionstruct([],'scramnet')
ans =
Address: '0x0'
Type: 'uint32'
Size: '1'
Alignment: '4'
RIE: 'off'
TIE: 'off'
ExtTrigger1: 'off'
ExtTrigger2: 'off'
HIPRO: 'off'
Internal: [1x1 struct]At the MATLAB Command Window, create a user-defined partition structure. The easiest way to do this is to create an M-file, partially define a structure, load that M-file into the MATLAB workspace, and supplement the resulting structure with a call to the completepartitionstruct function. For example
Partition(1).Address='0x5000'; Partition(1).Type='int8'; Partition(1).Size='10'; Partition(2).Type='uint16'; Partition(2).Size='5'; Partition(3).Type='double'; Partition(3).Size='3'; Partition(4).Type='uint8'; Partition(4).Size='[2, 3]';
This example defines a partition with four segments.
The Address field is optional. Only specify this field for the first segment of a partition. The elements of a partition are defined as a continuous memory block from the first address. The following segments extrapolate their addresses from the first segment. If you have fragmented memory, use multiple partitions and SCRAMNet+ SC150 read/write blocks to work with the memory.
The Type and Size fields are required for all fields in the partition structure.
The base addresses of subsequent segments are fully defined by the data type, size, and alignment of the preceding segment.
You can then call the completepartitionstruct() command to full populate the partition structure.
To use the xPC Target SCRAMNet+ SC150 shared memory, you must define a node initialization structure. SCRAMNet+ SC150 shared memory drivers use MATLAB structures to define shared memory node initializations. A node initialization structure describes the shared memory partition (see Create Shared Memory Partitions) and the SCRAMNet+ SC150 board configuration, including interrupt configurations. The following SCRAMNet+ SC150 block requires shared memory node initialization structures:
SC150 init
After you define the node initialization partition, you can add SCRAMNet+ SC150 shared memory driver blocks to your Simulink model. Create a shared memory structure in one of the following ways. See Shared Memory Node Initialization Structure for the complete list of fields for the structure.
The following description refers to the completenodestruct command. Type
help completenodestruct
for a description of the command.
Using the completenodestruct command at the MATLAB Command Window, create a default node initialization structure. For example, type
node=completenodestruct([],'scramnet')
node =
Interface: [1x1 struct]
Partitions: [1x1 struct]A user-defined node structure, create with m-code or from the MATLAB Command Window and supplement the resulting structure with a call to the completenodestruct function.
| Systran | Systran Shared Memory Structure Reference | ![]() |
© 1984-2007 The MathWorks, Inc. Terms of Use Patents Trademarks Acknowledgments