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