mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-17 17:04:42 -04:00
removed obsolete constructor from ObservableValue.java
This commit is contained in:
parent
8d4ce9bcc2
commit
694584157c
@ -30,40 +30,16 @@ public class ObservableValue extends Observable implements PinDescription {
|
||||
private String pinNumber;
|
||||
|
||||
/**
|
||||
* Creates a new instance
|
||||
* Creates a new instance.
|
||||
*
|
||||
* @param name the name of this value
|
||||
* @param bits the number of bits
|
||||
* @param name the name of this value
|
||||
* @param bits the number of bits
|
||||
*/
|
||||
public ObservableValue(String name, int bits) {
|
||||
this(name, bits, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*
|
||||
* @param name the name of this value
|
||||
* @param bits the number of bits
|
||||
* @param highZ if true this value can be a high impedance value
|
||||
*/
|
||||
public ObservableValue(String name, int bits, boolean highZ) {
|
||||
this(name, bits, highZ ? -1 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*
|
||||
* @param name the name of this value
|
||||
* @param bits the number of bits
|
||||
* @param highZ if true this value can be a high impedance value
|
||||
*/
|
||||
public ObservableValue(String name, int bits, long highZ) {
|
||||
super();
|
||||
this.name = name;
|
||||
this.bits = bits;
|
||||
mask = Bits.mask(bits);
|
||||
this.highZ = highZ & mask;
|
||||
signedFlag = Bits.signedFlagMask(bits);
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
|
@ -52,14 +52,15 @@ public class In implements Element {
|
||||
*/
|
||||
public In(ElementAttributes attributes) {
|
||||
InValue value = attributes.get(Keys.INPUT_DEFAULT);
|
||||
boolean highZ = attributes.get(Keys.IS_HIGH_Z) || value.isHighZ();
|
||||
pinNumber = attributes.get(Keys.PINNUMBER);
|
||||
output = new ObservableValue("out", attributes.get(Keys.BITS), highZ).setPinDescription(DESCRIPTION).setPinNumber(pinNumber);
|
||||
output = new ObservableValue("out", attributes.get(Keys.BITS))
|
||||
.setPinDescription(DESCRIPTION)
|
||||
.setPinNumber(pinNumber);
|
||||
boolean highZ = attributes.get(Keys.IS_HIGH_Z) || value.isHighZ();
|
||||
if (highZ)
|
||||
output.setToHighZ();
|
||||
output.setToHighZ().setBidirectional();
|
||||
else
|
||||
output.setValue(value.getValue());
|
||||
if (highZ) output.setBidirectional();
|
||||
label = attributes.getCleanLabel();
|
||||
format = attributes.get(Keys.INT_FORMAT);
|
||||
}
|
||||
|
@ -60,8 +60,11 @@ public class RAMDualAccess extends Node implements Element, RAMInterface {
|
||||
public RAMDualAccess(ElementAttributes attr) {
|
||||
super(true);
|
||||
bits = attr.get(Keys.BITS);
|
||||
out1 = new ObservableValue("1D", bits, true).setPinDescription(DESCRIPTION);
|
||||
out2 = new ObservableValue("2D", bits).setPinDescription(DESCRIPTION);
|
||||
out1 = new ObservableValue("1D", bits)
|
||||
.setToHighZ()
|
||||
.setPinDescription(DESCRIPTION);
|
||||
out2 = new ObservableValue("2D", bits)
|
||||
.setPinDescription(DESCRIPTION);
|
||||
addrBits = attr.get(Keys.ADDR_BITS);
|
||||
size = 1 << addrBits;
|
||||
memory = new DataField(size);
|
||||
|
@ -68,7 +68,9 @@ public class RAMDualPort extends Node implements Element, RAMInterface {
|
||||
* @return the output value
|
||||
*/
|
||||
protected ObservableValue createOutput() {
|
||||
return new ObservableValue("D", bits, true).setPinDescription(DESCRIPTION);
|
||||
return new ObservableValue("D", bits)
|
||||
.setToHighZ()
|
||||
.setPinDescription(DESCRIPTION);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -66,7 +66,10 @@ public class RAMSinglePortSel extends Node implements Element, RAMInterface {
|
||||
size = 1 << addrBits;
|
||||
memory = createDataField(attr, size);
|
||||
label = attr.getCleanLabel();
|
||||
dataOut = new ObservableValue("D", bits, true).setPinDescription(DESCRIPTION).setBidirectional();
|
||||
dataOut = new ObservableValue("D", bits)
|
||||
.setToHighZ()
|
||||
.setPinDescription(DESCRIPTION)
|
||||
.setBidirectional();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -61,7 +61,9 @@ public class ROM extends Node implements Element, ROMInterface {
|
||||
*/
|
||||
public ROM(ElementAttributes attr) {
|
||||
dataBits = attr.get(Keys.BITS);
|
||||
output = new ObservableValue("D", dataBits, true).setPinDescription(DESCRIPTION);
|
||||
output = new ObservableValue("D", dataBits)
|
||||
.setToHighZ()
|
||||
.setPinDescription(DESCRIPTION);
|
||||
data = attr.get(Keys.DATA);
|
||||
addrBits = attr.get(Keys.ADDR_BITS);
|
||||
autoLoad = attr.get(Keys.AUTO_RELOAD_ROM);
|
||||
|
@ -36,8 +36,12 @@ public class Diode implements Element, NodeInterface {
|
||||
* @param attr the elements attributes
|
||||
*/
|
||||
public Diode(ElementAttributes attr) {
|
||||
cathode = new ObservableValue("cathode", 1, true).setBidirectional();
|
||||
anode = new ObservableValue("anode", 1, true).setBidirectional();
|
||||
cathode = new ObservableValue("cathode", 1)
|
||||
.setToHighZ()
|
||||
.setBidirectional();
|
||||
anode = new ObservableValue("anode", 1)
|
||||
.setToHighZ()
|
||||
.setBidirectional();
|
||||
blown = attr.get(Keys.BLOWN);
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,10 @@ public class DiodeForward implements Element, NodeInterface {
|
||||
* @param requiredResistor resistor needed at the output net
|
||||
*/
|
||||
protected DiodeForward(ElementAttributes attr, ElementTypeDescription description, PinDescription.PullResistor requiredResistor) {
|
||||
output = new ObservableValue("out", 1, true).setPinDescription(description).setBidirectional();
|
||||
output = new ObservableValue("out", 1)
|
||||
.setToHighZ()
|
||||
.setPinDescription(description)
|
||||
.setBidirectional();
|
||||
this.requiredResistor = requiredResistor;
|
||||
blown = attr.get(Keys.BLOWN);
|
||||
if (blown)
|
||||
|
@ -57,7 +57,8 @@ public class PullDown implements Element {
|
||||
private final PullResistor res;
|
||||
|
||||
PullObservableValue(int bits, PullResistor res) {
|
||||
super("out", bits, true);
|
||||
super("out", bits);
|
||||
setToHighZ();
|
||||
this.res = res;
|
||||
}
|
||||
|
||||
|
@ -73,8 +73,8 @@ public class Switch implements Element, NodeInterface {
|
||||
public Switch(ElementAttributes attr, boolean closed, String out1, String out2) {
|
||||
bits = attr.getBits();
|
||||
this.closed = closed;
|
||||
output1 = new ObservableValue(out1, bits, true).setBidirectional().setToHighZ();
|
||||
output2 = new ObservableValue(out2, bits, true).setBidirectional().setToHighZ();
|
||||
output1 = new ObservableValue(out1, bits).setBidirectional().setToHighZ();
|
||||
output2 = new ObservableValue(out2, bits).setBidirectional().setToHighZ();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -47,13 +47,15 @@ public class BusSplitter extends Node implements Element {
|
||||
public BusSplitter(ElementAttributes attr) {
|
||||
ObservableValues.Builder builder = new ObservableValues.Builder();
|
||||
bits = attr.getBits();
|
||||
commonOut = new ObservableValue("D", bits, true)
|
||||
commonOut = new ObservableValue("D", bits)
|
||||
.setToHighZ()
|
||||
.setBidirectional()
|
||||
.setPinDescription(DESCRIPTION);
|
||||
builder.add(commonOut);
|
||||
out = new ObservableValue[bits];
|
||||
for (int i = 0; i < bits; i++) {
|
||||
out[i] = new ObservableValue("D" + i, 1, true)
|
||||
out[i] = new ObservableValue("D" + i, 1)
|
||||
.setToHighZ()
|
||||
.setBidirectional()
|
||||
.setDescription(Lang.get("elem_BusSplitter_pin_D_N", i));
|
||||
builder.add(out[i]);
|
||||
|
@ -45,7 +45,9 @@ public class Driver extends Node implements Element {
|
||||
*/
|
||||
public Driver(ElementAttributes attributes) {
|
||||
bits = attributes.get(Keys.BITS);
|
||||
output = new ObservableValue("out", bits, true).setPinDescription(DESCRIPTION);
|
||||
output = new ObservableValue("out", bits)
|
||||
.setToHighZ()
|
||||
.setPinDescription(DESCRIPTION);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -29,7 +29,9 @@ public final class CommonBusValue extends ObservableValue implements NodeInterfa
|
||||
}
|
||||
|
||||
CommonBusValue(int bits, BusModelStateObserver obs, PullResistor resistor, ObservableValue[] inputs, File origin) {
|
||||
super("commonBusOut", bits, resistor.equals(PullResistor.none));
|
||||
super("commonBusOut", bits);
|
||||
if (resistor.equals(PullResistor.none))
|
||||
setToHighZ();
|
||||
this.obs = obs;
|
||||
this.resistor = resistor;
|
||||
this.inputs = inputs;
|
||||
|
@ -86,7 +86,8 @@ public class GraphicCard extends Node implements Element, RAMInterface {
|
||||
addrBits = aBits;
|
||||
memory = new DataField(size);
|
||||
|
||||
dataOut = new ObservableValue("D", bits, true)
|
||||
dataOut = new ObservableValue("D", bits)
|
||||
.setToHighZ()
|
||||
.setPinDescription(DESCRIPTION)
|
||||
.setBidirectional();
|
||||
}
|
||||
|
@ -45,7 +45,9 @@ public class Keyboard extends Node implements Element {
|
||||
* @param attributes the attributes
|
||||
*/
|
||||
public Keyboard(ElementAttributes attributes) {
|
||||
data = new ObservableValue("D", 16, true).setPinDescription(DESCRIPTION);
|
||||
data = new ObservableValue("D", 16)
|
||||
.setToHighZ()
|
||||
.setPinDescription(DESCRIPTION);
|
||||
label = attributes.getCleanLabel();
|
||||
}
|
||||
|
||||
|
@ -63,16 +63,18 @@ public class ObservableValueTest extends TestCase {
|
||||
}
|
||||
|
||||
public void testNoChange() {
|
||||
ObservableValue v = new ObservableValue("z", 4, 3).addObserverToValue(Assert::fail);
|
||||
v.set(0,3);
|
||||
v.set(1,3);
|
||||
v.set(2,3);
|
||||
v.set(3,3);
|
||||
ObservableValue v = new ObservableValue("z", 4)
|
||||
.setToHighZ()
|
||||
.addObserverToValue(Assert::fail);
|
||||
v.set(0,15);
|
||||
v.set(1,15);
|
||||
v.set(2,15);
|
||||
v.set(3,15);
|
||||
}
|
||||
|
||||
public void testChange() {
|
||||
ChangeDetector cd = new ChangeDetector();
|
||||
ObservableValue v = new ObservableValue("z", 4, 3).addObserverToValue(cd);
|
||||
ObservableValue v = new ObservableValue("z", 4).addObserverToValue(cd);
|
||||
v.set(0, 2);
|
||||
assertTrue(cd.isChanged());
|
||||
v.set(2, 2);
|
||||
|
@ -18,8 +18,10 @@ import junit.framework.TestCase;
|
||||
public class DataBusTest extends TestCase {
|
||||
|
||||
public void testSimple() throws PinException, NodeException {
|
||||
ObservableValue a = new ObservableValue("a", 4, true);
|
||||
ObservableValue b = new ObservableValue("b", 4, true);
|
||||
ObservableValue a = new ObservableValue("a", 4)
|
||||
.setToHighZ();
|
||||
ObservableValue b = new ObservableValue("b", 4)
|
||||
.setToHighZ();
|
||||
|
||||
Model m = new Model();
|
||||
|
||||
|
@ -22,7 +22,8 @@ import static de.neemann.digital.core.ObservableValues.ovs;
|
||||
public class SplitterHighZTest extends TestCase {
|
||||
|
||||
public void testHighZError() throws NodeException, PinException {
|
||||
ObservableValue a = new ObservableValue("a", 1, true);
|
||||
ObservableValue a = new ObservableValue("a", 1)
|
||||
.setToHighZ();
|
||||
ObservableValue b = new ObservableValue("b", 1);
|
||||
|
||||
Splitter splitter = new Splitter(new ElementAttributes()
|
||||
@ -43,7 +44,8 @@ public class SplitterHighZTest extends TestCase {
|
||||
}
|
||||
|
||||
public void testHighZEnabled() throws NodeException, PinException {
|
||||
ObservableValue a = new ObservableValue("a", 2, true);
|
||||
ObservableValue a = new ObservableValue("a", 2)
|
||||
.setToHighZ();
|
||||
|
||||
Splitter splitter = new Splitter(new ElementAttributes()
|
||||
.set(Keys.INPUT_SPLIT, "2")
|
||||
|
Loading…
x
Reference in New Issue
Block a user