2.7.5 LISA+ elements in behaviors

Behaviors contain C/C++ code and additional syntactic constructs that have a special meaning in LISA+ that they do not have in C/C++.

These are the types of behavior:

Port behaviors
are declared inside a port.
Component behaviors and local behaviors
are not declared inside a port.
Special-purpose behaviors
are component behaviors, for example init(), reset(), and terminate().

The following types of function call can occur in component and port behavior sections, to:

  • Local behavior, for example foo().
  • Local port behavior, for example myport.foo().
  • Port behavior of a subcomponent, for example subcomp.aport.foo().
  • Special-purpose behaviors of a subcomponent, for example subcomp.init().
  • Special-purpose behaviors of all subcomponents, for example composition.init().
  • getInstanceName() to return the instance name of the component.
  • getInstancePath() to return the instance name relative to the top-level component.
Special-purpose behavior calls
The use of the composition keyword to call a special-purpose behavior for all subcomponents recursively.
Behavior reset(int level)
   // reset subcomponents
   // reset state variables
   status = 0;
   counter = 0;
   control = 0;

SimGen calls the subcomponents in the order of declaration in the composition section. SimGen calls local behaviors, that is, non-port behaviors in the same component, by using the name of the local behavior.

Subcomponent special-purpose behaviors

Call the special-purpose behaviors of subcomponents by putting the subcomponent instance name and a dot before the behavior name.

Always call subcomponent special-purpose behaviors from the corresponding special-purpose behavior in the parent component. Otherwise, the results are undefined.

Calling subcomponent behaviors explicitly enables defining a specific initialization order.

Initialization order
component MyComponent
        subcomp0: AnotherComponent 
        subcomp1: AnotherComponent 
        subcomp2: AnotherComponent 
     behavior init
            // explicit initialization order

Port behavior access

Access local ports (ports of the same component) by using the name of the port.

Access ports of subcomponents by using the syntax:

Subcomponent port access
How to call a subcomponent port behavior.
component MyComponent
    composition { subcomp: AnotherComponent }
     behavior set42_on_subcomp

Component instance name behavior access

Use the getInstanceName() function to get the component instance name of the component. It returns the instance name of the component in its parent component as a std::string. The system component has no parent so the result is undefined, but most implementations return a generic string like "system".

This function is slow, so ARM does not recommend it for simulation of a component that implements normal functionality. It might, however, be useful in component error messages and debugging output.

Component error message display
component MyComponent
    behavior init
            cout << "initializing '" << getInstanceName() << "'" << endl;
Non-ConfidentialPDF file icon PDF version101092_0100_04_en
Copyright © 2014–2018 Arm Limited or its affiliates. All rights reserved.