From a6d82e7bbef0c7c32a75fa04403f0ffd94c86e32 Mon Sep 17 00:00:00 2001 From: Jeremiah C Leary Date: Sun, 8 Sep 2019 06:40:01 -0500 Subject: [PATCH] Updates for issue #248: Updated the process classifier to update the insideResetProcess line attribute. --- vsg/line.py | 1 + vsg/tests/vhdlFile/test_vhdlFile_after.py | 17 +++++++++++++++++ vsg/vhdlFile/classify/process.py | 20 +++++++++++++++++--- vsg/vhdlFile/vhdlFile.py | 2 +- 4 files changed, 36 insertions(+), 4 deletions(-) diff --git a/vsg/line.py b/vsg/line.py index 82a17cdf..9ac4198d 100644 --- a/vsg/line.py +++ b/vsg/line.py @@ -77,6 +77,7 @@ class line(): self.isSensitivityListBegin = False self.isSensitivityListEnd = False self.insideClockProcess = False + self.insideResetProcess = False # Concurrent attributes self.insideConcurrent = False self.isConcurrentBegin = False diff --git a/vsg/tests/vhdlFile/test_vhdlFile_after.py b/vsg/tests/vhdlFile/test_vhdlFile_after.py index c7761efd..c46efe10 100644 --- a/vsg/tests/vhdlFile/test_vhdlFile_after.py +++ b/vsg/tests/vhdlFile/test_vhdlFile_after.py @@ -54,3 +54,20 @@ class testVhdlFileAfterMethods(unittest.TestCase): lActual.append(iIndex) # Compare self.assertEqual(lActual, lExpected) + + def test_inside_reset_process(self): + lExpected = [] + lExpected.extend(range(9, 14)) + lExpected.extend(range(26, 31)) + lExpected.extend(range(43, 48)) + lExpected.extend(range(70, 75)) + lExpected.extend(range(87, 92)) + lExpected.extend(range(144, 149)) + + # Generic actual list + lActual = [] + for iIndex, oLine in enumerate(oFile.lines): + if oLine.insideResetProcess: + lActual.append(iIndex) + # Compare + self.assertEqual(lActual, lExpected) diff --git a/vsg/vhdlFile/classify/process.py b/vsg/vhdlFile/classify/process.py index f28c78a9..7f12b716 100644 --- a/vsg/vhdlFile/classify/process.py +++ b/vsg/vhdlFile/classify/process.py @@ -1,13 +1,13 @@ import re -def process(dVars, oLine): +def process(dVars, oLine, lLines): classify_process_keyword(dVars, oLine) if oLine.insideProcess: classify_process_sensitivity_list(dVars, oLine) classify_process_begin_keyword(dVars, oLine) classify_process_end_keyword(dVars, oLine) - classify_clock_process(dVars, oLine) + classify_clock_process(dVars, oLine, lLines) def classify_process_keyword(dVars, oLine): @@ -66,10 +66,24 @@ def classify_process_end_keyword(dVars, oLine): dVars['iCurrentIndentLevel'] = dVars['iCurrentIndentLevel'] - 1 dVars['SensitivityListFound'] = False -def classify_clock_process(dVars, oLine): +def classify_clock_process(dVars, oLine, lLines): if re.match('^\s*[elsif|if]\s*.*\'event\s+and\s+\w+\s*=\s*\'[0-1]\'', oLine.lineNoComment, flags=re.IGNORECASE): oLine.insideClockProcess = True + classify_reset_process(oLine, lLines) if re.match('^\s*[elsif|if]\s*.*rising_edge', oLine.lineNoComment, flags=re.IGNORECASE): oLine.insideClockProcess = True + classify_reset_process(oLine, lLines) if re.match('^\s*[elsif|if]\s*.*falling_edge', oLine.lineNoComment, flags=re.IGNORECASE): oLine.insideClockProcess = True + classify_reset_process(oLine, lLines) + +def classify_reset_process(oLine, lLines): + if re.match('^\s*if', oLine.lineNoComment, flags=re.IGNORECASE): + return + + iIndex = len(lLines) - 1 + + while lLines[iIndex].isIfKeyword is False: + lLines[iIndex].insideResetProcess = True + iIndex = iIndex - 1 + lLines[iIndex].insideResetProcess = True diff --git a/vsg/vhdlFile/vhdlFile.py b/vsg/vhdlFile/vhdlFile.py index 74926abb..f3db5a29 100644 --- a/vsg/vhdlFile/vhdlFile.py +++ b/vsg/vhdlFile/vhdlFile.py @@ -72,7 +72,7 @@ class vhdlFile(): classify.constant(dVars, oLine, oLinePrevious) classify.variable(dVars, oLine) classify.procedure(dVars, oLine, oLinePrevious) - classify.process(dVars, oLine) + classify.process(dVars, oLine, self.lines) classify.generate(dVars, oLine, oLinePrevious) classify.attribute(dVars, oLine) classify.file_statement(dVars, oLine)