X-Git-Url: https://git.stderr.nl/gitweb?p=matthijs%2Fmaster-project%2Fdsd-paper.git;a=blobdiff_plain;f=HigherOrderCPU.hs;h=a881001cb756df49c8c61bf005b7531842b397dc;hp=8833766ebca36789ff9feb1808fe8207c90b5e03;hb=197f33f41a022d438997327361c759ffe6cadd03;hpb=9135be92f8b1e6b93d8dc7e8b7c69e0954c91cd5 diff --git a/HigherOrderCPU.hs b/HigherOrderCPU.hs index 8833766..a881001 100644 --- a/HigherOrderCPU.hs +++ b/HigherOrderCPU.hs @@ -24,11 +24,11 @@ type CpuState = State (Vector D4 Word) {-# ANN cpu TopEntity #-} {-# ANN cpu (InitState 'cpuState) #-} -cpu :: CpuState -> Word -> Vector D4 (Index D6, Index D6) +cpu :: CpuState -> Word -> Vector D4 (Index D6, Index D6) -> Opcode -> (CpuState, Word) -cpu (State fuss) input addrs = (State fuss', out) +cpu (State fuss) input addrs opc = (State fuss', out) where - fuss' = (fu const inputs (addrs!(0 :: Index D3))) +> ( + fuss' = (fu (multiop opc) inputs (addrs!(0 :: Index D3))) +> ( (fu (+) inputs (addrs!(1 :: Index D3))) +> ( (fu (-) inputs (addrs!(2 :: Index D3))) +> ( (fu (*) inputs (addrs!(3 :: Index D3))) +> empty))) @@ -36,4 +36,17 @@ cpu (State fuss) input addrs = (State fuss', out) out = head fuss cpuState :: Vector D4 Word -cpuState = copy 0 \ No newline at end of file +cpuState = copy 0 + +data Opcode = Shift | Xor | Equal + +multiop :: Opcode -> Word -> Word -> Word +multiop opc a b = case opc of + Shift -> shift a b + Xor -> xor a b + Equal | a == b -> 1 + | otherwise -> 0 + +-- Placeholders, since we don't have these operations +xor = const +shift = const