/ src / hal / components / mux4.comp
mux4.comp
 1  component mux4 "Select from one of four input values";
 2  pin in bit sel0;
 3  pin in bit sel1 """\
 4  Together, these determine which \\fBin\\fIN\\fR value is copied to \\fBout\\fR.
 5  """;
 6  pin out float out """\
 7  Follows the value of one of the \\fBin\\fIN\\fR values according to the two \\fBsel\\fR values
 8  .RS
 9  .TP
10  \\fBsel1=FALSE\\fR, \\fBsel0=FALSE\\fR
11  \\fBout\\fR follows \\fBin0\\fR
12  .TP
13  \\fBsel1=FALSE\\fR, \\fBsel0=TRUE\\fR
14  \\fBout\\fR follows \\fBin1\\fR
15  .TP
16  \\fBsel1=TRUE\\fR, \\fBsel0=FALSE\\fR
17  \\fBout\\fR follows \\fBin2\\fR
18  .TP
19  \\fBsel1=TRUE\\fR, \\fBsel0=TRUE\\fR
20  \\fBout\\fR follows \\fBin3\\fR
21  .RE
22  """;
23  pin in float in0;
24  pin in float in1;
25  pin in float in2;
26  pin in float in3;
27  function _;
28  license "GPL";
29  ;;
30  FUNCTION(_) {
31      if(sel1) {
32          if(sel0) out = in3;
33          else out = in2;
34      } else {
35          if(sel0) out = in1;
36          else out = in0;
37      }
38  }