X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.logic.core%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fcore%2Fwires%2FCoreWire.java;h=13f54a0188bbb4d62f763e8f6181c4b4569aceba;hb=9c98bb5456a7ead6d92fcc6acd9d1497688b244d;hp=7d81f6dde13a48f086e677a3d2fdba910d7c364a;hpb=b32414f8406634aca730d724a011023c0da8bf22;p=Mograsim.git
diff --git a/net.mograsim.logic.core/src/net/mograsim/logic/core/wires/CoreWire.java b/net.mograsim.logic.core/src/net/mograsim/logic/core/wires/CoreWire.java
index 7d81f6dd..13f54a01 100644
--- a/net.mograsim.logic.core/src/net/mograsim/logic/core/wires/CoreWire.java
+++ b/net.mograsim.logic.core/src/net/mograsim/logic/core/wires/CoreWire.java
@@ -124,68 +124,9 @@ public class CoreWire
*/
public void forceValues(BitVector values)
{
- setNewValues(values);
- }
-
- /**
- * The {@link CoreWire} is interpreted as an unsigned integer with n bits.
- *
- * @return true
if all bits are either Bit.ONE
or Bit.ZERO
(they do not all have to have the same
- * value), not Bit.U
, Bit.X
or Bit.Z
. false
is returned otherwise.
- *
- * @author Fabian Stemmler
- */
- public boolean hasNumericValue()
- {
- return getValues().isBinary();
- }
-
- /**
- * The {@link CoreWire} is interpreted as an unsigned integer with n bits.
- *
- * @return The unsigned value of the {@link CoreWire}'s bits, where value 0 corresponds with 2^0, value 1 is 2^1 and so on.
- *
- * @author Fabian Stemmler
- */
- public long getUnsignedValue()
- {
- long val = 0;
- long mask = 1;
- for (Bit bit : getValues())
- {
- switch (bit)
- {
- default:
- case Z:
- case X:
- return 0; // TODO: Proper handling for getUnsignedValue(), if not all bits are 1 or 0;
- case ONE:
- val |= mask;
- break;
- case ZERO:
- }
- mask = mask << 1;
- }
- return val;
- }
-
- /**
- * The {@link CoreWire} is interpreted as a signed integer with n bits.
- *
- * @return The signed value of the {@link CoreWire}'s bits, where value 0 corresponds with 2^0, value 1 is 2^1 and so on.
- *
- * @author Fabian Stemmler
- */
- public long getSignedValue()
- {
- long val = getUnsignedValue();
- long mask = 1 << (width - 1);
- if ((mask & val) != 0)
- {
- int shifts = 64 - width;
- return (val << shifts) >> shifts;
- }
- return val;
+ bitsWithoutFusions = values.getBits();
+ invalidateCachedValuesForAllFusedWires();
+ notifyObservers();
}
/**
@@ -324,43 +265,6 @@ public class CoreWire
return CoreWire.this.getValues(start, end);
}
- /**
- * The {@link CoreWire} is interpreted as an unsigned integer with n bits.
- *
- * @return true
if all bits are either Bit.ONE
or Bit.ZERO
(they do not all have to have the
- * same value), not Bit.X
or Bit.Z
. false
is returned otherwise.
- *
- * @author Fabian Stemmler
- */
- public boolean hasNumericValue()
- {
- return CoreWire.this.hasNumericValue();
- }
-
- /**
- * The {@link CoreWire} is interpreted as an unsigned integer with n bits.
- *
- * @return The unsigned value of the {@link CoreWire}'s bits, where value 0 corresponds with 2^0, value 1 is 2^1 and so on.
- *
- * @author Fabian Stemmler
- */
- public long getUnsignedValue()
- {
- return CoreWire.this.getUnsignedValue();
- }
-
- /**
- * The {@link CoreWire} is interpreted as a signed integer with n bits.
- *
- * @return The signed value of the {@link CoreWire}'s bits, where value 0 corresponds with 2^0, value 1 is 2^1 and so on.
- *
- * @author Fabian Stemmler
- */
- public long getSignedValue()
- {
- return CoreWire.this.getSignedValue();
- }
-
@Override
public String toString()
{
@@ -445,6 +349,7 @@ public class CoreWire
feedSignals(BitVector.of(newValues));
}
+ // TODO what if this is called multiple times at the same simulation time? (happens in component unit tests)
public void feedSignals(BitVector newValues)
{
if (newValues.length() != width)