terça-feira, 10 de maio de 2011

Somador Completo de 1bit em prolog

and(1,1).

not(0).

or(1,1).

or(1,0).

or(0,1).

xor(1,0).

xor(0,1).

xnor(0,0).

xnor(1,1).

correto(1).

sum(P,Q,Cin):-xor(P,Q),not(Cin).

sum(P,Q,Cin):-xnor(P,Q),correto(Cin).

carryOut(P,Q,Cin):-and(P,Q),not(Cin).

carryOut(P,Q,Cin):-or(P,Q),correto(Cin).