Model Setup/VariableList
Block Name: VariableList

Code File Location: VisualSim/actor/lib/Memory_Init 

Block Overview

o            Initialize local and global memory locations. 

o            It can be placed anywhere in the model.

Description

The block is used to define memory locations that can be used in Expression, Decision, Basic Processing (Statement etc.), Smart_Machine and Virtual_Machine blocks.  The values of the Global memories are available anywhere in the model.  Local memory is available only in the current block-diagram window.  All block diagram windows that are, below, above or in parallel cannot access local memory.

To understand the usage and how to initialize the memory, view the Memory Initialize Example in the BDE.  To see the current value in a memory location at any time during the simulation, view the Memory Trace Example in the BDE.

The memory is defined with the following format:

Memory Name        Type (Local/global)        Initial_Value   

ArrayMem                local                                1.0             

ÞNote:

  1. All global memories must have unique names and cannot overlap local memory names. 
  2. Local memories in different windows can have the same name.  Each local memory is an unique location.
  3. Memory Names can be a concatenation of three items, which can be strings or parameters.
  4. Memories can have values or any function in the RegEx.
  5. All data types are supported in memories.
  6. If you are creating a Hierarchical block and replicating in the model, it is best to use a concatenated string for a global memory name.  You can then access it directly using readMemory and update using writeMemory.  In a Virtual_Machine, you can assign the memory to a block memory.  If you update this block memory using block_memory_name.newValue(RegEx or value), the global memory is updated.  If you update the block_memory_name using an expression, then the local variable is updated.  See the Using Memory in Hierarchy Example in the BDE.
  7. If you need to access a local memory outside of it's window, then use readMemory and provide the complete path- model_name.Hierarchy_name1.Hierarchy_name2....memory_init_name.local_memory_name.  See the Local Memory Access Example in the BDE.

 

ÞAccess:

  1. Global and local memory can be accessed from any block by the memory name.
  2. A field of a memory is memory_name.field_name; array index in a field is memory_name.field_name(index).
  3. Memory names created by concatenating strings can be accessed anywhere in the model by using the readMemory and writeMemory functions.

 

Parameter

Explanation

Type

Example

Block Documentation

Enter the comments or brief description about the Memory_Init_Text.

-

                    -

Memory_Init_Text

The list of memories is defined in this window.

Each memory location must be on a separate line and must conform to:

MemoryName    Type    InitialValue  

 

-

Memory1    local      1    
Memory2    global    1    

 

The possible initial values are:

 

Name

Type

Value 

Memint

global

1              /* Integer Memory */

Memdbl

global

1.0            /* Double Memory */

Memarray

global

{1,2,3,4}      /* Array memory. All must be same type. */

MemDS

global

Processor_DS   /* DS Memory. Processor_DS is a Data Structure Template */

Memarray1

global

{10:Processor_DS} /*DS Array Memory. 10 Processor_DS */

MemDS1

global

{first=1, third="string"}  /* Fields defined here */

Memstr

global

"Destination" /* String Memory */

Membool

global

TRUE       /* Boolean Memory of TRUE or FALSE */

Memlong 

global

1L         /* Long memory */

MemExpr

global

(1+2+ParamName)  /* Long memory */