X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=Adders.hs;h=7243b504063c0871350745daf98036839078d83b;hb=0dd32af30fee665611e77cfb7bf8fc82f70c970b;hp=ac93a3366db359f3fc368467fe7280320aece926;hpb=0082f01a853476cdcec0e73bacf8c0d4508dbec0;p=matthijs%2Fmaster-project%2Fc%CE%BBash.git diff --git a/Adders.hs b/Adders.hs index ac93a33..7243b50 100644 --- a/Adders.hs +++ b/Adders.hs @@ -16,6 +16,10 @@ show_add f = do print ("Sum: " ++ (displaysigs s)); print ("Carry: " ++ (displ b = [Low, Low, Low, High] (s, c) = f (a, b) +mux2 :: Bit -> (Bit, Bit) -> Bit +mux2 Low (a, b) = a +mux2 High (a, b) = b + -- Not really an adder, but this is nice minimal hardware description wire :: Bit -> Bit wire a = a @@ -55,6 +59,7 @@ no_carry_adder (a, b) = a `hwxor` b -- Combinatoric stateless half adder -- A -> B -> (S, C) half_adder :: (Bit, Bit) -> (Bit, Bit) +{-# NOINLINE half_adder #-} half_adder (a, b) = ( a `hwxor` b, a `hwand` b )