Różnice

Różnice między wybraną wersją a wersją aktualną.

Odnośnik do tego porównania

pl:prolog:pllib:and_gate [2019/06/27 15:50]
pl:prolog:pllib:and_gate [2019/06/27 15:50] (aktualna)
Linia 1: Linia 1:
 +====== And gate ======
 +{{tag>​electronics logic}}
 +===== Description =====
 +A circuit for a logical and-gate
 +
 +**Source**: ​ The Art of Prolog
 +===== Download =====
 +Program source code: {{and_gate.pl}}
 +===== Listing =====
 +<code prolog>
 +resistor(power,​n1).
 +resistor(power,​n2).
 +
 +transistor(n2,​ground,​n1).
 +transistor(n3,​n4,​n2).
 +transistor(n5,​ground,​n4).
 +
 +
 +/*
 +inverter(Input,​Output) :-
 + Output is the inversion of Input.
 +*/
 +inverter(Input,​Output) :-
 + transistor(Input,​ground,​Output),​
 + resistor(power,​Output).
 +
 +/*
 +nand_gate(Input1,​Input2,​Output):​-
 +   ​Output is the logical nand of Input1 and Input2.
 +*/
 +
 +nand_gate(Input1,​Input2,​Output) :-
 + transistor(Input1,​X,​Output),​
 + transistor(Input2,​ground,​X),​
 + resistor(power,​Output).
 +
 +/*
 +and_gate(Input1,​Input2,​Output):​-
 +  Output is the logical and of Input1 and Input2.  ​    
 +*/
 +
 +and_gate(Input1,​Input2,​Output) :-
 + nand_gate(Input1,​Input2,​X),​
 + inverter(X,​Output).
 +
 +%Program 2.2: A circuit for a logical and-gate
 +
 +</​code>​
 +===== Comments =====
  
pl/prolog/pllib/and_gate.txt · ostatnio zmienione: 2019/06/27 15:50 (edycja zewnętrzna)
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0