1 package era.mi.logic;
\r
3 import java.util.Arrays;
\r
9 public static Bit and(Bit a, Bit b)
\r
14 public Bit and(Bit other)
\r
16 if (this == ZERO || other == ZERO)
\r
18 else if (this == other && this == ONE)
\r
20 else if (this == X || other == X)
\r
26 public static Bit or(Bit a, Bit b)
\r
31 public Bit or(Bit other)
\r
33 if (this == ONE || other == ONE)
\r
35 else if (this == other && this == ZERO)
\r
37 else if (this == X || other == X)
\r
43 public static Bit xor(Bit a, Bit b)
\r
48 public Bit xor(Bit other)
\r
50 if(this == X || this == Z || other == X || other == Z)
\r
53 return this == other ? ZERO : ONE;
\r
69 public Bit[] makeArray(int length)
\r
71 Bit[] bits = new Bit[length];
\r
72 Arrays.fill(bits, this);
\r
77 * Rules for two bits that get directly connected<br>
\r
80 * <tr><td><td>X<td>0<td>1<td>Z</tr>
\r
81 * <tr><td>X<td>X<td>X<td>X<td>X</tr>
\r
82 * <tr><td>0<td>X<td>0<td>X<td>0</tr>
\r
83 * <tr><td>1<td>X<td>X<td>1<td>1</tr>
\r
84 * <tr><td>Z<td>X<td>0<td>1<td>Z</tr>
\r
88 * @return the result according to the table
\r
90 * @author Christian Femers
\r
92 public Bit combineWith(Bit other)
\r
96 if (this == X || other == X)
\r
105 public static Bit combine(Bit a, Bit b)
\r
107 return a.combineWith(b);
\r