Implementation of DUTs

Topics:

  1. Use attributes 'qualified_only' and 'strict' for enumeration [++]
  2. Initialize no value, only the first value or all values for enumeration [+]

Use attributes 'qualified_only' and 'strict' for enumeration

When defining an enumeration, use the attributes {attribute 'qualified_only'} and {attribute 'strict'}.

Static Analysis:

Verify using the following Static Analysis rules:

Negative sample:

TYPE E_SignalColor :

    Red,
    Yellow,
    Green  
);
END_TYPE

Positive sample:

{attribute 'qualified_only'}
{attribute 'strict'}
TYPE E_SignalColor :
(
    Red,
    Yellow,
    Green
);
END_TYPE

Initialize no value, only the first value or all values for enumeration

In an enumeration, you do not initialize any of the values, only the first one or all values with the allocation operator ':='.

Negative sample:

// NON COMPLIANT: init none, the first or all enumerators
{attribute 'qualified_only'}
{attribute 'strict'}
TYPE E_SignalColor :

    Red    := 0,
    Yellow := 1,
    Green  
);
END_TYPE

Positive sample 1:

// COMPLIANT: no enumerator is initialized
{attribute 'qualified_only'}
{attribute 'strict'}
TYPE E_SignalColor :
(
    Red,
    Yellow,
    Green
);
END_TYPE

Positive sample 2:

// COMPLIANT: first enumerator is initialized
{attribute 'qualified_only'}
{attribute 'strict'}
TYPE E_SignalColor :
(
    Red  := 0,
    Yellow,
    Green
);
END_TYPE

Positive sample 3:

// COMPLIANT: all enumerators are initialized
{attribute 'qualified_only'}
{attribute 'strict'}
TYPE E_SignalColor :
(
    Red    := 0,
    Yellow := 1,
    Green  := 2
);
END_TYPE

 

See also: