Configuring Concurrent Alignment Rules¶
There are rules which will check indent and alignment of multiline conditional expressions and conditional waveforms.
Conditional expressions and conditional waveforms are defined as:
conditional_expressions ::=
expression **when** condition
{ **else** expression **when** condition }
[ **else** expression ]
conditional_waveforms ::=
waveform **when** condition
{ **else** waveform **when** condition }
[ **else** waveform ]
Below is an example of a conditional waveform:
architecture rtl of fifo is
begin
output <= '1' when input = "00" else
sig_a or sig_b when input = "01" else
sig_c and sig_d when input = "10" else
'0';
end architecture rtl;
The alignment of multiline rules is handled by a corresponding rule. Both rules are required to ensure proper formatting of multiline expressions and conditions. The corresponding rule will be noted in the rule documentation.
There are several options to these rules:
Option | Type | Default | Description |
---|---|---|---|
align_left | string | ‘no’ | Align multilines to the left. |
align_paren | string | ‘yes’ | Indent lines based on parenthesis. |
align_when_keywords | string | ‘no’ | Each when keyword will be aligned. |
wrap_at_when | string | ‘yes’ | Indent multiline condition at ‘when’ keyword. |
align_else_keywords | string | ‘no’ | Each else keyword will be aligned. |
The options can be combined to format the conditional expression or conditional waveform.
Each option allows one of two values: ‘yes’ and ‘no’.
Option Value | Action |
---|---|
‘yes’ | Option will be enforced. |
‘no’ | The inverse of the Option will be enforced. |
This is an example of how to configure these options.
rule :
concurrent_009:
wrap_at_when : 'yes'
align_when_keywords : 'yes'
align_else_keywords : 'yes'
align_left : 'no'
Note
All examples below are using the rule concurrent_009.
Example: indent_condition_at_when¶
The following code would fail with this option:
output <= '1' when input = "0000" or
input = "1111" else
sig_a or sig_b when input = "0001" and
input = "1001" else
sig_c and sig_d when input = "0010" or
input = "1010" else
'0';
The following code would pass with this option:
output <= '1' when input = "0000" or
input = "1111" else
sig_a or sig_b when input = "0001" and
input = "1001" else
sig_c and sig_d when input = "0010" or
input = "1010" else
'0';
Example: align_when_keywords¶
The following code would fail with this option:
output <= '1' when input = "00" else
sig_a or sig_b when input = "01" else
sig_c and sig_d when input = "10" else
'0';
The following code would pass with this option:
output <= '1' when input = "00" else
sig_a or sig_b when input = "01" else
sig_c and sig_d when input = "10" else
'0';
Example: align_when_keywords and align_else_keywords¶
The following code would fail with this option:
output <= '1' when input = "0000" else
sig_a or sig_b when input = "0100" and input = "1100" else
sig_c when input = "10" else
'0';
The following code would pass with this option:
output <= '1' when input = "0000" else
sig_a or sig_b when input = "0100" and input = "1100" else
sig_c when input = "10" else
'0';
Example: align_left ‘yes’¶
The following code would fail with this option:
output <= '1' when input = "0000" else
sig_a or sig_b when input = "0100" and input = "1100" else
sig_c when input = "10" else
'0';
The following code would pass with this option:
output <= '1' when input = "0000" else
sig_a or sig_b when input = "0100" and input = "1100" else
sig_c when input = "10" else
'0';
Example: align_left ‘no’¶
The following code would fail with this option:
output <= '1' when input = "0000" else
sig_a or sig_b when input = "0100" and input = "1100" else
sig_c when input = "10" else
'0';
The following code would pass with this option:
output <= '1' when input = "0000" else
sig_a or sig_b when input = "0100" and input = "1100" else
sig_c when input = "10" else
'0';
Example: align_paren ‘yes’ and align_left ‘no’¶
The following code would fail with this option:
output <= '1' when func1(func2(G_VALUE1,
G_VALUE2), func3(
G_VALUE3)
) else
'0';
The following code would pass with this option:
output <= '1' when func1(func2(G_VALUE1,
G_VALUE2), func3(
G_VALUE3)
) else
'0';