mirror of
https://github.com/enjoy-digital/litex.git
synced 2025-01-04 09:52:26 -05:00
fhdl/visit: support Constant
This commit is contained in:
parent
87a8531952
commit
1767eef9cb
1 changed files with 8 additions and 7 deletions
|
@ -1,13 +1,14 @@
|
||||||
from copy import copy
|
from copy import copy
|
||||||
|
|
||||||
from migen.fhdl.structure import *
|
from migen.fhdl.structure import *
|
||||||
from migen.fhdl.structure import _Operator, _Slice, _Assign, _ArrayProxy, _Fragment
|
from migen.fhdl.structure import (_Operator, _Slice, _Assign, _ArrayProxy,
|
||||||
|
_Fragment)
|
||||||
|
|
||||||
|
|
||||||
class NodeVisitor:
|
class NodeVisitor:
|
||||||
def visit(self, node):
|
def visit(self, node):
|
||||||
if isinstance(node, (int, bool)):
|
if isinstance(node, Constant):
|
||||||
self.visit_constant(node)
|
self.visit_Constant(node)
|
||||||
elif isinstance(node, Signal):
|
elif isinstance(node, Signal):
|
||||||
self.visit_Signal(node)
|
self.visit_Signal(node)
|
||||||
elif isinstance(node, ClockSignal):
|
elif isinstance(node, ClockSignal):
|
||||||
|
@ -39,7 +40,7 @@ class NodeVisitor:
|
||||||
elif node is not None:
|
elif node is not None:
|
||||||
self.visit_unknown(node)
|
self.visit_unknown(node)
|
||||||
|
|
||||||
def visit_constant(self, node):
|
def visit_Constant(self, node):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def visit_Signal(self, node):
|
def visit_Signal(self, node):
|
||||||
|
@ -107,8 +108,8 @@ class NodeVisitor:
|
||||||
# In those cases, the original node is returned unchanged.
|
# In those cases, the original node is returned unchanged.
|
||||||
class NodeTransformer:
|
class NodeTransformer:
|
||||||
def visit(self, node):
|
def visit(self, node):
|
||||||
if isinstance(node, (int, bool)):
|
if isinstance(node, Constant):
|
||||||
return self.visit_constant(node)
|
return self.visit_Constant(node)
|
||||||
elif isinstance(node, Signal):
|
elif isinstance(node, Signal):
|
||||||
return self.visit_Signal(node)
|
return self.visit_Signal(node)
|
||||||
elif isinstance(node, ClockSignal):
|
elif isinstance(node, ClockSignal):
|
||||||
|
@ -142,7 +143,7 @@ class NodeTransformer:
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def visit_constant(self, node):
|
def visit_Constant(self, node):
|
||||||
return node
|
return node
|
||||||
|
|
||||||
def visit_Signal(self, node):
|
def visit_Signal(self, node):
|
||||||
|
|
Loading…
Reference in a new issue