Answer 3.32

main
Felix Martin 2020-12-26 01:57:27 -05:00
parent 861b8fe73e
commit 0c68a2d996
2 changed files with 32 additions and 2 deletions

View File

@ -19,8 +19,8 @@
(call-each action-procedures))
'done))
(define (accept-action-procedure! proc)
(set! action-procedures (cons proc action-procedures)))
; (proc))
(set! action-procedures (cons proc action-procedures))
(proc))
(define (dispatch m)
(cond ((eq? m 'get-signal) signal-value)
((eq? m 'set-signal!) set-my-signal!)
@ -202,6 +202,7 @@
(display "\nex-3.31 - accept-action-procedure!\n")
(display "[see comment]\n")
(define input-1 (make-wire))
(define input-2 (make-wire))
@ -227,4 +228,28 @@
; one.
(display "\nex-3.32\n")
(display "[see comment]\n")
(define input-1 (make-wire))
(define input-2 (make-wire))
(define out (make-wire))
(and-gate input-1 input-2 out)
; (probe 'out out)
(set-signal! input-1 0)
(set-signal! input-2 1)
(propagate)
(assert (get-signal out) 0)
(set-signal! input-1 1)
(set-signal! input-2 0)
(propagate)
(assert (get-signal out) 0)
; Executing the queued action items out of order could lead to unexpected
; states. In the example above, if we set input-1 to 1 first, and then input-2
; to 0, we would expect the output to change to 1 for one and-gate-delay. If we
; probe the output signal we can see that this is indeed what happens. Now, if
; the actions would not be processed in FIFO order, the output would never
; switch to 1.

5
ex-3_33-xx.scm Normal file
View File

@ -0,0 +1,5 @@
(load "util.scm")
(display "\nexample - propagation of constraints\n")
(display "\nex-3.33\n")