X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=Adders.hs;h=2e8cf35c98e3fe622e31cc76c3043149ae27067a;hb=0b54fb07697815cb343e7f217b1bd8362365f22d;hp=c49ba810ce1ae4768ac2bd7efd673d1c198a0a28;hpb=dc4be58dbddaa8e72b55efab24125404506617ff;p=matthijs%2Fmaster-project%2Fc%CE%BBash.git diff --git a/Adders.hs b/Adders.hs index c49ba81..2e8cf35 100644 --- a/Adders.hs +++ b/Adders.hs @@ -15,6 +15,12 @@ show_add f = do print ("Sum: " ++ (displaysigs s)); print ("Carry: " ++ (displ no_carry_adder :: (Bit, Bit) -> Bit no_carry_adder (a, b) = a `hwxor` b +-- Combinatoric half adder +-- A -> B -> (S, C) +half_adder :: (Bit, Bit) -> (Bit, Bit) +half_adder (a, b) = + ( a `hwxor` b, a `hwand` b ) + -- Combinatoric (one-bit) full adder -- (A, B, C) -> (S, C) full_adder :: (Bit, Bit, Bit) -> (Bit, Bit)