[clash] a few clash experiments
This commit is contained in:
parent
a422453130
commit
89a3ab876a
|
@ -0,0 +1,77 @@
|
||||||
|
-- Trying to see if a function type is synthesizable when enclosed
|
||||||
|
-- within a type with NFDataX
|
||||||
|
--
|
||||||
|
-- Verdict: No, it isn't (compiles though).
|
||||||
|
|
||||||
|
import Clash.Prelude
|
||||||
|
|
||||||
|
data Foo
|
||||||
|
= Foo (Int -> Bool)
|
||||||
|
deriving (Generic, NFDataX)
|
||||||
|
|
||||||
|
tf :: Foo -> Int -> (Foo, Bool)
|
||||||
|
tf (Foo f) inp = (s', out)
|
||||||
|
where
|
||||||
|
out = f inp
|
||||||
|
s' = Foo $ \x -> not $ f x
|
||||||
|
|
||||||
|
mon
|
||||||
|
:: SystemClockResetEnable
|
||||||
|
=> Signal System Int
|
||||||
|
-> Signal System Bool
|
||||||
|
mon = mealy tf $ Foo (\x -> True)
|
||||||
|
|
||||||
|
topEntity
|
||||||
|
:: Clock System
|
||||||
|
-> Reset System
|
||||||
|
-> Enable System
|
||||||
|
-> Signal System Int
|
||||||
|
-> Signal System Bool
|
||||||
|
topEntity = exposeClockResetEnable mon
|
||||||
|
|
||||||
|
{-
|
||||||
|
GHC: Setting up GHC took: 0.688s
|
||||||
|
GHC: Compiling and loading modules took: 0.970s
|
||||||
|
Clash: Parsing and compiling primitives took 0.203s
|
||||||
|
GHC+Clash: Loading modules cumulatively took 2.085s
|
||||||
|
Clash: Compiling Main.topEntity
|
||||||
|
Clash.Normalize.Transformations.Inline(523): InlineNonRep: c$Main.mon_ds[19] already inlined 20 times in: Main.mon[8214565720323816241]
|
||||||
|
. The type of the subject is:
|
||||||
|
|
||||||
|
GHC.Tuple.(,)[3746994889972252676]
|
||||||
|
Main.Foo[8214565720323816238]
|
||||||
|
GHC.Types.Bool[3674937295934324744]
|
||||||
|
|
||||||
|
Function Main.mon[8214565720323816241] will not reach a normal form and compilation
|
||||||
|
might fail.
|
||||||
|
|
||||||
|
Run with '-fclash-inline-limit=N' to increase the inline limit to N.
|
||||||
|
Clash.Normalize.Transformations.Inline(523): InlineNonRep: c$Main.mon_ds[19] already inlined 20 times in: Main.mon[8214565720323816241]
|
||||||
|
. The type of the subject is:
|
||||||
|
|
||||||
|
GHC.Tuple.(,)[3746994889972252676]
|
||||||
|
Main.Foo[8214565720323816238]
|
||||||
|
GHC.Types.Bool[3674937295934324744]
|
||||||
|
|
||||||
|
Function Main.mon[8214565720323816241] will not reach a normal form and compilation
|
||||||
|
might fail.
|
||||||
|
|
||||||
|
Run with '-fclash-inline-limit=N' to increase the inline limit to N.
|
||||||
|
Clash.Normalize.Transformations.Inline(523): InlineNonRep: c$Main.mon_ds[19] already inlined 20 times in: Main.mon[8214565720323816241]
|
||||||
|
. The type of the subject is:
|
||||||
|
|
||||||
|
GHC.Tuple.(,)[3746994889972252676]
|
||||||
|
Main.Foo[8214565720323816238]
|
||||||
|
GHC.Types.Bool[3674937295934324744]
|
||||||
|
|
||||||
|
Function Main.mon[8214565720323816241] will not reach a normal form and compilation
|
||||||
|
might fail.
|
||||||
|
|
||||||
|
Run with '-fclash-inline-limit=N' to increase the inline limit to N.
|
||||||
|
|
||||||
|
<no location info>: error:
|
||||||
|
Clash error call:
|
||||||
|
Clash.Core.Type(395): Report as bug: not a FunTy
|
||||||
|
CallStack (from HasCallStack):
|
||||||
|
error, called at src/Clash/Core/Type.hs:395:20 in clash-lib-1.6.3-4vM2gwSsWPHufxjlmfu4S:Clash.Core.Type
|
||||||
|
-}
|
|
@ -0,0 +1,111 @@
|
||||||
|
-- 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
|
||||||
|
| ^^^^^^^^^
|
||||||
|
-}
|
|
@ -0,0 +1,42 @@
|
||||||
|
{-# LANGUAGE StandaloneDeriving #-}
|
||||||
|
-- Trying to see if void is synthesizable
|
||||||
|
-- Verdict: Yes it is.
|
||||||
|
|
||||||
|
module VoidSynth where
|
||||||
|
|
||||||
|
import Clash.Prelude
|
||||||
|
import Clash.Explicit.Testbench
|
||||||
|
import Data.Void
|
||||||
|
|
||||||
|
deriving instance NFDataX Void
|
||||||
|
|
||||||
|
tf :: Maybe Void -> Int -> (Maybe Void, Bool)
|
||||||
|
tf s inp = case s of
|
||||||
|
Nothing -> (Nothing, False)
|
||||||
|
_ -> (Nothing, True)
|
||||||
|
|
||||||
|
mon
|
||||||
|
:: SystemClockResetEnable
|
||||||
|
=> Signal System Int
|
||||||
|
-> Signal System Bool
|
||||||
|
mon = mealy tf Nothing
|
||||||
|
|
||||||
|
topEntity
|
||||||
|
:: Clock System
|
||||||
|
-> Reset System
|
||||||
|
-> Enable System
|
||||||
|
-> Signal System Int
|
||||||
|
-> Signal System Bool
|
||||||
|
topEntity = exposeClockResetEnable mon
|
||||||
|
|
||||||
|
{-
|
||||||
|
GHC: Setting up GHC took: 0.665s
|
||||||
|
GHC: Compiling and loading modules took: 0.699s
|
||||||
|
Clash: Parsing and compiling primitives took 0.275s
|
||||||
|
GHC+Clash: Loading modules cumulatively took 1.750s
|
||||||
|
Clash: Compiling Main.topEntity
|
||||||
|
Clash: Normalization took 0.004s
|
||||||
|
Clash: Netlist generation took 0.000s
|
||||||
|
Clash: Compiling Main.topEntity took 0.027s
|
||||||
|
Clash: Total compilation took 1.778s
|
||||||
|
-}
|
Loading…
Reference in New Issue