From bcd22a5a72ec35004d76a084da9876ae35d35cda Mon Sep 17 00:00:00 2001 From: Jeremiah C Leary Date: Sun, 5 Nov 2017 08:40:03 -0600 Subject: [PATCH] Updates for instantiations: 1) Fixed issue where instantiations were not detected inside generates --- .../instantiation_generate_test_input.vhd | 18 ++++++++++++++++++ .../test_vhdlFile_instantiation_assignments.py | 11 +++++++++++ vsg/vhdlFile.py | 3 ++- 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 vsg/tests/instantiation/instantiation_generate_test_input.vhd diff --git a/vsg/tests/instantiation/instantiation_generate_test_input.vhd b/vsg/tests/instantiation/instantiation_generate_test_input.vhd new file mode 100644 index 00000000..7eaf056c --- /dev/null +++ b/vsg/tests/instantiation/instantiation_generate_test_input.vhd @@ -0,0 +1,18 @@ + +architecture ARCH of ENTITY is + +begin + + GENERATE_1 : for CONDITION in 0 to 7 generate + + U_INST1 : INST1 + port map ( + PORT_1 => w_port_1, + PORT_2 => w_port_2, + PORT_3 => w_port_3 + ); + + end generate; + +end architecture ARCH; + diff --git a/vsg/tests/vhdlFile/test_vhdlFile_instantiation_assignments.py b/vsg/tests/vhdlFile/test_vhdlFile_instantiation_assignments.py index cbfed89e..c5f9e7b8 100644 --- a/vsg/tests/vhdlFile/test_vhdlFile_instantiation_assignments.py +++ b/vsg/tests/vhdlFile/test_vhdlFile_instantiation_assignments.py @@ -5,6 +5,7 @@ from vsg import vhdlFile oFile = vhdlFile.vhdlFile(os.path.join(os.path.dirname(__file__),'..','instantiation','instantiation_test_input.vhd')) oFileGeneric = vhdlFile.vhdlFile(os.path.join(os.path.dirname(__file__),'..','instantiation','instantiation_generic_test_input.vhd')) +oFileGenerate = vhdlFile.vhdlFile(os.path.join(os.path.dirname(__file__),'..','instantiation','instantiation_generate_test_input.vhd')) class testVhdlFileInstantiationAssignments(unittest.TestCase): @@ -102,5 +103,15 @@ class testVhdlFileInstantiationAssignments(unittest.TestCase): # Compare self.assertEqual(lActual, lExpected) + def test_isInstantiation_assignment_inside_generate(self): + lExpected = [8] + # Generic actual list + lActual = [] + for iIndex, oLine in enumerate(oFileGenerate.lines): + if oLine.isInstantiationDeclaration: + lActual.append(iIndex) + # Compare + self.assertEqual(lActual, lExpected) + if __name__ == '__main__': unittest.main() diff --git a/vsg/vhdlFile.py b/vsg/vhdlFile.py index 35f672ce..ac0362dc 100644 --- a/vsg/vhdlFile.py +++ b/vsg/vhdlFile.py @@ -409,7 +409,8 @@ class vhdlFile(): oLine.isSequentialEnd = True # Check instantiation statements - if fInsideArchitecture and not fInsideProcess and not oLine.isConcurrentBegin and not fInsideComponent and not fInsideGenerate and not fInsideFunction: +# if fInsideArchitecture and not fInsideProcess and not oLine.isConcurrentBegin and not fInsideComponent and not fInsideGenerate and not fInsideFunction: + if fInsideArchitecture and not fInsideProcess and not oLine.isConcurrentBegin and not fInsideComponent and not oLine.isGenerateKeyword and not fInsideFunction: if re.match('^\s*\w+\s*:\s*\w+', oLine.line): oLine.isInstantiationDeclaration = True oLine.indentLevel = iCurrentIndentLevel