Add the atbegshi package, which is not available on Debian.
[matthijs/master-project/final-presentation.git] / macc.hs
1 {-#  LANGUAGE TemplateHaskell, TypeOperators, RecordWildCards, ScopedTypeVariables, TypeFamilies  #-}
2 module MultiplyAccumulate where
3
4 import CLasH.HardwareTypes
5 import CLasH.Translator.Annotations
6 type Word = SizedInt D8
7
8 initacc :: Word
9 initacc = 0
10
11 {-# ANN macc (InitState  'initacc) #-}
12 {-# ANN macc TopEntity #-}
13 macc :: (Word,Word) -> State Word -> (State Word, Word)
14 macc (x, y) (State acc) = (State u, u)
15   where
16     u = acc + x * y
17
18 {-# ANN program TestInput #-}
19 program :: [(Word,Word)]
20 program =
21   [ (4, 2) --  4 * 2 + 0  = 8
22   , (1, 3) --  1 * 3 + 8  = 11
23   , (2, 2) --  2 * 2 + 11 = 15
24   ]
25
26 run _     _    []        = []
27 run func state (i:input) = o:out
28   where
29     (state', o) = func i state
30     out         = run func state' input