The problem was, that the method getInputValues() did not really return
the current input values, but the last ones that already reached the
wire. This means that different value ranges could not be combined,
since the method already returned the some time ago successfully inputed
values.
This could also cause Problems with setState, since this method used to
compare the argument against the values inputed on the wire, but not
some feedSignals call that is sill due in the Timeline. Therefore a
value change might be discarded although it might actually change the
values again (back):
new: 1010 --- (still in Timeline: 0000) --- already set: 1010
The old method would not have noticed this and ignored the new values.
It is possible, that there are more bugs like this in logic core.
{
private Collection<LogicObserver> observers;
private ReadWriteEnd output;
+ private BitVector inputValues;
public ManualSwitch(Timeline timeline, ReadWriteEnd output)
{
super(timeline);
observers = new ArrayList<>();
this.output = output;
+ this.inputValues = output.getInputValues();
}
public void switchFullOn()
{
if (bits.length() != output.width())
throw new IllegalArgumentException("Incorrect bit vector length");
- if (bits.equals(output.getInputValues()))
+ if (bits.equals(inputValues))
return;
+ inputValues = bits;
output.feedSignals(bits);
notifyObservers();
}
public BitVector getValues()
{
- return output.getInputValues();
+ return inputValues;
}
@Override