Guest User

Untitled

a guest
May 19th, 2018
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scheme 0.61 KB | None | 0 0
  1. ;;Ex.3.30
  2. ;;a-wire, b-wire, s-wire are lists of n wires
  3. (define (ripple-carry-adder a-wire b-wire s-wire c)
  4.   (define (get-carry a b s) ;a,b,s are lists of wires
  5.     (if (null? a)
  6.         (let ((d (make-wire))) ;initial carry-in value of 0
  7.           (set-signal! d 0)
  8.           d)
  9.         (let ((e (make-wire))) ;the carry wire
  10.           (full-adder (car a) (car b)
  11.                       (get-carry (cdr a) (cdr b) (cdr s)) (car s) e)
  12.           e))) ;return it
  13.  
  14.   (full-adder (car a-wire) (car b-wire)
  15.               (get-carry (cdr a-wire) (cdr b-wire) (cdr s-wire))
  16.               (car s-wire) c)
  17.   'ok)
Add Comment
Please, Sign In to add comment