contents.gifindex.gif

Set Indexing

Set indexing allows you to access elements within a set. The following example uses set indexing to assign four elements of a 16-bit set to a smaller set.

declarations
Set1 = [f15..f0];
Set2 = [q3..q0];
equations
Set2 := Set1[7..4];

The numeric values used for defining a set index refer the the bit positions of the set, with 0 being the least significant (left-most) element in the set.

If you are indexing into a set to access a single element, then you can use the following syntax:

declarations
out1 pin istype 'com';
Set1 = [f15..f0];
equations
out1 = Set1[4] == 1;

In this example, a comparator operator (==) was used to convert the single-element set (Set1[4]) into a bit value (equivalent to f4).