36 lines
757 B
Haskell
36 lines
757 B
Haskell
-- | Multiply and accumulate
|
|
module MAC where
|
|
|
|
-- https://haskell-haddock.readthedocs.io/en/latest/markup.html
|
|
|
|
import Clash.Prelude
|
|
|
|
-- | Multiply and accumulate
|
|
mac' :: (Num a) =>
|
|
a -- ^ accumulator
|
|
-> (a, a) -- ^ next arguments
|
|
-> a -- ^ new accumulator
|
|
mac' acc (x, y) = acc + (x*y)
|
|
|
|
mac :: (Num a) => a -> (a, a) -> (a, a)
|
|
mac acc (x, y) = (acc + x*y, acc)
|
|
|
|
macS :: (HiddenClockResetEnable dom, Num a, NFDataX a) =>
|
|
Signal dom (a, a) -- ^
|
|
-> Signal dom a -- ^
|
|
macS = mealy mac 0
|
|
|
|
-- s = a
|
|
-- i = (a, a)
|
|
-- s,o = (a, a)
|
|
-- ie,
|
|
-- s,i,o = a,a,a
|
|
|
|
topEntity
|
|
:: Clock System
|
|
-> Reset System
|
|
-> Enable System
|
|
-> Signal System (Int, Int)
|
|
-> Signal System Int
|
|
topEntity = exposeClockResetEnable macS
|