diff options
author | Patrick Lehmann <Patrick.Lehmann@plc2.de> | 2021-08-17 13:30:49 +0200 |
---|---|---|
committer | umarcor <unai.martinezcorral@ehu.eus> | 2021-08-23 16:35:36 +0200 |
commit | f8d7ac62564e4bdefb35e58178c4df1b4feae844 (patch) | |
tree | d2997da28b50815494b540c4bd0bae8e2094fd90 /pyGHDL/dom | |
parent | d0dc820554320ad076854481f5cb0957edd3cda5 (diff) | |
download | ghdl-f8d7ac62564e4bdefb35e58178c4df1b4feae844.tar.gz ghdl-f8d7ac62564e4bdefb35e58178c4df1b4feae844.tar.bz2 ghdl-f8d7ac62564e4bdefb35e58178c4df1b4feae844.zip |
Handle simple sequential signal assignments and it's waveforms.
Diffstat (limited to 'pyGHDL/dom')
-rw-r--r-- | pyGHDL/dom/Concurrent.py | 27 | ||||
-rw-r--r-- | pyGHDL/dom/Sequential.py | 9 | ||||
-rw-r--r-- | pyGHDL/dom/_Translate.py | 7 |
3 files changed, 26 insertions, 17 deletions
diff --git a/pyGHDL/dom/Concurrent.py b/pyGHDL/dom/Concurrent.py index f4ded4e80..f4681dbf9 100644 --- a/pyGHDL/dom/Concurrent.py +++ b/pyGHDL/dom/Concurrent.py @@ -616,9 +616,23 @@ class ForGenerateStatement(VHDLModel_ForGenerateStatement, DOMMixin): @export class WaveformElement(VHDLModel_WaveformElement, DOMMixin): - def __init__(self, waveformNode: Iir, expression: Expression, after: Expression): + def __init__(self, waveNode: Iir, expression: Expression, after: Expression): super().__init__(expression, after) - DOMMixin.__init__(self, waveformNode) + DOMMixin.__init__(self, waveNode) + + @classmethod + def parse(cls, waveNode: Iir): + from pyGHDL.dom._Translate import GetExpressionFromNode + + value = GetExpressionFromNode(nodes.Get_We_Value(waveNode)) + + timeNode = nodes.Get_Time(waveNode) + if timeNode is nodes.Null_Iir: + time = None + else: + time = GetExpressionFromNode(timeNode) + + return cls(waveNode, value, time) @export @@ -644,12 +658,11 @@ class ConcurrentSimpleSignalAssignment( target = nodes.Get_Target(assignmentNode) targetName = GetNameFromNode(target) - waveform = nodes.Get_Waveform_Chain(assignmentNode) - - # TODO: translate waveforms to series of "expressions". - expression = [None] + waveform = [] + for wave in utils.chain_iter(nodes.Get_Waveform_Chain(assignmentNode)): + waveform.append(WaveformElement.parse(wave)) - return cls(assignmentNode, label, targetName, expression) + return cls(assignmentNode, label, targetName, waveform) @export diff --git a/pyGHDL/dom/Sequential.py b/pyGHDL/dom/Sequential.py index d2efef8eb..28b6f2b98 100644 --- a/pyGHDL/dom/Sequential.py +++ b/pyGHDL/dom/Sequential.py @@ -421,12 +421,11 @@ class SequentialSimpleSignalAssignment( target = nodes.Get_Target(assignmentNode) targetName = GetNameFromNode(target) - waveform = nodes.Get_Waveform_Chain(assignmentNode) + waveform = [] + for wave in utils.chain_iter(nodes.Get_Waveform_Chain(assignmentNode)): + waveform.append(WaveformElement.parse(wave)) - # TODO: translate waveforms to series of "expressions". - expression = [None] - - return cls(assignmentNode, targetName, expression, label) + return cls(assignmentNode, targetName, waveform, label) @export diff --git a/pyGHDL/dom/_Translate.py b/pyGHDL/dom/_Translate.py index dfc919504..133d9386f 100644 --- a/pyGHDL/dom/_Translate.py +++ b/pyGHDL/dom/_Translate.py @@ -41,6 +41,7 @@ from pyGHDL.dom.Sequential import ( SequentialReportStatement, SequentialAssertStatement, WaitStatement, + SequentialSimpleSignalAssignment, ) from pyVHDLModel.SyntaxModel import ( Constraint, @@ -886,11 +887,7 @@ def GetSequentialStatementsFromChainedNodes( elif kind == nodes.Iir_Kind.Case_Statement: yield CaseStatement.parse(statement, label) elif kind == nodes.Iir_Kind.Simple_Signal_Assignment_Statement: - print( - "[NOT IMPLEMENTED] (Simple) signal assignment (label: '{label}') at line {line}".format( - label=label, line=pos.Line - ) - ) + yield SequentialSimpleSignalAssignment.parse(statement, label) elif kind in ( nodes.Iir_Kind.Variable_Assignment_Statement, nodes.Iir_Kind.Conditional_Variable_Assignment_Statement, |