Configuring Multiline Constraint Rules
There are rules which will check indent and formatting of constraints as part of a subtype_indication
:
subtype_indication ::=
[ resolution_indication ] type_mark [ constraint ]
constraint ::=
range_constraint
| array_constraint
| record_constraint
There are separate rules for the structure of the constraint and the indenting. Both rules are required to ensure proper formatting of multiline constraints.
There are several options to the structure rules:
Option |
Symbol |
Values |
Structural Element |
Default Value |
Description |
---|---|---|---|---|---|
|
|
opening parenthesis |
|
|
|
|
|
closing parenthesis |
|
||
|
|
comma |
|
||
|
|
new element |
|
||
|
|
array range indication |
|
|
|
|
NA |
NA |
NA |
NA |
Refer to Exceptions for more information. |
The following figure illustrates a multiline constraint in a signal declaration and where the options will be applied. The same structure applies for constraints in constant and variable declarations.
The following configuration for signals replicates the above code snippet. The corresponding configuration for constants and variables can be identical or different.
rule :
signal_016:
record_constraint_open_paren : 'add_new_line'
record_constraint_close_paren : 'add_new_line'
record_constraint_comma : 'remove_new_line'
record_constraint_element : 'add_new_line'
array_constraint : 'all_in_one_line'
Note
All examples use the above configuration.
Example: record_constraint_open_paren
set to remove_new_line
Setting the record_constraint_open_paren
option to remove_new_line
will result in the following formatting:
signal sig8 : record_type_3(
element1(7 downto 0),
element2(4 downto 0)(7 downto 0)(
elementA(7 downto 0),
elementB(3 downto 0)
),
element3(3 downto 0)(
elementC(4 downto 1),
elementD(1 downto 0)
),
element5(
elementE(3 downto 0),
elementF(7 downto 0)
),
element6(4 downto 0),
element7(7 downto 0)
);
Example: record_constraint_close_paren
set to remove_new_line
Setting the record_constraint_close_paren
option to remove_new_line
will result in the following formatting:
signal sig8 : record_type_3
(
element1(7 downto 0),
element2(4 downto 0)(7 downto 0)
(
elementA(7 downto 0),
elementB(3 downto 0)),
element3(3 downto 0)
(
elementC(4 downto 1),
elementD(1 downto 0)),
element5
(
elementE(3 downto 0),
elementF(7 downto 0)),
element6(4 downto 0),
element7(7 downto 0));
Example: record_constraint_element
set to remove_new_line
Setting the record_constraint_element
option to remove_new_line
will result in the following formatting:
signal sig8 : record_type_3
(element1(7 downto 0), element2(4 downto 0)(7 downto 0)
(elementA(7 downto 0), elementB(3 downto 0)
), element3(3 downto 0)
(elementC(4 downto 1), elementD(1 downto 0)
), element5
(elementE(3 downto 0), elementF(7 downto 0)
), element6(4 downto 0), element7(7 downto 0)
);
Example: array_constraint
set to one_line_per_dimension
Setting the array_constraint
option to one_line_per_dimension
will result in the following formatting:
signal sig8 : record_type_3
(
element1
(7 downto 0),
element2
(4 downto 0)
(7 downto 0)
(
elementA
(7 downto 0),
elementB
(3 downto 0)
),
element3
(3 downto 0)
(
elementC
(4 downto 1),
elementD
(1 downto 0)
),
element5
(
elementE
(3 downto 0),
elementF
(7 downto 0)
),
element6
(4 downto 0),
element7
(7 downto 0)
);
Exceptions
Exceptions to the above rules exist to allow formatting of specific structures.
These exceptions can be enabled by adding them to the exceptions
option.
The following exceptions are defined:
keep_record_constraint_with_single_element_on_one_line
keep_record_constraint_with_single_element_on_one_line
This exception will force a record constraint with a single element to a single line.
signal my_sig : t_data_struct(data(7 downto 0));