* 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
+ * @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 width The amount of bits to fuse
*/
- public static void fuse(Wire a, Wire b, int fromA, int fromB, int length)
+ public static void fuse(Wire a, Wire b, int fromA, int fromB, int width)
{
ReadWriteEnd rA = a.createReadWriteEnd(), rB = b.createReadWriteEnd();
rA.setWriting(false);
rB.setWriting(false);
rA.setValues(BitVector.of(Bit.Z, a.width));
rB.setValues(BitVector.of(Bit.Z, b.width));
- Fusion aF = new Fusion(rB, fromA, fromB, length), bF = new Fusion(rA, fromB, fromA, length);
+ Fusion aF = new Fusion(rB, fromA, fromB, width), bF = new Fusion(rA, fromB, fromA, width);
rA.registerObserver(aF);
rB.registerObserver(bF);
aF.update(rA);
private static class Fusion implements LogicObserver
{
private ReadWriteEnd target;
- int fromSource, fromTarget, length;
+ int fromSource, fromTarget, width;
- public Fusion(ReadWriteEnd target, int fromSource, int fromTarget, int length)
+ public Fusion(ReadWriteEnd target, int fromSource, int fromTarget, int width)
{
this.target = target;
this.fromSource = fromSource;
this.fromTarget = fromTarget;
- this.length = length;
+ this.width = width;
}
@Override
else
{
target.setWriting(true);
- BitVector targetInput = source.wireValuesExcludingMe().subVector(fromSource, fromSource + length);
+ BitVector targetInput = source.wireValuesExcludingMe().subVector(fromSource, fromSource + width);
target.setValues(fromTarget, targetInput);
}
}