playground/clash/FuncSyth.hs

112 lines
4.1 KiB
Haskell

-- Trying to see if a function type is synthesizable
-- Verdict: No, it isn't (compiles though).
import Clash.Prelude
tf :: (Int -> Bool) -> Int -> ((Int -> Bool), Bool)
tf s inp = (s', out)
where
out = s inp
s' = \x -> not $ s x
mon
:: SystemClockResetEnable
=> Signal System Int
-> Signal System Bool
mon = mealy tf (\x -> True)
topEntity
:: Clock System
-> Reset System
-> Enable System
-> Signal System Int
-> Signal System Bool
topEntity = exposeClockResetEnable mon
{-
GHC: Setting up GHC took: 0.673s
GHC: Compiling and loading modules took: 0.360s
Clash: Parsing and compiling primitives took 0.318s
GHC+Clash: Loading modules cumulatively took 1.459s
Clash: Compiling Main.topEntity
Clash: Normalization took 0.028s
/home/username/gits/playground/clash/FuncSyth.hs:26:1: error:
Clash.Netlist(296): Clash.Netlist.Util(184): Not in normal form: no Letrec:
λ(clk[6989586621679047087] :: Clash.Signal.Internal.Clock[8214565720323787981]
"System") ->
λ(rst[6989586621679047088] :: Clash.Signal.Internal.Reset[8214565720323788005]
"System") ->
λ(en[6989586621679047089] :: Clash.Signal.Internal.Enable[8214565720323787996]
"System") ->
λ(eta[4755801206503243777] :: Clash.Signal.Internal.Signal[8214565720323788026]
"System"
GHC.Types.Int[3674937295934324766]) ->
<prefixName>"mon_ds"
<prefixName>"tf"
λ(c$arg[37] :: GHC.Types.Int[3674937295934324766]) ->
let
result[14304] :: GHC.Types.Bool[3674937295934324744]
= Clash.Signal.Internal.register# @"System"
@(GHC.Types.Int[3674937295934324766]
-> GHC.Types.Bool[3674937295934324744])
(Clash.Normalize.Primitives.removedArg
@(Clash.Signal.Internal.KnownDomain[8214565720323788003]
"System"))
(Clash.Normalize.Primitives.removedArg
@(Clash.XException.NFDataX[8214565720323788071]
(GHC.Types.Int[3674937295934324766]
-> GHC.Types.Bool[3674937295934324744])))
<prefixName>"$p1(%,,%)"
clk[6989586621679047087][LocalId]
<prefixName>"$p2(%,,%)"
rst[6989586621679047088][LocalId]
<prefixName>"$p3(%,,%)"
en[6989586621679047089][LocalId]
(λ(x[6989586621679042492] :: GHC.Types.Int[3674937295934324766]) ->
GHC.Types.True[3891110078048108589])
(λ(x[6989586621679042492] :: GHC.Types.Int[3674937295934324766]) ->
GHC.Types.True[3891110078048108589])
(λ(c$arg[1998] :: GHC.Types.Int[3674937295934324766]) ->
<prefixName>"mon_ds"
<prefixName>"tf"
letrec
c$app_arg[2002] :: GHC.Types.Bool[3674937295934324744]
= c$Main.mon_s[20][GlobalId]
eta[4755801206503243777][LocalId]
clk[6989586621679047087][LocalId]
rst[6989586621679047088][LocalId]
en[6989586621679047089][LocalId]
result[2003] :: GHC.Types.Bool[3674937295934324744]
= <prefixName>"not"
GHC.Classes.not
c$app_arg[2002][LocalId]
in result[2003][LocalId])
c$arg[37][LocalId]
in result[14304][LocalId]
Which has type:
Clash.Signal.Internal.Clock[8214565720323787981]
"System"
-> Clash.Signal.Internal.Reset[8214565720323788005]
"System"
-> Clash.Signal.Internal.Enable[8214565720323787996]
"System"
-> Clash.Signal.Internal.Signal[8214565720323788026]
"System"
GHC.Types.Int[3674937295934324766]
-> GHC.Types.Int[3674937295934324766]
-> GHC.Types.Bool[3674937295934324744]
The source location of the error is not exact, only indicative, as it is acquired
after optimizations. The actual location of the error can be in a function that is
inlined. To prevent inlining of those functions, annotate them with a NOINLINE pragma.
|
26 | topEntity = exposeClockResetEnable mon
| ^^^^^^^^^
-}