projects
/
matthijs
/
master-project
/
cλash.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
dc4be58
)
Add a haskell model for a half adder.
author
Matthijs Kooijman
<m.kooijman@student.utwente.nl>
Wed, 21 Jan 2009 12:37:56 +0000
(13:37 +0100)
committer
Matthijs Kooijman
<m.kooijman@student.utwente.nl>
Wed, 21 Jan 2009 12:37:56 +0000
(13:37 +0100)
Adders.hs
patch
|
blob
|
history
diff --git
a/Adders.hs
b/Adders.hs
index c49ba810ce1ae4768ac2bd7efd673d1c198a0a28..2e8cf35c98e3fe622e31cc76c3043149ae27067a 100644
(file)
--- 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)