Updates for instantiation rules:
1) Flagging instantiation ports with 0 or more than one space after the => operator.
This commit is contained in:
parent
c17fed570a
commit
c96bf8317b
|
|
@ -371,3 +371,20 @@ class rule_021(instantiation_rule):
|
|||
if oLine.isInstantiationPortAssignment:
|
||||
if re.match('^\s*\S+\s*=>\s*\S+,\s*\S+\s*=>', oLine.line):
|
||||
self.add_violation(iLineNumber)
|
||||
|
||||
|
||||
class rule_022(instantiation_rule):
|
||||
'''Instantiation rule 022 checks for a single space after the => operator.'''
|
||||
|
||||
def __init__(self):
|
||||
instantiation_rule.__init__(self)
|
||||
self.identifier = '022'
|
||||
self.solution = 'Only a single space after => operator.'
|
||||
self.phase = 2
|
||||
|
||||
def analyze(self, oFile):
|
||||
lFailureLines = []
|
||||
for iLineNumber, oLine in enumerate(oFile.lines):
|
||||
if oLine.isInstantiationPortAssignment and not oLine.isInstantiationPortKeyword:
|
||||
if not re.match('^.*=>\s\S+', oLine.line):
|
||||
self.add_violation(iLineNumber)
|
||||
|
|
|
|||
|
|
@ -23,8 +23,8 @@ begin
|
|||
U_INST1 : InST1
|
||||
port map (
|
||||
port_1 => w_port_1,
|
||||
port_2 => w_port_2,
|
||||
port_3 => w_port_3
|
||||
port_2 => w_port_2,
|
||||
port_3 =>w_port_3
|
||||
);
|
||||
U_INST1 : INST1
|
||||
|
||||
|
|
|
|||
|
|
@ -232,6 +232,15 @@ class testRuleInstantiationMethods(unittest.TestCase):
|
|||
oRule.analyze(oFilePort)
|
||||
self.assertEqual(oRule.violations, dExpected)
|
||||
|
||||
def test_rule_022(self):
|
||||
oRule = instantiation.rule_022()
|
||||
self.assertTrue(oRule)
|
||||
self.assertEqual(oRule.name, 'instantiation')
|
||||
self.assertEqual(oRule.identifier, '022')
|
||||
|
||||
dExpected = [26,27]
|
||||
oRule.analyze(oFilePort)
|
||||
self.assertEqual(oRule.violations, dExpected)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
|||
Loading…
Reference in New Issue