mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-27 15:03:21 -04:00
fixed a bug in the power supply
This commit is contained in:
parent
9ca0b2b84b
commit
e4367eb1b0
@ -14,7 +14,7 @@ import static de.neemann.digital.core.element.PinInfo.input;
|
||||
* Enforces a power supply
|
||||
* Created by hneemann on 15.07.17.
|
||||
*/
|
||||
public class PowerSupply implements Element {
|
||||
public class PowerSupply extends Node implements Element {
|
||||
|
||||
/**
|
||||
* Enforces a power supply
|
||||
@ -24,6 +24,9 @@ public class PowerSupply implements Element {
|
||||
.addAttribute(Keys.ROTATE)
|
||||
.addAttribute(Keys.LABEL);
|
||||
|
||||
private ObservableValue vcc;
|
||||
private ObservableValue gnd;
|
||||
|
||||
/**
|
||||
* Creates a new instance
|
||||
*
|
||||
@ -34,13 +37,8 @@ public class PowerSupply implements Element {
|
||||
|
||||
@Override
|
||||
public void setInputs(ObservableValues inputs) throws NodeException {
|
||||
check(inputs.get(0).checkBits(1, null, 0), 1);
|
||||
check(inputs.get(1).checkBits(1, null, 1), 0);
|
||||
}
|
||||
|
||||
private void check(ObservableValue val, int expected) throws NodeException {
|
||||
if (!val.isConstant() || val.getValue() != expected)
|
||||
throw new NodeException(Lang.get("err_errorInPowerSupply"), val);
|
||||
vcc = inputs.get(0).checkBits(1, null, 0).addObserverToValue(this);
|
||||
gnd = inputs.get(1).checkBits(1, null, 1).addObserverToValue(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -49,6 +47,15 @@ public class PowerSupply implements Element {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerNodes(Model model) {
|
||||
public void readInputs() throws NodeException {
|
||||
if (vcc.getValue() != 1 || vcc.isHighZ())
|
||||
throw new NodeException(Lang.get("err_errorInPowerSupply", "VCC"), vcc);
|
||||
if (gnd.getValue() != 0 || gnd.isHighZ())
|
||||
throw new NodeException(Lang.get("err_errorInPowerSupply", "GND"), gnd);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeOutputs() throws NodeException {
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import de.neemann.digital.core.element.ElementAttributes;
|
||||
import de.neemann.digital.core.element.Key;
|
||||
import de.neemann.digital.core.element.Keys;
|
||||
import de.neemann.digital.core.io.In;
|
||||
import de.neemann.digital.core.io.InValue;
|
||||
import de.neemann.digital.core.io.Out;
|
||||
import de.neemann.digital.core.io.PowerSupply;
|
||||
import de.neemann.digital.core.memory.ROM;
|
||||
@ -732,6 +733,7 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
|
||||
.setShapeFactory(shapeFactory)
|
||||
.setAttribute(Keys.LABEL, "VCC")
|
||||
.setAttribute(Keys.PINNUMBER, maxNum)
|
||||
.setAttribute(Keys.INPUT_DEFAULT, new InValue(1))
|
||||
.setPos(new Vector(0, 0)));
|
||||
list.add(new VisualElement(In.DESCRIPTION.getName())
|
||||
.setShapeFactory(shapeFactory)
|
||||
|
@ -555,7 +555,7 @@ Sind evtl. die Namen der Variablen nicht eindeutig?</string>
|
||||
<string name="err_nameUsedTwice_N">Signal {0} wurde mehrfach verwendet!</string>
|
||||
<string name="err_errorParsingTestdata">Fehler beim Einlesen der Testdaten.</string>
|
||||
<string name="err_backtrackOf_N_isImpossible">Die Modelkomponente {0} kann nicht analysiert werden.</string>
|
||||
<string name="err_errorInPowerSupply">Fehler in der Stromversorgung.</string>
|
||||
<string name="err_errorInPowerSupply">Fehler in der Stromversorgung an {0}.</string>
|
||||
|
||||
<string name="key_AddrBits">Adress-Bits</string>
|
||||
<string name="key_AddrBits_tt">Anzahl der Adress-Bits die verwendet werden.</string>
|
||||
|
@ -543,7 +543,7 @@ The names of the variables may not be unique.</string>
|
||||
<string name="err_nameUsedTwice_N">Signal {0} is used twice!</string>
|
||||
<string name="err_errorParsingTestdata">Error parsing the test data.</string>
|
||||
<string name="err_backtrackOf_N_isImpossible">The model component {0} can not be analysed.</string>
|
||||
<string name="err_errorInPowerSupply">Error in wiring of power supply.</string>
|
||||
<string name="err_errorInPowerSupply">Error in wiring of power supply at {0}.</string>
|
||||
|
||||
<string name="key_AddrBits">Address Bits</string>
|
||||
<string name="key_AddrBits_tt">Number of address bits used.</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user