I'm trying to implement a full adder. But it does not work. Sb an idea????
Code: Select all
(define a (make-wire))
(define b (make-wire))
(define cin (make-wire))
(define s (make-wire))
(define cout (make-wire))
; XOR is not implemented till now
(define xor
(lambda (x y xor)
(letrec ((a (make-wire))
(b (make-wire)))
(or-gate x y a)
(inverter (and-gate x y b) b)
(: full-adder (wire wire wire wire wire -> unspecific))
(define full-adder
(lambda (a b cin s cout)
(letrec((d (make-wire))
(e (make-wire))
(f (make-wire))
(g (make-wire))
(h (make-wire))
(i (make-wire)) )
(begin
(or-gate (and-gate b cin d) (and-gate a cin e) f)
(or-gate f (and-gate a b g) cout )
(xor (xor a b g) cin s)
; or instead of XOR above, folloing code
; (or-gate a b g)
; (inverter (and-gate a b h) h)
; (and a b i)
; (or-gate i cin g)
; (inverter (and-gate i cin h) h)
; (and i cin s)))))
"ok"))))