You copied the Doc URL to your clipboard.

Port arrays

A LISA+ component can contain arrays of ports, for example multiple interrupt ports in an IRQ controller.

It is useful to declare multiple instances of a port at the same time using the array construct:

slave port<MyType> access[2];

This declares two slave ports using the protocol MyType. In the behavior that implements the protocol MyType, an additional parameter of type unsigned int is available and denotes the port index. As an example protocol MyType has a behavior read:

protocol MyType
{
    slave behavior read(uint32_t addr, uint32_t &data)
}
Implementing read() for a port vector
The parameter list and implementation of a read method, which uses the portIndex parameter to distinguish between the ports.
slave port <MyType> access[2]
{
    behavior read( /* additional parameter */ unsigned int portIndex,
                uint32_t addr, uint32_t &data)
    {
        // implementation of read behavior
        if (portIndex == 0)
            // do something for port 0
            ;
        else
            // do something for port 1
            ;
    }
}

The length of the port must be a literal number. Expressions and parameter references are not permitted.

Was this page helpful? Yes No