Skip to content

Commit 2c9b934

Browse files
authored
Merge pull request #3022 from clash-lang/fix_3021
Make `ensureSpine` on Clash number types synthesizable
2 parents dc70c15 + fddfa89 commit 2c9b934

File tree

7 files changed

+14
-0
lines changed

7 files changed

+14
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
FIXED: Clash will no longer error out when converting `ensureSpine` on Clash number types to HDL [#3021](https://github.com/clash-lang/clash-compiler/issues/3021)

clash-prelude/src/Clash/Sized/Internal/BitVector.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ instance ShowX Bit where
298298

299299
instance NFDataX Bit where
300300
deepErrorX = errorX
301+
ensureSpine = unpack# . xToBV . pack#
301302
rnfX = rwhnfX
302303
hasUndefined bv = isLeft (isX bv) || unsafeMask# bv /= 0
303304

clash-prelude/src/Clash/Sized/Internal/Index.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,7 @@ instance ShowX (Index n) where
557557

558558
instance NFDataX (Index n) where
559559
deepErrorX = errorX
560+
ensureSpine = id
560561
rnfX = rwhnfX
561562

562563
-- | None of the 'Read' class' methods are synthesizable.

clash-prelude/src/Clash/Sized/Internal/Signed.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ data Signed (n :: Nat) =
194194

195195
instance NFDataX (Signed n) where
196196
deepErrorX = errorX
197+
ensureSpine = id
197198
rnfX = rwhnfX
198199

199200
-- See: https://github.com/clash-lang/clash-compiler/pull/2511

clash-prelude/src/Clash/Sized/Internal/Unsigned.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ instance ShowX (Unsigned n) where
233233

234234
instance NFDataX (Unsigned n) where
235235
deepErrorX = errorX
236+
ensureSpine = id
236237
rnfX = rwhnfX
237238

238239
-- | None of the 'Read' class' methods are synthesizable.

tests/Main.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,8 @@ runClashTest = defaultMain
671671
, runTest "T2988" def{hdlSim=[]}
672672
, outputTest "T3008" def{hdlSim=[]}
673673
, outputTest "T3011" def{hdlSim=[]}
674+
, let _opts = def { hdlTargets = [VHDL], hdlLoad = [], hdlSim = []}
675+
in runTest "T3021" _opts
674676
] <>
675677
if compiledWith == Cabal then
676678
-- This tests fails without environment files present, which are only

tests/shouldwork/Issues/T3021.hs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module T3021 where
2+
3+
import Clash.Prelude
4+
5+
topEntity ::
6+
(Unsigned 8, Signed 8, Index 8, Bit) -> (Unsigned 8, Signed 8, Index 8, Bit)
7+
topEntity = ensureSpine

0 commit comments

Comments
 (0)