From 54fb8761bbcbc647ec7e50dae76d2e75d61ab34d Mon Sep 17 00:00:00 2001 From: Jeremiah Leary Date: Thu, 10 Jul 2025 22:04:22 -0500 Subject: [PATCH] Issue#1458: Rules port_011 and port_025 were operating on component declarations. --- tests/port/rule_011_test_input.vhd | 20 ++++++++++++++++++++ tests/port/rule_025_test_input.vhd | 20 ++++++++++++++++++++ vsg/rules/port/rule_011.py | 12 +++++++++--- vsg/rules/port/rule_025.py | 12 +++++++++--- 4 files changed, 58 insertions(+), 6 deletions(-) diff --git a/tests/port/rule_011_test_input.vhd b/tests/port/rule_011_test_input.vhd index a9cb58e4..d6d9406a 100644 --- a/tests/port/rule_011_test_input.vhd +++ b/tests/port/rule_011_test_input.vhd @@ -17,3 +17,23 @@ entity FIFO is DATA : out std_logic_vector(31 downto 0) ); end entity FIFO; + +architecture rtl of fifo is + + component foo is + port ( + WR_EN : in std_logic; + DATA : out std_logic; + RD_EN : inout std_logic + ); + end component foo; + +begin + + U_FOO : foo + port map ( + WR_EN => '0', + DATA => '1' + ); + +end architecture rtl; diff --git a/tests/port/rule_025_test_input.vhd b/tests/port/rule_025_test_input.vhd index 159caa80..2838ce66 100644 --- a/tests/port/rule_025_test_input.vhd +++ b/tests/port/rule_025_test_input.vhd @@ -17,3 +17,23 @@ entity FIFO is DATA : out std_logic_vector(31 downto 0) ); end entity FIFO; + +architecture rtl of fifo is + + component foo is + port ( + WR_EN : in std_logic; + DATA : out std_logic; + RD_EN : inout std_logic + ); + end component foo; + +begin + + U_FOO : foo + port map ( + WR_EN => '0', + DATA => '1' + ); + +end architecture rtl; diff --git a/vsg/rules/port/rule_011.py b/vsg/rules/port/rule_011.py index 1eba8b3b..c5bc98f5 100644 --- a/vsg/rules/port/rule_011.py +++ b/vsg/rules/port/rule_011.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- from vsg import token -from vsg.rules import token_prefix_between_tokens +from vsg.rules import token_prefix_between_tokens_unless_between_tokens as Rule lTokens = [] lTokens.append(token.interface_constant_declaration.identifier) @@ -9,8 +9,14 @@ lTokens.append(token.interface_signal_declaration.identifier) lTokens.append(token.interface_variable_declaration.identifier) lTokens.append(token.interface_unknown_declaration.identifier) +oStart = token.port_clause.open_parenthesis +oEnd = token.port_clause.close_parenthesis -class rule_011(token_prefix_between_tokens): +lUnless = [] +lUnless.append([token.component_declaration.component_keyword, token.component_declaration.semicolon]) + + +class rule_011(Rule): """ This rule checks for valid prefixes on port identifiers. The default port prefixes are: *i_*, *o_*, *io_*. @@ -42,5 +48,5 @@ class rule_011(token_prefix_between_tokens): """ def __init__(self): - super().__init__(lTokens, token.port_clause.open_parenthesis, token.port_clause.close_parenthesis) + super().__init__(lTokens, oStart, oEnd, lUnless) self.prefixes = ["i_", "o_", "io_"] diff --git a/vsg/rules/port/rule_025.py b/vsg/rules/port/rule_025.py index 000c4779..afbd1b8b 100644 --- a/vsg/rules/port/rule_025.py +++ b/vsg/rules/port/rule_025.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- from vsg import token -from vsg.rules import token_suffix_between_tokens +from vsg.rules import token_suffix_between_tokens_unless_between_tokens as Rule lTokens = [] lTokens.append(token.interface_constant_declaration.identifier) @@ -9,8 +9,14 @@ lTokens.append(token.interface_signal_declaration.identifier) lTokens.append(token.interface_variable_declaration.identifier) lTokens.append(token.interface_unknown_declaration.identifier) +oStart = token.port_clause.open_parenthesis +oEnd = token.port_clause.close_parenthesis -class rule_025(token_suffix_between_tokens): +lUnless = [] +lUnless.append([token.component_declaration.component_keyword, token.component_declaration.semicolon]) + + +class rule_025(Rule): """ This rule checks for valid suffixes on port identifiers. The default port suffixes are *_i*, *_o*, *_io*. @@ -41,5 +47,5 @@ class rule_025(token_suffix_between_tokens): """ def __init__(self): - super().__init__(lTokens, token.port_clause.open_parenthesis, token.port_clause.close_parenthesis) + super().__init__(lTokens, oStart, oEnd, lUnless) self.suffixes = ["_i", "_o", "_io"]