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): ...@@ -356,11 +356,11 @@ def _can_lower(overrides, specials):
return False return False
def lower_specials(overrides, specials): def lower_specials(overrides, f):
f, lowered_specials = _lower_specials_step(overrides, specials) lowered_specials = set()
while _can_lower(overrides, f.specials): while _can_lower(overrides, f.specials):
f2, lowered_specials2 = _lower_specials_step(overrides, f.specials) fs, lowered_specials_step = _lower_specials_step(overrides, f.specials)
f += f2 f += fs
lowered_specials |= lowered_specials2 lowered_specials |= lowered_specials_step
f.specials -= lowered_specials2 f.specials -= lowered_specials_step
return f, lowered_specials return f, lowered_specials
...@@ -336,8 +336,8 @@ def convert(fi, ios=None, name="top", ...@@ -336,8 +336,8 @@ def convert(fi, ios=None, name="top",
f = lower_complex_slices(f) f = lower_complex_slices(f)
insert_resets(f) insert_resets(f)
f = lower_basics(f) f = lower_basics(f)
fs, lowered_specials = lower_specials(special_overrides, f.specials) f, lowered_specials = lower_specials(special_overrides, f)
f += lower_basics(fs) f = lower_basics(f)
for io in sorted(ios, key=lambda x: x.duid): for io in sorted(ios, key=lambda x: x.duid):
if io.name_override is None: if io.name_override is None:
......
...@@ -261,9 +261,7 @@ class Simulator: ...@@ -261,9 +261,7 @@ class Simulator:
overrides = {AsyncResetSynchronizer: DummyAsyncResetSynchronizer} overrides = {AsyncResetSynchronizer: DummyAsyncResetSynchronizer}
overrides.update(special_overrides) overrides.update(special_overrides)
fs, lowered = lower_specials(overrides=overrides, specials=self.fragment.specials) f, lowered = lower_specials(overrides, self.fragment)
self.fragment += fs
self.fragment.specials -= lowered
if self.fragment.specials: if self.fragment.specials:
raise ValueError("Could not lower all specials", 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