/ src / hal / components / xor2.comp
xor2.comp
 1  component xor2 "Two-input XOR (exclusive OR) gate";
 2  pin in bit in0;
 3  pin in bit in1;
 4  pin out bit out """\
 5  \\fBout\\fR is computed from the value of \\fBin0\\fR and \\fBin1\\fR according
 6  to the following rule:
 7  .RS
 8  .TP
 9  \\fBin0=TRUE in1=FALSE\\fR
10  .TQ
11  \\fBin0=FALSE in1=TRUE\\fR
12  \\fBout=TRUE\\fR
13  .TP
14  Otherwise,
15  \\fBout=FALSE\\fR""";
16  function _ nofp;
17  license "GPL";
18  ;;
19  FUNCTION(_) {
20      if (( in0 && !in1 ) || ( in1 && !in0 )) {
21  	out = 1;
22      } else {
23  	out = 0;
24      }
25  }
26