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
record_constraint_open_paren green_diamond add_new_line, remove_new_line, ignore opening parenthesis remove_new_line
  • The setting add_new_line enforces a carriage return (alias “new line”) [and, consequently by indentation rules kicking in, also (indirectly) enforces the indentation of the new line]
  • The setting remove_new_line enforces the removal of any potential space and carriage return
  • The setting ignore disables the option and hence no formatting check is done at all: spaces and new lines can be anything
record_constraint_close_paren red_penta_star add_new_line, remove_new_line, ignore closing parenthesis remove_new_line
record_constraint_comma purple_hexa_star remove_new_line, ignore comma remove_new_line
record_constraint_element orange_triangle add_new_line, remove_new_line, ignore new element remove_new_line
array_constraint grey_box all_in_one_line, one_line_per_dimension, ignore array range indication all_in_one_line
  • The setting all_in_one_line will combine array_constraints into a single line
  • The setting one_line_per_dimension will place each dimension on it’s own line
  • The setting ignore disables the option and hence no formatting check is done at all: spaces and new lines can be anything
exceptions 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.

_images/constraints_code.png

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));

Rules Enforcing Multiline Constraint Rules