4.4.3 LISA+ protocol behavior prototype attributes

This section describes behavior prototype attributes.

About LISA+ protocol behavior prototype attributes

In most cases, a protocol behavior is a slave or optional slave behavior. Master behaviors are not common.

If set, the attribute specifier for the behavior must be one of:

master
You must implement a behavior for a master port. A default implementation is not permitted.
slave
You must implement a behavior for a slave port. A default implementation is not permitted.
optional master
You do not have to implement this behavior for a master port. A default implementation can be provided as part of the prototype definition.
optional slave
You do not have to implement this behavior for a slave port. A default implementation can be provided as part of the prototype definition.

The attribute specifier for the behavior in the protocol definition must:

  • Exactly match the attributes in the port definition section.
  • Be omitted from the port behavior definition.

Note:

  • If there is no attribute specifier, none of these constraints apply. That is, the behavior is optional, and you can specify a default implementation if required.
  • The presence of default behaviors is part of the protocol definition.

Mandatory LISA+ protocol behavior

A description of mandatory behavior.

For this behavior declaration in a protocol:

slave behavior f();
  • All slave ports using this protocol must implement this behavior f().
  • Calling f() invokes all behaviors f() in all slave ports connected to the same port.
  • Master ports might not implement behavior f().
  • The slave must provide read and write functions to access resources.
  • Without the optional keyword, you must not specify a default implementation. The presence of a default implementation causes an error.

Optional LISA+ protocol behavior without default implementation

A description of optional behavior without default implementation.

For this optional behavior declaration in a protocol:

optional slave behavior f();
  • Not all slave ports that use this protocol have to implement behavior f(). There is no default behavior, so a call to a missing behavior results in an error.
  • Calling f() invokes all behaviors f() in all slave ports connected to the same port. A master might, for example, notify or query information from all connected slaves, but the handling of this is optional.
  • A master must check whether at least one behavior is connected to a behavior in the specified port:

    if (myport.f.implemented()) myport.f();

    Note:

    ARM recommends the use of the implemented() test only if the default implementation in protocol is not usable. Ensure that optional behaviors in new code have default implementations. However, if you are using unmodified legacy code and the called behavior has the optional keyword but no default implementation, you must test for implementation.
  • Calling a behavior on a port that none of the slaves implements causes a run-time error.

Optional LISA+ protocol behavior with default implementation

A description of optional behavior with default implementation.

For this optional behavior definition in a protocol:

optional slave behavior f()
{
// default implementation. Can be empty
}
  • Not all slave ports that use this protocol have to implement behavior f(). If a slave does not implement the behavior, the default implementation is used instead. The default can be {} if no action is required.
  • If the port implements behavior f(), that implementation is used instead of the default implementation.
  • Calling f() invokes all behaviors f() in all slave ports connected to the same port. A master might, for example, notify or query information from all connected slaves, but the handling of this is optional.
  • A master does not have to use the form:

    if (myport.f.implemented()) myport.f();

    to test for implementation of the behavior in a port. The default implementation means that f.implemented() returns true whether or not there is a local implementation.

  • If a behavior returns a value, the default implementation can return 0 or any another value that is valid in the context of the calling function.

    optional slave behavior f() : uint8_t
    {
        // additional code can be present here, but is not required
        return 0;
    }

    If the return value is undefined, the compiler generates a warning if you enable such warnings. System Canvas does not issue a warning.

Non-ConfidentialPDF file icon PDF version101092_0100_04_en
Copyright © 2014–2018 Arm Limited or its affiliates. All rights reserved.