Adding parsing of simple_force_assignment.

This commit is contained in:
Jeremiah Leary 2020-09-12 12:54:23 -05:00
parent 61a71bfae2
commit e80774208b
6 changed files with 299 additions and 4 deletions

View File

@ -0,0 +1,182 @@
--------------------------------------------------------------------------------
0 | None |
--------------------------------------------------------------------------------
1 | None |
<class 'vsg.parser.blank_line'>
--------------------------------------------------------------------------------
2 | None | architecture RTL of ENTITY_NAME is
<class 'vsg.token.architecture_body.architecture_keyword'>
<class 'vsg.token.architecture_body.identifier'>
<class 'vsg.token.architecture_body.of_keyword'>
<class 'vsg.token.architecture_body.entity_name'>
<class 'vsg.token.architecture_body.is_keyword'>
--------------------------------------------------------------------------------
3 | None |
<class 'vsg.parser.blank_line'>
--------------------------------------------------------------------------------
4 | None | begin
<class 'vsg.token.architecture_body.begin_keyword'>
--------------------------------------------------------------------------------
5 | None |
<class 'vsg.parser.blank_line'>
--------------------------------------------------------------------------------
6 | None | process
<class 'vsg.token.process_statement.process_keyword'>
--------------------------------------------------------------------------------
7 | None | begin
<class 'vsg.token.process_statement.begin_keyword'>
--------------------------------------------------------------------------------
8 | None |
<class 'vsg.parser.blank_line'>
--------------------------------------------------------------------------------
9 | None | FORCE_LABEL : sig1 <= force in a + b - c after 10 ns, d + e after 25 ns;
<class 'vsg.token.signal_assignment_statement.label'>
<class 'vsg.token.signal_assignment_statement.label_colon'>
<class 'vsg.token.simple_force_assignment.target'>
<class 'vsg.token.simple_force_assignment.assignment'>
<class 'vsg.token.simple_force_assignment.force_keyword'>
<class 'vsg.token.force_mode.in_keyword'>
<class 'vsg.parser.todo'>
<class 'vsg.parser.todo'>
<class 'vsg.parser.todo'>
<class 'vsg.parser.todo'>
<class 'vsg.parser.todo'>
<class 'vsg.parser.todo'>
<class 'vsg.parser.todo'>
<class 'vsg.parser.todo'>
<class 'vsg.parser.todo'>
<class 'vsg.parser.todo'>
<class 'vsg.parser.todo'>
<class 'vsg.parser.todo'>
<class 'vsg.parser.todo'>
<class 'vsg.parser.todo'>
<class 'vsg.parser.todo'>
<class 'vsg.token.simple_force_assignment.semicolon'>
--------------------------------------------------------------------------------
10 | None |
<class 'vsg.parser.blank_line'>
--------------------------------------------------------------------------------
11 | None | FORCE_LABEL : sig1 <= force out a + b - c after 10 ns, d + e after 25 ns;
<class 'vsg.token.signal_assignment_statement.label'>
<class 'vsg.token.signal_assignment_statement.label_colon'>
<class 'vsg.token.simple_force_assignment.target'>
<class 'vsg.token.simple_force_assignment.assignment'>
<class 'vsg.token.simple_force_assignment.force_keyword'>
<class 'vsg.token.force_mode.out_keyword'>
<class 'vsg.parser.todo'>
<class 'vsg.parser.todo'>
<class 'vsg.parser.todo'>
<class 'vsg.parser.todo'>
<class 'vsg.parser.todo'>
<class 'vsg.parser.todo'>
<class 'vsg.parser.todo'>
<class 'vsg.parser.todo'>
<class 'vsg.parser.todo'>
<class 'vsg.parser.todo'>
<class 'vsg.parser.todo'>
<class 'vsg.parser.todo'>
<class 'vsg.parser.todo'>
<class 'vsg.parser.todo'>
<class 'vsg.parser.todo'>
<class 'vsg.token.simple_force_assignment.semicolon'>
--------------------------------------------------------------------------------
12 | None |
<class 'vsg.parser.blank_line'>
--------------------------------------------------------------------------------
13 | None | FORCE_LABEL : sig1 <= force a + b - c after 10 ns, d + e after 25 ns;
<class 'vsg.token.signal_assignment_statement.label'>
<class 'vsg.token.signal_assignment_statement.label_colon'>
<class 'vsg.token.simple_force_assignment.target'>
<class 'vsg.token.simple_force_assignment.assignment'>
<class 'vsg.token.simple_force_assignment.force_keyword'>
<class 'vsg.parser.todo'>
<class 'vsg.parser.todo'>
<class 'vsg.parser.todo'>
<class 'vsg.parser.todo'>
<class 'vsg.parser.todo'>
<class 'vsg.parser.todo'>
<class 'vsg.parser.todo'>
<class 'vsg.parser.todo'>
<class 'vsg.parser.todo'>
<class 'vsg.parser.todo'>
<class 'vsg.parser.todo'>
<class 'vsg.parser.todo'>
<class 'vsg.parser.todo'>
<class 'vsg.parser.todo'>
<class 'vsg.parser.todo'>
<class 'vsg.token.simple_force_assignment.semicolon'>
--------------------------------------------------------------------------------
14 | None |
<class 'vsg.parser.blank_line'>
--------------------------------------------------------------------------------
15 | None | FORCE_LABEL : sig1 <= force a + b - c, d + e;
<class 'vsg.token.signal_assignment_statement.label'>
<class 'vsg.token.signal_assignment_statement.label_colon'>
<class 'vsg.token.simple_force_assignment.target'>
<class 'vsg.token.simple_force_assignment.assignment'>
<class 'vsg.token.simple_force_assignment.force_keyword'>
<class 'vsg.parser.todo'>
<class 'vsg.parser.todo'>
<class 'vsg.parser.todo'>
<class 'vsg.parser.todo'>
<class 'vsg.parser.todo'>
<class 'vsg.parser.todo'>
<class 'vsg.parser.todo'>
<class 'vsg.parser.todo'>
<class 'vsg.parser.todo'>
<class 'vsg.token.simple_force_assignment.semicolon'>
--------------------------------------------------------------------------------
16 | None |
<class 'vsg.parser.blank_line'>
--------------------------------------------------------------------------------
17 | None | FORCE_LABEL : sig1 <= force a + b - c;
<class 'vsg.token.signal_assignment_statement.label'>
<class 'vsg.token.signal_assignment_statement.label_colon'>
<class 'vsg.token.simple_force_assignment.target'>
<class 'vsg.token.simple_force_assignment.assignment'>
<class 'vsg.token.simple_force_assignment.force_keyword'>
<class 'vsg.parser.todo'>
<class 'vsg.parser.todo'>
<class 'vsg.parser.todo'>
<class 'vsg.parser.todo'>
<class 'vsg.parser.todo'>
<class 'vsg.token.simple_force_assignment.semicolon'>
--------------------------------------------------------------------------------
18 | None |
<class 'vsg.parser.blank_line'>
--------------------------------------------------------------------------------
19 | None | FORCE_LABEL : sig2 <= force a;
<class 'vsg.token.signal_assignment_statement.label'>
<class 'vsg.token.signal_assignment_statement.label_colon'>
<class 'vsg.token.simple_force_assignment.target'>
<class 'vsg.token.simple_force_assignment.assignment'>
<class 'vsg.token.simple_force_assignment.force_keyword'>
<class 'vsg.parser.todo'>
<class 'vsg.token.simple_force_assignment.semicolon'>
--------------------------------------------------------------------------------
20 | None |
<class 'vsg.parser.blank_line'>
--------------------------------------------------------------------------------
21 | None | sig2 <= force a;
<class 'vsg.token.simple_force_assignment.target'>
<class 'vsg.token.simple_force_assignment.assignment'>
<class 'vsg.token.simple_force_assignment.force_keyword'>
<class 'vsg.parser.todo'>
<class 'vsg.token.simple_force_assignment.semicolon'>
--------------------------------------------------------------------------------
22 | None |
<class 'vsg.parser.blank_line'>
--------------------------------------------------------------------------------
23 | None | end process;
<class 'vsg.token.process_statement.end_keyword'>
<class 'vsg.token.process_statement.end_process_keyword'>
<class 'vsg.token.process_statement.semicolon'>
--------------------------------------------------------------------------------
24 | None |
<class 'vsg.parser.blank_line'>
--------------------------------------------------------------------------------
25 | None | end architecture RTL;
<class 'vsg.token.architecture_body.end_keyword'>
<class 'vsg.token.architecture_body.end_architecture_keyword'>
<class 'vsg.token.architecture_body.architecture_simple_name'>
<class 'vsg.token.architecture_body.semicolon'>

View File

@ -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;

View File

@ -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)

View File

@ -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)

View File

@ -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

View File

@ -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: