0
|
1
|
|
2
|
|
3 rs(R,S,NQ,Q) :-
|
|
4 (nand(S,Q,NQ,2) && true),
|
|
5 (nand(R,NQ,Q,3) && true).
|
|
6
|
|
7 nand(A,B,Out,Delay) :-
|
|
8 A = 1,B = 1,
|
|
9 length(Delay),
|
|
10 Out <- 0 .
|
|
11 nand(A,B,Out,Delay) :-
|
|
12 A = 1,B = 0,
|
|
13 length(Delay),
|
|
14 Out <- 1 .
|
|
15 nand(A,B,Out,Delay) :-
|
|
16 A = 0,B = 1,
|
|
17 length(Delay),
|
|
18 Out <- 1 .
|
|
19 nand(A,B,Out,Delay) :-
|
|
20 A = 0,B = 0,
|
|
21 length(Delay),
|
|
22 Out <- 1 .
|
|
23
|
|
24 test :- data(R,S),
|
|
25 #rs(R,S,NQ,Q),
|
|
26 #write((NQ,Q)).
|
|
27
|
|
28 data(R,S) :- length(4),
|
|
29 read((R,S)),
|
|
30 stable(R),stable(S)
|
|
31 && @data(R,S).
|