diff --git a/modules/rule_entity.py b/modules/rule_entity.py index 3288621e..930bbf0e 100644 --- a/modules/rule_entity.py +++ b/modules/rule_entity.py @@ -980,12 +980,17 @@ class rule_040(entity_rule): def analyze(self, lines): lFailureLines = [] fEntityFound = False + fGenericMapFound = False for iLineNumber, sLine in enumerate(lines): if fEntityFound: if re.match('^\s*port', sLine.lower()): - if not re.match('^\s*\)', lines[iLineNumber - 1]): - lFailureLines.append(iLineNumber + 1) + if fGenericMapFound: + if not re.match('^\s*\)', lines[iLineNumber - 1]): + lFailureLines.append(iLineNumber + 1) fEntityFound = False + fGenericMapFound = False + if re.match('^\s*generic\s\s*\(', sLine.lower()): + fGenericMapFound = True if re.match('\s*entity', sLine.lower()): fEntityFound = True self.violations = lFailureLines diff --git a/modules/tests/rule_entity/entity_test_input.vhd b/modules/tests/rule_entity/entity_test_input.vhd index 452928bc..b4e70568 100644 --- a/modules/tests/rule_entity/entity_test_input.vhd +++ b/modules/tests/rule_entity/entity_test_input.vhd @@ -122,3 +122,14 @@ entity ENTITY1 is ); end entity ENTITY1 +-- Check if no generic is present + +entity ENTITY1 is + port ( + I_PORT1 : in std_logic; + O_PORT2 : out std_logic; + IO_PORT3 : inout std_logic + ); +end entity ENTITY1 + + diff --git a/modules/tests/rule_entity/rule_entity_tests.py b/modules/tests/rule_entity/rule_entity_tests.py index af96608c..42d1e0d6 100644 --- a/modules/tests/rule_entity/rule_entity_tests.py +++ b/modules/tests/rule_entity/rule_entity_tests.py @@ -330,7 +330,7 @@ class testRuleEntityMethods(unittest.TestCase): oRule = rule_entity.rule_023() oRule.port_direction = 'Suffix' - dExpected = [9,10,11,12,13,14,26,27,28,29,30,31,40,41,42,43,44,45,57,58,59,60,61,62,71,72,73,74,75,76,87,88,89,120] + dExpected = [9,10,11,12,13,14,26,27,28,29,30,31,40,41,42,43,44,45,57,58,59,60,61,62,71,72,73,74,75,76,87,88,89,120, 129,130,131] oRule.analyze(lLines) self.assertEqual(oRule.violations, dExpected)