values = U.toVector(length);\r
}\r
\r
- private void recalculateSingleInput()\r
- {\r
- setNewValues(inputs.get(0).getInputValues());\r
- }\r
-\r
- private void recalculateMultipleInputs()\r
- {\r
- BitVectorMutator mutator = BitVectorMutator.empty();\r
- for (ReadWriteEnd wireArrayEnd : inputs)\r
- mutator.join(wireArrayEnd.getInputValues());\r
- setNewValues(mutator.toBitVector());\r
- }\r
-\r
private void setNewValues(BitVector newValues)\r
{\r
if (values.equals(newValues))\r
\r
void recalculate()\r
{\r
- switch (inputs.size())\r
- {\r
- case 0:\r
+ if (inputs.size() == 0)\r
setNewValues(BitVector.of(Bit.U, length));\r
- break;\r
- case 1:\r
- recalculateSingleInput();\r
- break;\r
- default:\r
- recalculateMultipleInputs();\r
+ else\r
+ {\r
+ BitVectorMutator mutator = BitVectorMutator.empty();\r
+ for (ReadWriteEnd wireArrayEnd : inputs)\r
+ mutator.join(wireArrayEnd.getInputValues());\r
+ setNewValues(mutator.toBitVector());\r
}\r
}\r
\r
+ /**\r
+ * Forces a Wire to take on specific values. If the new values differ from the old ones, the observers of the Wire will be notified.\r
+ * WARNING! Use this with care! The preferred way of writing the values is ReadWriteEnd.feedSignals(BitVector)\r
+ * \r
+ * @param values The values the <code>Wire</code> will have immediately after this method is called\r
+ */\r
+ public void forceValues(BitVector values)\r
+ {\r
+ setNewValues(values);\r
+ }\r
+\r
/**\r
* The {@link Wire} is interpreted as an unsigned integer with n bits.\r
* \r
return val;\r
}\r
\r
+ /**\r
+ * Returns the least significant bit (LSB)\r
+ */\r
public Bit getValue()\r
{\r
return getValue(0);\r
}\r
\r
+ /**\r
+ * Returns the least significant bit (LSB) of the given index\r
+ */\r
public Bit getValue(int index)\r
{\r
- return values.getBit(index);\r
+ return values.getLSBit(index);\r
}\r
\r
public BitVector getValues(int start, int end)\r
}\r
\r
/**\r
- * @return The value (of bit 0) the {@link ReadEnd} is currently feeding into the associated {@link Wire}.\r
+ * @return The value (of bit 0) the {@link ReadEnd} is currently feeding into the associated {@link Wire}.Returns the least\r
+ * significant bit (LSB)\r
*/\r
public Bit getInputValue()\r
{\r
\r
/**\r
* @return The value which the {@link ReadEnd} is currently feeding into the associated {@link Wire} at the indexed {@link Bit}.\r
+ * Returns the least significant bit (LSB)\r
+ * \r
*/\r
public Bit getInputValue(int index)\r
{\r
- return inputValues.getBit(index);\r
+ return inputValues.getLSBit(index);\r
}\r
\r
/**\r
*/\r
public BitVector getInputValues()\r
{\r
- return getInputValues(0, length);\r
+ return inputValues;\r
}\r
\r
public BitVector getInputValues(int start, int end)\r