Subversion Repositories programming

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
107 ira 1
/* digital logic circuit */
2
/*
3
      +-----+
4
A ----|     |
5
      | and |--not---+
6
B ----|     |        |   +-----+
7
      +-----+        +---|     |
8
                         | and |--- Z
9
      +-----+        +---|     |
10
C ----|     |        |   +-----+
11
      | or  |--not---+
12
D ----|     |
13
      +-----+
14
*/
15
 
16
bit(0).
17
bit(1).
18
 
19
and(0,0,0).
20
and(0,1,0).
21
and(1,0,0).
22
and(1,1,1).
23
 
24
or(0,0,0).
25
or(0,1,1).
26
or(1,0,1).
27
or(1,1,1).
28
 
29
inv(0,1).
30
inv(1,0).
31
 
32
circuit(A,B,C,D,Z) :- bit(A),bit(B),bit(C),bit(D),
33
                      and(A,B,X),
34
                      or(C,D,Y),
35
                      inv(X,XBAR),
36
                      inv(Y,YBAR),
37
                      and(XBAR,YBAR,Z).
38
 
39