A memory shared element identifies a location in the memory, used to share information between MLDesigner modules. The information is sent as a Data Structure and as a result every memory has an associated type.
A memory element with an internal scope is the defining memory. This is where the space for the data structure is really allocated. An internal memory can have an initial value which is set to conform with the Data Structure string representation syntax (see Using Data Structures). This default value is assigned during the simulation initialization phase, before any events are executed.
An external block memory element must be linked to a memory element of the same type in the module which uses the block. External memory shared elements become block memory elements when a module is used as a block. Memories cannot be External in a system module. For every chain of memories linked together (that is, sharing the same memory) there is a single memory that has an Internal scope. The value stored in a memory can change during the course of a simulation.
Memories can be manipulated using primitives from the Memory Access libraries. Generally, memory is modified with ReadMemory and WriteMemory blocks.
Memories having vector types (Vector, IntVector and FloatVector) are initialized by specifying the initial value and the length of the vector.
Several primitives are supplied to handle memories. Most of them are located in the Memory Access libraries of the DE and SDF domains. There are two types of memories: Local Memory and Shared Memory - memories that are shared by linking them over several levels of modules.
The memory location used by local memory blocks is accessible only through that instance of the block. Local memory primitives have one input which writes to the memory when enabled, and another input as Trigger which causes the memory to be read and its content to be placed on the output port. Primitives that provide access to the local memory are: LocalMemory, LocalMemoryInt and LocalMemoryFloat.
Shared Memory allows access to a single copy of a data structure (a memory location) from many blocks at arbitrary points in the hierarchical block diagram. Access to the memory value is typically through the MemoryRead primitive. The MemoryWrite primitive allows you to change the contents of the memory. MLDesigner provides also modules to access memories that operate specifically on vectors. Some of these modules are MemoryAccessVector, MemorySetVector, MemoryAccessIVector,and MemorySetIVector (they can be found in the Vector Operations library). The MemoryWrite primitive also allows access or modification to elements of Vector, IntVector and FloatVector base types data structures stored in memory.
Each of these modules has an external memory argument. The way this shared element is linked to others affects the way blocks share memory. To allow several instances of a memory block to share the same memory location, link the memory element of all instances to the same memory. If the memory they are linked to has a scope of Internal, the memory is not visible at higher levels in the block diagram. That means that all MemoryRead and -Write modules whose memories are explicitly linked together will have access to the same memory. Memory elements are explicitly linked together when you select link for a memory in the property editor.
Exporting memories allows other modules in the hierarchy to access the memory. However, localizing memory allocates sufficient space to hold a data structure of the specified type and limits the scope of the memory to the block diagram where it is localized. Localizing memories involves providing an initial value which is placed in the memory upon its creation.
Nonlocal memory is a powerful feature within MLDesigner. Nonlocal memories permit one (or several) modules to modify the state of another module in a non-obvious way (by modifying nonlocal memory). To minimize this effect localize memory at the lowest possible level in the block diagram hierarchy. This restricts the number of modules which can access the nonlocal memory.
MLDesigner provides two modules GlobalMemoryWrite and GlobalMemoryRead to access the global memories. The only parameter of these modules is a string that indicates the name of the global memory on which the block operates. All global memory modules which refer to the same string name will operate on the same global memory.
The string parameters need not be linked together; they must, however, be spelt the same.