greatscottgadgets / luna

Amaranth HDL framework for monitoring, hacking, and developing USB devices
https://greatscottgadgets.com/cynthion/
BSD 3-Clause "New" or "Revised" License
991 stars 171 forks source link

gateware: fix an order-of-operations bug with cdc.synchronize #263

Closed antoinevg closed 5 months ago

antoinevg commented 5 months ago

In https://github.com/greatscottgadgets/luna/commit/db754379448e606c4e80bb499ef052abcaec4183 a subtle bug was introduced into cdc.synchronize where nested elements of type Pin with directionality output would be recursed into and end up being driven by FFSynchronizer rather than being skipped.

This would result in the signal being driven from multiple fragments: once from the top-level design and again by the undesired FFSynchronizer.

Prior to this change this was not an issue as the recursion operation only applied to elements of type Record.

Moving the directionality check to occur prior to the recursive operation resolves the issue.

antoinevg commented 5 months ago

Closes #101

antoinevg commented 5 months ago

Updated (with bonus unit test!)