1 {-# LANGUAGE TemplateHaskell #-}
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
10 import CLasH.Translator.Annotations
12 type CpuState = State (Vector D4 (Signed D16))
14 fu op inputs (a1, a2) =
15 op (inputs!a1) (inputs!a2)
21 data Opcode = ShiftL | Xor | Equal
23 multiop ShiftL = shiftL
25 multiop Equal = \a b -> if a == b then 1 else 0
27 fu0 c = fu (multiop c)
29 {-# ANN cpu TopEntity #-}
30 {-# ANN cpu (InitState 'cpuState) #-}
32 -> (Signed D16, Opcode, Vector D4 (Index D7, Index D7))
33 -> (CpuState, Signed D16)
34 cpu (State s) (x,opc,addrs) = (State s', out)
36 inputs = x +> (0 +> (1 +> s))
37 s' = (fu0 opc inputs (addrs!0)) +> (
38 (fu1 inputs (addrs!1)) +> (
39 (fu2 inputs (addrs!2)) +> (
40 (fu3 inputs (addrs!3)) +> empty)))
43 cpuState :: Vector D4 (Signed D16)