Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

convertReset: always filter synchronous source #2573

Merged
merged 1 commit into from Sep 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 1 addition & 3 deletions changelog/2023-07-30T11_33_02+02_00_convertreset_glitch
@@ -1,3 +1 @@
FIXED: If `convertReset` is used to convert a synchronous reset into an
asynchronous reset, a flip-flop in the source domain is inserted to filter
glitches from the source reset.
FIXED: If the source reset of `convertReset` is synchronous, a flip-flop in the source domain is inserted to filter glitches from the source reset.
11 changes: 5 additions & 6 deletions clash-prelude/src/Clash/Explicit/Reset.hs
Expand Up @@ -436,9 +436,8 @@ holdReset clk en SNat rst =
-- the domains are not the same. See 'resetSynchronizer' for further details
-- about reset synchronization.
--
-- If @domA@ has 'Synchronous' resets and @domB@ has 'Asynchronous' resets, a
-- flip-flop is inserted in @domA@ to filter glitches. This adds one @domA@
-- clock cycle delay.
-- If @domA@ has 'Synchronous' resets, a flip-flop is inserted in @domA@ to
-- filter glitches. This adds one @domA@ clock cycle delay.
convertReset
:: forall domA domB
. ( KnownDomain domA
Expand All @@ -457,9 +456,9 @@ convertReset clkA clkB rstA0 = rstB1
(SActiveHigh, SActiveHigh) -> rstA1
_ -> not <$> rstA1
rstA3 =
case (resetKind @domA, resetKind @domB) of
(SSynchronous, SAsynchronous) -> delay clkA enableGen assertedA rstA2
_ -> rstA2
case resetKind @domA of
SSynchronous -> delay clkA enableGen assertedA rstA2
_ -> rstA2
rstB0 = unsafeToReset $ unsafeSynchronizer clkA clkB rstA3
rstB1 =
case (sameDomain @domA @domB) of
Expand Down