Skip to content

Commit 3c9eaf2

Browse files
committed
Add ExtractClockDom and ExtractResetDom
1 parent d24ac30 commit 3c9eaf2

File tree

12 files changed

+42
-33
lines changed

12 files changed

+42
-33
lines changed

clash-cores/src/Clash/Cores/Xilinx/BlockRam.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
module Clash.Cores.Xilinx.BlockRam (tdpbram) where
1515

1616
import Clash.Explicit.Prelude
17-
import Clash.Signal.Internal (Clock(Clock))
1817

1918
import GHC.Stack (HasCallStack)
2019

@@ -60,7 +59,7 @@ tdpbram ::
6059
( Signal domA a
6160
, Signal domB a
6261
)
63-
tdpbram clkA@(Clock{}) enA addrA byteEnaA datA clkB@(Clock{}) enB addrB byteEnaB datB =
62+
tdpbram clkA@ExtractClockDom enA addrA byteEnaA datA clkB@ExtractClockDom enB addrB byteEnaB datB =
6463
-- [Note: eta port names for tdpbram]
6564
--
6665
-- By naming all the arguments and setting the -fno-do-lambda-eta-expansion GHC

clash-cores/src/Clash/Cores/Xilinx/DcFifo.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ module Clash.Cores.Xilinx.DcFifo
7171
) where
7272

7373
import Clash.Explicit.Prelude
74-
import Clash.Signal.Internal (Clock(..), Signal (..), ClockAB (..), clockTicks)
74+
import Clash.Signal.Internal (Signal (..), ClockAB (..), clockTicks)
7575
import Data.Maybe (isJust)
7676
import qualified Data.Sequence as Seq
7777
import Data.Sequence (Seq)
@@ -153,7 +153,7 @@ dcFifo ::
153153
-- | Read enable @rd_en@
154154
Signal read Bool ->
155155
FifoOut read write depth a
156-
dcFifo DcConfig{..} wClk@(Clock{}) wRst rClk@(Clock{}) rRst writeData rEnable =
156+
dcFifo DcConfig{..} wClk@ExtractClockDom wRst rClk@ExtractClockDom rRst writeData rEnable =
157157
case (resetKind @write, resetKind @read) of
158158
(SSynchronous, SSynchronous) ->
159159
let

clash-cores/src/Clash/Cores/Xilinx/Xpm/Cdc/ArraySingle.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ module Clash.Cores.Xilinx.Xpm.Cdc.ArraySingle
1212
) where
1313

1414
import Clash.Explicit.Prelude
15-
import Clash.Signal.Internal (Clock(Clock))
1615

1716
import GHC.Stack (HasCallStack)
1817

@@ -41,7 +40,7 @@ xpmCdcArraySingle ::
4140
Clock dst ->
4241
Signal src a ->
4342
Signal dst a
44-
xpmCdcArraySingle clkSrc@(Clock{}) clkDst@(Clock{}) = xpmCdcArraySingleWith XpmCdcArraySingleConfig{..} clkSrc clkDst
43+
xpmCdcArraySingle clkSrc@ExtractClockDom clkDst@ExtractClockDom = xpmCdcArraySingleWith XpmCdcArraySingleConfig{..} clkSrc clkDst
4544
where
4645
registerInput = True
4746
stages = d4

clash-cores/src/Clash/Cores/Xilinx/Xpm/Cdc/Gray.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ module Clash.Cores.Xilinx.Xpm.Cdc.Gray
1515
import GHC.Stack (HasCallStack)
1616

1717
import Clash.Explicit.Prelude
18-
import Clash.Signal.Internal (Clock(Clock))
1918

2019
import Clash.Cores.Xilinx.Xpm.Cdc.Gray.Internal (xpmCdcGray#)
2120

@@ -53,7 +52,7 @@ xpmCdcGray ::
5352
Clock dst ->
5453
Signal src (Unsigned n) ->
5554
Signal dst (Unsigned n)
56-
xpmCdcGray clkSrc@(Clock{}) clkDst@(Clock{}) = xpmCdcGrayWith XpmCdcGrayConfig{..} clkSrc clkDst
55+
xpmCdcGray clkSrc@ExtractClockDom clkDst@ExtractClockDom = xpmCdcGrayWith XpmCdcGrayConfig{..} clkSrc clkDst
5756
where
5857
stages = d4
5958
initialValues =

clash-cores/src/Clash/Cores/Xilinx/Xpm/Cdc/Handshake.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ module Clash.Cores.Xilinx.Xpm.Cdc.Handshake
1212
) where
1313

1414
import Clash.Explicit.Prelude
15-
import Clash.Signal.Internal (Clock(Clock))
1615

1716
import GHC.Stack (HasCallStack)
1817

@@ -66,7 +65,7 @@ xpmCdcHandshake ::
6665
, "dest_req" ::: Signal dst Bool
6766
, "src_rcv" ::: Signal src Bool
6867
)
69-
xpmCdcHandshake clkSrc@(Clock{}) clkDst@(Clock{}) = xpmCdcHandshakeWith XpmCdcHandshakeConfig{..} clkSrc clkDst
68+
xpmCdcHandshake clkSrc@ExtractClockDom clkDst@ExtractClockDom = xpmCdcHandshakeWith XpmCdcHandshakeConfig{..} clkSrc clkDst
7069
where
7170
srcStages = d4
7271
dstStages = d4

clash-cores/src/Clash/Cores/Xilinx/Xpm/Cdc/Single.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ module Clash.Cores.Xilinx.Xpm.Cdc.Single
1212
) where
1313

1414
import Clash.Explicit.Prelude
15-
import Clash.Signal.Internal (Clock(Clock))
1615

1716
import GHC.Stack (HasCallStack)
1817

@@ -40,7 +39,7 @@ xpmCdcSingle ::
4039
Clock dst ->
4140
Signal src a ->
4241
Signal dst a
43-
xpmCdcSingle clkSrc@(Clock{}) clkDst@(Clock{}) = xpmCdcSingleWith XpmCdcSingleConfig{..} clkSrc clkDst
42+
xpmCdcSingle clkSrc@ExtractClockDom clkDst@ExtractClockDom = xpmCdcSingleWith XpmCdcSingleConfig{..} clkSrc clkDst
4443
where
4544
registerInput = True
4645
stages = d4

clash-prelude/src/Clash/Explicit/RAM.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ asyncRam#
139139
-- ^ Value to write (at address @w@)
140140
-> Signal rdom a
141141
-- ^ Value of the RAM at address @r@
142-
asyncRam# wClk@(Clock{}) rClk@(Clock{}) en sz rd we wr din = dout
142+
asyncRam# wClk@ExtractClockDom rClk@ExtractClockDom en sz rd we wr din = dout
143143
where
144144
ramI = Seq.replicate
145145
szI

clash-prelude/src/Clash/Explicit/Reset.hs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ orReset = unsafeOrReset
8484
-- domains with components with asynchronous resets, where use of this function
8585
-- can introduce glitches triggering a reset.
8686
unsafeOrReset :: forall dom. Reset dom -> Reset dom -> Reset dom
87-
unsafeOrReset r0@(Reset{}) r1 =
87+
unsafeOrReset r0@ExtractResetDom r1 =
8888
unsafeToReset $
8989
case resetPolarity @dom of
9090
SActiveHigh -> rst0 .||. rst1
@@ -107,7 +107,7 @@ andReset = unsafeAndReset
107107
-- components with asynchronous resets, where use of this function can introduce
108108
-- glitches triggering a reset.
109109
unsafeAndReset :: forall dom. Reset dom -> Reset dom -> Reset dom
110-
unsafeAndReset r0@(Reset{}) r1 =
110+
unsafeAndReset r0@ExtractResetDom r1 =
111111
unsafeToReset $
112112
case resetPolarity @dom of
113113
SActiveHigh -> rst0 .&&. rst1
@@ -221,7 +221,7 @@ resetSynchronizer
221221
. Clock dom
222222
-> Reset dom
223223
-> Reset dom
224-
resetSynchronizer clk@(Clock{}) rst = rstOut
224+
resetSynchronizer clk@ExtractClockDom rst = rstOut
225225
where
226226
isActiveHigh = case resetPolarity @dom of { SActiveHigh -> True; _ -> False }
227227
rstOut =
@@ -316,7 +316,7 @@ unsafeResetGlitchFilter
316316
-> Clock dom
317317
-> Reset dom
318318
-> Reset dom
319-
unsafeResetGlitchFilter glitchlessPeriod clk@(Clock{}) =
319+
unsafeResetGlitchFilter glitchlessPeriod clk@ExtractClockDom =
320320
resetGlitchFilter# glitchlessPeriod reg dffSync
321321
where
322322
reg = delay clk enableGen
@@ -377,7 +377,7 @@ resetGlitchFilter#
377377
)
378378
-> Reset dom
379379
-> Reset dom
380-
resetGlitchFilter# SNat reg dffSync rstIn0@(Reset{}) =
380+
resetGlitchFilter# SNat reg dffSync rstIn0@ExtractResetDom =
381381
let s' = go <$> s <*> rstIn2
382382
s = reg (asserted, 0) s'
383383
in unsafeToReset $ fst <$> s
@@ -427,7 +427,7 @@ holdReset
427427
-> Reset dom
428428
-- ^ Reset to extend
429429
-> Reset dom
430-
holdReset clk en SNat rst@(Reset{}) =
430+
holdReset clk en SNat rst@ExtractResetDom =
431431
unsafeFromActiveHigh ((/=maxBound) <$> counter)
432432
where
433433
counter :: Signal dom (Index (n+1))
@@ -445,7 +445,7 @@ convertReset
445445
-> Clock domB
446446
-> Reset domA
447447
-> Reset domB
448-
convertReset clkA@(Clock{}) clkB@(Clock{}) rstA0 = rstB1
448+
convertReset clkA@ExtractClockDom clkB@ExtractClockDom rstA0 = rstB1
449449
where
450450
rstA1 = unsafeFromReset rstA0
451451
rstA2 =

clash-prelude/src/Clash/Explicit/Signal.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,15 +203,15 @@ module Clash.Explicit.Signal
203203
, fromEnable
204204
, enableGen
205205
-- * Clock
206-
, Clock
206+
, Clock(ExtractClockDom)
207207
, DiffClock
208208
, periodToHz
209209
, hzToPeriod
210210
-- ** Synchronization primitive
211211
, unsafeSynchronizer
212212
, veryUnsafeSynchronizer
213213
-- * Reset
214-
, Reset
214+
, Reset(ExtractResetDom)
215215
, unsafeToReset
216216
, unsafeFromReset
217217
, unsafeToActiveHigh

clash-prelude/src/Clash/Explicit/Testbench.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ seClockToDiffClock ::
468468
Clock dom ->
469469
-- | Differential output
470470
DiffClock dom
471-
seClockToDiffClock clk@(Clock{}) = DiffClock clk (ClockN SSymbol)
471+
seClockToDiffClock clk@ExtractClockDom = DiffClock clk (ClockN SSymbol)
472472
-- See: https://github.com/clash-lang/clash-compiler/pull/2511
473473
{-# CLASH_OPAQUE seClockToDiffClock #-}
474474
{-# ANN seClockToDiffClock hasBlackBox #-}

0 commit comments

Comments
 (0)