playground/haskell/clash/mux.hs

26 lines
540 B
Haskell

module MUX where -- MUX2
import Clash.Prelude
mux2 :: () -> (a, a, Bool) -> ((), a)
mux2 _ (x, y, sel) =
case sel of
False -> ((), x)
_ -> ((), y)
-- *MAC> mux2 () (3, 2, False)
-- ((),3)
-- *MAC> mux2 () (3, 2, True)
-- ((),2)
mux2S :: (HiddenClockResetEnable dom, Num a, NFDataX a) => Signal dom (a, a, Bool) -> Signal dom a
mux2S = mealy mux2 ()
topEntity
:: Clock System
-> Reset System
-> Enable System
-> Signal System (Int, Int, Bool)
-> Signal System Int
topEntity = exposeClockResetEnable mux2S