Skip to content

Commit

Permalink
Minimum GHC version: 9.6
Browse files Browse the repository at this point in the history
Rationale:
 - With at least GHC 9.2, we can use `OverloadedRecordDot`
 - With at least GHC 9.4, we can use `OPAQUE`
 - GHC 9.4 itself doesn't work well with Clash. Versions 9.4.8 and
   above are extremely slow.

Possibly there are several more good reasons as well, this list is not
meant to be exhaustive.

Using `--prefer-oldest`, I could not even get Cabal to give me an older
`prettyprinter` package than 1.7.0 with GHC 9.6.1. So raising the lower
bound of `prettyprinter` is completely harmless.
  • Loading branch information
DigitalBrains1 committed Jan 30, 2025
1 parent d9da6d8 commit f88d19c
Show file tree
Hide file tree
Showing 32 changed files with 69 additions and 194 deletions.
12 changes: 0 additions & 12 deletions .ci/cabal.project.local
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,6 @@ package *
-- Dynamic executables save oozles of space when archiving it on CI
executable-dynamic: True

package clash-prelude
flags: -workaround-ghc-mmap-crash

package clash-lib
flags: -workaround-ghc-mmap-crash

package clash-ghc
flags: -workaround-ghc-mmap-crash

package clash-cores
ghc-options: -Werror
tests: True
Expand All @@ -25,6 +16,3 @@ package clash-cores
-- Cabal-the-library in combination with custom setup where the library path
-- is not added to the RPATH
executable-dynamic: False

package clash-testsuite
flags: -workaround-ghc-mmap-crash
11 changes: 0 additions & 11 deletions .ci/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@ cabal v2-update | tee cabal_update_output
if [ ! -f cabal.project.local ]; then
cp .ci/cabal.project.local .

set +u
if [[ "$WORKAROUND_GHC_MMAP_CRASH" == "yes" ]]; then
sed -i 's/-workaround-ghc-mmap-crash/+workaround-ghc-mmap-crash/g' cabal.project.local
fi
set -u

# Fix index-state to prevent rebuilds if Hackage changes between build -> test.
# Note we can't simply set it to a timestamp of "now", as Cabal will error out
# when its index state is older than what's mentioned in cabal.project(.local).
Expand All @@ -45,11 +39,6 @@ cat cabal.project.local
rm -f $HOME/.cabal/config
cabal user-config init
sed -i "s/-- ghc-options:/ghc-options: -j$THREADS/g" $HOME/.cabal/config
set +u
if [[ "$WORKAROUND_GHC_MMAP_CRASH" == "yes" ]]; then
sed -i "s/ghc-options:/ghc-options: +RTS -xm20000000 -RTS -with-rtsopts=-xm20000000/g" $HOME/.cabal/config
fi
set -u
sed -i "s/^[- ]*jobs:.*/jobs: $CABAL_JOBS/g" $HOME/.cabal/config
sed -i "/remote-repo-cache:.*/d" $HOME/.cabal/config
cat $HOME/.cabal/config
10 changes: 2 additions & 8 deletions clash-cores.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,6 @@ common basic-config
TypeFamilies
TypeOperators

-- See https://github.com/clash-lang/clash-compiler/pull/2511
if impl(ghc >= 9.4)
CPP-Options: -DCLASH_OPAQUE=OPAQUE
else
CPP-Options: -DCLASH_OPAQUE=NOINLINE

ghc-options:
-Wall -Wcompat

Expand Down Expand Up @@ -111,7 +105,7 @@ common basic-config
-fplugin GHC.TypeLits.KnownNat.Solver

build-depends:
base >= 4.10 && < 5,
base >= 4.18 && < 5,
constraints >= 0.9 && < 1.0,
containers >=0.5 && <0.8,
ghc-typelits-extra >= 0.3.2,
Expand Down Expand Up @@ -202,7 +196,7 @@ library
ghc-prim >= 0.3.1.0 && < 1.0,
mtl >= 2.1.1 && < 2.4,
pretty-show,
prettyprinter >= 1.2.0.1 && < 1.8,
prettyprinter >= 1.7 && < 1.8,
prettyprinter-interp ^>= 0.2,
reducers >= 3.12.2 && < 4.0,
text >= 1.2.2 && < 2.2,
Expand Down
6 changes: 0 additions & 6 deletions hdl-tests/cores-hdl-tests.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,3 @@ executable cores-hdl-tests
else
build-depends:
singletons < 3.0

-- See https://github.com/clash-lang/clash-compiler/pull/2511
if impl(ghc >= 9.4)
CPP-Options: -DCLASH_OPAQUE=OPAQUE
else
CPP-Options: -DCLASH_OPAQUE=NOINLINE
8 changes: 2 additions & 6 deletions hdl-tests/shouldwork/Xilinx/DcFifo/Basic.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
{-# LANGUAGE CPP #-}

module Basic where

import Clash.Explicit.Prelude
Expand Down Expand Up @@ -50,8 +48,7 @@ topEntity clk rst writeData rEnable =
, dcOverflow=True
, dcUnderflow=True
}
-- See: https://github.com/clash-lang/clash-compiler/pull/2511
{-# CLASH_OPAQUE topEntity #-}
{-# OPAQUE topEntity #-}

testBench ::
Signal XilinxSystem Bool
Expand Down Expand Up @@ -82,8 +79,7 @@ testBench = done
(fDone <$> fsmOut)
clk = tbClockGen (not <$> done)
en = enableGen
-- See: https://github.com/clash-lang/clash-compiler/pull/2511
{-# CLASH_OPAQUE testBench #-}
{-# OPAQUE testBench #-}

data FsmOut = FsmOut
{ fDone :: Bool
Expand Down
28 changes: 9 additions & 19 deletions hdl-tests/shouldwork/Xilinx/DcFifo/Lfsr.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# OPTIONS_GHC -Wno-orphans #-}
module Lfsr where
Expand Down Expand Up @@ -37,8 +36,7 @@ lfsrF clk rst ena seed = msb <$> r
five, three, two, zero :: Unsigned 16
(five, three, two, zero) = (5, 3, 2, 0)
lfsrFeedback = s ! five `xor` s ! three `xor` s ! two `xor` s ! zero
-- See: https://github.com/clash-lang/clash-compiler/pull/2511
{-# CLASH_OPAQUE lfsrF #-}
{-# OPAQUE lfsrF #-}

fifoSampler ::
KnownDomain dom =>
Expand All @@ -60,8 +58,7 @@ fifoSampler clk rst ena stalls inps =
where
maybeData = readLastCycle `orNothing` readData
readNow = not stall && not fifoEmpty
-- See: https://github.com/clash-lang/clash-compiler/pull/2511
{-# CLASH_OPAQUE fifoSampler #-}
{-# OPAQUE fifoSampler #-}

-- | Drives Xilinx FIFO with an ascending sequence of 'BitVector's. Stalls
-- intermittently based on stall input.
Expand Down Expand Up @@ -163,41 +160,34 @@ fifoVerifier clk rst ena actual = done0
done0 =
assert clk rst "Doesn't time out" stuck (pure False) $
assert clk rst "fifoVerifier" actual expected0 done
-- See: https://github.com/clash-lang/clash-compiler/pull/2511
{-# CLASH_OPAQUE fifoVerifier #-}
{-# OPAQUE fifoVerifier #-}

topEntity_17_2 :: ConfiguredFifo (BitVector 16) Dom17 Dom2
topEntity_17_2 = dcFifo defConfig
-- See: https://github.com/clash-lang/clash-compiler/pull/2511
{-# CLASH_OPAQUE topEntity_17_2 #-}
{-# OPAQUE topEntity_17_2 #-}
{-# ANN topEntity_17_2 (defSyn "topEntity_17_2") #-}

testBench_17_2 :: Signal Dom17 Bool
testBench_17_2 = mkTestBench topEntity_17_2
-- See: https://github.com/clash-lang/clash-compiler/pull/2511
{-# CLASH_OPAQUE testBench_17_2 #-}
{-# OPAQUE testBench_17_2 #-}
{-# ANN testBench_17_2 (TestBench 'topEntity_17_2) #-}

topEntity_2_17 :: ConfiguredFifo (BitVector 16) Dom2 Dom17
topEntity_2_17 = dcFifo defConfig
-- See: https://github.com/clash-lang/clash-compiler/pull/2511
{-# CLASH_OPAQUE topEntity_2_17 #-}
{-# OPAQUE topEntity_2_17 #-}
{-# ANN topEntity_2_17 (defSyn "topEntity_2_17") #-}

testBench_2_17 :: Signal Dom2 Bool
testBench_2_17 = mkTestBench topEntity_2_17
-- See: https://github.com/clash-lang/clash-compiler/pull/2511
{-# CLASH_OPAQUE testBench_2_17 #-}
{-# OPAQUE testBench_2_17 #-}
{-# ANN testBench_2_17 (TestBench 'topEntity_2_17) #-}

topEntity_2_2 :: ConfiguredFifo (Unsigned 16) Dom2 Dom2
topEntity_2_2 = dcFifo defConfig
-- See: https://github.com/clash-lang/clash-compiler/pull/2511
{-# CLASH_OPAQUE topEntity_2_2 #-}
{-# OPAQUE topEntity_2_2 #-}
{-# ANN topEntity_2_2 (defSyn "topEntity_2_2") #-}

testBench_2_2 :: Signal Dom2 Bool
testBench_2_2 = mkTestBench topEntity_2_2
-- See: https://github.com/clash-lang/clash-compiler/pull/2511
{-# CLASH_OPAQUE testBench_2_2 #-}
{-# OPAQUE testBench_2_2 #-}
{-# ANN testBench_2_2 (TestBench 'topEntity_2_2) #-}
6 changes: 2 additions & 4 deletions hdl-tests/shouldwork/Xilinx/DnaPortE2.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
{-# LANGUAGE CPP #-}

module DnaPortE2 where

import Clash.Explicit.Prelude
Expand All @@ -11,7 +9,7 @@ topEntity ::
Reset XilinxSystem ->
Signal XilinxSystem (Maybe (BitVector 96))
topEntity clk rst = readDnaPortE2 clk rst enableGen simDna2
{-# CLASH_OPAQUE topEntity #-}
{-# OPAQUE topEntity #-}

testBench :: Signal XilinxSystem Bool
testBench = done
Expand All @@ -22,4 +20,4 @@ testBench = done
done = outputVerifier' clk rst expected (topEntity clk rst)
clk = tbClockGen (not <$> done)
rst = noReset
{-# CLASH_OPAQUE testBench #-}
{-# OPAQUE testBench #-}
38 changes: 12 additions & 26 deletions hdl-tests/shouldwork/Xilinx/Floating.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ License : BSD2 (see the file LICENSE)
Maintainer : QBayLogic B.V. <[email protected]>
-}

{-# LANGUAGE CPP #-}

{-# OPTIONS_GHC -fconstraint-solver-iterations=10 -Wall -Werror #-}

module Floating where
Expand Down Expand Up @@ -138,8 +136,7 @@ addBasic
-> DSignal XilinxSystem 0 Float
-> DSignal XilinxSystem F.AddDefDelay Float
addBasic clk x y = withClock clk $ withEnable enableGen $ F.add x y
-- See: https://github.com/clash-lang/clash-compiler/pull/2511
{-# CLASH_OPAQUE addBasic #-}
{-# OPAQUE addBasic #-}
{-# ANN addBasic (binaryTopAnn "addBasic") #-}

addBasicTB :: Signal XilinxSystem Bool
Expand All @@ -157,8 +154,7 @@ addEnable
-> DSignal XilinxSystem 0 Float
-> DSignal XilinxSystem 11 Float
addEnable clk en x y = withClock clk $ withEnable en $ F.add x y
-- See: https://github.com/clash-lang/clash-compiler/pull/2511
{-# CLASH_OPAQUE addEnable #-}
{-# OPAQUE addEnable #-}
{-# ANN addEnable (binaryEnTopAnn "addEnable") #-}

addEnableTB :: Signal XilinxSystem Bool
Expand Down Expand Up @@ -198,8 +194,7 @@ addShortPL
-> DSignal XilinxSystem 6 Float
addShortPL clk x y =
withClock clk $ withEnable enableGen $ F.addWith F.defConfig x y
-- See: https://github.com/clash-lang/clash-compiler/pull/2511
{-# CLASH_OPAQUE addShortPL #-}
{-# OPAQUE addShortPL #-}
{-# ANN addShortPL (binaryTopAnn "addShortPL") #-}

addShortPLTB :: Signal XilinxSystem Bool
Expand All @@ -217,8 +212,7 @@ subBasic
-> DSignal XilinxSystem 0 Float
-> DSignal XilinxSystem F.SubDefDelay Float
subBasic clk x y = withClock clk $ withEnable enableGen $ F.sub x y
-- See: https://github.com/clash-lang/clash-compiler/pull/2511
{-# CLASH_OPAQUE subBasic #-}
{-# OPAQUE subBasic #-}
{-# ANN subBasic (binaryTopAnn "subBasic") #-}

subBasicTB :: Signal XilinxSystem Bool
Expand All @@ -235,8 +229,7 @@ mulBasic
-> DSignal XilinxSystem 0 Float
-> DSignal XilinxSystem F.MulDefDelay Float
mulBasic clk x y = withClock clk $ withEnable enableGen $ F.mul x y
-- See: https://github.com/clash-lang/clash-compiler/pull/2511
{-# CLASH_OPAQUE mulBasic #-}
{-# OPAQUE mulBasic #-}
{-# ANN mulBasic (binaryTopAnn "mulBasic") #-}

mulBasicTB :: Signal XilinxSystem Bool
Expand All @@ -253,8 +246,7 @@ divBasic
-> DSignal XilinxSystem 0 Float
-> DSignal XilinxSystem F.DivDefDelay Float
divBasic clk x y = withClock clk $ withEnable enableGen $ F.div x y
-- See: https://github.com/clash-lang/clash-compiler/pull/2511
{-# CLASH_OPAQUE divBasic #-}
{-# OPAQUE divBasic #-}
{-# ANN divBasic (binaryTopAnn "divBasic") #-}

divBasicTB :: Signal XilinxSystem Bool
Expand All @@ -272,8 +264,7 @@ compareBasic
-> DSignal XilinxSystem F.CompareDefDelay F.Ordering
compareBasic clk x y =
withClock clk $ withEnable enableGen $ F.compare x y
-- See: https://github.com/clash-lang/clash-compiler/pull/2511
{-# CLASH_OPAQUE compareBasic #-}
{-# OPAQUE compareBasic #-}
{-# ANN compareBasic (binaryTopAnn "compareBasic") #-}

compareBasicTB :: Signal XilinxSystem Bool
Expand All @@ -288,8 +279,7 @@ compareEnable
-> DSignal XilinxSystem 0 Float
-> DSignal XilinxSystem F.CompareDefDelay F.Ordering
compareEnable clk en x y = withClock clk $ withEnable en $ F.compare x y
-- See: https://github.com/clash-lang/clash-compiler/pull/2511
{-# CLASH_OPAQUE compareEnable #-}
{-# OPAQUE compareEnable #-}
{-# ANN compareEnable (binaryEnTopAnn "compareEnable") #-}

compareEnableTB :: Signal XilinxSystem Bool
Expand All @@ -313,8 +303,7 @@ fromUBasic
-> DSignal XilinxSystem 0 (Unsigned 32)
-> DSignal XilinxSystem F.FromU32DefDelay Float
fromUBasic clk x = withClock clk $ withEnable enableGen $ F.fromU32 x
-- See: https://github.com/clash-lang/clash-compiler/pull/2511
{-# CLASH_OPAQUE fromUBasic #-}
{-# OPAQUE fromUBasic #-}
{-# ANN fromUBasic (unaryTopAnn "fromUBasic") #-}

fromUBasicTB :: Signal XilinxSystem Bool
Expand All @@ -339,8 +328,7 @@ fromUEnable
-> DSignal XilinxSystem 0 (Unsigned 32)
-> DSignal XilinxSystem 5 Float
fromUEnable clk en x = withClock clk $ withEnable en $ F.fromU32 x
-- See: https://github.com/clash-lang/clash-compiler/pull/2511
{-# CLASH_OPAQUE fromUEnable #-}
{-# OPAQUE fromUEnable #-}
{-# ANN fromUEnable (unaryEnTopAnn "fromUEnable") #-}

fromUEnableTB :: Signal XilinxSystem Bool
Expand Down Expand Up @@ -373,8 +361,7 @@ fromSBasic
-> DSignal XilinxSystem 0 (Signed 32)
-> DSignal XilinxSystem F.FromS32DefDelay Float
fromSBasic clk x = withClock clk $ withEnable enableGen $ F.fromS32 x
-- See: https://github.com/clash-lang/clash-compiler/pull/2511
{-# CLASH_OPAQUE fromSBasic #-}
{-# OPAQUE fromSBasic #-}
{-# ANN fromSBasic (unaryTopAnn "fromSBasic") #-}

fromSBasicTB :: Signal XilinxSystem Bool
Expand All @@ -399,8 +386,7 @@ fromSEnable
-> DSignal XilinxSystem 0 (Signed 32)
-> DSignal XilinxSystem 6 Float
fromSEnable clk en x = withClock clk $ withEnable en $ F.fromS32 x
-- See: https://github.com/clash-lang/clash-compiler/pull/2511
{-# CLASH_OPAQUE fromSEnable #-}
{-# OPAQUE fromSEnable #-}
{-# ANN fromSEnable (unaryEnTopAnn "fromSEnable") #-}

fromSEnableTB :: Signal XilinxSystem Bool
Expand Down
4 changes: 1 addition & 3 deletions hdl-tests/shouldwork/Xilinx/Ila.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE OverloadedStrings #-}

module Ila where
Expand All @@ -20,8 +19,7 @@ type Dom = XilinxSystem

top :: "result" ::: Unsigned 8
top = 0
-- See: https://github.com/clash-lang/clash-compiler/pull/2511
{-# CLASH_OPAQUE top #-}
{-# OPAQUE top #-}
makeTopEntity 'top

oneCounter :: IlaConfig 1 -> Clock Dom -> Signal Dom ()
Expand Down
10 changes: 3 additions & 7 deletions hdl-tests/shouldwork/Xilinx/TdpBlockRam.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
{-# OPTIONS_GHC -Wno-orphans #-}

{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE ViewPatterns #-}

module TdpBlockRam where
Expand All @@ -27,8 +26,7 @@ topEntity
tdpbram
clkA (toEnable enA) addrA byteEnaA datA
clkB (toEnable enB) addrB byteEnaB datB
-- See: https://github.com/clash-lang/clash-compiler/pull/2511
{-# CLASH_OPAQUE topEntity #-}
{-# OPAQUE topEntity #-}

tb ::
( KnownNat n0, KnownNat n1, KnownNat n2, KnownNat n3
Expand Down Expand Up @@ -72,8 +70,7 @@ tb inputA expectedA inputB expectedB =
clkB :: Clock B
clkB = tbClockGen (not <$> doneB)

-- See: https://github.com/clash-lang/clash-compiler/pull/2511
{-# CLASH_OPAQUE normalWritesTB #-}
{-# OPAQUE normalWritesTB #-}
{-# ANN normalWritesTB (TestBench 'topEntity) #-}
-- | Test bench doing some (non-overlapping) writes and reads on two ports, either
-- with the byte enable fully set, or fully unset.
Expand Down Expand Up @@ -124,8 +121,7 @@ normalWritesTB = tb inputA expectedA inputB expectedB
:> Nil
) ++ repeat @10 noOp

-- See: https://github.com/clash-lang/clash-compiler/pull/2511
{-# CLASH_OPAQUE writeEnableWritesTB #-}
{-# OPAQUE writeEnableWritesTB #-}
{-# ANN writeEnableWritesTB (TestBench 'topEntity) #-}
-- | Test bench doing some (non-overlapping) writes and reads on two ports, with
-- varying byte enables.
Expand Down
Loading

0 comments on commit f88d19c

Please sign in to comment.