module ForSyDe.Atom.MoC.SDF.BDF (
bSwitch, bSelect,
iSwitch2, iSwitch3, iSwitch4,
iSelect2, iSelect3, iSelect4
) where
import ForSyDe.Atom.MoC.SDF.SADF
import ForSyDe.Atom.MoC.SDF.Core
bSwitch :: Prod -> Signal Bool -> Signal a -> (Signal a, Signal a)
bSwitch :: Prod -> Signal Bool -> Signal a -> (Signal a, Signal a)
bSwitch p :: Prod
p sb :: Signal Bool
sb = Signal (Prod, (Prod, Prod), [a] -> ([a], [a]))
-> Signal a -> (Signal a, Signal a)
forall a1 b1 b2.
Signal (Prod, (Prod, Prod), [a1] -> ([b1], [b2]))
-> Signal a1 -> (Signal b1, Signal b2)
kernel12 Signal (Prod, (Prod, Prod), [a] -> ([a], [a]))
forall a. Signal (Prod, (Prod, Prod), [a] -> ([a], [a]))
cSw
where cSw :: Signal (Prod, (Prod, Prod), [a] -> ([a], [a]))
cSw = Prod
-> (Bool -> [Bool] -> Bool)
-> (Bool -> (Prod, [(Prod, (Prod, Prod), [a] -> ([a], [a]))]))
-> Bool
-> Signal Bool
-> Signal (Prod, (Prod, Prod), [a] -> ([a], [a]))
forall s a1 y.
Prod
-> (s -> [a1] -> s)
-> (s -> (Prod, [y]))
-> s
-> Signal a1
-> Signal y
detector11 1 (\_ [s :: Bool
s] -> Bool
s) Bool -> (Prod, [(Prod, (Prod, Prod), [a] -> ([a], [a]))])
forall a a.
Num a =>
Bool -> (a, [(Prod, (Prod, Prod), [a] -> ([a], [a]))])
chSel Bool
False Signal Bool
sb
chSel :: Bool -> (a, [(Prod, (Prod, Prod), [a] -> ([a], [a]))])
chSel False = (1, [(Prod
p, (Prod
p,0), \d :: [a]
d -> ([a]
d,[]))])
chSel True = (1, [(Prod
p, (0,Prod
p), \d :: [a]
d -> ([],[a]
d))])
bSelect :: (Cons,Cons) -> Signal Bool -> Signal a -> Signal a -> Signal a
bSelect :: (Prod, Prod) -> Signal Bool -> Signal a -> Signal a -> Signal a
bSelect (c1 :: Prod
c1,c2 :: Prod
c2) sb :: Signal Bool
sb = Signal ((Prod, Prod), Prod, [a] -> [a] -> [a])
-> Signal a -> Signal a -> Signal a
forall a1 a2 b1.
Signal ((Prod, Prod), Prod, [a1] -> [a2] -> [b1])
-> Signal a1 -> Signal a2 -> Signal b1
kernel21 Signal ((Prod, Prod), Prod, [a] -> [a] -> [a])
forall p. Signal ((Prod, Prod), Prod, p -> p -> p)
cSel
where cSel :: Signal ((Prod, Prod), Prod, p -> p -> p)
cSel = Prod
-> (Bool -> [Bool] -> Bool)
-> (Bool -> (Prod, [((Prod, Prod), Prod, p -> p -> p)]))
-> Bool
-> Signal Bool
-> Signal ((Prod, Prod), Prod, p -> p -> p)
forall s a1 y.
Prod
-> (s -> [a1] -> s)
-> (s -> (Prod, [y]))
-> s
-> Signal a1
-> Signal y
detector11 1 (\_ [s :: Bool
s] -> Bool
s) Bool -> (Prod, [((Prod, Prod), Prod, p -> p -> p)])
forall a p.
Num a =>
Bool -> (a, [((Prod, Prod), Prod, p -> p -> p)])
chSel Bool
False Signal Bool
sb
chSel :: Bool -> (a, [((Prod, Prod), Prod, p -> p -> p)])
chSel False = (1, [((Prod
c1,0), Prod
c1, \d :: p
d _ -> p
d)])
chSel True = (1, [((0,Prod
c2), Prod
c2, \_ d :: p
d -> p
d)])
iSwitch2 :: Prod -> Signal Int -> Signal a -> (Signal a, Signal a)
iSwitch3 :: Prod -> Signal Int -> Signal a -> (Signal a, Signal a, Signal a)
iSwitch4 :: Prod -> Signal Int -> Signal a -> (Signal a, Signal a, Signal a, Signal a)
iSwitch2 :: Prod -> Signal Prod -> Signal a -> (Signal a, Signal a)
iSwitch2 p :: Prod
p sb :: Signal Prod
sb = Signal (Prod, (Prod, Prod), [a] -> ([a], [a]))
-> Signal a -> (Signal a, Signal a)
forall a1 b1 b2.
Signal (Prod, (Prod, Prod), [a1] -> ([b1], [b2]))
-> Signal a1 -> (Signal b1, Signal b2)
kernel12 Signal (Prod, (Prod, Prod), [a] -> ([a], [a]))
forall a. Signal (Prod, (Prod, Prod), [a] -> ([a], [a]))
cSw
where cSw :: Signal (Prod, (Prod, Prod), [a] -> ([a], [a]))
cSw = Prod
-> (Prod -> [Prod] -> Prod)
-> (Prod -> (Prod, [(Prod, (Prod, Prod), [a] -> ([a], [a]))]))
-> Prod
-> Signal Prod
-> Signal (Prod, (Prod, Prod), [a] -> ([a], [a]))
forall s a1 y.
Prod
-> (s -> [a1] -> s)
-> (s -> (Prod, [y]))
-> s
-> Signal a1
-> Signal y
detector11 1 (\_ [s :: Prod
s] -> Prod
s) Prod -> (Prod, [(Prod, (Prod, Prod), [a] -> ([a], [a]))])
forall a a a.
(Eq a, Num a, Num a, Show a) =>
a -> (a, [(Prod, (Prod, Prod), [a] -> ([a], [a]))])
chSel 0 Signal Prod
sb
chSel :: a -> (a, [(Prod, (Prod, Prod), [a] -> ([a], [a]))])
chSel 1 = (1, [(Prod
p, (Prod
p,0), \d :: [a]
d -> ([a]
d,[]))])
chSel 2 = (1, [(Prod
p, (0,Prod
p), \d :: [a]
d -> ([],[a]
d))])
chSel n :: a
n = [Char] -> (a, [(Prod, (Prod, Prod), [a] -> ([a], [a]))])
forall a. HasCallStack => [Char] -> a
error ([Char] -> (a, [(Prod, (Prod, Prod), [a] -> ([a], [a]))]))
-> [Char] -> (a, [(Prod, (Prod, Prod), [a] -> ([a], [a]))])
forall a b. (a -> b) -> a -> b
$ "iSwitch2: received control token " [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ a -> [Char]
forall a. Show a => a -> [Char]
show a
n [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ "!"
iSwitch3 :: Prod -> Signal Prod -> Signal a -> (Signal a, Signal a, Signal a)
iSwitch3 p :: Prod
p sb :: Signal Prod
sb = Signal (Prod, (Prod, Prod, Prod), [a] -> ([a], [a], [a]))
-> Signal a -> (Signal a, Signal a, Signal a)
forall a1 b1 b2 b3.
Signal (Prod, (Prod, Prod, Prod), [a1] -> ([b1], [b2], [b3]))
-> Signal a1 -> (Signal b1, Signal b2, Signal b3)
kernel13 Signal (Prod, (Prod, Prod, Prod), [a] -> ([a], [a], [a]))
forall a. Signal (Prod, (Prod, Prod, Prod), [a] -> ([a], [a], [a]))
cSw
where cSw :: Signal (Prod, (Prod, Prod, Prod), [a] -> ([a], [a], [a]))
cSw = Prod
-> (Prod -> [Prod] -> Prod)
-> (Prod
-> (Prod, [(Prod, (Prod, Prod, Prod), [a] -> ([a], [a], [a]))]))
-> Prod
-> Signal Prod
-> Signal (Prod, (Prod, Prod, Prod), [a] -> ([a], [a], [a]))
forall s a1 y.
Prod
-> (s -> [a1] -> s)
-> (s -> (Prod, [y]))
-> s
-> Signal a1
-> Signal y
detector11 1 (\_ [s :: Prod
s] -> Prod
s) Prod
-> (Prod, [(Prod, (Prod, Prod, Prod), [a] -> ([a], [a], [a]))])
forall a a a.
(Eq a, Num a, Num a, Show a) =>
a -> (a, [(Prod, (Prod, Prod, Prod), [a] -> ([a], [a], [a]))])
chSel 0 Signal Prod
sb
chSel :: a -> (a, [(Prod, (Prod, Prod, Prod), [a] -> ([a], [a], [a]))])
chSel 1 = (1, [(Prod
p, (Prod
p,0,0), \d :: [a]
d -> ([a]
d,[],[]))])
chSel 2 = (1, [(Prod
p, (0,Prod
p,0), \d :: [a]
d -> ([],[a]
d,[]))])
chSel 3 = (1, [(Prod
p, (0,0,Prod
p), \d :: [a]
d -> ([],[],[a]
d))])
chSel n :: a
n = [Char] -> (a, [(Prod, (Prod, Prod, Prod), [a] -> ([a], [a], [a]))])
forall a. HasCallStack => [Char] -> a
error ([Char]
-> (a, [(Prod, (Prod, Prod, Prod), [a] -> ([a], [a], [a]))]))
-> [Char]
-> (a, [(Prod, (Prod, Prod, Prod), [a] -> ([a], [a], [a]))])
forall a b. (a -> b) -> a -> b
$ "iSwitch3: received control token " [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ a -> [Char]
forall a. Show a => a -> [Char]
show a
n [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ "!"
iSwitch4 :: Prod
-> Signal Prod
-> Signal a
-> (Signal a, Signal a, Signal a, Signal a)
iSwitch4 p :: Prod
p sb :: Signal Prod
sb = Signal
(Prod, (Prod, Prod, Prod, Prod), [a] -> ([a], [a], [a], [a]))
-> Signal a -> (Signal a, Signal a, Signal a, Signal a)
forall a1 b1 c d e.
Signal
(Prod, (Prod, Prod, Prod, Prod), [a1] -> ([b1], [c], [d], [e]))
-> Signal a1 -> (Signal b1, Signal c, Signal d, Signal e)
kernel14 Signal
(Prod, (Prod, Prod, Prod, Prod), [a] -> ([a], [a], [a], [a]))
forall a.
Signal
(Prod, (Prod, Prod, Prod, Prod), [a] -> ([a], [a], [a], [a]))
cSw
where cSw :: Signal
(Prod, (Prod, Prod, Prod, Prod), [a] -> ([a], [a], [a], [a]))
cSw = Prod
-> (Prod -> [Prod] -> Prod)
-> (Prod
-> (Prod,
[(Prod, (Prod, Prod, Prod, Prod), [a] -> ([a], [a], [a], [a]))]))
-> Prod
-> Signal Prod
-> Signal
(Prod, (Prod, Prod, Prod, Prod), [a] -> ([a], [a], [a], [a]))
forall s a1 y.
Prod
-> (s -> [a1] -> s)
-> (s -> (Prod, [y]))
-> s
-> Signal a1
-> Signal y
detector11 1 (\_ [s :: Prod
s] -> Prod
s) Prod
-> (Prod,
[(Prod, (Prod, Prod, Prod, Prod), [a] -> ([a], [a], [a], [a]))])
forall a a a.
(Eq a, Num a, Num a, Show a) =>
a
-> (a,
[(Prod, (Prod, Prod, Prod, Prod), [a] -> ([a], [a], [a], [a]))])
chSel 0 Signal Prod
sb
chSel :: a
-> (a,
[(Prod, (Prod, Prod, Prod, Prod), [a] -> ([a], [a], [a], [a]))])
chSel 1 = (1, [(Prod
p, (Prod
p,0,0,0), \d :: [a]
d -> ([a]
d,[],[],[]))])
chSel 2 = (1, [(Prod
p, (0,Prod
p,0,0), \d :: [a]
d -> ([],[a]
d,[],[]))])
chSel 3 = (1, [(Prod
p, (0,0,Prod
p,0), \d :: [a]
d -> ([],[],[a]
d,[]))])
chSel 4 = (1, [(Prod
p, (0,0,0,Prod
p), \d :: [a]
d -> ([],[],[],[a]
d))])
chSel n :: a
n = [Char]
-> (a,
[(Prod, (Prod, Prod, Prod, Prod), [a] -> ([a], [a], [a], [a]))])
forall a. HasCallStack => [Char] -> a
error ([Char]
-> (a,
[(Prod, (Prod, Prod, Prod, Prod), [a] -> ([a], [a], [a], [a]))]))
-> [Char]
-> (a,
[(Prod, (Prod, Prod, Prod, Prod), [a] -> ([a], [a], [a], [a]))])
forall a b. (a -> b) -> a -> b
$ "iSwitch4: received control token " [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ a -> [Char]
forall a. Show a => a -> [Char]
show a
n [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ "!"
iSelect2 :: (Cons,Cons) -> Signal Int
-> Signal a -> Signal a -> Signal a
iSelect3 :: (Cons,Cons,Cons) -> Signal Int
-> Signal a -> Signal a -> Signal a -> Signal a
iSelect4 :: (Cons,Cons,Cons,Cons) -> Signal Int
-> Signal a -> Signal a -> Signal a -> Signal a -> Signal a
iSelect2 :: (Prod, Prod) -> Signal Prod -> Signal a -> Signal a -> Signal a
iSelect2 (c1 :: Prod
c1,c2 :: Prod
c2) sb :: Signal Prod
sb = Signal ((Prod, Prod), Prod, [a] -> [a] -> [a])
-> Signal a -> Signal a -> Signal a
forall a1 a2 b1.
Signal ((Prod, Prod), Prod, [a1] -> [a2] -> [b1])
-> Signal a1 -> Signal a2 -> Signal b1
kernel21 Signal ((Prod, Prod), Prod, [a] -> [a] -> [a])
forall p. Signal ((Prod, Prod), Prod, p -> p -> p)
cSel
where cSel :: Signal ((Prod, Prod), Prod, p -> p -> p)
cSel = Prod
-> (Prod -> [Prod] -> Prod)
-> (Prod -> (Prod, [((Prod, Prod), Prod, p -> p -> p)]))
-> Prod
-> Signal Prod
-> Signal ((Prod, Prod), Prod, p -> p -> p)
forall s a1 y.
Prod
-> (s -> [a1] -> s)
-> (s -> (Prod, [y]))
-> s
-> Signal a1
-> Signal y
detector11 1 (\_ [s :: Prod
s] -> Prod
s) Prod -> (Prod, [((Prod, Prod), Prod, p -> p -> p)])
forall a a p.
(Eq a, Num a, Num a, Show a) =>
a -> (a, [((Prod, Prod), Prod, p -> p -> p)])
chSel 0 Signal Prod
sb
chSel :: a -> (a, [((Prod, Prod), Prod, p -> p -> p)])
chSel 1 = (1, [((Prod
c1,0), Prod
c1, \d :: p
d _ -> p
d)])
chSel 2 = (1, [((0,Prod
c2), Prod
c2, \_ d :: p
d -> p
d)])
chSel n :: a
n = [Char] -> (a, [((Prod, Prod), Prod, p -> p -> p)])
forall a. HasCallStack => [Char] -> a
error ([Char] -> (a, [((Prod, Prod), Prod, p -> p -> p)]))
-> [Char] -> (a, [((Prod, Prod), Prod, p -> p -> p)])
forall a b. (a -> b) -> a -> b
$ "iSelect2: received control token " [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ a -> [Char]
forall a. Show a => a -> [Char]
show a
n [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ "!"
iSelect3 :: (Prod, Prod, Prod)
-> Signal Prod -> Signal a -> Signal a -> Signal a -> Signal a
iSelect3 (c1 :: Prod
c1,c2 :: Prod
c2,c3 :: Prod
c3) sb :: Signal Prod
sb = Signal ((Prod, Prod, Prod), Prod, [a] -> [a] -> [a] -> [a])
-> Signal a -> Signal a -> Signal a -> Signal a
forall a1 a2 a3 b1.
Signal ((Prod, Prod, Prod), Prod, [a1] -> [a2] -> [a3] -> [b1])
-> Signal a1 -> Signal a2 -> Signal a3 -> Signal b1
kernel31 Signal ((Prod, Prod, Prod), Prod, [a] -> [a] -> [a] -> [a])
forall p. Signal ((Prod, Prod, Prod), Prod, p -> p -> p -> p)
cSel
where cSel :: Signal ((Prod, Prod, Prod), Prod, p -> p -> p -> p)
cSel = Prod
-> (Prod -> [Prod] -> Prod)
-> (Prod -> (Prod, [((Prod, Prod, Prod), Prod, p -> p -> p -> p)]))
-> Prod
-> Signal Prod
-> Signal ((Prod, Prod, Prod), Prod, p -> p -> p -> p)
forall s a1 y.
Prod
-> (s -> [a1] -> s)
-> (s -> (Prod, [y]))
-> s
-> Signal a1
-> Signal y
detector11 1 (\_ [s :: Prod
s] -> Prod
s) Prod -> (Prod, [((Prod, Prod, Prod), Prod, p -> p -> p -> p)])
forall a a p.
(Eq a, Num a, Num a, Show a) =>
a -> (a, [((Prod, Prod, Prod), Prod, p -> p -> p -> p)])
chSel 0 Signal Prod
sb
chSel :: a -> (a, [((Prod, Prod, Prod), Prod, p -> p -> p -> p)])
chSel 1 = (1, [((Prod
c1,0,0), Prod
c1, \d :: p
d _ _ -> p
d)])
chSel 2 = (1, [((0,Prod
c2,0), Prod
c2, \_ d :: p
d _ -> p
d)])
chSel 3 = (1, [((0,0,Prod
c3), Prod
c3, \_ _ d :: p
d -> p
d)])
chSel n :: a
n = [Char] -> (a, [((Prod, Prod, Prod), Prod, p -> p -> p -> p)])
forall a. HasCallStack => [Char] -> a
error ([Char] -> (a, [((Prod, Prod, Prod), Prod, p -> p -> p -> p)]))
-> [Char] -> (a, [((Prod, Prod, Prod), Prod, p -> p -> p -> p)])
forall a b. (a -> b) -> a -> b
$ "iSelect3: received control token " [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ a -> [Char]
forall a. Show a => a -> [Char]
show a
n [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ "!"
iSelect4 :: (Prod, Prod, Prod, Prod)
-> Signal Prod
-> Signal a
-> Signal a
-> Signal a
-> Signal a
-> Signal a
iSelect4 (c1 :: Prod
c1,c2 :: Prod
c2,c3 :: Prod
c3,c4 :: Prod
c4) sb :: Signal Prod
sb = Signal
((Prod, Prod, Prod, Prod), Prod, [a] -> [a] -> [a] -> [a] -> [a])
-> Signal a -> Signal a -> Signal a -> Signal a -> Signal a
forall a1 a2 a3 a4 b1.
Signal
((Prod, Prod, Prod, Prod), Prod,
[a1] -> [a2] -> [a3] -> [a4] -> [b1])
-> Signal a1 -> Signal a2 -> Signal a3 -> Signal a4 -> Signal b1
kernel41 Signal
((Prod, Prod, Prod, Prod), Prod, [a] -> [a] -> [a] -> [a] -> [a])
forall p.
Signal ((Prod, Prod, Prod, Prod), Prod, p -> p -> p -> p -> p)
cSel
where cSel :: Signal ((Prod, Prod, Prod, Prod), Prod, p -> p -> p -> p -> p)
cSel = Prod
-> (Prod -> [Prod] -> Prod)
-> (Prod
-> (Prod,
[((Prod, Prod, Prod, Prod), Prod, p -> p -> p -> p -> p)]))
-> Prod
-> Signal Prod
-> Signal ((Prod, Prod, Prod, Prod), Prod, p -> p -> p -> p -> p)
forall s a1 y.
Prod
-> (s -> [a1] -> s)
-> (s -> (Prod, [y]))
-> s
-> Signal a1
-> Signal y
detector11 1 (\_ [s :: Prod
s] -> Prod
s) Prod
-> (Prod,
[((Prod, Prod, Prod, Prod), Prod, p -> p -> p -> p -> p)])
forall a a p.
(Eq a, Num a, Num a, Show a) =>
a -> (a, [((Prod, Prod, Prod, Prod), Prod, p -> p -> p -> p -> p)])
chSel 0 Signal Prod
sb
chSel :: a -> (a, [((Prod, Prod, Prod, Prod), Prod, p -> p -> p -> p -> p)])
chSel 1 = (1, [((Prod
c1,0,0,0), Prod
c1, \d :: p
d _ _ _ -> p
d)])
chSel 2 = (1, [((0,Prod
c2,0,0), Prod
c2, \_ d :: p
d _ _ -> p
d)])
chSel 3 = (1, [((0,0,Prod
c3,0), Prod
c3, \_ _ d :: p
d _ -> p
d)])
chSel 4 = (1, [((0,0,0,Prod
c4), Prod
c4, \_ _ _ d :: p
d -> p
d)])
chSel n :: a
n = [Char]
-> (a, [((Prod, Prod, Prod, Prod), Prod, p -> p -> p -> p -> p)])
forall a. HasCallStack => [Char] -> a
error ([Char]
-> (a, [((Prod, Prod, Prod, Prod), Prod, p -> p -> p -> p -> p)]))
-> [Char]
-> (a, [((Prod, Prod, Prod, Prod), Prod, p -> p -> p -> p -> p)])
forall a b. (a -> b) -> a -> b
$ "iSelect4: received control token " [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ a -> [Char]
forall a. Show a => a -> [Char]
show a
n [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ "!"