7 import CLasH.Translator.Annotations
8 import qualified Prelude as P
13 main = Sim.simulate exec program initial_state
14 mainIO = Sim.simulateIO exec initial_state
18 newtype State s = State s deriving (P.Show)
22 (High, Low, High), -- z = r1 and t (0) ; t = r1 (1)
23 (Low, Low, Low), -- z = r0 or t (1); t = r0 (0)
24 (Low, High, dontcare), -- r0 = z (1)
25 (High, Low, High), -- z = r1 and t (0); t = r1 (1)
26 (High, High, dontcare) -- r1 = z (0)
29 --initial_state = (Regs Low High, Low, Low)
30 initial_state = State (State (0, 1), 0, 0)
32 type Word = SizedWord D4
35 type RegisterBankState = State (Word, Word)
36 --data RegisterBankState = Regs { r0, r1 :: Bit} deriving (Show)
40 -> Bit -- ^ Write Enable
42 -> RegisterBankState -> -- State
43 (RegisterBankState, Word) -- (State', Output)
45 register_bank addr we d (State s) =
49 o = case addr of Low -> fst s; High -> snd s
50 in (State s, o) -- Don't change state
54 r0' = case addr of Low -> d; High -> r0
55 r1' = case addr of High -> d; Low -> r1
57 in (State s', 0) -- Don't output anything useful
63 alu :: AluOp -> Word -> Word -> Word
65 --alu High a b = a `hwand` b
66 --alu Low a b = a `hwor` b
67 alu High a b = a P.+ b
70 type ExecState = State (RegisterBankState, Word, Word)
71 exec :: (RegAddr, Bit, AluOp) -> ExecState -> (ExecState, Word)
73 {-# ANN exec TopEntity #-}
75 exec (addr, we, op) (State s) =
79 (reg_s', t') = register_bank addr we z reg_s
83 -- vim: set ts=8 sw=2 sts=2 expandtab: