Structure¶
You define a structure by a DUT object in your project via command Add Object.
The structure declaration starts with the keywords TYPE
and STRUCT
and ends with END_STRUCT
and END_TYPE
.
Syntax for the structure declaration:
TYPE <structurname>:
STRUCT
\ <declaration of variable 1>
\ ...
\ <declaration of variable n>
END_STRUCT
END_TYPE
<structure name> is a type, which will is valid in the whole project and which you can use like a standard data type.
You also can use nested structures. Thereby the only restriction is, that you not may assign variables to addresses (the AT-declaration is not allowed!).
Example of a structure definition, named “polygonline”
TYPE polygonline:
STRUCT
\ start:ARRAY [1..2] OF INT;
\ point1:ARRAY [1..2] OF INT;
\ point2:ARRAY [1..2] OF INT;
\ point3:ARRAY [1..2] OF INT;
\ point4:ARRAY [1..2] OF INT;
\ end:ARRAY [1..2] OF INT;
END_STRUCT
END_TYPE
See also
Initialization of structures
Example
poly_1 : polygonline := ( start:=[3,3], point1 := [5,2], point2 : [7,3], point3 := [8,5], point4 := [5,7], end := [3,5]);
You may not use initializations with variables. For an example of the initialization of an array of a structure see the help page on data type ARRAY.
See also
Accessing structure components
You gain access to structure components using the following syntax:
<structurename>.<componentname>
So for the above mentioned example of the structure polygonline
you can access the component start
by poly_1.start
.
See also
Accessing bits in structures
The datatype BIT
is a special datatype which can only be defined in structures. It consumes memory space of 1 bit and allows to address single bits of a structure by name.
TYPE <structurename>:
STRUCT
\ <Bitname bit1> : BIT;
\ <Bitname bit2> : BIT;
\ <Bitname bit3> : BIT;
\ ...
\ <Bitname bitn> : BIT;
END_STRUCT
END_TYPE
You gain access to the structure component BIT
by using the following syntax:
<structurname>.<bitname>
Note
The usage of references and pointers on BIT variables is not possible. Furthermore BIT
variables are not allowed in arrays.
See also