+ public void addParticipatingWireBit(Wire w, int bit)
+ {
+ addParticipatingWireBit(new WireBit(w, bit));
+ }
+
+ private void addParticipatingWireBit(WireBit wb)
+ {
+ wb.wire.fusedBits[wb.bit] = this;
+ participatingWireBits.add(wb);
+ wb.wire.invalidateCachedValuesForAllFusedWires();
+ }
+
+ public void mergeOtherIntoThis(FusedBit other)
+ {
+ for (WireBit wb : other.participatingWireBits)
+ addParticipatingWireBit(wb);
+ }
+
+ public void invalidateCachedValuesForAllParticipatingWires()
+ {
+ for (WireBit wb : participatingWireBits)
+ wb.wire.invalidateCachedValues();
+ }
+
+ public Bit getValue()
+ {
+ Bit result = null;
+ for (WireBit wb : participatingWireBits)
+ if (!wb.wire.inputs.isEmpty())
+ {
+ Bit bit = wb.wire.bitsWithoutFusions[wb.bit];
+ result = result == null ? bit : result.join(bit);
+ }
+ return result == null ? U : result;
+ }
+ }
+
+ private static class WireBit
+ {
+ public final Wire wire;
+ public final int bit;
+
+ public WireBit(Wire wire, int bit)