diff --git a/vsg/tests/simple_force_assignment/classification_results.txt b/vsg/tests/simple_force_assignment/classification_results.txt new file mode 100644 index 00000000..faa9158e --- /dev/null +++ b/vsg/tests/simple_force_assignment/classification_results.txt @@ -0,0 +1,182 @@ +-------------------------------------------------------------------------------- +0 | None | +-------------------------------------------------------------------------------- +1 | None | + +-------------------------------------------------------------------------------- +2 | None | architecture RTL of ENTITY_NAME is + + + + + +-------------------------------------------------------------------------------- +3 | None | + +-------------------------------------------------------------------------------- +4 | None | begin + +-------------------------------------------------------------------------------- +5 | None | + +-------------------------------------------------------------------------------- +6 | None | process + +-------------------------------------------------------------------------------- +7 | None | begin + +-------------------------------------------------------------------------------- +8 | None | + +-------------------------------------------------------------------------------- +9 | None | FORCE_LABEL : sig1 <= force in a + b - c after 10 ns, d + e after 25 ns; + + + + + + + + + + + + + + + + + + + + + + +-------------------------------------------------------------------------------- +10 | None | + +-------------------------------------------------------------------------------- +11 | None | FORCE_LABEL : sig1 <= force out a + b - c after 10 ns, d + e after 25 ns; + + + + + + + + + + + + + + + + + + + + + + +-------------------------------------------------------------------------------- +12 | None | + +-------------------------------------------------------------------------------- +13 | None | FORCE_LABEL : sig1 <= force a + b - c after 10 ns, d + e after 25 ns; + + + + + + + + + + + + + + + + + + + + + +-------------------------------------------------------------------------------- +14 | None | + +-------------------------------------------------------------------------------- +15 | None | FORCE_LABEL : sig1 <= force a + b - c, d + e; + + + + + + + + + + + + + + + +-------------------------------------------------------------------------------- +16 | None | + +-------------------------------------------------------------------------------- +17 | None | FORCE_LABEL : sig1 <= force a + b - c; + + + + + + + + + + + +-------------------------------------------------------------------------------- +18 | None | + +-------------------------------------------------------------------------------- +19 | None | FORCE_LABEL : sig2 <= force a; + + + + + + + +-------------------------------------------------------------------------------- +20 | None | + +-------------------------------------------------------------------------------- +21 | None | sig2 <= force a; + + + + + +-------------------------------------------------------------------------------- +22 | None | + +-------------------------------------------------------------------------------- +23 | None | end process; + + + +-------------------------------------------------------------------------------- +24 | None | + +-------------------------------------------------------------------------------- +25 | None | end architecture RTL; + + + + diff --git a/vsg/tests/simple_force_assignment/classification_test_input.vhd b/vsg/tests/simple_force_assignment/classification_test_input.vhd new file mode 100644 index 00000000..89f8bcf0 --- /dev/null +++ b/vsg/tests/simple_force_assignment/classification_test_input.vhd @@ -0,0 +1,25 @@ + +architecture RTL of ENTITY_NAME is + +begin + + process + begin + + FORCE_LABEL : sig1 <= force in a + b - c after 10 ns, d + e after 25 ns; + + FORCE_LABEL : sig1 <= force out a + b - c after 10 ns, d + e after 25 ns; + + FORCE_LABEL : sig1 <= force a + b - c after 10 ns, d + e after 25 ns; + + FORCE_LABEL : sig1 <= force a + b - c, d + e; + + FORCE_LABEL : sig1 <= force a + b - c; + + FORCE_LABEL : sig2 <= force a; + + sig2 <= force a; + + end process; + +end architecture RTL; diff --git a/vsg/tests/vhdlFile_new/test_simple_force_assignment.py b/vsg/tests/vhdlFile_new/test_simple_force_assignment.py new file mode 100644 index 00000000..009f48a0 --- /dev/null +++ b/vsg/tests/vhdlFile_new/test_simple_force_assignment.py @@ -0,0 +1,30 @@ +import os + +import unittest + +from vsg.tests import utils +from vsg.vhdlFile import vhdlFile_new + +sLrmUnit = utils.extract_lrm_unit_name(__name__) + +lFile = utils.read_vhdlfile(os.path.join(os.path.dirname(__file__),'..',sLrmUnit,'classification_test_input.vhd')) +oFile = vhdlFile_new.vhdlFile(lFile) + + +class test_token(unittest.TestCase): + + def test_classification(self): + sTestDir = os.path.join(os.path.dirname(__file__),'..',sLrmUnit) + + lExpected = [] + utils.read_file(os.path.join(sTestDir, 'classification_results.txt'), lExpected, False) + + lActual = [] + + for oObject in utils.extract_objects(oFile, True): + lActual.append(str(oObject)) + + self.assertEqual(lExpected, lActual) + +# def test_debug(self): +# utils.print_objects(oFile,True) diff --git a/vsg/token/simple_force_assignment.py b/vsg/token/simple_force_assignment.py new file mode 100644 index 00000000..306c80ce --- /dev/null +++ b/vsg/token/simple_force_assignment.py @@ -0,0 +1,26 @@ + +from vsg import parser + + +class target(parser.target): + + def __init__(self, sString): + parser.target.__init__(self, sString) + + +class assignment(parser.assignment): + + def __init__(self, sString): + parser.assignment.__init__(self, sString) + + +class force_keyword(parser.keyword): + + def __init__(self, sString): + parser.keyword.__init__(self, sString) + + +class semicolon(parser.semicolon): + + def __init__(self, sString=';'): + parser.semicolon.__init__(self) diff --git a/vsg/vhdlFile/classify_new/simple_force_assignment.py b/vsg/vhdlFile/classify_new/simple_force_assignment.py new file mode 100644 index 00000000..2a60525f --- /dev/null +++ b/vsg/vhdlFile/classify_new/simple_force_assignment.py @@ -0,0 +1,32 @@ + +from vsg.token import simple_force_assignment as token + +from vsg.vhdlFile import utils + +from vsg.vhdlFile.classify_new import expression +from vsg.vhdlFile.classify_new import force_mode + +''' + simple_force_assignment ::= + target <= force [ force_mode ] expression ; +''' + +def detect(iToken, lObjects): + + if utils.find_in_range('force', iToken, ';', lObjects): + return classify(iToken, lObjects) + return iToken + + +def classify(iToken, lObjects): + + iCurrent = utils.assign_tokens_until('<=', token.target, iToken, lObjects) + iCurrent = utils.assign_next_token_required('<=', token.assignment, iCurrent, lObjects) + iCurrent = utils.assign_next_token_required('force', token.force_keyword, iCurrent, lObjects) + + iCurrent = force_mode.detect(iCurrent, lObjects) + iCurrent = expression.classify_until([';'], iCurrent, lObjects) + + iCurrent = utils.assign_next_token_required(';', token.semicolon, iCurrent, lObjects) + + return iCurrent diff --git a/vsg/vhdlFile/classify_new/simple_signal_assignment.py b/vsg/vhdlFile/classify_new/simple_signal_assignment.py index 10acfd2e..94ef3885 100644 --- a/vsg/vhdlFile/classify_new/simple_signal_assignment.py +++ b/vsg/vhdlFile/classify_new/simple_signal_assignment.py @@ -1,7 +1,7 @@ from vsg.vhdlFile import utils -#from vsg.vhdlFile.classify_new import simple_force_assignment +from vsg.vhdlFile.classify_new import simple_force_assignment from vsg.vhdlFile.classify_new import simple_release_assignment #from vsg.vhdlFile.classify_new import simple_waveform_assignment @@ -25,9 +25,9 @@ def detect(iToken, lObjects): def classify(iToken, lObjects): -# iCurrent = simple_force_assignment.detect(iToken, lObjects) -# if iCurrent != iToken: -# return iCurrent + iCurrent = simple_force_assignment.detect(iToken, lObjects) + if iCurrent != iToken: + return iCurrent iCurrent = simple_release_assignment.detect(iToken, lObjects) if iCurrent != iToken: