Initialising Arrays

Arrays are instantiated in entities by a declaration of the form:

RARRAY ( type_name, instance_name, no_of_elements)

where:

no_of_elements:

int (>0)

The integer value which is specified is the default size. That is to say: for each RARRAY created from this type, an array of the size specified in that field will be allocated at the beginning of the simulation. The HASE user interface allows users to modify the size of RARRAY parameters. Each instance of a defined ARRAY is independent regarding its number of elements.

int -1

-1 is to be set (before building the project: in EDL or with the GUI) whenever the user wants the size of the array to be computed from values of other parameters.

str

The user may also type the name of an RINT (See the reference section) parameter to represent the number of elements. The value taken by this parameter just before running the simulation will be used to set the size of the array. This value MUST be positive. The RINT parameter can either be declared in the GLOBALS section of the EDL file or as a parameter of the entity which defines the RARRAY.

Examples
  1. ARRAY ( Memory, Memory_Contents_Structure )
  2. ARRAY ( Cache, int)
    ...
    ENTITY Sender(
    ...
    PARAMS (
    RINT(no_lines, 256)
    RINT(no_blocks, 4)
    RARRAY(Cache, data, -1)
    ...

    in Sender.hase:
    $class_defs
    int Sender::data_size_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. The 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 following criteria are tested in sequence and the first readable file with a name which matches one of the criteria is used:

When the array's entity does not belong to a compound entity or when no file is found matching any of these criteria, the following two files are checked:
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 file. 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 sections. The section separator is a line of the form: //$next section.
When a file contains 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 section part of the project definition file. The //$next section construct is most frequently used with MESH entities.