mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-16 00:15:01 -04:00
allows unconnected wires; closes #546
This commit is contained in:
parent
afd3e737d9
commit
6c891f9978
@ -46,9 +46,12 @@ public class ObservableValue extends Observable implements PinDescription {
|
||||
|
||||
/**
|
||||
* Makes this value a constant value
|
||||
*
|
||||
* @return this for chained calls
|
||||
*/
|
||||
public void setConstant() {
|
||||
public ObservableValue setConstant() {
|
||||
isConstant = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -27,6 +27,7 @@ import java.util.HashSet;
|
||||
* After creation all the ObservableValues belonging to the outputs are set.
|
||||
*/
|
||||
public class Net {
|
||||
private static final ObservableValue UNCONNECTED_WIRE = new ObservableValue("unconnected wire", 1).setToHighZ().setConstant();
|
||||
|
||||
private final HashSet<Vector> points;
|
||||
private final ArrayList<Pin> pins;
|
||||
@ -172,14 +173,17 @@ public class Net {
|
||||
outputs.add(p);
|
||||
}
|
||||
|
||||
if (outputs.size() == 0)
|
||||
if (outputs.size() == 0 && inputs.size() > 0)
|
||||
throw new PinException(Lang.get("err_noOutConnectedToWire", this.toString()), this);
|
||||
|
||||
ObservableValue value = null;
|
||||
ObservableValue value;
|
||||
if (outputs.size() == 1 && outputs.get(0).getPullResistor() == PinDescription.PullResistor.none) {
|
||||
value = outputs.get(0).getValue();
|
||||
} else {
|
||||
value = new DataBus(this, m, outputs).getReadableOutput();
|
||||
if (inputs.size() == 0 && outputs.size() == 0) // unconnected wire
|
||||
value = UNCONNECTED_WIRE;
|
||||
else
|
||||
value = new DataBus(this, m, outputs).getReadableOutput();
|
||||
}
|
||||
|
||||
if (value == null)
|
||||
|
Loading…
x
Reference in New Issue
Block a user