Commit f5005b5b authored by whitequark's avatar whitequark
Browse files

fhdl: append lowered specials to the original fragment.

This allows using values such as ClockSignal() and ResetSignal()
in specials.

Also, this commit removes a mismatch between simulation and Verilog
synthesis in the way they were using lower_specials().
parent 29b4e658
......@@ -356,11 +356,11 @@ def _can_lower(overrides, specials):
return False
def lower_specials(overrides, specials):
f, lowered_specials = _lower_specials_step(overrides, specials)
def lower_specials(overrides, f):
lowered_specials = set()
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
fs, lowered_specials_step = _lower_specials_step(overrides, f.specials)
f += fs
lowered_specials |= lowered_specials_step
f.specials -= lowered_specials_step
return f, lowered_specials
......@@ -336,8 +336,8 @@ def convert(fi, ios=None, name="top",
f = lower_complex_slices(f)
insert_resets(f)
f = lower_basics(f)
fs, lowered_specials = lower_specials(special_overrides, f.specials)
f += lower_basics(fs)
f, lowered_specials = lower_specials(special_overrides, f)
f = lower_basics(f)
for io in sorted(ios, key=lambda x: x.duid):
if io.name_override is None:
......
......@@ -261,9 +261,7 @@ class Simulator:
overrides = {AsyncResetSynchronizer: DummyAsyncResetSynchronizer}
overrides.update(special_overrides)
fs, lowered = lower_specials(overrides=overrides, specials=self.fragment.specials)
self.fragment += fs
self.fragment.specials -= lowered
f, lowered = lower_specials(overrides, self.fragment)
if self.fragment.specials:
raise ValueError("Could not lower all specials", self.fragment.specials)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment