File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change
1
+ #lang racket
2
+
3
+ (require "digital-circuit.rkt " )
4
+ (require "after-delay.rkt " )
5
+ ;;; The implementation of `or-gate` is in `digital-circuit.rkt`
6
+ (module+ test
7
+ (require rackunit)
8
+
9
+
10
+ (test-case "Test for or-gate "
11
+ (define a1 (make-wire))
12
+ (define a2 (make-wire))
13
+ (define output (make-wire))
14
+
15
+ (or-gate a1 a2 output)
16
+
17
+ ;; 0 OR 0 = 0
18
+ (set-signal! a1 0 )
19
+ (set-signal! a2 0 )
20
+ (propagate)
21
+ (check-equal? (get-signal output)0 )
22
+
23
+ ;; 0 OR 1 = 1
24
+ (set-signal! a1 0 )
25
+ (set-signal! a2 1 )
26
+ (propagate)
27
+ (check-equal? (get-signal output)1 )
28
+
29
+ ;; 1 OR 0 = 1
30
+ (set-signal! a1 1 )
31
+ (set-signal! a2 0 )
32
+ (propagate)
33
+ (check-equal? (get-signal output) 1 )
34
+
35
+ ;; 1 OR 1 = 1
36
+ (set-signal! a1 1 )
37
+ (set-signal! a2 1 )
38
+ (propagate)
39
+ (check-equal? (get-signal output )1 ))
40
+
41
+ )
You can’t perform that action at this time.
0 commit comments