Skip to content

Commit 053669c

Browse files
Mark resetGen as non-synthesizable (#2379)
Fixes #2375 Co-authored-by: Peter Lebbing <[email protected]>
1 parent 14209c7 commit 053669c

File tree

4 files changed

+19
-8
lines changed

4 files changed

+19
-8
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
FIXED: `resetGen`'s documentation now mentions it is non-synthesizable ([#2375](https://github.com/clash-lang/clash-compiler/issues/2375))

clash-lib/prims/systemverilog/Clash_Signal_Internal.primitives.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -231,4 +231,5 @@
231231
`endif
232232
// pragma translate_on
233233
// resetGen end
234+
warning: Clash.Signal.Internal.resetGenN can not be synthesized to hardware!
234235
workInfo: Always

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

+6-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Copyright : (C) 2013-2016, University of Twente,
33
2016-2019, Myrtle Software,
44
2017-2022, Google Inc.
55
2020 , Ben Gamari,
6-
2021 , QBayLogic B.V.
6+
2021-2023, QBayLogic B.V.
77
License : BSD2 (see the file LICENSE)
88
Maintainer : QBayLogic B.V. <[email protected]>
99
@@ -338,9 +338,11 @@ systemClockGen
338338
:: Clock System
339339
systemClockGen = clockGen
340340

341-
-- | Reset generator for the 'System' clock domain.
341+
-- | Reset generator for use in simulation, for the 'System' clock domain.
342+
-- Asserts the reset for a single cycle.
342343
--
343-
-- __NB__: should only be used for simulation or the \testBench\ function.
344+
-- __NB__: While this can be used in the @testBench@ function, it cannot be
345+
-- synthesized to hardware.
344346
--
345347
-- === __Example__
346348
--
@@ -353,7 +355,7 @@ systemClockGen = clockGen
353355
-- where
354356
-- testInput = pure ((1 :> 2 :> 3 :> Nil) :> (4 :> 5 :> 6 :> Nil) :> Nil)
355357
-- expectedOutput = outputVerifier' ((1:>2:>3:>4:>5:>6:>Nil):>Nil)
356-
-- done = exposeClockResetEnable (expectedOutput (topEntity <$> testInput)) clk rst
358+
-- done = exposeClockResetEnable (expectedOutput (topEntity \<$\> testInput)) clk rst
357359
-- clk = tbSystemClockGen (not <\$\> done)
358360
-- rst = 'systemResetGen'
359361
-- @

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

+11-4
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ import Clash.XException
194194
>>> import Clash.Prelude (SSymbol(..))
195195
>>> import Clash.Signal.Internal
196196
>>> import Clash.Promoted.Nat
197+
>>> import Clash.Promoted.Nat.Literals
197198
>>> import Clash.XException
198199
>>> import Data.Ratio (Ratio)
199200
>>> import Numeric.Natural (Natural)
@@ -1016,7 +1017,8 @@ tbDynamicClockGen periods ena =
10161017
{-# ANN tbDynamicClockGen hasBlackBox #-}
10171018

10181019

1019-
-- | Reset generator
1020+
-- | Reset generator for simulation purposes. Asserts the reset for a single
1021+
-- cycle.
10201022
--
10211023
-- To be used like:
10221024
--
@@ -1026,26 +1028,31 @@ tbDynamicClockGen periods ena =
10261028
--
10271029
-- See 'Clash.Explicit.Testbench.tbClockGen' for example usage.
10281030
--
1031+
-- __NB__: While this can be used in the @testBench@ function, it cannot be
1032+
-- synthesized to hardware.
10291033
resetGen
10301034
:: forall dom
10311035
. KnownDomain dom
10321036
=> Reset dom
10331037
resetGen = resetGenN (SNat @1)
10341038
{-# INLINE resetGen #-}
10351039

1036-
-- | Generate reset that's asserted for the first /n/ cycles.
1040+
-- | Reset generator for simulation purposes. Asserts the reset for the first /n/
1041+
-- cycles.
10371042
--
10381043
-- To be used like:
10391044
--
10401045
-- @
1041-
-- rstSystem5 = resetGen @System (SNat @5)
1046+
-- rstSystem5 = resetGen @System d5
10421047
-- @
10431048
--
10441049
-- Example usage:
10451050
--
1046-
-- >>> sampleN 7 (unsafeToHighPolarity (resetGenN @System (SNat @3)))
1051+
-- >>> sampleN 7 (unsafeToHighPolarity (resetGenN @System d3))
10471052
-- [True,True,True,False,False,False,False]
10481053
--
1054+
-- __NB__: While this can be used in the @testBench@ function, it cannot be
1055+
-- synthesized to hardware.
10491056
resetGenN
10501057
:: forall dom n
10511058
. (KnownDomain dom, 1 <= n)

0 commit comments

Comments
 (0)