Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;;Ex.3.30
- ;;a-wire, b-wire, s-wire are lists of n wires
- (define (ripple-carry-adder a-wire b-wire s-wire c)
- (define (get-carry a b s) ;a,b,s are lists of wires
- (if (null? a)
- (let ((d (make-wire))) ;initial carry-in value of 0
- (set-signal! d 0)
- d)
- (let ((e (make-wire))) ;the carry wire
- (full-adder (car a) (car b)
- (get-carry (cdr a) (cdr b) (cdr s)) (car s) e)
- e))) ;return it
- (full-adder (car a-wire) (car b-wire)
- (get-carry (cdr a-wire) (cdr b-wire) (cdr s-wire))
- (car s-wire) c)
- 'ok)
Add Comment
Please, Sign In to add comment