Skip to content

Commit

Permalink
Add KnownDomain to unsafeToReset
Browse files Browse the repository at this point in the history
In preparation for #2589 "Remove KnownDomain".
This is the only constraint addition in clash-prelude in for the KnownDomain removal,
by adding it here for 1.8 we can do the KnownDomain removal later,
with less backwards compatibility issues.

This commit also had to add a KnownDomain to invertReset,
because it used unsafeToReset, but this will be removed again by #2589.
  • Loading branch information
leonschoorl committed Nov 2, 2023
1 parent 6ab581f commit 7aaadce
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
ADDED: You can now use ~PERIOD, ~ISSYNC, ~ISINITDEFINED and ~ACTIVEEDGE
on arguments of type Clock,Reset,Enable,ClockN and DiffClock.

CHANGED: unsafeToReset and invertReset now have a KnownDomain constraint
This was done in preparation for [Remove KnownDomain #2589](https://github.com/clash-lang/clash-compiler/pull/2589)
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
name: Clash.Signal.Internal.unsafeToReset
kind: Expression
type: 'unsafeToReset ::
Signal dom Bool -> Reset dom'
template: ~ARG[0]
KnownDomain dom => Signal dom Bool -> Reset dom'
template: ~ARG[1]
workInfo: Never
4 changes: 2 additions & 2 deletions clash-lib/prims/vhdl/Clash_Signal_Internal.primitives.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,6 @@
name: Clash.Signal.Internal.unsafeToReset
kind: Declaration
type: 'unsafeToReset ::
Signal dom Bool -> Reset dom'
template: ~RESULT <= '1' when ~ARG[0] = true else '0';
KnownDomain dom => Signal dom Bool -> Reset dom'
template: ~RESULT <= '1' when ~ARG[1] = true else '0';
workInfo: Never
5 changes: 3 additions & 2 deletions clash-prelude/src/Clash/Signal/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1279,7 +1279,8 @@ unsafeFromReset (Reset r) = r
-- __NB__: You probably want to use 'unsafeFromActiveLow' or
-- 'unsafeFromActiveHigh'.
unsafeToReset
:: Signal dom Bool
:: KnownDomain dom
=> Signal dom Bool
-> Reset dom
unsafeToReset r = Reset r
-- See: https://github.com/clash-lang/clash-compiler/pull/2511
Expand Down Expand Up @@ -1359,7 +1360,7 @@ unsafeFromActiveLow r =
SActiveLow -> r

-- | Invert reset signal
invertReset :: Reset dom -> Reset dom
invertReset :: KnownDomain dom => Reset dom -> Reset dom
invertReset = unsafeToReset . fmap not . unsafeFromReset

infixr 2 .||.
Expand Down

0 comments on commit 7aaadce

Please sign in to comment.