How-to use ARRAY and RARRAY ?

Synopsis

ARRAY ( typename, no_of_elements, type_of_elements )

The ARRAY construct provides a mechanism for defining lists of objects of the same type, similar to the array construct in C & C++. Anytime such a declaration is encountered, a new C++ class will be created. This class will have the name typename. Examples:
  1. ARRAY ( Memory, 4096, Memory_Contents_Structure )
  2. ARRAY ( Cache, -1, int)
    ...
    ENTITY Sender(
    ...
    PARAMS (
    RINT(no_lines,256)
    RINT(no_blocks,4)
    RARRAY(Cache, data)
    ...

    in Sender.hase:
    $class_defs
    int Sender::data_f() { return no_lines*no_blocks; }

Initialisation

The arrays, which most of the time are used to represent the content of a memory, can be initialised by providing a .mem file. The C++ code which is generated does not depend of the content of the .mem file. This right .mem file is read to fill the array just before the simulation is run. Thus, the same executable file can be used with different memory contents.
The initialisation process depends on the context of the array (entity type name, entity instance name, parent type and parent instance name) and of the name of the RARRAY instance.
When the array belongs to an entity, which itself belongs to a compound entity the first readable file which name match the following criterions is used:
  • <compound_instance_name>.<entity_instance_name>.<array_instance_name>.mem
  • <compound_instance_name>.<entity_type_name>.<array_instance_name>.mem
  • <compound_type_name>.<entity_instance_name>.<array_instance_name>.mem
  • <compound_type_name>.<entity_type_name>.<array_instance_name>.mem
  • When the array's entity does not belong to a compound entity or when one of the preceding .mem file was not found the two following files are checked:
  • <entity_instance_name>.<array_instance_name>.mem
  • <entity_type_name>.<array_instance_name>.mem
  • Examples: Warning: Sharing the same file for the initialisation does not mean that the arrays are physically shared. This mechanism is mainly useful when defining meshes with lots of nodes to avoid creating a different file for each node (The number of nodes may be important and may change).
    Notes:
    1. The format of the data contained in the .mem file is checked during the initialisation process. It has to match the format declared in the EDL. Otherwise, an error message occurs at the beginning of the simulation and the initialisation process is cancelled.
    2. Empty lines are ignored.
    3. Lines starting with '//' are also ignored.
    4. if the size of the array is >0, size elements are read at most.

    Initialisation and sections

    A .mem file may contain some sections. The section separator is a line equals to: //$next section.
    When a file contains some sections (no_section), the ith array which has to be initialised from that file will be initialised with the content of the (i modulo no_section)th section.
    The order of the arrays is determined by the declaration order of instances (AENTITY) in the STRUCTURE part of the EDL file.
    Frederic Mallet
    Last modified: Tue Apr 2 15:06:35 BST 2002