File: circuit1.clp

package info (click to toggle)
clips 6.30-4.1
  • links: PTS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 72,580 kB
  • sloc: ansic: 92,903; makefile: 374; sh: 175; modula3: 8
file content (54 lines) | stat: -rw-r--r-- 1,419 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
;;;======================================================
;;;   Example Circuit #1
;;;
;;;     An example circuit to be loaded for use with
;;;     the "electronic.clp" example program. Note
;;;     that OR gate #1 receives both inputs from the
;;;     same source with one of the inputs negated.
;;;     Therefore, the output of this OR gate should
;;;     always be 1 and the value of source #1 is
;;;     has no effect on the value of the LEDs.
;;;
;;; LEGEND
;;; ------------
;;; S = Source
;;; P = Splitter
;;; N = NOT Gate
;;; O = OR Gate
;;; X = XOR Gate
;;; L = LED
;;;
;;; 
;;;          /---N1>--\           /---------L1
;;; S1>--P1>-|         O1>---P2>--|
;;;          \--------/           |
;;;                               |
;;;                               |
;;;                               \---\
;;;                                    X2>--L2
;;; S2>-------------------------------/
;;;
;;;======================================================

(definstances circuit
  (S-1 of SOURCE)
  (S-2 of SOURCE)
  (P-1 of SPLITTER)
  (P-2 of SPLITTER)
  (N-1 of NOT-GATE)
  (O-1 of OR-GATE)
  (X-1 of XOR-GATE)
  (L-1 of LED)
  (L-2 of LED))

(deffunction connect-circuit ()
  (connect [S-1] [P-1])
  (connect [S-2] [X-1] 2)
  (connect [P-1] 1 [N-1])
  (connect [P-1] 2 [O-1] 2)
  (connect [N-1] [O-1] 1)
  (connect [O-1] [P-2])
  (connect [P-2] 1 [L-1])
  (connect [P-2] 2 [X-1] 1)
  (connect [X-1] [L-2]))