From: Matthijs Kooijman Date: Fri, 30 Jan 2009 08:55:44 +0000 (+0100) Subject: Implement full_adder in terms of half_adder. X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=ed6bb401ef9c3726084f9477e01228466d34e29c;p=matthijs%2Fmaster-project%2Fc%CE%BBash.git Implement full_adder in terms of half_adder. --- diff --git a/Adders.hs b/Adders.hs index 71d38dc..f35021c 100644 --- a/Adders.hs +++ b/Adders.hs @@ -42,9 +42,9 @@ half_adder (a, b) = full_adder :: (Bit, Bit, Bit) -> (Bit, Bit) full_adder (a, b, cin) = (s, c) where - x = a `hwxor` b - s = x `hwxor` cin - c = a `hwand` b `hwor` (cin `hwand` x) + (s1, c1) = half_adder(a, b) + (s, c2) = half_adder(s1, cin) + c = c1 `hwor` c2 -- Four bit adder -- Explicit version