X-Git-Url: https://git.stderr.nl/gitweb?p=matthijs%2Fmaster-project%2Fc%CE%BBash.git;a=blobdiff_plain;f=Alu.hs;fp=Alu.hs;h=edb4d1a7440d63b9447ec7264fdc2595700cdd8a;hp=1c60c0414886cbb975d18fb994a286beb46e1c24;hb=26fa82ed9c6c355343972ff1ca254b2cb4931b06;hpb=284c4ebfce06dbde8581236d9e7295271e95cd2b diff --git a/Alu.hs b/Alu.hs index 1c60c04..edb4d1a 100644 --- a/Alu.hs +++ b/Alu.hs @@ -37,19 +37,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