1 {-# LANGUAGE TypeOperators, TemplateHaskell, TypeFamilies, ScopedTypeVariables #-}
3 module HigherOrderCPU where
5 -- hide default prelude functions
6 import qualified Prelude as P
8 -- import CλaSH specific types
9 import CLasH.HardwareTypes hiding (min,foldl1,const)
10 import CLasH.Translator.Annotations
12 type Word = SizedInt D16
13 type Index = RangedWord
18 fu :: ( PositiveT p, NaturalT n, (p :>: n) ~ True) =>
24 fu op inputs (addr1, addr2) out =
31 type CpuState = State (Vector D4 Word)
33 {-# ANN cpu TopEntity #-}
34 {-# ANN cpu (InitState 'cpuState) #-}
37 -> Vector D4 (Index D6, Index D6)
40 cpu input addrs (State fuss) =
43 fures = (fu const inputs (addrs!(0 :: Index D3)) (fuss!(0 :: Index D3))) +> (
44 (fu (+) inputs (addrs!(1 :: Index D3)) (fuss!(1 :: Index D3))) +> (
45 (fu (-) inputs (addrs!(2 :: Index D3)) (fuss!(2 :: Index D3))) +> ( singleton
46 (fu (*) inputs (addrs!(3 :: Index D3)) (fuss!(3 :: Index D3))))))
47 (fuss', outputs) = unzip fures
48 inputs = 0 +> (1 +> (input +> outputs))
51 cpuState :: Vector D4 Word