diff --git a/docs/configuring_identifier_alignment_rules.rst b/docs/configuring_identifier_alignment_rules.rst index 5e433548..cb521044 100644 --- a/docs/configuring_identifier_alignment_rules.rst +++ b/docs/configuring_identifier_alignment_rules.rst @@ -148,3 +148,4 @@ Rules Enforcing Identifier Alignment * `package_019 `_ * `package_body_400 `_ * `procedure_010 `_ +* `protected_type_body_400 `_ diff --git a/docs/configuring_keyword_alignment_rules.rst b/docs/configuring_keyword_alignment_rules.rst index 4c17032b..d99940d8 100644 --- a/docs/configuring_keyword_alignment_rules.rst +++ b/docs/configuring_keyword_alignment_rules.rst @@ -986,6 +986,8 @@ Rules Enforcing Keyword Alignment * `process_035 `_ * `process_400 `_ * `process_401 `_ +* `protected_type_body_401 `_ +* `protected_type_body_402 `_ * `sequential_400 `_ * `subprogram_body_400 `_ * `subprogram_body_401 `_ diff --git a/docs/protected_type_body_rules.rst b/docs/protected_type_body_rules.rst index 0faca905..a82ded61 100644 --- a/docs/protected_type_body_rules.rst +++ b/docs/protected_type_body_rules.rst @@ -24,6 +24,87 @@ This rule checks the indent of the end protected type body declaration. type flag_pt is protected body end protected body; +protected_type_body_400 +####################### + +|phase_5| |error| |alignment| + +This rule checks the identifiers for all declarations are aligned in the protected type body declarative region. + +|configuring_identifier_alignment_rules_link| + +**Violation** + +.. code-block:: vhdl + + variable var1 : natural; + constant c_period : time; + +**Fix** + +.. code-block:: vhdl + + variable var1 : natural; + constant c_period : time; + +protected_type_body_401 +####################### + +|phase_5| |error| |alignment| + +This rule checks the colons are in the same column for all declarations in the protected type body declarative part. + +|configuring_keyword_alignment_rules_link| + +**Violation** + +.. code-block:: vhdl + + type my_type protected body is + + signal wr_en : std_logic; + signal rd_en : std_logic; + constant c_period : time; + + end protected body; + +**Fix** + +.. code-block:: vhdl + + type my_type protected body is + + signal wr_en : std_logic; + signal rd_en : std_logic; + constant c_period : time; + + end protected body; + +protected_type_body_402 +####################### + +|phase_5| |error| |alignment| + +This rule checks the colons are in the same column for all attribute specifications. + +|configuring_keyword_alignment_rules_link| + +**Violation** + +.. code-block:: vhdl + + attribute mark_debug of wr_en : signal is "true"; + attribute mark_debug of almost_empty : signal is "true"; + attribute mark_debug of full : signal is "true"; + +**Fix** + +.. code-block:: vhdl + + attribute mark_debug of wr_en : signal is "true"; + attribute mark_debug of almost_empty : signal is "true"; + attribute mark_debug of full : signal is "true"; + protected_type_body_500 ####################### diff --git a/docs/rule_groups/alignment_rule_group.rst b/docs/rule_groups/alignment_rule_group.rst index b493cddf..67723a43 100644 --- a/docs/rule_groups/alignment_rule_group.rst +++ b/docs/rule_groups/alignment_rule_group.rst @@ -64,6 +64,9 @@ Rules Enforcing Alignment Rule Group * `process_035 <../process_rules.html#process-035>`_ * `process_400 <../process_rules.html#process-400>`_ * `process_401 <../process_rules.html#process-401>`_ +* `protected_type_body_400 <../protected_type_body_rules.html#protected-type-body-400>`_ +* `protected_type_body_401 <../protected_type_body_rules.html#protected-type-body-401>`_ +* `protected_type_body_402 <../protected_type_body_rules.html#protected-type-body-402>`_ * `report_statement_400 <../report_statement_rules.html#report-statement-400>`_ * `selected_assignment_400 <../selected_assignment_rules.html#selected-assignment-400>`_ * `sequential_004 <../sequential_rules.html#sequential-004>`_ diff --git a/tests/architecture/rule_026_test_input.fixed_no_no_no_no.vhd b/tests/architecture/rule_026_test_input.fixed_no_no_no_no.vhd index 94e5587f..a18ca132 100644 --- a/tests/architecture/rule_026_test_input.fixed_no_no_no_no.vhd +++ b/tests/architecture/rule_026_test_input.fixed_no_no_no_no.vhd @@ -24,6 +24,17 @@ architecture RTL of FIFO is shared variable var_1234 : integer; file file1234 : integer; + -- Checking exclusions + constant c_abc : integer; + function my_func return integer is + constant c_abc : integer; + begin + end function; + constant c_abc : integer; + type flag_pt is protected body + variable flag : boolean; + end protected body; + begin end architecture RTL; diff --git a/tests/architecture/rule_026_test_input.fixed_yes_no_no_no.vhd b/tests/architecture/rule_026_test_input.fixed_yes_no_no_no.vhd index 0842ffcd..afcc6a1f 100644 --- a/tests/architecture/rule_026_test_input.fixed_yes_no_no_no.vhd +++ b/tests/architecture/rule_026_test_input.fixed_yes_no_no_no.vhd @@ -24,6 +24,17 @@ architecture RTL of FIFO is shared variable var_1234 : integer; file file1234 : integer; + -- Checking exclusions + constant c_abc : integer; + function my_func return integer is + constant c_abc : integer; + begin + end function; + constant c_abc : integer; + type flag_pt is protected body + variable flag : boolean; + end protected body; + begin end architecture RTL; diff --git a/tests/architecture/rule_026_test_input.fixed_yes_no_yes_no.vhd b/tests/architecture/rule_026_test_input.fixed_yes_no_yes_no.vhd index 1f84f7f9..ecfb99b1 100644 --- a/tests/architecture/rule_026_test_input.fixed_yes_no_yes_no.vhd +++ b/tests/architecture/rule_026_test_input.fixed_yes_no_yes_no.vhd @@ -24,6 +24,17 @@ architecture RTL of FIFO is shared variable var_1234 : integer; file file1234 : integer; + -- Checking exclusions + constant c_abc : integer; + function my_func return integer is + constant c_abc : integer; + begin + end function; + constant c_abc : integer; + type flag_pt is protected body + variable flag : boolean; + end protected body; + begin end architecture RTL; diff --git a/tests/architecture/rule_026_test_input.fixed_yes_yes_no_no.vhd b/tests/architecture/rule_026_test_input.fixed_yes_yes_no_no.vhd index 88fb869a..c4954f2b 100644 --- a/tests/architecture/rule_026_test_input.fixed_yes_yes_no_no.vhd +++ b/tests/architecture/rule_026_test_input.fixed_yes_yes_no_no.vhd @@ -24,6 +24,17 @@ architecture RTL of FIFO is shared variable var_1234 : integer; file file1234 : integer; + -- Checking exclusions + constant c_abc : integer; + function my_func return integer is + constant c_abc : integer; + begin + end function; + constant c_abc : integer; + type flag_pt is protected body + variable flag : boolean; + end protected body; + begin end architecture RTL; diff --git a/tests/architecture/rule_026_test_input.fixed_yes_yes_no_yes.vhd b/tests/architecture/rule_026_test_input.fixed_yes_yes_no_yes.vhd index 49e6c8b9..a22b1005 100644 --- a/tests/architecture/rule_026_test_input.fixed_yes_yes_no_yes.vhd +++ b/tests/architecture/rule_026_test_input.fixed_yes_yes_no_yes.vhd @@ -24,6 +24,17 @@ architecture RTL of FIFO is shared variable var_1234 : integer; file file1234 : integer; + -- Checking exclusions + constant c_abc : integer; + function my_func return integer is + constant c_abc : integer; + begin + end function; + constant c_abc : integer; + type flag_pt is protected body + variable flag : boolean; + end protected body; + begin end architecture RTL; diff --git a/tests/architecture/rule_026_test_input.vhd b/tests/architecture/rule_026_test_input.vhd index d88c3c0b..6dceee6e 100644 --- a/tests/architecture/rule_026_test_input.vhd +++ b/tests/architecture/rule_026_test_input.vhd @@ -24,6 +24,17 @@ architecture RTL of FIFO is shared variable var_1234 : integer; file file1234 : integer; + -- Checking exclusions + constant c_abc : integer; + function my_func return integer is + constant c_abc : integer; + begin + end function; + constant c_abc : integer; + type flag_pt is protected body + variable flag : boolean; + end protected body; + begin end architecture RTL; diff --git a/tests/architecture/rule_029_test_input.fixed.vhd b/tests/architecture/rule_029_test_input.fixed.vhd index b1963756..b7decd81 100644 --- a/tests/architecture/rule_029_test_input.fixed.vhd +++ b/tests/architecture/rule_029_test_input.fixed.vhd @@ -59,6 +59,17 @@ architecture RTL of ENTITY1 is signal sig1 : std_logic; + -- Checking exclusions + constant c_abc : integer; + function my_func return integer is + constant c_abc : integer; + begin + end function; + constant c_abc : integer; + type flag_pt is protected body + variable flag : boolean; + end protected body; + begin end architecture RTL; diff --git a/tests/architecture/rule_029_test_input.vhd b/tests/architecture/rule_029_test_input.vhd index cfaacb02..d65fa7d1 100644 --- a/tests/architecture/rule_029_test_input.vhd +++ b/tests/architecture/rule_029_test_input.vhd @@ -59,6 +59,17 @@ architecture RTL of ENTITY1 is signal sig1 : std_logic; + -- Checking exclusions + constant c_abc : integer; + function my_func return integer is + constant c_abc : integer; + begin + end function; + constant c_abc : integer; + type flag_pt is protected body + variable flag : boolean; + end protected body; + begin end architecture RTL; diff --git a/tests/architecture/test_rule_026.py b/tests/architecture/test_rule_026.py index 26afd412..fb992c2a 100644 --- a/tests/architecture/test_rule_026.py +++ b/tests/architecture/test_rule_026.py @@ -27,7 +27,7 @@ class test_rule(unittest.TestCase): self.assertEqual(oRule.name, "architecture") self.assertEqual(oRule.identifier, "026") - lExpected = [5, 6, 7, 8, 9, 12, 13, 14, 15, 17, 18, 19, 20, 22, 23, 25] + lExpected = [5, 6, 7, 8, 9, 12, 13, 14, 15, 17, 18, 19, 20, 22, 23, 25, 28, 33] oRule.analyze(self.oFile) self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) @@ -42,7 +42,7 @@ class test_rule(unittest.TestCase): self.assertEqual(oRule.name, "architecture") self.assertEqual(oRule.identifier, "026") - lExpected = [5, 6, 7, 8, 9, 12, 13, 14, 15, 17, 18, 19, 20, 22, 23, 25] + lExpected = [5, 6, 7, 8, 9, 12, 13, 14, 15, 17, 18, 19, 20, 22, 23, 25, 28, 33] oRule.analyze(self.oFile) self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) @@ -75,7 +75,7 @@ class test_rule(unittest.TestCase): oRule.comment_line_ends_group = "no" oRule.include_type_is_keyword = "no" - lExpected = [4, 5, 6, 7, 8, 9, 12, 13, 14, 15, 17, 19, 20, 22, 23, 24, 25] + lExpected = [4, 5, 6, 7, 8, 9, 12, 13, 14, 15, 17, 19, 20, 22, 23, 24, 25, 28, 33] oRule.analyze(self.oFile) self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) @@ -87,7 +87,7 @@ class test_rule(unittest.TestCase): oRule.comment_line_ends_group = False oRule.include_type_is_keyword = False - lExpected = [4, 5, 6, 7, 8, 9, 12, 13, 14, 15, 17, 19, 20, 22, 23, 24, 25] + lExpected = [4, 5, 6, 7, 8, 9, 12, 13, 14, 15, 17, 19, 20, 22, 23, 24, 25, 28, 33] oRule.analyze(self.oFile) self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) @@ -210,7 +210,7 @@ class test_rule(unittest.TestCase): oRule.comment_line_ends_group = "no" oRule.include_type_is_keyword = "yes" - lExpected = [4, 5, 6, 7, 8, 9, 10, 12, 13, 15, 17, 18, 19, 20, 22, 23, 25] + lExpected = [4, 5, 6, 7, 8, 9, 10, 12, 13, 15, 17, 18, 19, 20, 22, 23, 25, 34] oRule.analyze(self.oFile) self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) @@ -222,7 +222,7 @@ class test_rule(unittest.TestCase): oRule.comment_line_ends_group = False oRule.include_type_is_keyword = True - lExpected = [4, 5, 6, 7, 8, 9, 10, 12, 13, 15, 17, 18, 19, 20, 22, 23, 25] + lExpected = [4, 5, 6, 7, 8, 9, 10, 12, 13, 15, 17, 18, 19, 20, 22, 23, 25, 34] oRule.analyze(self.oFile) self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) diff --git a/tests/architecture/test_rule_029.py b/tests/architecture/test_rule_029.py index 20323ba8..98767f4b 100644 --- a/tests/architecture/test_rule_029.py +++ b/tests/architecture/test_rule_029.py @@ -24,7 +24,7 @@ class test_architecture_rule(unittest.TestCase): def test_rule_029(self): oRule = architecture.rule_029() - lExpected = [6, 8, 9, 10, 11, 23, 25, 26, 28, 29, 48] + lExpected = [6, 8, 9, 10, 11, 23, 25, 26, 28, 29, 48, 69] oRule.analyze(self.oFile) self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) diff --git a/tests/block/rule_400_test_input.fixed.vhd b/tests/block/rule_400_test_input.fixed.vhd index 55ffda61..b2db68ca 100644 --- a/tests/block/rule_400_test_input.fixed.vhd +++ b/tests/block/rule_400_test_input.fixed.vhd @@ -10,6 +10,17 @@ begin file file1 : std_logic; alias alias1 is name; + -- Checking exclusions + constant c_abc : integer; + function my_func return integer is + constant c_abc : integer; + begin + end function; + constant c_abc : integer; + type flag_pt is protected body + variable flag : boolean; + end protected body; + begin end block BLOCK_LABEL; diff --git a/tests/block/rule_400_test_input.vhd b/tests/block/rule_400_test_input.vhd index a50b16c4..7ee7141d 100644 --- a/tests/block/rule_400_test_input.vhd +++ b/tests/block/rule_400_test_input.vhd @@ -10,6 +10,17 @@ begin file file1 : std_logic; alias alias1 is name; + -- Checking exclusions + constant c_abc : integer; + function my_func return integer is + constant c_abc : integer; + begin + end function; + constant c_abc : integer; + type flag_pt is protected body + variable flag : boolean; + end protected body; + begin end block BLOCK_LABEL; diff --git a/tests/block/rule_401_test_input.fixed.vhd b/tests/block/rule_401_test_input.fixed.vhd index cdb05272..f8df4b67 100644 --- a/tests/block/rule_401_test_input.fixed.vhd +++ b/tests/block/rule_401_test_input.fixed.vhd @@ -11,6 +11,17 @@ begin alias alias1 : subtype_indicator is name; alias alias1 is name; + -- Checking exclusions + constant c_abc : integer; + function my_func return integer is + constant c_abc : integer; + begin + end function; + constant c_abc : integer; + type flag_pt is protected body + variable flag : boolean; + end protected body; + begin end block BLOCK_LABEL; diff --git a/tests/block/rule_401_test_input.vhd b/tests/block/rule_401_test_input.vhd index e30f361d..86ae1b0d 100644 --- a/tests/block/rule_401_test_input.vhd +++ b/tests/block/rule_401_test_input.vhd @@ -11,6 +11,17 @@ begin alias alias1 : subtype_indicator is name; alias alias1 is name; + -- Checking exclusions + constant c_abc : integer; + function my_func return integer is + constant c_abc : integer; + begin + end function; + constant c_abc : integer; + type flag_pt is protected body + variable flag : boolean; + end protected body; + begin end block BLOCK_LABEL; diff --git a/tests/block/test_rule_400.py b/tests/block/test_rule_400.py index a05e4dbf..429bd0e5 100644 --- a/tests/block/test_rule_400.py +++ b/tests/block/test_rule_400.py @@ -27,7 +27,7 @@ class test_block_rule(unittest.TestCase): self.assertEqual(oRule.name, "block") self.assertEqual(oRule.identifier, "400") - lExpected = [8, 10, 11] + lExpected = [8, 10, 11, 20] oRule.analyze(self.oFile) self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) diff --git a/tests/function/rule_012_test_input.fixed.vhd b/tests/function/rule_012_test_input.fixed.vhd index 74ed7805..ea48164a 100644 --- a/tests/function/rule_012_test_input.fixed.vhd +++ b/tests/function/rule_012_test_input.fixed.vhd @@ -16,6 +16,18 @@ architecture RTL of FIFO is file f : something; alias a : subtype_indicator is name; alias a is name; + + -- Checking exclusions + constant c_abc : integer; + function my_func return integer is + constant c_abc : integer; + begin + end function; + constant c_abc : integer; + type flag_pt is protected body + variable flag : boolean; + end protected body; + begin end function func1; diff --git a/tests/function/rule_012_test_input.vhd b/tests/function/rule_012_test_input.vhd index e64bfaeb..a7dea1b7 100644 --- a/tests/function/rule_012_test_input.vhd +++ b/tests/function/rule_012_test_input.vhd @@ -16,6 +16,18 @@ architecture RTL of FIFO is file f : something; alias a: subtype_indicator is name; alias a is name; + + -- Checking exclusions + constant c_abc : integer; + function my_func return integer is + constant c_abc : integer; + begin + end function; + constant c_abc : integer; + type flag_pt is protected body + variable flag : boolean; + end protected body; + begin end function func1; diff --git a/tests/function/rule_015_test_input.fixed.vhd b/tests/function/rule_015_test_input.fixed.vhd index 58b87027..874194d3 100644 --- a/tests/function/rule_015_test_input.fixed.vhd +++ b/tests/function/rule_015_test_input.fixed.vhd @@ -14,6 +14,18 @@ architecture RTL of FIFO is variable v : integer; file f : something; alias a is name; + + -- Checking exclusions + constant c_abc : integer; + function my_func return integer is + constant c_abc : integer; + begin + end function; + constant c_abc : integer; + type flag_pt is protected body + variable flag : boolean; + end protected body; + begin end function func1; diff --git a/tests/function/rule_015_test_input.vhd b/tests/function/rule_015_test_input.vhd index bd78da82..7fedffcd 100644 --- a/tests/function/rule_015_test_input.vhd +++ b/tests/function/rule_015_test_input.vhd @@ -14,6 +14,18 @@ architecture RTL of FIFO is variable v : integer; file f : something; alias a is name; + + -- Checking exclusions + constant c_abc : integer; + function my_func return integer is + constant c_abc : integer; + begin + end function; + constant c_abc : integer; + type flag_pt is protected body + variable flag : boolean; + end protected body; + begin end function func1; diff --git a/tests/function/test_rule_012.py b/tests/function/test_rule_012.py index b54dfee1..4a6f020a 100644 --- a/tests/function/test_rule_012.py +++ b/tests/function/test_rule_012.py @@ -28,7 +28,7 @@ class test_function_rule(unittest.TestCase): self.assertEqual(oRule.identifier, "012") self.assertEqual(oRule.groups, ["alignment"]) - lExpected = [14, 16, 17, 18] + lExpected = [14, 16, 17, 18, 21, 26] oRule.analyze(self.oFile) self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) diff --git a/tests/function/test_rule_015.py b/tests/function/test_rule_015.py index b476bcf2..a40f6262 100644 --- a/tests/function/test_rule_015.py +++ b/tests/function/test_rule_015.py @@ -28,7 +28,7 @@ class test_function_rule(unittest.TestCase): self.assertEqual(oRule.identifier, "015") self.assertEqual(oRule.groups, ["alignment"]) - lExpected = [13, 14, 15, 16] + lExpected = [13, 14, 15, 16, 19, 24, 25] oRule.analyze(self.oFile) self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) diff --git a/tests/generic_map/rule_001_test_input.fixed_lower.vhd b/tests/generic_map/rule_001_test_input.fixed_lower.vhd index f57d8a36..d5286c8a 100644 --- a/tests/generic_map/rule_001_test_input.fixed_lower.vhd +++ b/tests/generic_map/rule_001_test_input.fixed_lower.vhd @@ -1,6 +1,26 @@ architecture ARCH of ENTITY1 is + function my_func is new my_func + generic map ( + g_test => c_test + ); + + function my_func is new my_func + generic map ( + g_test => c_test + ); + + function my_func is new my_func + generic map ( + g_test => c_test + ); + + function my_func is new my_func + generic map ( + g_test => c_test + ); + begin U_INST1 : INST1 @@ -15,8 +35,6 @@ begin PORT_3 => w_port_3 ); - -- Violations below - U_INST1 : INST1 generic map ( G_GEN_1 => 1, @@ -38,4 +56,64 @@ begin G_GEN_3 => 3 ); + my_block : block is + GENERIC ( + g_test : BOOLEAN + ); + generic map ( + g_test => C_TEST + ); + begin + end block; + + my_block : block is + GENERIC ( + g_test : BOOLEAN + ); + generic map ( + g_test => C_TEST + ); + begin + end block; + + my_block : block is + GENERIC ( + g_test : BOOLEAN + ); + generic map ( + g_test => C_TEST + ); + begin + end block; + + my_block : block is + GENERIC ( + g_test : BOOLEAN + ); + generic map ( + g_test => C_TEST + ); + begin + end block; + end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( + g_test => c_test + ); + +package my_pkg_g is new my_pkg + generic map ( + g_test => c_test + ); + +package my_pkg_g is new my_pkg + generic map ( + g_test => c_test + ); + +package my_pkg_g is new my_pkg + generic map ( + g_test => c_test + ); diff --git a/tests/generic_map/rule_001_test_input.fixed_upper.vhd b/tests/generic_map/rule_001_test_input.fixed_upper.vhd index 8fcb9932..14fe08d4 100644 --- a/tests/generic_map/rule_001_test_input.fixed_upper.vhd +++ b/tests/generic_map/rule_001_test_input.fixed_upper.vhd @@ -1,6 +1,26 @@ architecture ARCH of ENTITY1 is + function my_func is new my_func + GENERIC MAP ( + g_test => c_test + ); + + function my_func is new my_func + GENERIC MAP ( + g_test => c_test + ); + + function my_func is new my_func + GENERIC MAP ( + g_test => c_test + ); + + function my_func is new my_func + GENERIC MAP ( + g_test => c_test + ); + begin U_INST1 : INST1 @@ -15,8 +35,6 @@ begin PORT_3 => w_port_3 ); - -- Violations below - U_INST1 : INST1 GENERIC MAP ( G_GEN_1 => 1, @@ -38,4 +56,64 @@ begin G_GEN_3 => 3 ); + my_block : block is + GENERIC ( + g_test : BOOLEAN + ); + GENERIC MAP ( + g_test => C_TEST + ); + begin + end block; + + my_block : block is + GENERIC ( + g_test : BOOLEAN + ); + GENERIC MAP ( + g_test => C_TEST + ); + begin + end block; + + my_block : block is + GENERIC ( + g_test : BOOLEAN + ); + GENERIC MAP ( + g_test => C_TEST + ); + begin + end block; + + my_block : block is + GENERIC ( + g_test : BOOLEAN + ); + GENERIC MAP ( + g_test => C_TEST + ); + begin + end block; + end architecture ARCH; + +package my_pkg_g is new my_pkg + GENERIC MAP ( + g_test => c_test + ); + +package my_pkg_g is new my_pkg + GENERIC MAP ( + g_test => c_test + ); + +package my_pkg_g is new my_pkg + GENERIC MAP ( + g_test => c_test + ); + +package my_pkg_g is new my_pkg + GENERIC MAP ( + g_test => c_test + ); diff --git a/tests/generic_map/rule_001_test_input.vhd b/tests/generic_map/rule_001_test_input.vhd index 0f14ffcf..0e7d2e58 100644 --- a/tests/generic_map/rule_001_test_input.vhd +++ b/tests/generic_map/rule_001_test_input.vhd @@ -1,6 +1,26 @@ architecture ARCH of ENTITY1 is + function my_func is new my_func + generic map ( + g_test => c_test + ); + + function my_func is new my_func + GENERIC MAP ( + g_test => c_test + ); + + function my_func is new my_func + GENERIC map ( + g_test => c_test + ); + + function my_func is new my_func + generic MAP ( + g_test => c_test + ); + begin U_INST1 : INST1 @@ -15,8 +35,6 @@ begin PORT_3 => w_port_3 ); - -- Violations below - U_INST1 : INST1 GENERIC MAP ( G_GEN_1 => 1, @@ -38,4 +56,64 @@ begin G_GEN_3 => 3 ); + my_block : block is + GENERIC ( + g_test : BOOLEAN + ); + generic map ( + g_test => C_TEST + ); + begin + end block; + + my_block : block is + GENERIC ( + g_test : BOOLEAN + ); + GENERIC MAP ( + g_test => C_TEST + ); + begin + end block; + + my_block : block is + GENERIC ( + g_test : BOOLEAN + ); + generic MAP ( + g_test => C_TEST + ); + begin + end block; + + my_block : block is + GENERIC ( + g_test : BOOLEAN + ); + generic MAP ( + g_test => C_TEST + ); + begin + end block; + end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( + g_test => c_test + ); + +package my_pkg_g is new my_pkg + GENERIC MAP ( + g_test => c_test + ); + +package my_pkg_g is new my_pkg + GENERIC map ( + g_test => c_test + ); + +package my_pkg_g is new my_pkg + generic MAP ( + g_test => c_test + ); diff --git a/tests/generic_map/rule_002_test_input.fixed_lower.vhd b/tests/generic_map/rule_002_test_input.fixed_lower.vhd index 499d0010..cc1392b2 100644 --- a/tests/generic_map/rule_002_test_input.fixed_lower.vhd +++ b/tests/generic_map/rule_002_test_input.fixed_lower.vhd @@ -1,22 +1,23 @@ -architecture ARCH of ENTITY1 is +package my_pkg_g is new my_pkg + generic map ( + g_gen_1(3 downto 0) => 3, + g_gen_2(2 downto 1) => 4, + g_gen_3 => 5 + ); + +architecture rtl of test is + +function my_func is new my_func + generic map ( + g_gen_1(3 downto 0) => 3, + g_gen_2(2 downto 1) => 4, + g_gen_3 => 5 + ); begin - U_INST1 : INST1 - generic map ( - g_gen_1(3 downto 0) => 3, - g_gen_2(2 downto 1) => 4, - g_gen_3 => 5 - ) - port map ( - PORT_1(3 downto 0) => w_port_1, - PORT_2 => w_port_2, - PORT_3(2 downto 1) => w_port_3 - ); - - -- Violations below - U_INST1 : INST1 + u_inst1 : inst1 generic map ( g_gen_1(3 downto 0) => 3, g_gen_2(2 downto 1) => 4, @@ -28,4 +29,68 @@ begin port_3(2 downto 1) => w_port_3 ); -end architecture ARCH; + my_block : block is + + generic ( + g_test : boolean + ); + generic map ( + g_gen_1(3 downto 0) => 3, + g_gen_2(2 downto 1) => 4, + g_gen_3 => 5 + ); + + begin + + end block my_block; + +end architecture rtl; + + -- Violations below + +PACKAGE MY_PKG_G IS NEW MY_PKG + GENERIC MAP ( + g_gen_1(3 DOWNTO 0) => 3, + g_gen_2(2 DOWNTO 1) => 4, + g_gen_3 => 5 + ); + +ARCHITECTURE RTL OF TEST IS + +FUNCTION MY_FUNC IS NEW MY_FUNC + GENERIC MAP ( + g_gen_1(3 DOWNTO 0) => 3, + g_gen_2(2 DOWNTO 1) => 4, + g_gen_3 => 5 + ); + +BEGIN + + U_INST1 : INST1 + GENERIC MAP ( + g_gen_1(3 DOWNTO 0) => 3, + g_gen_2(2 DOWNTO 1) => 4, + g_gen_3 => 5 + ) + PORT MAP ( + PORT_1(3 DOWNTO 0) => W_PORT_1, + PORT_2 => W_PORT_2, + PORT_3(2 DOWNTO 1) => W_PORT_3 + ); + + MY_BLOCK : BLOCK IS + + GENERIC ( + G_TEST : BOOLEAN + ); + GENERIC MAP ( + g_gen_1(3 DOWNTO 0) => 3, + g_gen_2(2 DOWNTO 1) => 4, + g_gen_3 => 5 + ); + + BEGIN + + END BLOCK MY_BLOCK; + +END ARCHITECTURE RTL; diff --git a/tests/generic_map/rule_002_test_input.fixed_upper.vhd b/tests/generic_map/rule_002_test_input.fixed_upper.vhd index 46c2fc07..14184d08 100644 --- a/tests/generic_map/rule_002_test_input.fixed_upper.vhd +++ b/tests/generic_map/rule_002_test_input.fixed_upper.vhd @@ -1,22 +1,23 @@ -architecture ARCH of ENTITY1 is +package my_pkg_g is new my_pkg + generic map ( + G_GEN_1(3 downto 0) => 3, + G_GEN_2(2 downto 1) => 4, + G_GEN_3 => 5 + ); + +architecture rtl of test is + +function my_func is new my_func + generic map ( + G_GEN_1(3 downto 0) => 3, + G_GEN_2(2 downto 1) => 4, + G_GEN_3 => 5 + ); begin - U_INST1 : INST1 - generic map ( - G_GEN_1(3 downto 0) => 3, - G_GEN_2(2 downto 1) => 4, - G_GEN_3 => 5 - ) - port map ( - PORT_1(3 downto 0) => w_port_1, - PORT_2 => w_port_2, - PORT_3(2 downto 1) => w_port_3 - ); - - -- Violations below - U_INST1 : INST1 + u_inst1 : inst1 generic map ( G_GEN_1(3 downto 0) => 3, G_GEN_2(2 downto 1) => 4, @@ -28,4 +29,68 @@ begin port_3(2 downto 1) => w_port_3 ); -end architecture ARCH; + my_block : block is + + generic ( + g_test : boolean + ); + generic map ( + G_GEN_1(3 downto 0) => 3, + G_GEN_2(2 downto 1) => 4, + G_GEN_3 => 5 + ); + + begin + + end block my_block; + +end architecture rtl; + + -- Violations below + +PACKAGE MY_PKG_G IS NEW MY_PKG + GENERIC MAP ( + G_GEN_1(3 DOWNTO 0) => 3, + G_GEN_2(2 DOWNTO 1) => 4, + G_GEN_3 => 5 + ); + +ARCHITECTURE RTL OF TEST IS + +FUNCTION MY_FUNC IS NEW MY_FUNC + GENERIC MAP ( + G_GEN_1(3 DOWNTO 0) => 3, + G_GEN_2(2 DOWNTO 1) => 4, + G_GEN_3 => 5 + ); + +BEGIN + + U_INST1 : INST1 + GENERIC MAP ( + G_GEN_1(3 DOWNTO 0) => 3, + G_GEN_2(2 DOWNTO 1) => 4, + G_GEN_3 => 5 + ) + PORT MAP ( + PORT_1(3 DOWNTO 0) => W_PORT_1, + PORT_2 => W_PORT_2, + PORT_3(2 DOWNTO 1) => W_PORT_3 + ); + + MY_BLOCK : BLOCK IS + + GENERIC ( + G_TEST : BOOLEAN + ); + GENERIC MAP ( + G_GEN_1(3 DOWNTO 0) => 3, + G_GEN_2(2 DOWNTO 1) => 4, + G_GEN_3 => 5 + ); + + BEGIN + + END BLOCK MY_BLOCK; + +END ARCHITECTURE RTL; diff --git a/tests/generic_map/rule_002_test_input.vhd b/tests/generic_map/rule_002_test_input.vhd index 03583d52..09af694f 100644 --- a/tests/generic_map/rule_002_test_input.vhd +++ b/tests/generic_map/rule_002_test_input.vhd @@ -1,22 +1,23 @@ -architecture ARCH of ENTITY1 is +package my_pkg_g is new my_pkg + generic map ( + g_gen_1(3 downto 0) => 3, + g_gen_2(2 downto 1) => 4, + g_gen_3 => 5 + ); + +architecture rtl of test is + +function my_func is new my_func + generic map ( + g_gen_1(3 downto 0) => 3, + g_gen_2(2 downto 1) => 4, + g_gen_3 => 5 + ); begin - U_INST1 : INST1 - generic map ( - G_GEN_1(3 downto 0) => 3, - G_GEN_2(2 downto 1) => 4, - G_GEN_3 => 5 - ) - port map ( - PORT_1(3 downto 0) => w_port_1, - PORT_2 => w_port_2, - PORT_3(2 downto 1) => w_port_3 - ); - - -- Violations below - U_INST1 : INST1 + u_inst1 : inst1 generic map ( g_gen_1(3 downto 0) => 3, g_gen_2(2 downto 1) => 4, @@ -28,4 +29,68 @@ begin port_3(2 downto 1) => w_port_3 ); -end architecture ARCH; + my_block : block is + + generic ( + g_test : boolean + ); + generic map ( + g_gen_1(3 downto 0) => 3, + g_gen_2(2 downto 1) => 4, + g_gen_3 => 5 + ); + + begin + + end block my_block; + +end architecture rtl; + + -- Violations below + +PACKAGE MY_PKG_G IS NEW MY_PKG + GENERIC MAP ( + G_GEN_1(3 DOWNTO 0) => 3, + G_GEN_2(2 DOWNTO 1) => 4, + G_GEN_3 => 5 + ); + +ARCHITECTURE RTL OF TEST IS + +FUNCTION MY_FUNC IS NEW MY_FUNC + GENERIC MAP ( + G_GEN_1(3 DOWNTO 0) => 3, + G_GEN_2(2 DOWNTO 1) => 4, + G_GEN_3 => 5 + ); + +BEGIN + + U_INST1 : INST1 + GENERIC MAP ( + G_GEN_1(3 DOWNTO 0) => 3, + G_GEN_2(2 DOWNTO 1) => 4, + G_GEN_3 => 5 + ) + PORT MAP ( + PORT_1(3 DOWNTO 0) => W_PORT_1, + PORT_2 => W_PORT_2, + PORT_3(2 DOWNTO 1) => W_PORT_3 + ); + + MY_BLOCK : BLOCK IS + + GENERIC ( + G_TEST : BOOLEAN + ); + GENERIC MAP ( + G_GEN_1(3 DOWNTO 0) => 3, + G_GEN_2(2 DOWNTO 1) => 4, + G_GEN_3 => 5 + ); + + BEGIN + + END BLOCK MY_BLOCK; + +END ARCHITECTURE RTL; diff --git a/tests/generic_map/rule_003_test_input.fixed.vhd b/tests/generic_map/rule_003_test_input.fixed.vhd index 29e96751..d080c0cc 100644 --- a/tests/generic_map/rule_003_test_input.fixed.vhd +++ b/tests/generic_map/rule_003_test_input.fixed.vhd @@ -1,6 +1,11 @@ architecture ARCH of ENTITY1 is + function my_func is new my_func + generic map ( + g_test => c_test + ); + begin U_INST1 : INST1 @@ -15,6 +20,32 @@ begin PORT_3 => w_port_3 ); + my_block : block is + generic ( + g_test : BOOLEAN + ); + generic map ( + g_test => C_TEST + ); + begin + end block; + +end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( + g_test => c_test + ); + +architecture ARCH of ENTITY1 is + + function my_func is new my_func + generic map( + g_test => c_test + ); + +begin + U_INST1 : INST1 generic map( G_GEN_1 => 3, @@ -27,8 +58,35 @@ begin PORT_3 => w_port_3 ); + my_block : block is + generic ( + g_test : BOOLEAN + ); + generic map( + g_test => C_TEST + ); + begin + end block; + +end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map( + g_test => c_test + ); + -- Violations below +architecture ARCH of ENTITY1 is + + function my_func is new my_func + generic map ( + + g_test => c_test + ); + +begin + U_INST1 : INST1 generic map ( @@ -36,10 +94,28 @@ begin G_GEN_2 => 4, G_GEN_3 => 5 ) - port map ( + port map + ( PORT_1 => w_port_1, PORT_2 => w_port_2, PORT_3 => w_port_3 ); + my_block : block is + generic ( + g_test : BOOLEAN + ); + generic map ( + + g_test => C_TEST + ); + begin + end block; + end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( + + g_test => c_test + ); diff --git a/tests/generic_map/rule_003_test_input.vhd b/tests/generic_map/rule_003_test_input.vhd index 837bd592..308dd912 100644 --- a/tests/generic_map/rule_003_test_input.vhd +++ b/tests/generic_map/rule_003_test_input.vhd @@ -1,6 +1,11 @@ architecture ARCH of ENTITY1 is + function my_func is new my_func + generic map ( + g_test => c_test + ); + begin U_INST1 : INST1 @@ -15,6 +20,32 @@ begin PORT_3 => w_port_3 ); + my_block : block is + generic ( + g_test : BOOLEAN + ); + generic map ( + g_test => C_TEST + ); + begin + end block; + +end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( + g_test => c_test + ); + +architecture ARCH of ENTITY1 is + + function my_func is new my_func + generic map( + g_test => c_test + ); + +begin + U_INST1 : INST1 generic map( G_GEN_1 => 3, @@ -27,8 +58,35 @@ begin PORT_3 => w_port_3 ); + my_block : block is + generic ( + g_test : BOOLEAN + ); + generic map( + g_test => C_TEST + ); + begin + end block; + +end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map( + g_test => c_test + ); + -- Violations below +architecture ARCH of ENTITY1 is + + function my_func is new my_func + generic map + ( + g_test => c_test + ); + +begin + U_INST1 : INST1 generic map ( @@ -36,10 +94,28 @@ begin G_GEN_2 => 4, G_GEN_3 => 5 ) - port map ( + port map + ( PORT_1 => w_port_1, PORT_2 => w_port_2, PORT_3 => w_port_3 ); + my_block : block is + generic ( + g_test : BOOLEAN + ); + generic map + ( + g_test => C_TEST + ); + begin + end block; + end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map + ( + g_test => c_test + ); diff --git a/tests/generic_map/rule_004_test_input.fixed.vhd b/tests/generic_map/rule_004_test_input.fixed.vhd index eac8fc07..bb72dafd 100644 --- a/tests/generic_map/rule_004_test_input.fixed.vhd +++ b/tests/generic_map/rule_004_test_input.fixed.vhd @@ -1,6 +1,11 @@ architecture ARCH of ENTITY1 is + function my_func is new my_func + generic map ( + g_test => c_test + ); + begin U_INST1 : INST1 @@ -15,8 +20,34 @@ begin PORT_3 => w_port_3 ); + my_block : block is + generic ( + g_test : BOOLEAN + ); + generic map ( + g_test => C_TEST + ); + begin + end block; + +end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( + g_test => c_test + ); + -- Violations below +architecture ARCH of ENTITY1 is + + function my_func is new my_func + generic map ( + g_test => c_test +); + +begin + U_INST1 : INST1 generic map ( G_GEN_1 => 3, @@ -27,13 +58,58 @@ begin PORT_1 => w_port_1, PORT_2 => w_port_2, PORT_3 => w_port_3 - ); +); + + my_block : block is + generic ( + g_test : BOOLEAN +); + generic map ( + g_test => C_TEST +); + begin + end block; + +end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( + g_test => c_test +); + +architecture ARCH of ENTITY1 is + + function my_func is new my_func + generic map ( + g_test => c_test +); + +begin U_INST1 : INST1 generic map ( - G_GEN_1 => 1, - G_GEN_2 => 2, - G_GEN_3 => 3 + G_GEN_1 => 3, + G_GEN_2 => 4, + G_GEN_3 => 5 +) + port map + ( + PORT_1 => w_port_1, + PORT_2 => w_port_2, + PORT_3 => w_port_3); + + my_block : block is + generic ( + g_test : BOOLEAN); + generic map ( + g_test => C_TEST ); + begin + end block; end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( + g_test => c_test +); diff --git a/tests/generic_map/rule_004_test_input.vhd b/tests/generic_map/rule_004_test_input.vhd index e22d7991..e577164c 100644 --- a/tests/generic_map/rule_004_test_input.vhd +++ b/tests/generic_map/rule_004_test_input.vhd @@ -1,6 +1,11 @@ architecture ARCH of ENTITY1 is + function my_func is new my_func + generic map ( + g_test => c_test + ); + begin U_INST1 : INST1 @@ -15,23 +20,92 @@ begin PORT_3 => w_port_3 ); + my_block : block is + generic ( + g_test : BOOLEAN + ); + generic map ( + g_test => C_TEST + ); + begin + end block; + +end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( + g_test => c_test + ); + -- Violations below +architecture ARCH of ENTITY1 is + + function my_func is new my_func + generic map ( + g_test => c_test +); + +begin + + U_INST1 : INST1 + generic map ( + G_GEN_1 => 3, + G_GEN_2 => 4, + G_GEN_3 => 5 +) + port map ( + PORT_1 => w_port_1, + PORT_2 => w_port_2, + PORT_3 => w_port_3 +); + + my_block : block is + generic ( + g_test : BOOLEAN +); + generic map ( + g_test => C_TEST +); + begin + end block; + +end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( + g_test => c_test +); + +architecture ARCH of ENTITY1 is + + function my_func is new my_func + generic map ( + g_test => c_test); + +begin + U_INST1 : INST1 generic map ( G_GEN_1 => 3, G_GEN_2 => 4, G_GEN_3 => 5) - port map ( + port map + ( PORT_1 => w_port_1, PORT_2 => w_port_2, - PORT_3 => w_port_3 - ); + PORT_3 => w_port_3); - U_INST1 : INST1 + my_block : block is + generic ( + g_test : BOOLEAN); generic map ( - G_GEN_1 => 1, - G_GEN_2 => 2, - G_GEN_3 => 3); + g_test => C_TEST); + begin + end block; end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( + g_test => c_test); diff --git a/tests/generic_map/rule_005_test_input.fixed.vhd b/tests/generic_map/rule_005_test_input.fixed.vhd index 6d3480b3..eb087b74 100644 --- a/tests/generic_map/rule_005_test_input.fixed.vhd +++ b/tests/generic_map/rule_005_test_input.fixed.vhd @@ -1,6 +1,11 @@ architecture ARCH of ENTITY1 is + function my_func is new my_func + generic map ( + g_test => c_test + ); + begin U_INST1 : INST1 @@ -15,8 +20,34 @@ begin PORT_3 => w_port_3 ); + my_block : block is + generic ( + g_test : BOOLEAN + ); + generic map ( + g_test => C_TEST + ); + begin + end block; + +end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( + g_test => c_test + ); + -- Violations below +architecture ARCH of ENTITY1 is + + function my_func is new my_func + generic map ( +g_test => c_test + ); + +begin + U_INST1 : INST1 generic map ( G_GEN_1 => 3, @@ -29,11 +60,57 @@ G_GEN_1 => 3, PORT_3 => w_port_3 ); - U_INST1 : INST1 - generic map ( - G_GEN_1 => 1, - G_GEN_2 => 2, - G_GEN_3 => 3 + my_block : block is + generic ( + g_test : BOOLEAN ); + generic map ( +g_test => C_TEST + ); + begin + end block; end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( +g_test => c_test + ); + +architecture ARCH of ENTITY1 is + + function my_func is new my_func + generic map ( + g_test => c_test + ); + +begin + + U_INST1 : INST1 + generic map ( + G_GEN_1 => 3, + G_GEN_2 => 4, + G_GEN_3 => 5 + ) + port map ( + PORT_1 => w_port_1, + PORT_2 => w_port_2, + PORT_3 => w_port_3 + ); + + my_block : block is + generic ( + g_test : BOOLEAN + ); + generic map ( + g_test => C_TEST + ); + begin + end block; + +end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( + g_test => c_test + ); diff --git a/tests/generic_map/rule_005_test_input.vhd b/tests/generic_map/rule_005_test_input.vhd index c8194ecf..92184a1a 100644 --- a/tests/generic_map/rule_005_test_input.vhd +++ b/tests/generic_map/rule_005_test_input.vhd @@ -1,6 +1,11 @@ architecture ARCH of ENTITY1 is + function my_func is new my_func + generic map ( + g_test => c_test + ); + begin U_INST1 : INST1 @@ -15,8 +20,33 @@ begin PORT_3 => w_port_3 ); + my_block : block is + generic ( + g_test : BOOLEAN + ); + generic map ( + g_test => C_TEST + ); + begin + end block; + +end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( + g_test => c_test + ); + -- Violations below +architecture ARCH of ENTITY1 is + + function my_func is new my_func + generic map (g_test => c_test + ); + +begin + U_INST1 : INST1 generic map (G_GEN_1 => 3, G_GEN_2 => 4, @@ -28,10 +58,51 @@ begin PORT_3 => w_port_3 ); - U_INST1 : INST1 - generic map ( G_GEN_1 => 1, - G_GEN_2 => 2, - G_GEN_3 => 3 + my_block : block is + generic ( + g_test : BOOLEAN ); + generic map (g_test => C_TEST + ); + begin + end block; end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map (g_test => c_test + ); + +architecture ARCH of ENTITY1 is + + function my_func is new my_func + generic map ( g_test => c_test + ); + +begin + + U_INST1 : INST1 + generic map ( G_GEN_1 => 3, + G_GEN_2 => 4, + G_GEN_3 => 5 + ) + port map ( + PORT_1 => w_port_1, + PORT_2 => w_port_2, + PORT_3 => w_port_3 + ); + + my_block : block is + generic ( + g_test : BOOLEAN + ); + generic map ( g_test => C_TEST + ); + begin + end block; + +end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( g_test => c_test + ); diff --git a/tests/generic_map/rule_006_test_input.fixed.vhd b/tests/generic_map/rule_006_test_input.fixed.vhd index 99565fd5..2b6f1efe 100644 --- a/tests/generic_map/rule_006_test_input.fixed.vhd +++ b/tests/generic_map/rule_006_test_input.fixed.vhd @@ -1,6 +1,11 @@ architecture ARCH of ENTITY1 is + function my_func is new my_func + generic map ( + g_test => c_test + ); + begin U_INST1 : INST1 @@ -15,8 +20,34 @@ begin PORT_3 => w_port_3 ); + my_block : block is + generic ( + g_test : BOOLEAN + ); + generic map ( + g_test => C_TEST + ); + begin + end block; + +end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( + g_test => c_test + ); + -- Violations below +architecture ARCH of ENTITY1 is + + function my_func is new my_func + generic map ( + g_test => c_test + ); + +begin + U_INST1 : INST1 generic map ( G_GEN_1 => 3, @@ -27,7 +58,33 @@ begin PORT_1 => w_port_1, PORT_2 => w_port_2, PORT_3 => w_port_3 - ); + ); + + my_block : block is + generic ( + g_test : BOOLEAN + ); + generic map ( + g_test => C_TEST + ); + begin + end block; + +end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( + g_test => c_test + ); + +architecture ARCH of ENTITY1 is + + function my_func is new my_func + generic map ( + g_test => c_test + ); + +begin U_INST1 : INST1 generic map ( @@ -35,10 +92,25 @@ begin G_GEN_2 => 4, G_GEN_3 => 5 ) - port map ( + port map ( PORT_1 => w_port_1, PORT_2 => w_port_2, PORT_3 => w_port_3 - ); + ); + + my_block : block is + generic ( + g_test : BOOLEAN + ); + generic map ( + g_test => C_TEST + ); + begin + end block; end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( + g_test => c_test + ); diff --git a/tests/generic_map/rule_006_test_input.vhd b/tests/generic_map/rule_006_test_input.vhd index 19c33086..963565b0 100644 --- a/tests/generic_map/rule_006_test_input.vhd +++ b/tests/generic_map/rule_006_test_input.vhd @@ -1,6 +1,11 @@ architecture ARCH of ENTITY1 is + function my_func is new my_func + generic map ( + g_test => c_test + ); + begin U_INST1 : INST1 @@ -15,8 +20,34 @@ begin PORT_3 => w_port_3 ); + my_block : block is + generic ( + g_test : BOOLEAN + ); + generic map ( + g_test => C_TEST + ); + begin + end block; + +end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( + g_test => c_test + ); + -- Violations below +architecture ARCH of ENTITY1 is + + function my_func is new my_func + generic map( + g_test => c_test + ); + +begin + U_INST1 : INST1 generic map( G_GEN_1 => 3, @@ -27,18 +58,59 @@ begin PORT_1 => w_port_1, PORT_2 => w_port_2, PORT_3 => w_port_3 - ); + ); + + my_block : block is + generic ( + g_test : BOOLEAN + ); + generic map( + g_test => C_TEST + ); + begin + end block; + +end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map( + g_test => c_test + ); + +architecture ARCH of ENTITY1 is + + function my_func is new my_func + generic map ( + g_test => c_test + ); + +begin U_INST1 : INST1 - generic map ( + generic map ( G_GEN_1 => 3, G_GEN_2 => 4, G_GEN_3 => 5 ) - port map ( + port map ( PORT_1 => w_port_1, PORT_2 => w_port_2, PORT_3 => w_port_3 - ); + ); + + my_block : block is + generic ( + g_test : BOOLEAN + ); + generic map ( + g_test => C_TEST + ); + begin + end block; end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( + g_test => c_test + ); diff --git a/tests/generic_map/rule_007_test_input.fixed.vhd b/tests/generic_map/rule_007_test_input.fixed.vhd index 833f4bcd..5bf06a17 100644 --- a/tests/generic_map/rule_007_test_input.fixed.vhd +++ b/tests/generic_map/rule_007_test_input.fixed.vhd @@ -1,6 +1,11 @@ architecture ARCH of ENTITY1 is + function my_func is new my_func + generic map ( + g_test => c_test + ); + begin U_INST1 : INST1 @@ -15,8 +20,34 @@ begin PORT_3 => w_port_3 ); + my_block : block is + generic ( + g_test : BOOLEAN + ); + generic map ( + g_test => C_TEST + ); + begin + end block; + +end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( + g_test => c_test + ); + -- Violations below +architecture ARCH of ENTITY1 is + + function my_func is new my_func + generic map ( + g_test => c_test + ); + +begin + U_INST1 : INST1 generic map ( G_GEN_1 => 3, @@ -24,9 +55,24 @@ begin G_GEN_3 => 5 ) port map ( - PORT_1 => w_port_1, + PORT_1 => w_port_1, PORT_2 =>w_port_2, - PORT_3 => w_port_3 + PORT_3 => w_port_3 ); + my_block : block is + generic ( + g_test : BOOLEAN + ); + generic map ( + g_test => C_TEST + ); + begin + end block; + end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( + g_test => c_test + ); diff --git a/tests/generic_map/rule_007_test_input.vhd b/tests/generic_map/rule_007_test_input.vhd index 5572370f..01821e4f 100644 --- a/tests/generic_map/rule_007_test_input.vhd +++ b/tests/generic_map/rule_007_test_input.vhd @@ -1,6 +1,11 @@ architecture ARCH of ENTITY1 is + function my_func is new my_func + generic map ( + g_test => c_test + ); + begin U_INST1 : INST1 @@ -15,18 +20,59 @@ begin PORT_3 => w_port_3 ); + my_block : block is + generic ( + g_test : BOOLEAN + ); + generic map ( + g_test => C_TEST + ); + begin + end block; + +end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( + g_test => c_test + ); + -- Violations below +architecture ARCH of ENTITY1 is + + function my_func is new my_func + generic map ( + g_test => c_test + ); + +begin + U_INST1 : INST1 generic map ( G_GEN_1 => 3, G_GEN_2 =>4, - G_GEN_3 => 5 + G_GEN_3 => 5 ) port map ( - PORT_1 => w_port_1, + PORT_1 => w_port_1, PORT_2 =>w_port_2, - PORT_3 => w_port_3 + PORT_3 => w_port_3 ); + my_block : block is + generic ( + g_test : BOOLEAN + ); + generic map ( + g_test =>C_TEST + ); + begin + end block; + end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( + g_test => c_test + ); diff --git a/tests/generic_map/rule_008_test_input.vhd b/tests/generic_map/rule_008_test_input.vhd index 9c14d0e5..26309c07 100644 --- a/tests/generic_map/rule_008_test_input.vhd +++ b/tests/generic_map/rule_008_test_input.vhd @@ -1,6 +1,11 @@ architecture ARCH of ENTITY1 is + function my_func is new my_func + generic map ( + g_test => c_test + ); + begin U_INST1 : INST1 @@ -15,18 +20,33 @@ begin PORT_3 => w_port_3 ); + my_block : block is + generic ( + g_test : BOOLEAN + ); + generic map ( + g_test => C_TEST + ); + begin + end block; + +end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( + g_test => c_test + ); + -- Violations below - U_INST1 : INST1 - generic map( - G_GEN_1 => 3, - 4, - G_GEN_3 => 5 - ) - port map (w_port_1, - PORT_2 => w_port_2, - w_port_3 - ); +architecture ARCH of ENTITY1 is + + function my_func is new my_func + generic map ( + c_test + ); + +begin U_INST1 : INST1 generic map ( @@ -34,9 +54,25 @@ begin G_GEN_2 => 4, 5 ) - port map (PORT_1 => w_port_1, - w_port_2, + port map ( + w_port_1, + PORT_2 => w_port_2, w_port_3 - ); + ); + + my_block : block is + generic ( + g_test : BOOLEAN + ); + generic map ( + C_TEST + ); + begin + end block; end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( + c_test + ); diff --git a/tests/generic_map/rule_100_test_input.fixed.vhd b/tests/generic_map/rule_100_test_input.fixed.vhd index 7da5719f..701821fc 100644 --- a/tests/generic_map/rule_100_test_input.fixed.vhd +++ b/tests/generic_map/rule_100_test_input.fixed.vhd @@ -1,6 +1,11 @@ architecture ARCH of ENTITY1 is + function my_func is new my_func + generic map ( + g_test => c_test + ); + begin U_INST1 : INST1 @@ -15,10 +20,36 @@ begin PORT_3 => w_port_3 ); + my_block : block is + generic ( + g_test : BOOLEAN + ); + generic map ( + g_test => C_TEST + ); + begin + end block; + +end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( + g_test => c_test + ); + -- Violations below +architecture ARCH of ENTITY1 is + + function my_func is new my_func + generic map ( + g_test => c_test + ); + +begin + U_INST1 : INST1 - generic map( + generic map ( G_GEN_1 => 3, G_GEN_2 => 4, G_GEN_3 => 5 @@ -27,6 +58,21 @@ begin PORT_1=> w_port_1, PORT_2=> w_port_2, PORT_3=> w_port_3 - ); + ); + + my_block : block is + generic ( + g_test : BOOLEAN + ); + generic map ( + g_test => C_TEST + ); + begin + end block; end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( + g_test => c_test + ); diff --git a/tests/generic_map/rule_100_test_input.vhd b/tests/generic_map/rule_100_test_input.vhd index 9f4d9fea..3e4d829b 100644 --- a/tests/generic_map/rule_100_test_input.vhd +++ b/tests/generic_map/rule_100_test_input.vhd @@ -1,6 +1,11 @@ architecture ARCH of ENTITY1 is + function my_func is new my_func + generic map ( + g_test => c_test + ); + begin U_INST1 : INST1 @@ -15,10 +20,36 @@ begin PORT_3 => w_port_3 ); + my_block : block is + generic ( + g_test : BOOLEAN + ); + generic map ( + g_test => C_TEST + ); + begin + end block; + +end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( + g_test => c_test + ); + -- Violations below +architecture ARCH of ENTITY1 is + + function my_func is new my_func + generic map ( + g_test=> c_test + ); + +begin + U_INST1 : INST1 - generic map( + generic map ( G_GEN_1=> 3, G_GEN_2=> 4, G_GEN_3=> 5 @@ -27,6 +58,21 @@ begin PORT_1=> w_port_1, PORT_2=> w_port_2, PORT_3=> w_port_3 - ); + ); + + my_block : block is + generic ( + g_test : BOOLEAN + ); + generic map ( + g_test=> C_TEST + ); + begin + end block; end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( + g_test=> c_test + ); diff --git a/tests/generic_map/rule_600_test_input.vhd b/tests/generic_map/rule_600_test_input.vhd index ef8df6e9..f029c6f6 100644 --- a/tests/generic_map/rule_600_test_input.vhd +++ b/tests/generic_map/rule_600_test_input.vhd @@ -1,6 +1,11 @@ architecture ARCH of ENTITY1 is + function my_func is new my_func + generic map ( + test_g => c_test + ); + begin U_INST1 : INST1 @@ -15,13 +20,39 @@ begin PORT_3 => w_port_3 ); + my_block : block is + generic ( + test_g : BOOLEAN + ); + generic map ( + test_g => C_TEST + ); + begin + end block; + +end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( + test_g => c_test + ); + -- Violations below +architecture ARCH of ENTITY1 is + + function my_func is new my_func + generic map ( + g_test => c_test + ); + +begin + U_INST1 : INST1 generic map ( - GEN_1_W => 3, - GEN_2 => 4, - GEN_3_WR => 5 + G_GEN_1 => 3, + G_GEN_2 => 4, + G_GEN_3 => 5 ) port map ( PORT_1 => w_port_1, @@ -29,5 +60,25 @@ begin PORT_3 => w_port_3 ); + U_INST2 : INST2 + generic map ( + GEN_1_W(W_GEN_1) => 3, + GEN_2_G(W_GEN_1) => 10 + ); + + my_block : block is + generic ( + g_test : BOOLEAN + ); + generic map ( + g_test => C_TEST + ); + begin + end block; end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( + g_test => c_test + ); diff --git a/tests/generic_map/rule_601_test_input.vhd b/tests/generic_map/rule_601_test_input.vhd index 798b6924..e30ff735 100644 --- a/tests/generic_map/rule_601_test_input.vhd +++ b/tests/generic_map/rule_601_test_input.vhd @@ -1,6 +1,11 @@ architecture ARCH of ENTITY1 is + function my_func is new my_func + generic map ( + g_test => c_test + ); + begin U_INST1 : INST1 @@ -15,13 +20,39 @@ begin PORT_3 => w_port_3 ); + my_block : block is + generic ( + g_test : BOOLEAN + ); + generic map ( + g_test => C_TEST + ); + begin + end block; + +end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( + g_test => c_test + ); + -- Violations below +architecture ARCH of ENTITY1 is + + function my_func is new my_func + generic map ( + test_g => c_test + ); + +begin + U_INST1 : INST1 generic map ( - W_GEN_1 => 3, - GEN_2 => 4, - WR_GEN_3 => 5 + GEN_1_G => 3, + GEN_2_G => 4, + GEN_3_G => 5 ) port map ( PORT_1 => w_port_1, @@ -30,9 +61,24 @@ begin ); U_INST2 : INST2 - generic map ( - W_GEN_1(W_GEN_1) => 3, - G_GEN_2(W_GEN_1) => 10 + generic map ( + W_GEN_1(W_GEN_1) => 3, + G_GEN_2(W_GEN_1) => 10 + ); + + my_block : block is + generic ( + test_g : BOOLEAN ); + generic map ( + test_g => C_TEST + ); + begin + end block; end architecture ARCH; + +package my_pkg_g is new my_pkg + generic map ( + test_g => c_test + ); diff --git a/tests/generic_map/test_rule_001.py b/tests/generic_map/test_rule_001.py index 7787b26a..278911ff 100644 --- a/tests/generic_map/test_rule_001.py +++ b/tests/generic_map/test_rule_001.py @@ -31,7 +31,7 @@ class test_generic_map_rule(unittest.TestCase): self.assertEqual(oRule.name, "generic_map") self.assertEqual(oRule.identifier, "001") - lExpected = [21, 21, 28, 35] + lExpected = [10, 10, 15, 20, 39, 39, 46, 53, 73, 73, 83, 93, 107, 107, 112, 117] oRule.analyze(self.oFile) self.assertEqual(utils.extract_violation_lines_from_violation_object(oRule.violations), lExpected) @@ -43,7 +43,7 @@ class test_generic_map_rule(unittest.TestCase): self.assertEqual(oRule.name, "generic_map") self.assertEqual(oRule.identifier, "001") - lExpected = [7, 7, 28, 35] + lExpected = [5, 5, 15, 20, 27, 27, 46, 53, 63, 63, 83, 93, 102, 102, 112, 117] oRule.analyze(self.oFile) self.assertEqual(utils.extract_violation_lines_from_violation_object(oRule.violations), lExpected) diff --git a/tests/generic_map/test_rule_002.py b/tests/generic_map/test_rule_002.py index 44a8a748..ebee76db 100644 --- a/tests/generic_map/test_rule_002.py +++ b/tests/generic_map/test_rule_002.py @@ -31,7 +31,7 @@ class test_generic_map_rule(unittest.TestCase): self.assertEqual(oRule.name, "generic_map") self.assertEqual(oRule.identifier, "002") - lExpected = [8, 9, 10] + lExpected = [53, 54, 55, 62, 63, 64, 71, 72, 73, 87, 88, 89] oRule.analyze(self.oFile) self.assertEqual(utils.extract_violation_lines_from_violation_object(oRule.violations), lExpected) @@ -43,7 +43,7 @@ class test_generic_map_rule(unittest.TestCase): self.assertEqual(oRule.name, "generic_map") self.assertEqual(oRule.identifier, "002") - lExpected = [21, 22, 23] + lExpected = [4, 5, 6, 13, 14, 15, 22, 23, 24, 38, 39, 40] oRule.analyze(self.oFile) self.assertEqual(utils.extract_violation_lines_from_violation_object(oRule.violations), lExpected) diff --git a/tests/generic_map/test_rule_003.py b/tests/generic_map/test_rule_003.py index 1d348017..97fe9cb5 100644 --- a/tests/generic_map/test_rule_003.py +++ b/tests/generic_map/test_rule_003.py @@ -20,6 +20,7 @@ class test_generic_map_rule(unittest.TestCase): def setUp(self): self.oFile = vhdlFile.vhdlFile(lFile) self.assertIsNone(eError) + self.maxDiff = None def test_rule_003(self): oRule = generic_map.rule_003() @@ -27,7 +28,7 @@ class test_generic_map_rule(unittest.TestCase): self.assertEqual(oRule.name, "generic_map") self.assertEqual(oRule.identifier, "003") - lExpected = [33] + lExpected = [83, 91, 108, 118] oRule.analyze(self.oFile) self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) diff --git a/tests/generic_map/test_rule_004.py b/tests/generic_map/test_rule_004.py index c6424775..7ed41572 100644 --- a/tests/generic_map/test_rule_004.py +++ b/tests/generic_map/test_rule_004.py @@ -20,6 +20,7 @@ class test_generic_map_rule(unittest.TestCase): def setUp(self): self.oFile = vhdlFile.vhdlFile(lFile) self.assertIsNone(eError) + self.maxDiff = None def test_rule_004(self): oRule = generic_map.rule_004() @@ -27,7 +28,7 @@ class test_generic_map_rule(unittest.TestCase): self.assertEqual(oRule.name, "generic_map") self.assertEqual(oRule.identifier, "004") - lExpected = [24, 35] + lExpected = [84, 92, 103, 111] oRule.analyze(self.oFile) self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) diff --git a/tests/generic_map/test_rule_005.py b/tests/generic_map/test_rule_005.py index 42ff7b85..9bbc3f89 100644 --- a/tests/generic_map/test_rule_005.py +++ b/tests/generic_map/test_rule_005.py @@ -27,7 +27,7 @@ class test_generic_map_rule(unittest.TestCase): self.assertEqual(oRule.name, "generic_map") self.assertEqual(oRule.identifier, "005") - lExpected = [21, 32] + lExpected = [45, 51, 65, 73, 79, 85, 99, 107] oRule.analyze(self.oFile) self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) diff --git a/tests/generic_map/test_rule_006.py b/tests/generic_map/test_rule_006.py index 7bd2ab52..f9f456d7 100644 --- a/tests/generic_map/test_rule_006.py +++ b/tests/generic_map/test_rule_006.py @@ -27,7 +27,7 @@ class test_generic_map_rule(unittest.TestCase): self.assertEqual(oRule.name, "generic_map") self.assertEqual(oRule.identifier, "006") - lExpected = [21, 33] + lExpected = [45, 52, 67, 76, 83, 90, 105, 114] oRule.analyze(self.oFile) self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) diff --git a/tests/generic_map/test_rule_007.py b/tests/generic_map/test_rule_007.py index e6775cfe..b624fd47 100644 --- a/tests/generic_map/test_rule_007.py +++ b/tests/generic_map/test_rule_007.py @@ -27,7 +27,7 @@ class test_generic_map_rule(unittest.TestCase): self.assertEqual(oRule.name, "generic_map") self.assertEqual(oRule.identifier, "007") - lExpected = [22, 23, 24] + lExpected = [46, 53, 54, 55, 68, 77] oRule.analyze(self.oFile) self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) diff --git a/tests/generic_map/test_rule_008.py b/tests/generic_map/test_rule_008.py index eecd75b6..f1901965 100644 --- a/tests/generic_map/test_rule_008.py +++ b/tests/generic_map/test_rule_008.py @@ -23,7 +23,7 @@ class test_generic_map_rule(unittest.TestCase): self.assertEqual(oRule.name, "generic_map") self.assertEqual(oRule.identifier, "008") - lExpected = [23, 33, 35] + lExpected = [46, 53, 55, 68, 77] oRule.analyze(self.oFile) self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) diff --git a/tests/generic_map/test_rule_100.py b/tests/generic_map/test_rule_100.py index ca636270..fadb34d1 100644 --- a/tests/generic_map/test_rule_100.py +++ b/tests/generic_map/test_rule_100.py @@ -23,7 +23,7 @@ class test_rule(unittest.TestCase): self.assertEqual(oRule.name, "generic_map") self.assertEqual(oRule.identifier, "100") - lExpected = [22, 23, 24] + lExpected = [46, 53, 54, 55, 68, 77] oRule.analyze(self.oFile) self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) diff --git a/tests/generic_map/test_rule_600.py b/tests/generic_map/test_rule_600.py index ae04d30a..4c179a0d 100644 --- a/tests/generic_map/test_rule_600.py +++ b/tests/generic_map/test_rule_600.py @@ -23,7 +23,7 @@ class test_generic_map_rule(unittest.TestCase): self.assertEqual(oRule.name, "generic_map") self.assertEqual(oRule.identifier, "600") - lExpected = [22, 23, 24] + lExpected = [46, 53, 54, 55, 65, 74, 83] oRule.analyze(self.oFile) self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) @@ -35,7 +35,7 @@ class test_generic_map_rule(unittest.TestCase): self.assertEqual(oRule.name, "generic_map") self.assertEqual(oRule.identifier, "600") - lExpected = [22, 23, 24] + lExpected = [46, 53, 54, 55, 65, 74, 83] oRule.analyze(self.oFile) self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) diff --git a/tests/generic_map/test_rule_601.py b/tests/generic_map/test_rule_601.py index fb29a7cb..2c329cfb 100644 --- a/tests/generic_map/test_rule_601.py +++ b/tests/generic_map/test_rule_601.py @@ -23,7 +23,7 @@ class test_generic_map_rule(unittest.TestCase): self.assertEqual(oRule.name, "generic_map") self.assertEqual(oRule.identifier, "601") - lExpected = [22, 23, 24, 34] + lExpected = [46, 53, 54, 55, 65, 74, 83] oRule.analyze(self.oFile) self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) @@ -35,7 +35,7 @@ class test_generic_map_rule(unittest.TestCase): self.assertEqual(oRule.name, "generic_map") self.assertEqual(oRule.identifier, "601") - lExpected = [22, 23, 24, 34] + lExpected = [46, 53, 54, 55, 65, 74, 83] oRule.analyze(self.oFile) self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) diff --git a/tests/package_body/rule_400_test_input.fixed.vhd b/tests/package_body/rule_400_test_input.fixed.vhd index dc0c5975..ecaf12ae 100644 --- a/tests/package_body/rule_400_test_input.fixed.vhd +++ b/tests/package_body/rule_400_test_input.fixed.vhd @@ -55,6 +55,17 @@ package body RTL is constant sig1 : std_logic; + -- Checking exclusions + constant c_abc : integer; + function my_func return integer is + constant c_abc : integer; + begin + end function; + constant c_abc : integer; + type flag_pt is protected body + variable flag : boolean; + end protected body; + end package body RTL; -- Test functions and procedures defined in architectures diff --git a/tests/package_body/rule_400_test_input.vhd b/tests/package_body/rule_400_test_input.vhd index 6d3af1be..2ad5302c 100644 --- a/tests/package_body/rule_400_test_input.vhd +++ b/tests/package_body/rule_400_test_input.vhd @@ -55,6 +55,17 @@ package body RTL is constant sig1 : std_logic; + -- Checking exclusions + constant c_abc : integer; + function my_func return integer is + constant c_abc : integer; + begin + end function; + constant c_abc : integer; + type flag_pt is protected body + variable flag : boolean; + end protected body; + end package body RTL; -- Test functions and procedures defined in architectures diff --git a/tests/package_body/rule_401_test_input.fixed.vhd b/tests/package_body/rule_401_test_input.fixed.vhd index f3e32e11..2442f6e2 100644 --- a/tests/package_body/rule_401_test_input.fixed.vhd +++ b/tests/package_body/rule_401_test_input.fixed.vhd @@ -19,4 +19,15 @@ package body RTL is alias a_alias1 is name; alias a_alias2 : subtype_indictor is name; + -- Checking exclusions + constant c_abc : integer; + function my_func return integer is + constant c_abc : integer; + begin + end function; + constant c_abc : integer; + type flag_pt is protected body + variable flag : boolean; + end protected body; + end package body RTL; diff --git a/tests/package_body/rule_401_test_input.vhd b/tests/package_body/rule_401_test_input.vhd index cae2d585..fea84a60 100644 --- a/tests/package_body/rule_401_test_input.vhd +++ b/tests/package_body/rule_401_test_input.vhd @@ -19,4 +19,15 @@ package body RTL is alias a_alias1 is name; alias a_alias2 : subtype_indictor is name; + -- Checking exclusions + constant c_abc : integer; + function my_func return integer is + constant c_abc : integer; + begin + end function; + constant c_abc : integer; + type flag_pt is protected body + variable flag : boolean; + end protected body; + end package body RTL; diff --git a/tests/package_body/test_rule_400.py b/tests/package_body/test_rule_400.py index 8dd04004..a8f396dc 100644 --- a/tests/package_body/test_rule_400.py +++ b/tests/package_body/test_rule_400.py @@ -32,7 +32,8 @@ class test_package_body_rule(unittest.TestCase): lExpected.extend([21, 22, 23, 25, 26]) lExpected.extend([30, 31]) lExpected.append(44) - lExpected.extend([83, 84, 85]) + lExpected.append(65) + lExpected.extend([94, 95, 96]) oRule.analyze(self.oFile) self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) diff --git a/tests/procedure/rule_010_test_input.fixed.vhd b/tests/procedure/rule_010_test_input.fixed.vhd index 86324c9a..eba00c0d 100644 --- a/tests/procedure/rule_010_test_input.fixed.vhd +++ b/tests/procedure/rule_010_test_input.fixed.vhd @@ -102,6 +102,43 @@ architecture RTL of ENT is begin end procedure AVERAGE_SAMPLES; + procedure AVERAGE_SAMPLES (constant x : in integer; + constant a : in integer; + signal b : in std_logic; + variable c : in std_logic_vector(3 downto 0); + signal d : out std_logic) is + -- Checking exclusions + constant c_abc : integer; + function my_func return integer is + constant c_abc : integer; + begin + end function; + constant c_abc : integer; + type flag_pt is protected body + variable flag : boolean; + end protected body; + begin + end procedure AVERAGE_SAMPLES; + + procedure AVERAGE_SAMPLES (constant x : in integer; + constant a : in integer; + signal b : in std_logic; + variable c : in std_logic_vector(3 downto 0); + signal d : out std_logic) is + + -- Checking exclusions + constant c_abc : integer; + function my_func return integer is + constant c_abc : integer; + begin + end function; + constant c_abc : integer; + type flag_pt is protected body + variable flag : boolean; + end protected body; + begin + end procedure AVERAGE_SAMPLES; + procedure AVERAGE_SAMPLES (constant x : in integer; constant a : in integer; signal b : in std_logic; diff --git a/tests/procedure/rule_010_test_input.vhd b/tests/procedure/rule_010_test_input.vhd index 848d81af..a0cc45f2 100644 --- a/tests/procedure/rule_010_test_input.vhd +++ b/tests/procedure/rule_010_test_input.vhd @@ -102,6 +102,43 @@ architecture RTL of ENT is begin end procedure AVERAGE_SAMPLES; + procedure AVERAGE_SAMPLES (constant x : in integer; + constant a : in integer; + signal b : in std_logic; + variable c : in std_logic_vector(3 downto 0); + signal d : out std_logic) is + -- Checking exclusions + constant c_abc : integer; + function my_func return integer is + constant c_abc : integer; + begin + end function; + constant c_abc : integer; + type flag_pt is protected body + variable flag : boolean; + end protected body; + begin + end procedure AVERAGE_SAMPLES; + + procedure AVERAGE_SAMPLES (constant x : in integer; + constant a : in integer; + signal b : in std_logic; + variable c : in std_logic_vector(3 downto 0); + signal d : out std_logic) is + + -- Checking exclusions + constant c_abc : integer; + function my_func return integer is + constant c_abc : integer; + begin + end function; + constant c_abc : integer; + type flag_pt is protected body + variable flag : boolean; + end protected body; + begin + end procedure AVERAGE_SAMPLES; + procedure AVERAGE_SAMPLES (constant x : in integer; constant a : in integer; signal b : in std_logic; diff --git a/tests/procedure/rule_401_test_input.fixed.vhd b/tests/procedure/rule_401_test_input.fixed.vhd index b4ec9c70..29c6ff0a 100644 --- a/tests/procedure/rule_401_test_input.fixed.vhd +++ b/tests/procedure/rule_401_test_input.fixed.vhd @@ -19,6 +19,20 @@ architecture RTL of FIFO is begin end procedure proc1; + procedure proc1 is + -- Checking exclusions + constant c_abc : integer; + function my_func return integer is + constant c_abc : integer; + begin + end function; + constant c_abc : integer; + type flag_pt is protected body + variable flag : boolean; + end protected body; + begin + end procedure proc1; + function func1 return integer is constant c : integer; variable v : integer; diff --git a/tests/procedure/rule_401_test_input.vhd b/tests/procedure/rule_401_test_input.vhd index 1d3771b0..491dd022 100644 --- a/tests/procedure/rule_401_test_input.vhd +++ b/tests/procedure/rule_401_test_input.vhd @@ -19,6 +19,20 @@ architecture RTL of FIFO is begin end procedure proc1; + procedure proc1 is + -- Checking exclusions + constant c_abc : integer; + function my_func return integer is + constant c_abc : integer; + begin + end function; + constant c_abc : integer; + type flag_pt is protected body + variable flag : boolean; + end protected body; + begin + end procedure proc1; + function func1 return integer is constant c : integer; variable v : integer; diff --git a/tests/procedure/test_rule_010.py b/tests/procedure/test_rule_010.py index d8a1cc2e..fc3f0c69 100644 --- a/tests/procedure/test_rule_010.py +++ b/tests/procedure/test_rule_010.py @@ -27,7 +27,7 @@ class test_procedure_rule(unittest.TestCase): self.assertEqual(oRule.name, "procedure") self.assertEqual(oRule.identifier, "010") - lExpected = [31, 32, 34, 99, 100, 132, 133, 149] + lExpected = [31, 32, 34, 99, 100, 117, 169, 170, 186] oRule.analyze(self.oFile) self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) diff --git a/tests/process/rule_031_test_input.fixed.vhd b/tests/process/rule_031_test_input.fixed.vhd index 92e8e058..611885de 100644 --- a/tests/process/rule_031_test_input.fixed.vhd +++ b/tests/process/rule_031_test_input.fixed.vhd @@ -119,4 +119,13 @@ begin begin end process PROC; + -- Test protected type body in the process declarative region + PROC : process (a) is + constant c_abc : integer; + type flag_pt is protected body + variable flag : boolean; + end protected body; + begin + end process PROC; + end architecture RTL; diff --git a/tests/process/rule_031_test_input.vhd b/tests/process/rule_031_test_input.vhd index f4600ca9..3d15d7c0 100644 --- a/tests/process/rule_031_test_input.vhd +++ b/tests/process/rule_031_test_input.vhd @@ -119,4 +119,13 @@ begin begin end process PROC; + -- Test protected type body in the process declarative region + PROC : process (a) is + constant c_abc : integer; + type flag_pt is protected body + variable flag : boolean; + end protected body; + begin + end process PROC; + end architecture RTL; diff --git a/tests/process/rule_033_test_input.fixed.vhd b/tests/process/rule_033_test_input.fixed.vhd index 73ec23d0..41988b09 100644 --- a/tests/process/rule_033_test_input.fixed.vhd +++ b/tests/process/rule_033_test_input.fixed.vhd @@ -46,4 +46,19 @@ begin begin end process; + process + + variable var1 : integer := 0; + file file1 : load_file_file open read_mode is load_file_name; + constant con1 : std_logic := '1'; + alias alias1 is name; + alias alias1 : subtype_indicator is name; + + constant c_abc : integer; + type flag_pt is protected body + variable flag : boolean; + end protected body; + constant constant_1 : integer; + begin end process; + end architecture RTL; diff --git a/tests/process/rule_033_test_input.vhd b/tests/process/rule_033_test_input.vhd index 896d3c02..58d204b7 100644 --- a/tests/process/rule_033_test_input.vhd +++ b/tests/process/rule_033_test_input.vhd @@ -46,4 +46,19 @@ begin begin end process; + process + + variable var1 : integer := 0; + file file1 : load_file_file open read_mode is load_file_name; + constant con1 : std_logic := '1'; + alias alias1 is name; + alias alias1 : subtype_indicator is name; + + constant c_abc : integer; + type flag_pt is protected body + variable flag : boolean; + end protected body; + constant constant_1 : integer; + begin end process; + end architecture RTL; diff --git a/tests/process/test_rule_031.py b/tests/process/test_rule_031.py index 8a9c478c..1fdccc98 100644 --- a/tests/process/test_rule_031.py +++ b/tests/process/test_rule_031.py @@ -27,7 +27,7 @@ class test_process_rule(unittest.TestCase): self.assertEqual(oRule.name, "process") self.assertEqual(oRule.identifier, "031") - lExpected = [11, 12, 13, 14, 32, 34, 35, 37, 38, 65, 88, 103, 104, 118] + lExpected = [11, 12, 13, 14, 32, 34, 35, 37, 38, 65, 88, 103, 104, 118, 125] oRule.analyze(self.oFile) self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) diff --git a/tests/process/test_rule_033.py b/tests/process/test_rule_033.py index 056ee430..14034a8f 100644 --- a/tests/process/test_rule_033.py +++ b/tests/process/test_rule_033.py @@ -27,7 +27,7 @@ class test_process_rule(unittest.TestCase): self.assertEqual(oRule.name, "process") self.assertEqual(oRule.identifier, "033") - lExpected = [22, 23, 24, 25, 26, 41, 42, 43, 44, 45] + lExpected = [22, 23, 24, 25, 26, 41, 42, 43, 44, 45, 57] oRule.analyze(self.oFile) self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) diff --git a/tests/protected_type_body/rule_400_test_input.fixed.vhd b/tests/protected_type_body/rule_400_test_input.fixed.vhd new file mode 100644 index 00000000..c8e90f93 --- /dev/null +++ b/tests/protected_type_body/rule_400_test_input.fixed.vhd @@ -0,0 +1,101 @@ + +package body RTL is + type t_my_type is protected body + -- These should fail + variable v_var1 : std_logic; + constant c_cons1 : std_logic; + file f_fil1 : load_file_type open read_mode is load_file_name; + type t_typ1 is (idle, write, read); + subtype s_sub1 is integer range 0 to 9; + alias a_alias1 is name; + + -- These should pass + variable v_var1 : std_logic; + constant c_cons1 : std_logic; + file f_fil1 : load_file_type open read_mode is load_file_name; + type t_typ1 is (idle, write, read); + subtype s_sub1 is integer range 0 to 9; + alias a_alias1 is name; + + -- Test with different spacing + variable v_var1 : std_logic; + constant c_cons1 : std_logic; + file f_fil1 : load_file_type open read_mode is load_file_name; + type t_typ1 is (idle, write, read); + subtype s_sub1 is integer range 0 to 9; + alias a_alias1 is name; + + -- Test with shorter combinations + constant c_sig1 : std_logic; + file f_fil1 : load_file_type open read_mode is load_file_name; + type t_typ1 is (idle, write, read); + + -- Test with comments + variable v_var1 : std_logic; + constant c_sig1 : std_logic; + -- some comment + constant c_cons1 : std_logic; + file f_fil1 : load_file_type open read_mode is load_file_name; + -- some comment + type t_typ1 is (idle, write, read); + subtype s_sub1 is integer range 0 to 9; + + -- Test multiline declarations + type state_type is ( + state1, state2, + state3, state4 + ); + constant sig1 : std_logic; + + -- This should not error + type state_type2 is ( + state1, state2, + state3, state4 + ); + + constant sig1 : std_logic; + + -- Checking exclusions + constant c_abc : integer; + function my_func return integer is + constant c_abc : integer; + begin + end function; + end protected body; + + constant c_cons1 : std_logic; + type t_typ1 is (idle, write, read); + subtype s_sub1 is integer range 0 to 9; + +end package body RTL; + +-- Test functions and procedures defined in protected body + +package body RTL is + type t_my_type is protected body + procedure AVERAGE_SAMPLES; + + procedure AVERAGE_SAMPLES ( + constant a : in integer; + signal b : in std_logic; + variable c : in std_logic_vector(3 downto 0); + signal d : out std_logic); + + function func_1 ( + constant a : integer; + signal b : integer; + signal c : unsigned(3 downto 0); + signal d : std_logic_vector(7 downto 0); + constant e : std_logic) return integer; + + + -- These should fail + variable v_var1 : std_logic; + constant c_cons1 : std_logic; + file f_fil1 : load_file_type open read_mode is load_file_name; + type t_typ1 is (idle, write, read); + subtype s_sub1 is integer range 0 to 9; + + end protected body; + +end package body RTL; diff --git a/tests/protected_type_body/rule_400_test_input.vhd b/tests/protected_type_body/rule_400_test_input.vhd new file mode 100644 index 00000000..b125bac0 --- /dev/null +++ b/tests/protected_type_body/rule_400_test_input.vhd @@ -0,0 +1,101 @@ + +package body RTL is + type t_my_type is protected body + -- These should fail + variable v_var1 : std_logic; + constant c_cons1 : std_logic; + file f_fil1 : load_file_type open read_mode is load_file_name; + type t_typ1 is (idle, write, read); + subtype s_sub1 is integer range 0 to 9; + alias a_alias1 is name; + + -- These should pass + variable v_var1 : std_logic; + constant c_cons1 : std_logic; + file f_fil1 : load_file_type open read_mode is load_file_name; + type t_typ1 is (idle, write, read); + subtype s_sub1 is integer range 0 to 9; + alias a_alias1 is name; + + -- Test with different spacing + variable v_var1 : std_logic; + constant c_cons1 : std_logic; + file f_fil1 : load_file_type open read_mode is load_file_name; + type t_typ1 is (idle, write, read); + subtype s_sub1 is integer range 0 to 9; + alias a_alias1 is name; + + -- Test with shorter combinations + constant c_sig1 : std_logic; + file f_fil1 : load_file_type open read_mode is load_file_name; + type t_typ1 is (idle, write, read); + + -- Test with comments + variable v_var1 : std_logic; + constant c_sig1 : std_logic; + -- some comment + constant c_cons1 : std_logic; + file f_fil1 : load_file_type open read_mode is load_file_name; + -- some comment + type t_typ1 is (idle, write, read); + subtype s_sub1 is integer range 0 to 9; + + -- Test multiline declarations + type state_type is ( + state1, state2, + state3, state4 + ); + constant sig1 : std_logic; + + -- This should not error + type state_type2 is ( + state1, state2, + state3, state4 + ); + + constant sig1 : std_logic; + + -- Checking exclusions + constant c_abc : integer; + function my_func return integer is + constant c_abc : integer; + begin + end function; + end protected body; + + constant c_cons1 : std_logic; + type t_typ1 is (idle, write, read); + subtype s_sub1 is integer range 0 to 9; + +end package body RTL; + +-- Test functions and procedures defined in protected body + +package body RTL is + type t_my_type is protected body + procedure AVERAGE_SAMPLES; + + procedure AVERAGE_SAMPLES ( + constant a : in integer; + signal b : in std_logic; + variable c : in std_logic_vector(3 downto 0); + signal d : out std_logic); + + function func_1 ( + constant a : integer; + signal b : integer; + signal c : unsigned(3 downto 0); + signal d : std_logic_vector(7 downto 0); + constant e : std_logic) return integer; + + + -- These should fail + variable v_var1 : std_logic; + constant c_cons1 : std_logic; + file f_fil1 : load_file_type open read_mode is load_file_name; + type t_typ1 is (idle, write, read); + subtype s_sub1 is integer range 0 to 9; + + end protected body; + +end package body RTL; diff --git a/tests/protected_type_body/rule_401_test_input.fixed.vhd b/tests/protected_type_body/rule_401_test_input.fixed.vhd new file mode 100644 index 00000000..cef9204b --- /dev/null +++ b/tests/protected_type_body/rule_401_test_input.fixed.vhd @@ -0,0 +1,33 @@ + +package body RTL is + type t_my_type is protected body + -- These should pass + variable v_var1 : std_logic; + constant c_cons1 : std_logic; + file f_fil1 : load_file_type open read_mode is load_file_name; + type t_typ1 is (idle, write, read); + subtype s_sub1 is integer range 0 to 9; + alias a_alias1 is name; + alias a_alias2 : subtype_indictor is name; + + -- These should fail + variable v_var1 : std_logic; + constant c_cons1 : std_logic; + file f_fil1 : load_file_type open read_mode is load_file_name; + type t_typ1 is (idle, write, read); + subtype s_sub1 is integer range 0 to 9; + alias a_alias1 is name; + alias a_alias2 : subtype_indictor is name; + + -- Checking exclusions + constant c_abc : integer; + function my_func return integer is + constant c_abc : integer; + begin + end function; + end protected body; + + constant c_cons1 : std_logic; + constant c_cons_longer : std_logic; + +end package body RTL; diff --git a/tests/protected_type_body/rule_401_test_input.vhd b/tests/protected_type_body/rule_401_test_input.vhd new file mode 100644 index 00000000..d195f65a --- /dev/null +++ b/tests/protected_type_body/rule_401_test_input.vhd @@ -0,0 +1,33 @@ + +package body RTL is + type t_my_type is protected body + -- These should pass + variable v_var1 : std_logic; + constant c_cons1 : std_logic; + file f_fil1 : load_file_type open read_mode is load_file_name; + type t_typ1 is (idle, write, read); + subtype s_sub1 is integer range 0 to 9; + alias a_alias1 is name; + alias a_alias2 : subtype_indictor is name; + + -- These should fail + variable v_var1 : std_logic; + constant c_cons1 : std_logic; + file f_fil1 : load_file_type open read_mode is load_file_name; + type t_typ1 is (idle, write, read); + subtype s_sub1 is integer range 0 to 9; + alias a_alias1 is name; + alias a_alias2 : subtype_indictor is name; + + -- Checking exclusions + constant c_abc : integer; + function my_func return integer is + constant c_abc : integer; + begin + end function; + end protected body; + + constant c_cons1 : std_logic; + constant c_cons_longer : std_logic; + +end package body RTL; diff --git a/tests/protected_type_body/rule_402_test_input.fixed.vhd b/tests/protected_type_body/rule_402_test_input.fixed.vhd new file mode 100644 index 00000000..c62e4aff --- /dev/null +++ b/tests/protected_type_body/rule_402_test_input.fixed.vhd @@ -0,0 +1,22 @@ + +package body RTL is + type t_my_type is protected body + attribute mark_debug of wr_en : signal is "true"; + attribute mark_debug of almost_empty : signal is "true"; + attribute mark_debug of full : signal is "true"; + + procedure rst_procedure is + + attribute mark_debug of wr_en : signal is "true"; + attribute mark_debug of almost_empty : signal is "true"; + attribute mark_debug of full : signal is "true"; + + begin + end procedure; + end protected body; + + attribute mark_debug of wr_en : signal is "true"; + attribute mark_debug of almost_empty : signal is "true"; + attribute mark_debug of full : signal is "true"; + +end package body RTL; diff --git a/tests/protected_type_body/rule_402_test_input.vhd b/tests/protected_type_body/rule_402_test_input.vhd new file mode 100644 index 00000000..7285dd49 --- /dev/null +++ b/tests/protected_type_body/rule_402_test_input.vhd @@ -0,0 +1,22 @@ + +package body RTL is + type t_my_type is protected body + attribute mark_debug of wr_en : signal is "true"; + attribute mark_debug of almost_empty : signal is "true"; + attribute mark_debug of full : signal is "true"; + + procedure rst_procedure is + + attribute mark_debug of wr_en : signal is "true"; + attribute mark_debug of almost_empty : signal is "true"; + attribute mark_debug of full : signal is "true"; + + begin + end procedure; + end protected body; + + attribute mark_debug of wr_en : signal is "true"; + attribute mark_debug of almost_empty : signal is "true"; + attribute mark_debug of full : signal is "true"; + +end package body RTL; diff --git a/tests/protected_type_body/test_rule_400.py b/tests/protected_type_body/test_rule_400.py new file mode 100644 index 00000000..53b45860 --- /dev/null +++ b/tests/protected_type_body/test_rule_400.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- + +import os +import unittest + +from tests import utils +from vsg import vhdlFile +from vsg.rules import protected_type_body + +sTestDir = os.path.dirname(__file__) + +lFile, eError = vhdlFile.utils.read_vhdlfile(os.path.join(sTestDir, "rule_400_test_input.vhd")) + +lExpected = [] +lExpected.append("") +utils.read_file(os.path.join(sTestDir, "rule_400_test_input.fixed.vhd"), lExpected) + + +class test_protected_type_body_rule(unittest.TestCase): + def setUp(self): + self.oFile = vhdlFile.vhdlFile(lFile) + self.assertIsNone(eError) + + def test_rule_400(self): + oRule = protected_type_body.rule_400() + self.assertTrue(oRule) + self.assertEqual(oRule.name, "protected_type_body") + self.assertEqual(oRule.identifier, "400") + + lExpected = [] + lExpected.extend([7, 8, 9, 10, 21, 22, 23, 25, 26, 30, 31, 44, 95, 96, 97]) + + oRule.analyze(self.oFile) + self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) + + def test_fix_rule_400(self): + oRule = protected_type_body.rule_400() + + oRule.fix(self.oFile) + + lActual = self.oFile.get_lines() + + self.assertEqual(lExpected, lActual) + + oRule.analyze(self.oFile) + self.assertEqual(oRule.violations, []) diff --git a/tests/protected_type_body/test_rule_401.py b/tests/protected_type_body/test_rule_401.py new file mode 100644 index 00000000..b7204c9e --- /dev/null +++ b/tests/protected_type_body/test_rule_401.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- + +import os +import unittest + +from tests import utils +from vsg import vhdlFile +from vsg.rules import protected_type_body + +sTestDir = os.path.dirname(__file__) + +lFile, eError = vhdlFile.utils.read_vhdlfile(os.path.join(sTestDir, "rule_401_test_input.vhd")) + +lExpected = [] +lExpected.append("") +utils.read_file(os.path.join(sTestDir, "rule_401_test_input.fixed.vhd"), lExpected) + + +class test_protected_type_body_rule(unittest.TestCase): + def setUp(self): + self.oFile = vhdlFile.vhdlFile(lFile) + self.assertIsNone(eError) + + def test_rule_401(self): + oRule = protected_type_body.rule_401() + self.assertTrue(oRule) + self.assertEqual(oRule.name, "protected_type_body") + self.assertEqual(oRule.identifier, "401") + + lExpected = [] + lExpected.extend([14, 15, 16, 19, 20]) + + oRule.analyze(self.oFile) + self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) + + def test_fix_rule_401(self): + oRule = protected_type_body.rule_401() + + oRule.fix(self.oFile) + + lActual = self.oFile.get_lines() + + self.assertEqual(lExpected, lActual) + + oRule.analyze(self.oFile) + self.assertEqual(oRule.violations, []) diff --git a/tests/protected_type_body/test_rule_402.py b/tests/protected_type_body/test_rule_402.py new file mode 100644 index 00000000..b2a93dcc --- /dev/null +++ b/tests/protected_type_body/test_rule_402.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- + +import os +import unittest + +from tests import utils +from vsg import vhdlFile +from vsg.rules import protected_type_body + +sTestDir = os.path.dirname(__file__) + +lFile, eError = vhdlFile.utils.read_vhdlfile(os.path.join(sTestDir, "rule_402_test_input.vhd")) + +lExpected = [] +lExpected.append("") +utils.read_file(os.path.join(sTestDir, "rule_402_test_input.fixed.vhd"), lExpected) + + +class test_protected_type_body_rule(unittest.TestCase): + def setUp(self): + self.oFile = vhdlFile.vhdlFile(lFile) + self.assertIsNone(eError) + + def test_rule_402(self): + oRule = protected_type_body.rule_402() + self.assertTrue(oRule) + self.assertEqual(oRule.name, "protected_type_body") + self.assertEqual(oRule.identifier, "402") + + lExpected = [4, 6] + + oRule.analyze(self.oFile) + self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) + + def test_fix_rule_402(self): + oRule = protected_type_body.rule_402() + + oRule.fix(self.oFile) + + lActual = self.oFile.get_lines() + + self.assertEqual(lExpected, lActual) + + oRule.analyze(self.oFile) + self.assertEqual(oRule.violations, []) diff --git a/tests/styles/jcl/rule_400_test_input.fixed.vhd b/tests/styles/jcl/rule_400_test_input.fixed.vhd index 2c77b731..ce892868 100644 --- a/tests/styles/jcl/rule_400_test_input.fixed.vhd +++ b/tests/styles/jcl/rule_400_test_input.fixed.vhd @@ -47,14 +47,14 @@ package body pkg_bdy is end package body pkg_bdy; entity ENT is - signal sig1 : std_logic := '0'; -- Signal Comment - constant default_value : integer := 32; -- Constant Comment - shared variable var1 : std_logic_vector(3 downto 0) := "0101"; -- Variable Comment + signal sig1 : std_logic := '0'; -- Signal Comment + constant default_value : integer := 32; -- Constant Comment + shared variable var1 : std_logic_vector(3 downto 0) := "0101"; -- Variable Comment procedure proc1 is - constant c : std_logic := '0'; -- Constant Comment - variable v : integer := 32; -- Variable Comment + constant c : std_logic := '0'; -- Constant Comment + variable v : integer := 32; -- Variable Comment begin @@ -62,17 +62,17 @@ entity ENT is function func1 return integer is - constant c : integer := 32; -- Constant Comment - variable v : std_logic := '1'; -- Variable Comment + constant c : integer := 32; -- Constant Comment + variable v : std_logic := '1'; -- Variable Comment begin end function func1; - type t_flag_type is protected body -- protected type declaration + type t_flag_type is protected body -- protected type declaration - constant default_value : integer := 32; -- Constant Comment - shared variable var1 : std_logic_vector(3 downto 0) := "0101"; -- Variable Comment + constant default_value : integer := 32; -- Constant Comment + shared variable var1 : std_logic_vector(3 downto 0) := "0101"; -- Variable Comment end protected body T_FLAG_TYPE; @@ -80,9 +80,9 @@ end entity ENT; architecture RTL of FIFO is - signal sig1 : std_logic := '0'; -- Signal Comment - constant default_value : integer := 32; -- Constant Comment - shared variable var1 : std_logic_vector(3 downto 0) := "0101"; -- Variable Comment + signal sig1 : std_logic := '0'; -- Signal Comment + constant default_value : integer := 32; -- Constant Comment + shared variable var1 : std_logic_vector(3 downto 0) := "0101"; -- Variable Comment procedure proc1 is diff --git a/vsg/rules/architecture/rule_026.py b/vsg/rules/architecture/rule_026.py index 69efb730..89acbdbd 100644 --- a/vsg/rules/architecture/rule_026.py +++ b/vsg/rules/architecture/rule_026.py @@ -15,6 +15,7 @@ lAlign.append(token.alias_declaration.is_keyword) lUnless = [] lUnless.append([token.subprogram_body.is_keyword, token.subprogram_body.begin_keyword]) +lUnless.append([token.protected_type_body.body_keyword, token.protected_type_body.end_body_keyword]) class rule_026(Rule): diff --git a/vsg/rules/architecture/rule_029.py b/vsg/rules/architecture/rule_029.py index 936c1148..94048724 100644 --- a/vsg/rules/architecture/rule_029.py +++ b/vsg/rules/architecture/rule_029.py @@ -15,6 +15,7 @@ lAlign.append(token.alias_declaration.alias_designator) lUnless = [] lUnless.append([token.subprogram_body.is_keyword, token.subprogram_body.begin_keyword]) +lUnless.append([token.protected_type_body.body_keyword, token.protected_type_body.end_body_keyword]) class rule_029(align_tokens_in_region_between_tokens_unless_between_tokens): diff --git a/vsg/rules/block/rule_400.py b/vsg/rules/block/rule_400.py index 319db72c..9486cc69 100644 --- a/vsg/rules/block/rule_400.py +++ b/vsg/rules/block/rule_400.py @@ -15,6 +15,7 @@ lAlign.append(token.alias_declaration.alias_designator) lUnless = [] lUnless.append([token.subprogram_body.is_keyword, token.subprogram_body.begin_keyword]) +lUnless.append([token.protected_type_body.body_keyword, token.protected_type_body.end_body_keyword]) class rule_400(align_tokens_in_region_between_tokens_unless_between_tokens): diff --git a/vsg/rules/block/rule_401.py b/vsg/rules/block/rule_401.py index d885238d..482f4bda 100644 --- a/vsg/rules/block/rule_401.py +++ b/vsg/rules/block/rule_401.py @@ -13,6 +13,7 @@ lAlign.append(token.alias_declaration.is_keyword) lUnless = [] lUnless.append([token.subprogram_body.is_keyword, token.subprogram_body.begin_keyword]) +lUnless.append([token.protected_type_body.body_keyword, token.protected_type_body.end_body_keyword]) class rule_401(align_tokens_in_region_between_tokens_unless_between_tokens): diff --git a/vsg/rules/function/rule_012.py b/vsg/rules/function/rule_012.py index 40389054..5a28ebfd 100644 --- a/vsg/rules/function/rule_012.py +++ b/vsg/rules/function/rule_012.py @@ -17,6 +17,7 @@ oEndToken = token.subprogram_body.begin_keyword lUnless = [] lUnless.append([token.procedure_specification.procedure_keyword, token.subprogram_body.semicolon]) +lUnless.append([token.protected_type_body.body_keyword, token.protected_type_body.end_body_keyword]) class rule_012(Rule): diff --git a/vsg/rules/function/rule_015.py b/vsg/rules/function/rule_015.py index d0af77b2..7eea107b 100644 --- a/vsg/rules/function/rule_015.py +++ b/vsg/rules/function/rule_015.py @@ -15,6 +15,7 @@ lAlign.append(token.alias_declaration.alias_designator) lUnless = [] lUnless.append([token.procedure_specification.procedure_keyword, token.subprogram_body.semicolon]) +lUnless.append([token.protected_type_body.body_keyword, token.protected_type_body.end_body_keyword]) class rule_015(align_tokens_in_region_between_tokens_unless_between_tokens): diff --git a/vsg/rules/generic_map/rule_001.py b/vsg/rules/generic_map/rule_001.py index 78fd247b..ec30923c 100644 --- a/vsg/rules/generic_map/rule_001.py +++ b/vsg/rules/generic_map/rule_001.py @@ -1,17 +1,14 @@ # -*- coding: utf-8 -*- from vsg import token -from vsg.rules import token_case_in_range_bounded_by_tokens +from vsg.rules import token_case lTokens = [] lTokens.append(token.generic_map_aspect.generic_keyword) lTokens.append(token.generic_map_aspect.map_keyword) -oStart = token.component_instantiation_statement.label_colon -oEnd = token.component_instantiation_statement.semicolon - -class rule_001(token_case_in_range_bounded_by_tokens): +class rule_001(token_case): """ This rule checks the **generic map** keywords have proper case. @@ -31,5 +28,5 @@ class rule_001(token_case_in_range_bounded_by_tokens): """ def __init__(self): - super().__init__(lTokens, oStart, oEnd) + super().__init__(lTokens) self.groups.append("case::keyword") diff --git a/vsg/rules/generic_map/rule_002.py b/vsg/rules/generic_map/rule_002.py index 5d397c5b..62920005 100644 --- a/vsg/rules/generic_map/rule_002.py +++ b/vsg/rules/generic_map/rule_002.py @@ -5,8 +5,8 @@ from vsg.rules import ( token_case_formal_part_of_association_element_in_map_between_tokens, ) -oStart = token.component_instantiation_statement.instantiation_label -oEnd = token.component_instantiation_statement.semicolon +oStart = token.generic_map_aspect.generic_keyword +oEnd = token.generic_map_aspect.close_parenthesis sMapType = "generic" diff --git a/vsg/rules/package_body/rule_400.py b/vsg/rules/package_body/rule_400.py index f17c1b4e..b7493019 100644 --- a/vsg/rules/package_body/rule_400.py +++ b/vsg/rules/package_body/rule_400.py @@ -14,6 +14,7 @@ lAlign.append(token.alias_declaration.alias_designator) lUnless = [] lUnless.append([token.subprogram_body.is_keyword, token.subprogram_body.begin_keyword]) +lUnless.append([token.protected_type_body.body_keyword, token.protected_type_body.end_body_keyword]) class rule_400(align_tokens_in_region_between_tokens_unless_between_tokens): diff --git a/vsg/rules/package_body/rule_401.py b/vsg/rules/package_body/rule_401.py index e2dfc399..d79f498b 100644 --- a/vsg/rules/package_body/rule_401.py +++ b/vsg/rules/package_body/rule_401.py @@ -18,6 +18,7 @@ oEnd = token.package_body.end_keyword lUnless = [] lUnless.append([token.subprogram_body.is_keyword, token.subprogram_body.begin_keyword]) +lUnless.append([token.protected_type_body.body_keyword, token.protected_type_body.end_body_keyword]) class rule_401(Rule): diff --git a/vsg/rules/procedure/rule_010.py b/vsg/rules/procedure/rule_010.py index 6d074359..6573cfda 100644 --- a/vsg/rules/procedure/rule_010.py +++ b/vsg/rules/procedure/rule_010.py @@ -15,6 +15,7 @@ lAlign.append(token.alias_declaration.alias_designator) lUnless = [] lUnless.append([token.function_specification.function_keyword, token.subprogram_body.semicolon]) +lUnless.append([token.protected_type_body.body_keyword, token.protected_type_body.end_body_keyword]) class rule_010(align_tokens_in_region_between_tokens_unless_between_tokens): diff --git a/vsg/rules/procedure/rule_401.py b/vsg/rules/procedure/rule_401.py index 4dec4e9c..5038eef3 100644 --- a/vsg/rules/procedure/rule_401.py +++ b/vsg/rules/procedure/rule_401.py @@ -17,6 +17,7 @@ oEndToken = token.subprogram_body.begin_keyword lUnless = [] lUnless.append([token.function_specification.function_keyword, token.subprogram_body.semicolon]) +lUnless.append([token.protected_type_body.body_keyword, token.protected_type_body.end_body_keyword]) class rule_401(Rule): diff --git a/vsg/rules/process/rule_031.py b/vsg/rules/process/rule_031.py index 21153442..074862d6 100644 --- a/vsg/rules/process/rule_031.py +++ b/vsg/rules/process/rule_031.py @@ -18,6 +18,7 @@ oEnd = token.process_statement.begin_keyword lUnless = [] lUnless.append([token.subprogram_body.is_keyword, token.subprogram_body.begin_keyword]) +lUnless.append([token.protected_type_body.body_keyword, token.protected_type_body.end_body_keyword]) class rule_031(align_tokens_in_region_between_tokens_unless_between_tokens): diff --git a/vsg/rules/process/rule_033.py b/vsg/rules/process/rule_033.py index cfad4005..39d43a19 100644 --- a/vsg/rules/process/rule_033.py +++ b/vsg/rules/process/rule_033.py @@ -15,6 +15,7 @@ lAlign.append(token.alias_declaration.is_keyword) lUnless = [] lUnless.append([token.subprogram_body.is_keyword, token.subprogram_body.begin_keyword]) +lUnless.append([token.protected_type_body.body_keyword, token.protected_type_body.end_body_keyword]) class rule_033(Rule): diff --git a/vsg/rules/protected_type_body/__init__.py b/vsg/rules/protected_type_body/__init__.py index 6bc3a1ca..bd44cf86 100644 --- a/vsg/rules/protected_type_body/__init__.py +++ b/vsg/rules/protected_type_body/__init__.py @@ -1,6 +1,9 @@ # -*- coding: utf-8 -*- from .rule_300 import rule_300 +from .rule_400 import rule_400 +from .rule_401 import rule_401 +from .rule_402 import rule_402 from .rule_500 import rule_500 from .rule_501 import rule_501 from .rule_502 import rule_502 diff --git a/vsg/rules/protected_type_body/rule_400.py b/vsg/rules/protected_type_body/rule_400.py new file mode 100644 index 00000000..bb084440 --- /dev/null +++ b/vsg/rules/protected_type_body/rule_400.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- + +from vsg import token +from vsg.rules import ( + align_tokens_in_region_between_tokens_unless_between_tokens as Rule, +) + +lAlign = [] +lAlign.append(token.full_type_declaration.identifier) +lAlign.append(token.incomplete_type_declaration.identifier) +lAlign.append(token.file_declaration.identifier) +lAlign.append(token.constant_declaration.identifier) +lAlign.append(token.subtype_declaration.identifier) +lAlign.append(token.variable_declaration.identifier) +lAlign.append(token.alias_declaration.alias_designator) + +oStart = token.protected_type_body.body_keyword +oEnd = token.protected_type_body.end_body_keyword + +lUnless = [] +lUnless.append([token.subprogram_body.is_keyword, token.subprogram_body.begin_keyword]) + + +class rule_400(Rule): + """ + This rule checks the identifiers for all declarations are aligned in the protected type body declarative region. + + |configuring_identifier_alignment_rules_link| + + **Violation** + + .. code-block:: vhdl + + variable var1 : natural; + constant c_period : time; + + **Fix** + + .. code-block:: vhdl + + variable var1 : natural; + constant c_period : time; + """ + + def __init__(self): + super().__init__(lAlign, oStart, oEnd, lUnless) + self.solution = "Align identifier." + self.configuration_documentation_link = "configuring_identifier_alignment_rules_link" + self.configuration.remove("separate_generic_port_alignment") + self.configuration.remove("if_control_statements_ends_group") + self.configuration.remove("case_control_statements_ends_group") + self.configuration.remove("loop_control_statements_ends_group") diff --git a/vsg/rules/protected_type_body/rule_401.py b/vsg/rules/protected_type_body/rule_401.py new file mode 100644 index 00000000..aef07eb2 --- /dev/null +++ b/vsg/rules/protected_type_body/rule_401.py @@ -0,0 +1,61 @@ +# -*- coding: utf-8 -*- + +from vsg import token +from vsg.rules import ( + align_tokens_in_region_between_tokens_unless_between_tokens as Rule, +) + +lAlign = [] +lAlign.append(token.file_declaration.colon) +lAlign.append(token.signal_declaration.colon) +lAlign.append(token.constant_declaration.colon) +lAlign.append(token.variable_declaration.colon) +lAlign.append(token.alias_declaration.colon) +lAlign.append(token.alias_declaration.is_keyword) + +oStart = token.protected_type_body.body_keyword +oEnd = token.protected_type_body.end_body_keyword + +lUnless = [] +lUnless.append([token.subprogram_body.is_keyword, token.subprogram_body.begin_keyword]) + + +class rule_401(Rule): + """ + This rule checks the colons are in the same column for all declarations in the protected type body declarative part. + + |configuring_keyword_alignment_rules_link| + + **Violation** + + .. code-block:: vhdl + + type my_type protected body is + + signal wr_en : std_logic; + signal rd_en : std_logic; + constant c_period : time; + + end protected body; + + **Fix** + + .. code-block:: vhdl + + type my_type protected body is + + signal wr_en : std_logic; + signal rd_en : std_logic; + constant c_period : time; + + end protected body; + """ + + def __init__(self): + super().__init__(lAlign, oStart, oEnd, lUnless) + self.solution = "Align colon." + self.subphase = 3 + self.configuration.remove("separate_generic_port_alignment") + self.configuration.remove("if_control_statements_ends_group") + self.configuration.remove("case_control_statements_ends_group") + self.configuration.remove("loop_control_statements_ends_group") diff --git a/vsg/rules/protected_type_body/rule_402.py b/vsg/rules/protected_type_body/rule_402.py new file mode 100644 index 00000000..839700c1 --- /dev/null +++ b/vsg/rules/protected_type_body/rule_402.py @@ -0,0 +1,47 @@ +# -*- coding: utf-8 -*- + +from vsg import token +from vsg.rules import ( + align_tokens_in_region_between_tokens_unless_between_tokens as Rule, +) + +lAlign = [] +lAlign.append(token.entity_specification.colon) + +oStart = token.protected_type_body.body_keyword +oEnd = token.protected_type_body.end_body_keyword + +lUnless = [] +lUnless.append([token.subprogram_body.is_keyword, token.subprogram_body.begin_keyword]) + + +class rule_402(Rule): + """ + This rule checks the colons are in the same column for all attribute specifications. + + |configuring_keyword_alignment_rules_link| + + **Violation** + + .. code-block:: vhdl + + attribute mark_debug of wr_en : signal is "true"; + attribute mark_debug of almost_empty : signal is "true"; + attribute mark_debug of full : signal is "true"; + + **Fix** + + .. code-block:: vhdl + + attribute mark_debug of wr_en : signal is "true"; + attribute mark_debug of almost_empty : signal is "true"; + attribute mark_debug of full : signal is "true"; + """ + + def __init__(self): + super().__init__(lAlign, oStart, oEnd, lUnless) + self.solution = "Align colon." + self.configuration.remove("separate_generic_port_alignment") + self.configuration.remove("if_control_statements_ends_group") + self.configuration.remove("case_control_statements_ends_group") + self.configuration.remove("loop_control_statements_ends_group")