/ src / hal / components / mux8.comp
mux8.comp
 1  component mux8 "Select from one of eight input values";
 2  pin in bit sel0;
 3  pin in bit sel1;
 4  pin in bit sel2 """\
 5  Together, these determine which \\fBin\\fIN\\fR value is copied to \\fBout\\fR.
 6  """;
 7  pin out float out """\
 8  Follows the value of one of the \\fBin\\fIN\\fR values according to the three \\fBsel\\fR values
 9  .RS
10  .TP
11  \\fBsel2=FALSE\\fR, \\fBsel1=FALSE\\fR, \\fBsel0=FALSE\\fR
12  \\fBout\\fR follows \\fBin0\\fR
13  .TP
14  \\fBsel2=FALSE\\fR, \\fBsel1=FALSE\\fR, \\fBsel0=TRUE\\fR
15  \\fBout\\fR follows \\fBin1\\fR
16  .TP
17  \\fBsel2=FALSE\\fR, \\fBsel1=TRUE\\fR, \\fBsel0=FALSE\\fR
18  \\fBout\\fR follows \\fBin2\\fR
19  .TP
20  \\fBsel2=FALSE\\fR, \\fBsel1=TRUE\\fR, \\fBsel0=TRUE\\fR
21  \\fBout\\fR follows \\fBin3\\fR
22  .TP
23  \\fBsel2=TRUE\\fR, \\fBsel1=FALSE\\fR, \\fBsel0=FALSE\\fR
24  \\fBout\\fR follows \\fBin4\\fR
25  .TP
26  \\fBsel2=TRUE\\fR, \\fBsel1=FALSE\\fR, \\fBsel0=TRUE\\fR
27  \\fBout\\fR follows \\fBin5\\fR
28  .TP
29  \\fBsel2=TRUE\\fR, \\fBsel1=TRUE\\fR, \\fBsel0=FALSE\\fR
30  \\fBout\\fR follows \\fBin6\\fR
31  .TP
32  \\fBsel2=TRUE\\fR, \\fBsel1=TRUE\\fR, \\fBsel0=TRUE\\fR
33  \\fBout\\fR follows \\fBin7\\fR
34  .RE
35  """;
36  pin in float in0;
37  pin in float in1;
38  pin in float in2;
39  pin in float in3;
40  pin in float in4;
41  pin in float in5;
42  pin in float in6;
43  pin in float in7;
44  function _;
45  license "GPL";
46  ;;
47  FUNCTION(_) {
48      if(sel0) {
49          if(sel1) {
50              if(sel2) out = in7;
51              else     out = in3;
52          }
53          else {
54              if(sel2) out = in5;
55              else     out = in1;
56          }
57      }
58      else {
59         if(sel1) {
60              if(sel2) out = in6;
61              else     out = in2;
62          }
63          else {
64              if(sel2) out = in4;
65              else     out = in0;
66          }
67      }
68  }