Skip to content

Action Handle Array Traversal

Traversal Context

Context Semantics
parallel All array elements are scheduled for traversal in parallel.
schedule All array elements are scheduled for traversal independently.
select One array element is randomly selected and traversed.
sequence All array elements are scheduled for traversal in sequence from 0 to N-1.

Multidimensional Arrays

v3.1 Not supported yet

An action handle array may have more than one dimension. A traversal can name one element, one sub-array, or the whole array:

action A { }

action entry {
    rand int in [0..2] traverse_mode;
    A a_arr[3][2];

    activity {
        match (traverse_mode) {
            [0]: {
                a_arr[2][0];    //  one element
                a_arr[1][1];
            }
            [1]: a_arr[1];      //  sub-array: { a_arr[1][0]; a_arr[1][1]; }
            [2]: a_arr;         //  whole array: a_arr[0][0], a_arr[0][1], ..., a_arr[2][1]
        }
    }
}

  • sequence: the outer dimension is traversed in order, each element with all of its sub-dimensions, e.g., a[0][0], a[0][1], a[1][0], a[1][1] for a[2][2].
  • select: one leaf element (one action handle) is selected and traversed.
  • An attribute initialization list or an inline constraint cannot be applied when a whole array or sub-array is traversed.

parallel

Not supported yet

All array elements are scheduled for traversal in parallel.

schedule

v1.0.0

Both actions (i.e., sub with "Hello" and "World") in the schedule block will be traversed in a random order.

action top {
    activity {
        schedule {
            do sub with { str == "Hello"; };
            do sub with { str == "World"; };
        }
    }
}

action sub {
    rand string str;
    exec body ASM = """{{str}}""";
}

There are two possible results:

Hello
World
World
Hello

select

v1.0.0

Only one action in the select block will be chosen and traversed.

action top {
    activity {
        select {
            do sub with { str == "Hello"; };
            do sub with { str == "World"; };
        }
    }
}

action sub {
    rand string str;
    exec body ASM = """{{str}}""";
}

There are two possible results:

Hello
World

sequence

v1.0.0

All array elements are scheduled for traversal in sequence from 0 to N-1.