Skip to content

Commit 1912c20

Browse files
committed
Issue#1503: Added new rules for array alignment within signal initialisations.
1 parent 911d45f commit 1912c20

File tree

3 files changed

+86
-0
lines changed

3 files changed

+86
-0
lines changed

vsg/rules/signal/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,6 @@
2222
from .rule_200 import rule_200
2323
from .rule_400 import rule_400
2424
from .rule_401 import rule_401
25+
from .rule_402 import rule_402
26+
from .rule_403 import rule_403
2527
from .rule_600 import rule_600

vsg/rules/signal/rule_402.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# -*- coding: utf-8 -*-
2+
3+
4+
from vsg import token
5+
from vsg.rules import multiline_array_alignment as Rule
6+
7+
lTokenPairs = []
8+
lTokenPairs.append([token.signal_declaration.assignment_operator, token.signal_declaration.semicolon])
9+
10+
11+
class rule_402(Rule):
12+
"""
13+
This rule checks the alignment of multiline signal initializations that contain arrays.
14+
15+
|configuring_multiline_indent_rules_link|
16+
17+
.. NOTE:: The structure of multiline array signal initializations is handled by the rule `signal_403 <signal_rules.html#signal-403>`_.
18+
19+
**Violation**
20+
21+
.. code-block:: vhdl
22+
23+
signal rom : romq_type :=
24+
(
25+
0,
26+
65535,
27+
32768
28+
);
29+
30+
**Fix**
31+
32+
.. code-block:: vhdl
33+
34+
signal rom : romq_type :=
35+
(
36+
0,
37+
65535,
38+
32768
39+
);
40+
"""
41+
42+
def __init__(self):
43+
super().__init__(lTokenPairs)
44+
self.assignment_operator = token.signal_declaration.assignment_operator

vsg/rules/signal/rule_403.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# -*- coding: utf-8 -*-
2+
3+
from vsg import token
4+
from vsg.rules import multiline_structure as Rule
5+
6+
lTokenPairs = []
7+
lTokenPairs.append([token.signal_declaration.assignment_operator, token.signal_declaration.semicolon])
8+
9+
10+
class rule_403(Rule):
11+
"""
12+
This rule checks the structure of multiline signal initializations that contain arrays.
13+
14+
|configuring_array_multiline_structure_rules_link|
15+
16+
.. NOTE:: The indenting of multiline array signal initializations is handled by the rule `signal_402 <signal_rules.html#signal-402>`_.
17+
18+
**Violation**
19+
20+
.. code-block:: vhdl
21+
22+
signal rom : romq_type := (0, 65535, 32768);
23+
24+
**Fix**
25+
26+
.. code-block:: vhdl
27+
28+
signal rom : romq_type :=
29+
(
30+
0,
31+
65535,
32+
32768
33+
);
34+
"""
35+
36+
def __init__(self):
37+
super().__init__(lTokenPairs)
38+
self.assignment_operator = token.signal_declaration.assignment_operator
39+
self.semicolon = token.signal_declaration.semicolon
40+
self.phase = 5

0 commit comments

Comments
 (0)