X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=Alu.hs;h=e1aff99e98bbafc444ef29035dcaed1c2817781f;hb=85693fb7ac19042b767cd712e92aec9897a0155e;hp=b7fff900642ca72ae2ec6f70958a4a656591bb51;hpb=d162629abb03f376afec902e0a5d2087a6c34d7e;p=matthijs%2Fmaster-project%2Fc%CE%BBash.git diff --git a/Alu.hs b/Alu.hs index b7fff90..e1aff99 100644 --- a/Alu.hs +++ b/Alu.hs @@ -12,8 +12,6 @@ mainIO = Sim.simulateIO exec initial_state dontcare = Low -newtype State s = State s deriving (P.Show) - program = [ -- (addr, we, op) (High, Low, High), -- z = r1 and t (0) ; t = r1 (1) @@ -32,6 +30,7 @@ type RegAddr = Bit type RegisterBankState = State (Word, Word) --data RegisterBankState = Regs { r0, r1 :: Bit} deriving (Show) +{-# NOINLINE register_bank #-} register_bank :: RegAddr -- ^ Address -> Bit -- ^ Write Enable @@ -39,19 +38,21 @@ register_bank :: -> RegisterBankState -> -- State (RegisterBankState, Word) -- (State', Output) -register_bank addr we d (State s) = - case we of - Low -> -- Read - let - o = case addr of Low -> fst s; High -> snd s - in (State s, o) -- Don't change state - High -> -- Write - let - (r0, r1) = s - r0' = case addr of Low -> d; High -> r0 - r1' = case addr of High -> d; Low -> r1 - s' = (r0', r1') - in (State s', 0) -- Don't output anything useful +register_bank addr we d (State s) = (State s', o) + where + s' = case we of + Low -> s -- Read + High -> -- Write + let + (r0, r1) = s + r0' = case addr of Low -> d; High -> r0 + r1' = case addr of High -> d; Low -> r1 + in (r0', r1') + o = case we of + -- Read + Low -> case addr of Low -> fst s; High -> snd s + -- Write + High -> 0 -- Don't output anything useful -- ALU