mirror of
https://github.com/enjoy-digital/litex.git
synced 2025-01-04 09:52:26 -05:00
fhdl/verilog: recursive Special lowering
This commit is contained in:
parent
67c3119249
commit
b862b070d6
1 changed files with 19 additions and 1 deletions
|
@ -230,7 +230,7 @@ def _call_special_classmethod(overrides, obj, method, *args, **kwargs):
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def _lower_specials(overrides, specials):
|
def _lower_specials_step(overrides, specials):
|
||||||
f = Fragment()
|
f = Fragment()
|
||||||
lowered_specials = set()
|
lowered_specials = set()
|
||||||
for special in sorted(specials, key=lambda x: x.huid):
|
for special in sorted(specials, key=lambda x: x.huid):
|
||||||
|
@ -240,6 +240,24 @@ def _lower_specials(overrides, specials):
|
||||||
lowered_specials.add(special)
|
lowered_specials.add(special)
|
||||||
return f, lowered_specials
|
return f, lowered_specials
|
||||||
|
|
||||||
|
def _can_lower(overrides, specials):
|
||||||
|
for special in specials:
|
||||||
|
cl = special.__class__
|
||||||
|
if cl in overrides:
|
||||||
|
cl = overrides[cl]
|
||||||
|
if hasattr(cl, "lower"):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
def _lower_specials(overrides, specials):
|
||||||
|
f, lowered_specials = _lower_specials_step(overrides, specials)
|
||||||
|
while _can_lower(overrides, f.specials):
|
||||||
|
f2, lowered_specials2 = _lower_specials_step(overrides, f.specials)
|
||||||
|
f += f2
|
||||||
|
lowered_specials |= lowered_specials2
|
||||||
|
f.specials -= lowered_specials2
|
||||||
|
return f, lowered_specials
|
||||||
|
|
||||||
def _printspecials(overrides, specials, ns):
|
def _printspecials(overrides, specials, ns):
|
||||||
r = ""
|
r = ""
|
||||||
for special in sorted(specials, key=lambda x: x.huid):
|
for special in sorted(specials, key=lambda x: x.huid):
|
||||||
|
|
Loading…
Reference in a new issue