From ed6bb401ef9c3726084f9477e01228466d34e29c Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Fri, 30 Jan 2009 09:55:44 +0100 Subject: [PATCH] Implement full_adder in terms of half_adder. --- Adders.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 -- 2.30.2