BitVectorMutator mutator = BitVectorMutator.empty();
for (ReadWriteEnd wireArrayEnd : inputs)
mutator.join(wireArrayEnd.getInputValues());
BitVectorMutator mutator = BitVectorMutator.empty();
for (ReadWriteEnd wireArrayEnd : inputs)
mutator.join(wireArrayEnd.getInputValues());
- * @formatter:off
- * Fuses the selected bits of two wires together. If the bits change in one Wire, the other is changed accordingly immediately.
- * Warning: The bits are permanently fused together.
- * @formatter:on
- * @param a The {@link Wire} to be (partially) fused with b
- * @param b The {@link Wire} to be (partially) fused with a
- * @param fromA The first bit of {@link Wire} a to be fused
- * @param fromB The first bit of {@link Wire} b to be fused
+ * Fuses the selected bits of two wires together. If the bits change in one Wire, the other is changed accordingly immediately. Warning:
+ * The bits are permanently fused together.
+ *
+ * @param a The {@link Wire} to be (partially) fused with b
+ * @param b The {@link Wire} to be (partially) fused with a
+ * @param fromA The first bit of {@link Wire} a to be fused
+ * @param fromB The first bit of {@link Wire} b to be fused
* @param length The amount of bits to fuse
*/
public static void fuse(Wire a, Wire b, int fromA, int fromB, int length)
{
ReadWriteEnd rA = a.createReadWriteEnd(), rB = b.createReadWriteEnd();
* @param length The amount of bits to fuse
*/
public static void fuse(Wire a, Wire b, int fromA, int fromB, int length)
{
ReadWriteEnd rA = a.createReadWriteEnd(), rB = b.createReadWriteEnd();
rA.setValues(BitVector.of(Bit.Z, a.length));
rB.setValues(BitVector.of(Bit.Z, b.length));
rA.setValues(BitVector.of(Bit.Z, a.length));
rB.setValues(BitVector.of(Bit.Z, b.length));
- rA.registerObserver(new Fusion(rB, fromA, fromB, length));
- rB.registerObserver(new Fusion(rA, fromB, fromA, length));
+ Fusion aF = new Fusion(rB, fromA, fromB, length), bF = new Fusion(rA, fromB, fromA, length);
+ rA.registerObserver(aF);
+ rB.registerObserver(bF);
+ aF.update(rA);
+ bF.update(rB);
- * @formatter:off
- * Fuses the selected bits of two wires together. If the bits change in one Wire, the other is changed accordingly immediately.
- * Warning: The bits are permanently fused together.
- * @formatter:on
+ *
+ * Fuses two wires together. If the bits change in one Wire, the other is changed accordingly immediately. Warning: The bits are
+ * permanently fused together.
+ *
- ReadWriteEnd read = (ReadWriteEnd) initiator;
- target.setValues(fromTarget, read.wireValuesExcludingMe().subVector(fromSource, fromSource + length));
+ ReadWriteEnd source = (ReadWriteEnd) initiator;
+ if (source.getWire().inputs.size() - (source.isWriting() ? 1 : 0) == 0)
+ target.setWriting(false);
+ else
+ {
+ target.setWriting(true);
+ BitVector targetInput = source.wireValuesExcludingMe().subVector(fromSource, fromSource + length);
+ target.setValues(fromTarget, targetInput);
+ }