| Embedded IDE Link™ CC | ![]() |
In generated code, this block copies variables or data from and to target memory as configured by the block parameters. Your model can contain as many of these blocks as you require to manipulate memory on your target.
Each block works with one variable, address, or set of addresses provided to the block. Parameters for the block let you specify both the source and destination for the memory copy, as well as options for initializing the memory locations.
Using parameters provided by the block, you can change options like the memory stride and offset at run time. In addition, by selecting various parameters in the block, you can write to memory at program initialization, at program termination, and at every sample time. The initialization process occurs once, rather than occurring for every read and write operation.
With the custom source code options, the block enables you to add custom ANSI® C source code before and after each memory read and write (copy) operation. You can use the custom code capability to lock and unlock registers before and after accessing them. For example, some processors have registers that you may need to unlock and lock with EALLOW and EDIS macros before and after your program accesses them.
If your processor or target supports quick direct memory access (QDMA) the block provides a parameter to check that implements the QDMA copy operation, and enables you to specify a function call that can indicate that the QDMA copy is finished. Only the C621x, C64xx, and C671x processor families support QDMA copy.
This block performs operations at three periods during program execution—initialization, real-time operations, and termination. With the options for setting memory initialization and termination, you control when and how the block initializes memory, copies to and from memory, and terminates memory operations. The parameters enable you to turn on and off memory operations in all three periods independently.
Used in combination with the Memory Allocate block, this block supports building custom device drivers, such as PCI bus drivers or codec-style drivers, by letting you manipulate and allocate memory. This block does not require the Memory Allocate block to be in the model.
In a simulation, this block does not perform any operation. The block output is not defined.
When you employ this block to copy an individual data element from the source to the destination, the block copies the element from the source in the source data type, and then casts the data element to the destination data type as provided in the block parameters.
The block dialog box contains multiple tabs:
Source — Identifies the sequential memory location to copy from. Specify the data type, size, and other attributes of the source variable.
Destination — Specify the memory location to copy the source to. Here you also specify the attributes of the destination.
Options — Select various parameters to control the copy process.
The dialog box images show many of the available parameters enabled. Some parameters shown do not appear until you select one or more other parameters. Some parameters are not shown in the figures, but the text describes them and how to make them available.

Sections that follow describe the parameters on each tab in the dialog box.

Select the source of the data to copy. Choose one of the entries on the list:
Input port — This source reads the data from the block input port.
Specified address — This source reads the data at the specified location in Specify address source and Address.
Specified source code symbol — This source tells the block to read the symbol (variable) you enter in Source code symbol. When you select this copy from option, you enable the Source code symbol parameter.
Note If you do not select the Input port option for Copy from, change the Data type parameter setting from the default Inherit from source to one of the data types on the Data type list. If you do not make the change, you receive an error message that the data type cannot be inherited because the input port does not exist. |
Depending on the choice you make for Copy from, you see other parameters that let you configure the source of the data to copy.
This parameter directs the block to get the address for the variable either from an entry in Address or from the input port to the block. Select either Specify via dialog or Input port from the list. Selecting Specify via dialog activates the Address parameter for you to enter the address for the variable.
When you select Input port, the port label on the block changes to &src, indicating that the block expects the address to come from the input port. Being able to change the address dynamically lets you use the block to copy different variables by providing the variable address from an upstream block in your model.
Specify the symbol (variable) in the source code symbol table to copy. The symbol table for your program must include this symbol. The block does not verify that the symbol exists and uses valid syntax. Enter a string to specify the symbol exactly as you use it in your code.
When you select Specify via dialog for the address source, you enter the variable address here. Addresses should be in decimal form. Enter either the decimal address or the address as a hexadecimal string with single quotations marks and use hex2dec to convert the address to the proper format. The following example converts Ox1000 to decimal form.
4096 = hex2dec('1000');For this example, you could enter either 4096 or hex2dec('1000') as the address.
Use this parameter to specify the type of data that your source uses. The list includes the supported data types, such as int8, uint32, and Boolean, and the option Inherit from source for inheriting the data type from the block input port.
Specifies the number of elements to copy from the source location. Each element has the data type specified in Data type.
When you are reading the input, use this parameter to specify an offset for the input read. The offset value is in elements with the assigned data type. The Specify offset source parameter becomes available when you check this option.
The block provides two sources for the offset — Input port and Specify via dialog. Selecting Input port configures the block input to read the offset value by adding an input port labeled src ofs. This port enables your program to change the offset dynamically during execution by providing the offset value as an input to the block. If you select Specify via dialog, you enable the Offset parameter in this dialog box so you can enter the offset to use when reading the input data.
Offset tells the block whether to copy the first element of the data at the input address or value, or skip one or more values before starting to copy the input to the destination. Offset defines how many values to skip before copying the first value to the destination. Offset equal to one is the default value and Offset accepts only positive integers of one or greater.
Stride lets you specify the spacing for reading the input. By default, the stride value is one, meaning the generated code reads the input data sequentially. When you add a stride value that is not equal to one, the block reads the input data elements not sequentially, but by skipping spaces in the source address equal to the stride. Stride must be a positive integer.
The next two figures help explain the stride concept. In the first figure you see data copied without any stride. Following that figure, the second figure shows a stride value of two applied to reading the input when the block is copying the input to an output location. You can specify a stride value for the output with parameter Stride on the Destination pane. Compare stride with offset to see the differences.



Select the destination for the data. Choose one of the entries on the list:
Output port — Copies the data to the block output port. From the output port the block passes data to downstream blocks in the code.
Specified address — Copies the data to the specified location in Specify address source and Address.
Specified source code symbol — Tells the block to copy the variable or symbol (variable) to the symbol you enter in Source code symbol. When you select this copy to option, you enable the Source code symbol parameter.
Depending on the choice you make for Copy from, you see other parameters that let you configure the source of the data to copy.
This parameter directs the block to get the address for the variable either from an entry in Address or from the input port to the block. Select either Specify via dialog or Input port from the list. Selecting Specify via dialog activates the Address parameter for you to enter the address for the variable.
When you select Input port, the port label on the block changes to &dst, indicating that the block expects the destination address to come from the input port. Being able to change the address dynamically lets you use the block to copy different variables by providing the variable address from an upstream block in your model.
Specify the symbol (variable) in the source code symbol table to copy. The symbol table for your program must include this symbol. The block does not verify that the symbol exists and uses valid syntax.
When you select Specify via dialog for the address source, you enter the variable address here. Addresses should be in decimal form. Enter either the decimal address or the address as a hexadecimal string with single quotations marks and use hex2dec to convert the address to the proper format. This example converts Ox2000 to decimal form.
8192 = hex2dec('2000');For this example, you could enter either 8192 or hex2dec('2000') as the address.
Use this parameter to specify the type of data that your variable uses. The list includes the supported data types, such as int8, uint32, and Boolean, and the option inherit from source for inheriting the data type for the variable from the block input port.
The block provides two sources for the offset—Input port and Specify via dialog. Selecting Input port configures the block input to read the offset value by adding an input port labeled src ofs. This port enables your program to change the offset dynamically during execution by providing the offset value as an input to the block. If you select Specify via dialog, you enable the Offset parameter in this dialog box so you can enter the offset to use when writing the output data.
Offset tells the block whether to write the first element of the data to be copied to the first destination address location, or skip one or more locations at the destination before writing the output. Offset defines how many values to skip in the destination before writing the first value to the destination. One is the default offset value and Offset accepts only positive integers of one or greater.
Stride lets you specify the spacing for copying the input to the destination. By default, the stride value is one, meaning the generated code writes the input data sequentially to the destination in consecutive locations. When you add a stride value not equal to one, the output data is stored not sequentially, but by skipping addresses equal to the stride. Stride must be a positive integer.
This figure shows a stride value of three applied to writing the input to an output location. You can specify a stride value for the input with parameter Stride on the Source pane. As shown in the figure, you can use both an input stride and output stride at the same time to enable you to manipulate your memory more fully.

Sample time sets the rate at which the memory copy operation occurs, in seconds. The default value Inf tells the block to use a constant sample time. You can set Sample time to -1 to direct the block to inherit the sample time from the input, if there is one, or the Simulink® software model (when there are no input ports on the block). Enter the sample time in seconds as you need.

When you check this option, you direct the block to initialize the memory location to a specific value when you initialize your program at run time. After you select this option, use the Set memory value at termination and Specify initialization value source parameters to set your desired value. Alternately, you can tell the block to get the initial value from the block input.
After you check Set memory value at initialization, use this parameter to select the source of the initial value. Choose either
Specify constant value — Sets a single value to use when your program initializes memory. Enter any value that meets your needs.
Specify source code symbol — Specifies a variable (a symbol) to use for the initial value. Enter the symbol as a string.
If you check Set memory value at initialization and choose Specify constant value for Specify initialization value source, enter the constant value to use in this field. Any real value that meets your needs is acceptable.
If you check Set memory value at initialization and choose Specify source code symbol for Specify initialization value source, enter the symbol to use in this field. Any symbol that meets your needs and is in the symbol table for the program is acceptable. When you enter the symbol, the block does not verify whether the symbol is a valid one. If it is not valid you get an error when you try to compile, link, and run your generated code.
You can use the initialization value as a mask to manipulate register contents at the bit level. Your initialization value is treated as a string of bits for the mask.
Checking this parameter enables the Bitwise operator parameter for you to define how to apply the mask value.
To use your initialization value as a mask, the output from the copy has to be a specific address. It cannot be an output port, but it can be a symbol.
To use the initialization value as a mask, select one of the entries on the following table from the Bitwise operator list to describe how to apply the value as a mask to the memory value.
Bitwise Operator List Entry | Description |
|---|---|
bitwise AND | Apply the mask value as a bitwise AND to the value in the register. |
bitwise OR | Apply the mask value as a bitwise OR to the value in the register. |
bitwise exclusive OR | Apply the mask value as a bitwise exclusive OR to the value in the register. |
left shift | Shift the bits in the register left by the number of bits represented by the initialization value. For example, if your initialization value is 3, the block shifts the register value to the left 3 bits. In this case, the value must be a positive integer. |
right shift | Shift the bits in the register to the right by the number of bits represented by the initialization value. For example, if your initialization value is 6, the block shifts the register value to the right 6 bits. In this case, the value must be a positive integer. |
Applying a mask to the copy process lets you select individual bits in the result, for example, to read the value of the fifth bit by applying the mask.
Along with initializing memory when the program starts to access this memory location, this parameter directs the program to set memory to a specific value when the program terminates.
This block performs operations at three periods during program execution—initialization, real-time operations, and termination. When you check this option, the block only does the memory initialization and termination processes. It does not perform any copies during real-time operations.
Select this parameter to add custom ANSI C code before the program writes to the specified memory location. When you select this option, you enable the Custom code parameter where you enter your ANSI C code.
Enter the custom ANSI C code to insert into the generated code just before the memory write operation. Code you enter in this field appears in the generated code exactly as you enter it.
Select this parameter to add custom ANSI C code immediately after the program writes to the specified memory location. When you select this option, you enable the Custom code parameter where you enter your ANSI C code.
Enter the custom ANSI C code to insert into the generated code just after the memory write operation. Code you enter in this field appears in the generated code exactly as you enter it.
For processors that support quick direct memory access (QDMA), select this parameter to enable the QDMA operation and to access the blocking mode parameter.
If you select this parameter, your source and destination data types must be the same or the copy operation returns an error. Also, the input and output stride values must be one.
If you select the Use QDMA for copy parameter, select this option to make the memory copy operations blocking processes. With blocking enabled, other processing in the program waits while the memory copy operation finishes.
![]() | Memory Allocate | Target Preferences | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |