From: Matthijs Kooijman Date: Wed, 21 Jan 2009 12:37:56 +0000 (+0100) Subject: Add a haskell model for a half adder. X-Git-Url: https://git.stderr.nl/gitweb?p=matthijs%2Fmaster-project%2Fc%CE%BBash.git;a=commitdiff_plain;h=0b54fb07697815cb343e7f217b1bd8362365f22d Add a haskell model for a half adder. --- 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)