From 2ac0e8ee8ebafa3dcac05c187eb20ead3602bf2d Mon Sep 17 00:00:00 2001 From: Jeremiah C Leary Date: Sat, 1 Dec 2018 10:09:17 -0600 Subject: [PATCH] Updates for issue #184 Added support for processs without sensitivity lists. --- vsg/rules/process/rule_002.py | 2 +- vsg/tests/process/process_test_input.vhd | 21 +++++++++++++++++++++ vsg/tests/process/test_rule_process.py | 4 ++-- vsg/tests/vhdlFile/test_vhdlFile_process.py | 12 ++++++------ vsg/vhdlFile/classify/process.py | 15 +++++++++++++-- 5 files changed, 43 insertions(+), 11 deletions(-) diff --git a/vsg/rules/process/rule_002.py b/vsg/rules/process/rule_002.py index f88e1f3d..165a75d5 100644 --- a/vsg/rules/process/rule_002.py +++ b/vsg/rules/process/rule_002.py @@ -21,7 +21,7 @@ class rule_002(rule.rule): def analyze(self, oFile): for iLineNumber, oLine in enumerate(oFile.lines): - if oLine.isProcessKeyword and not re.match('^\s*.*process\s\(', oLine.lineLower): + if oLine.isProcessKeyword and re.match('^\s*.*process\s*\(', oLine.lineLower) and not re.match('^\s*.*process\s\(', oLine.lineLower): self.add_violation(iLineNumber) def _fix_violations(self, oFile): diff --git a/vsg/tests/process/process_test_input.vhd b/vsg/tests/process/process_test_input.vhd index 61e2546d..06d2e094 100644 --- a/vsg/tests/process/process_test_input.vhd +++ b/vsg/tests/process/process_test_input.vhd @@ -111,5 +111,26 @@ proc_name : process (one, two, three) is process_2 => '4' ); + -- processes without sensitivity lists + + MAIN : process + + variable var_a : std_logic_vector(16 downto 0); + variable var_b; + + begin + + end process MAIN; + + process + + variable var_a : std_logic_vector(16 downto 0); + variable var_b; + + begin + + end process; + + end architecture ARCH; diff --git a/vsg/tests/process/test_rule_process.py b/vsg/tests/process/test_rule_process.py index c2220c8c..28ca7bf9 100644 --- a/vsg/tests/process/test_rule_process.py +++ b/vsg/tests/process/test_rule_process.py @@ -151,7 +151,7 @@ class testRuleProcessMethods(unittest.TestCase): self.assertTrue(oRule) self.assertEqual(oRule.name, 'process') self.assertEqual(oRule.identifier, '016') - dExpected = [6,11,17,24,32,38,51,55] + dExpected = [6,11,17,24,32,38,51,55,125] oRule.analyze(oFile) self.assertEqual(oRule.violations, dExpected) @@ -169,7 +169,7 @@ class testRuleProcessMethods(unittest.TestCase): self.assertTrue(oRule) self.assertEqual(oRule.name, 'process') self.assertEqual(oRule.identifier, '018') - dExpected = [9,15,22,30,36,42,53,60] + dExpected = [9,15,22,30,36,42,53,60,132] oRule.analyze(oFile) self.assertEqual(oRule.violations, dExpected) diff --git a/vsg/tests/vhdlFile/test_vhdlFile_process.py b/vsg/tests/vhdlFile/test_vhdlFile_process.py index a6ebe70d..d8ec84a0 100644 --- a/vsg/tests/vhdlFile/test_vhdlFile_process.py +++ b/vsg/tests/vhdlFile/test_vhdlFile_process.py @@ -11,7 +11,7 @@ oFileProcess = vhdlFile.vhdlFile(os.path.join(os.path.dirname(__file__),'..','pr class testVhdlFileMethods(unittest.TestCase): def test_comment_assignment(self): - lExpected = [8,21,50,76,83,90] + lExpected = [8,21,50,76,83,90,114] # Generic actual list lActual = [] for iIndex, oLine in enumerate(oFileProcess.lines): @@ -21,7 +21,7 @@ class testVhdlFileMethods(unittest.TestCase): self.assertEqual(lActual, lExpected) def test_insideProcess_assignment(self): - lExpected = [6,7,8,9,11,12,13,14,15,17,18,19,20,21,22,24,25,26,27,28,29,30,32,33,34,35,36,38,39,40,41,42,46,47,48,51,52,53,55,56,57,58,59,60,63,64,65,68,69,70,71,72,75,76,77,78,79,81,82,83,84,85,86,88,89,90,91,92,93,94,97,98,99,100,101,102,103] + lExpected = [6,7,8,9,11,12,13,14,15,17,18,19,20,21,22,24,25,26,27,28,29,30,32,33,34,35,36,38,39,40,41,42,46,47,48,51,52,53,55,56,57,58,59,60,63,64,65,68,69,70,71,72,75,76,77,78,79,81,82,83,84,85,86,88,89,90,91,92,93,94,97,98,99,100,101,102,103,116,117,118,119,120,121,122,123,125,126,127,128,129,130,131,132] # Generic actual list lActual = [] for iIndex, oLine in enumerate(oFileProcess.lines): @@ -31,7 +31,7 @@ class testVhdlFileMethods(unittest.TestCase): self.assertEqual(lActual, lExpected) def test_isProcessBegin_assignment(self): - lExpected = [6,13,20,28,34,40,47,52,59,64,70,77,84,92,101] + lExpected = [6,13,20,28,34,40,47,52,59,64,70,77,84,92,101,121,130] # Generic actual list lActual = [] for iIndex, oLine in enumerate(oFileProcess.lines): @@ -41,7 +41,7 @@ class testVhdlFileMethods(unittest.TestCase): self.assertEqual(lActual, lExpected) def test_isProcessKeyword_assignment(self): - lExpected = [6,11,17,24,32,38,46,51,55,63,68,75,81,88,97] + lExpected = [6,11,17,24,32,38,46,51,55,63,68,75,81,88,97,116,125] # Generic actual list lActual = [] for iIndex, oLine in enumerate(oFileProcess.lines): @@ -51,7 +51,7 @@ class testVhdlFileMethods(unittest.TestCase): self.assertEqual(lActual, lExpected) def test_isProcessLabel_assignment(self): - lExpected = [46,63,68,75,81,88,97] + lExpected = [46,63,68,75,81,88,97,116] # Generic actual list lActual = [] for iIndex, oLine in enumerate(oFileProcess.lines): @@ -61,7 +61,7 @@ class testVhdlFileMethods(unittest.TestCase): self.assertEqual(lActual, lExpected) def test_isEndProcess_assignment(self): - lExpected = [9,15,22,30,36,42,48,53,60,65,72,79,86,94,103] + lExpected = [9,15,22,30,36,42,48,53,60,65,72,79,86,94,103,123,132] # Generic actual list lActual = [] for iIndex, oLine in enumerate(oFileProcess.lines): diff --git a/vsg/vhdlFile/classify/process.py b/vsg/vhdlFile/classify/process.py index b228ce43..b4b8205d 100644 --- a/vsg/vhdlFile/classify/process.py +++ b/vsg/vhdlFile/classify/process.py @@ -10,20 +10,31 @@ def process(dVars, oLine): def classify_process_keyword(dVars, oLine): - if re.match('^\s*process[:|\s|$|(]', oLine.lineLower): + if re.match('^\s*process[:|\s|(]', oLine.lineLower): oLine.isProcessKeyword = True oLine.insideProcess = True oLine.indentLevel = dVars['iCurrentIndentLevel'] + if re.match('^\s*process\s*$', oLine.lineNoComment): + oLine.isProcessKeyword = True + oLine.insideProcess = True + oLine.indentLevel = dVars['iCurrentIndentLevel'] + dVars['iCurrentIndentLevel'] += 1 if re.match('^\s*\S+\s*:\s*process', oLine.lineLower): oLine.isProcessKeyword = True oLine.insideProcess = True oLine.indentLevel = dVars['iCurrentIndentLevel'] oLine.isProcessLabel = True + if re.match('^\s*\S+\s*:\s*process\s*$', oLine.lineNoComment): + dVars['iCurrentIndentLevel'] += 1 def classify_process_sensitivity_list(dVars, oLine): # Check sensitivity list - if '(' in oLine.line and not oLine.insideSensitivityList and not dVars['fFoundProcessBegin'] and not dVars['SensitivityListFound']: + if '(' in oLine.line and \ + not oLine.insideSensitivityList and \ + not dVars['fFoundProcessBegin'] and \ + not dVars['SensitivityListFound'] and \ + not oLine.isVariable: oLine.isSensitivityListBegin = True oLine.insideSensitivityList = True dVars['SensitivityListFound'] = True