1 {-# LANGUAGE TypeOperators, TemplateHaskell, TypeFamilies,
2 ScopedTypeVariables, RecordWildCards, FlexibleContexts #-}
4 module HigherOrderCPU where
6 -- hide default prelude functions
7 import qualified Prelude as P
9 -- import CλaSH specific types
10 import CLasH.HardwareTypes hiding (min,foldl1,const)
11 import CLasH.Translator.Annotations
13 type Word = SizedInt D16
14 type Index = RangedWord
19 fu :: ( PositiveT p, NaturalT n, (p :>: n) ~ True) =>
25 fu op inputs (addr1, addr2) out =
32 type CpuState = State (Vector D4 Word)
34 {-# ANN cpu TopEntity #-}
35 {-# ANN cpu (InitState 'cpuState) #-}
38 -> Vector D4 (Index D6, Index D6)
41 cpu input addrs (State fuss) =
44 fures = (fu const inputs (addrs!(0 :: Index D3)) (fuss!(0 :: Index D3))) +> (
45 (fu (+) inputs (addrs!(1 :: Index D3)) (fuss!(1 :: Index D3))) +> (
46 (fu (-) inputs (addrs!(2 :: Index D3)) (fuss!(2 :: Index D3))) +> ( singleton
47 (fu (*) inputs (addrs!(3 :: Index D3)) (fuss!(3 :: Index D3))))))
48 (fuss', outputs) = unzip fures
49 inputs = 0 +> (1 +> (input +> outputs))
52 cpuState :: Vector D4 Word