Skip to content

Commit

Permalink
gateware: fix an order-of-operations bug with cdc.synchronize where o…
Browse files Browse the repository at this point in the history
…utput signals would not be skipped if they were of Pin type
  • Loading branch information
antoinevg committed Jun 6, 2024
1 parent bf2f346 commit 3907919
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions luna/gateware/utils/cdc.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,18 @@ def create_synchronizer(signal, output):
# Otherwise, we'll need to make sure we only synchronize
# elements with non-output directions.
for name, layout, direction in signal.layout:
# Skip any output elements, as they're already
# in our clock domain, and we don't want to drive them.
if (direction == DIR_FANOUT) or (hasattr(signal[name], 'o') and ~hasattr(signal[name], 'i')):
m.d.comb += signal[name].eq(output[name])
continue

# If this is a record itself, we'll need to recurse.
if isinstance(signal[name], (Record, Pin)):
synchronize(m, signal[name], output=output[name],
o_domain=o_domain, stages=stages)
continue

# Skip any output elements, as they're already
# in our clock domain, and we don't want to drive them.
if (direction == DIR_FANOUT) or (hasattr(signal[name], 'o') and ~hasattr(signal[name], 'i')):
m.d.comb += signal[name].eq(output[name])
continue

m.submodules += create_synchronizer(signal[name], output[name])

return output
Expand Down

0 comments on commit 3907919

Please sign in to comment.