diff --git a/src/main/dig/sequential/multip_D_working_T.dig b/src/main/dig/sequential/multip_D_working_T.dig
index 850cfa9f1..3499df5f9 100644
--- a/src/main/dig/sequential/multip_D_working_T.dig
+++ b/src/main/dig/sequential/multip_D_working_T.dig
@@ -1,96 +1,184 @@
- 1
-
-
- In
-
-
- 0
-
-
- Out
-
-
- 0
-
-
- In
-
-
- 0
-
-
- D-T.dig
-
-
- 0
-
-
- D-T.dig
-
-
- 0
-
-
- D-T.dig
-
-
- 0
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ 1
+
+
+ In
+
+
+ Label
+ D
+
+
+
+
+
+ Out
+
+
+ rotation
+
+
+
+ Label
+ D_2
+
+
+
+
+
+ In
+
+
+ Label
+ C
+
+
+
+
+
+ D-T.dig
+
+
+
+
+ D-T.dig
+
+
+
+
+ D-T.dig
+
+
+
+
+ Testcase
+
+
+ Testdata
+
+ C D D_0 D_1 D_2
+# clear all bits
+C 0 0 x x
+C 0 0 0 x
+C 0 0 0 0
+
+# fill with one
+C 1 1 0 0
+C 1 1 1 0
+C 1 1 1 1
+
+# fill with zero
+C 0 0 1 1
+C 0 0 0 1
+C 0 0 0 0
+
+
+
+
+
+
+
+ Out
+
+
+ rotation
+
+
+
+ Label
+ D_0
+
+
+
+
+
+ Out
+
+
+ rotation
+
+
+
+ Label
+ D_1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/de/neemann/digital/core/pld/DiodeBackward.java b/src/main/java/de/neemann/digital/core/pld/DiodeBackward.java
index db4b34861..26a0b67bc 100644
--- a/src/main/java/de/neemann/digital/core/pld/DiodeBackward.java
+++ b/src/main/java/de/neemann/digital/core/pld/DiodeBackward.java
@@ -4,6 +4,7 @@ import de.neemann.digital.core.ObservableValue;
import de.neemann.digital.core.element.ElementAttributes;
import de.neemann.digital.core.element.ElementTypeDescription;
import de.neemann.digital.core.element.Keys;
+import de.neemann.digital.core.element.PinDescription;
import static de.neemann.digital.core.element.PinInfo.input;
@@ -27,7 +28,7 @@ public class DiodeBackward extends DiodeForeward {
* @param attr the elements attributes
*/
public DiodeBackward(ElementAttributes attr) {
- super(attr, DESCRIPTION);
+ super(attr, DESCRIPTION, PinDescription.PullResistor.pullUp);
}
@Override
diff --git a/src/main/java/de/neemann/digital/core/pld/DiodeForeward.java b/src/main/java/de/neemann/digital/core/pld/DiodeForeward.java
index 270483d3f..3c32864c5 100644
--- a/src/main/java/de/neemann/digital/core/pld/DiodeForeward.java
+++ b/src/main/java/de/neemann/digital/core/pld/DiodeForeward.java
@@ -1,10 +1,9 @@
package de.neemann.digital.core.pld;
import de.neemann.digital.core.*;
-import de.neemann.digital.core.element.Element;
-import de.neemann.digital.core.element.ElementAttributes;
-import de.neemann.digital.core.element.ElementTypeDescription;
-import de.neemann.digital.core.element.Keys;
+import de.neemann.digital.core.element.*;
+import de.neemann.digital.core.wiring.bus.CommonBusValue;
+import de.neemann.digital.lang.Lang;
import static de.neemann.digital.core.element.PinInfo.input;
@@ -24,6 +23,7 @@ public class DiodeForeward implements Element, Observer {
private final ObservableValue output;
private final boolean blown;
private ObservableValue input;
+ private PinDescription.PullResistor requiredResistor;
/**
* Creates a new instance
@@ -31,17 +31,19 @@ public class DiodeForeward implements Element, Observer {
* @param attr the elements attributes
*/
public DiodeForeward(ElementAttributes attr) {
- this(attr, DESCRIPTION);
+ this(attr, DESCRIPTION, PinDescription.PullResistor.pullDown);
}
/**
* Creates a new instance
*
- * @param attr the elements attributes
- * @param description used to set the output pin description
+ * @param attr the elements attributes
+ * @param description used to set the output pin description
+ * @param requiredResistor resistor needed at the output net
*/
- protected DiodeForeward(ElementAttributes attr, ElementTypeDescription description) {
- output = new ObservableValue("out", 1, true).setPinDescription(description);
+ protected DiodeForeward(ElementAttributes attr, ElementTypeDescription description, PinDescription.PullResistor requiredResistor) {
+ output = new ObservableValue("out", 1, true).setPinDescription(description).setBidirectional();
+ this.requiredResistor = requiredResistor;
blown = attr.get(Keys.BLOWN);
if (blown)
output.set(1, true);
@@ -50,6 +52,17 @@ public class DiodeForeward implements Element, Observer {
@Override
public void setInputs(ObservableValues inputs) throws NodeException {
input = inputs.get(0).addObserverToValue(this).checkBits(1, null);
+
+ ObservableValue o = inputs.get(1);
+ if (o instanceof CommonBusValue) {
+ CommonBusValue cbv = (CommonBusValue) o;
+ if (cbv.getResistor().equals(requiredResistor))
+ return;
+ }
+ if (requiredResistor.equals(PinDescription.PullResistor.pullDown))
+ throw new NodeException(Lang.get("err_diodeNeedsPullDownResistorAtOutput"), output.asList());
+ else
+ throw new NodeException(Lang.get("err_diodeNeedsPullUpResistorAtOutput"), output.asList());
}
@Override
diff --git a/src/main/java/de/neemann/digital/testing/TestResult.java b/src/main/java/de/neemann/digital/testing/TestResult.java
index 1035db5f2..ac0602c45 100644
--- a/src/main/java/de/neemann/digital/testing/TestResult.java
+++ b/src/main/java/de/neemann/digital/testing/TestResult.java
@@ -8,6 +8,7 @@ import de.neemann.digital.core.wiring.Clock;
import de.neemann.digital.lang.Lang;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.NoSuchElementException;
@@ -47,23 +48,31 @@ public class TestResult {
*/
public TestResult create(Model model) throws TestingDataException, NodeException {
allPassed = true;
+ HashSet usedSignals = new HashSet<>();
+
ArrayList inputs = new ArrayList<>();
for (Signal s : model.getInputs()) {
final int index = getIndexOf(s.getName());
- if (index >= 0)
+ if (index >= 0) {
inputs.add(new TestSignal(index, s.getValue()));
+ usedSignals.add(s.getName());
+ }
}
for (Clock c : model.getClocks()) {
final int index = getIndexOf(c.getLabel());
- if (index >= 0)
+ if (index >= 0) {
inputs.add(new TestSignal(index, c.getClockOutput()));
+ usedSignals.add(c.getLabel());
+ }
}
ArrayList outputs = new ArrayList<>();
for (Signal s : model.getOutputs()) {
final int index = getIndexOf(s.getName());
- if (index >= 0)
+ if (index >= 0) {
outputs.add(new TestSignal(index, s.getValue()));
+ usedSignals.add(s.getName());
+ }
}
if (inputs.size() == 0)
@@ -72,6 +81,10 @@ public class TestResult {
if (outputs.size() == 0)
throw new TestingDataException(Lang.get("err_noTestOutputSignalsDefined"));
+ for (String name : names)
+ if (!usedSignals.contains(name))
+ throw new TestingDataException(Lang.get("err_testSignal_N_notFound", name));
+
model.init();
for (Value[] rowWithDontCare : lines) {
diff --git a/src/main/resources/lang/lang_de.xml b/src/main/resources/lang/lang_de.xml
index 9903f6447..b4e78d636 100644
--- a/src/main/resources/lang/lang_de.xml
+++ b/src/main/resources/lang/lang_de.xml
@@ -338,8 +338,8 @@ Die gesammte Speichergröße beträgt damit damit dx*dy*2 Speicherworte.
Ist der Eingang 0 ist auch der Ausgang 0. In allen anderen Fällen ist der Ausgang hochohmig.
Ist der Eingang 0 ist auch der Ausgang 0. In allen anderen Fällen ist der Ausgang hochohmig.
@@ -348,8 +348,8 @@ Die gesammte Speichergröße beträgt damit damit dx*dy*2 Speicherworte.
Ist der Eingang 1 ist auch der Ausgang 1. In allen anderen Fällen ist der Ausgang hochohmig.
Ist der Eingang 1 ist auch der Ausgang 1. In allen anderen Fällen ist der Ausgang hochohmig.
@@ -486,6 +486,9 @@ Es sind nur {1} Variablen erlaubt, es wurden jedoch {2} gefunden.
Das Ergebnis der Minimierung ist nicht korrekt!
Sind evtl. die Namen der Variablen nicht eindeutig?
Zu viele Einträge in der Testdatenmatrix.
+ Diode benötigt am Ausgang einen PullUp-Widerstand!
+ Diode benötigt am Ausgang einen PullDown-Widerstand!
+ Testsignal {0} in der Schaltung nicht gefunden!
Adress-Bits
Anzahl der Adress-Bits die verwendet werden.
diff --git a/src/main/resources/lang/lang_en.xml b/src/main/resources/lang/lang_en.xml
index 2c4c0309c..0ec92eae4 100644
--- a/src/main/resources/lang/lang_en.xml
+++ b/src/main/resources/lang/lang_en.xml
@@ -331,6 +331,8 @@
Diode to Ground
A simplified unidirectional diode, used to pull a wire to ground. It is used to implement a wired AND.
Is the input low, also the output is low. In the other cases (input is high or high z) the output is in high z state.
+ So two anti parallel connected diodes can keep each other in low state, which is not possible with real diodes.
+ To aviod such problems, it is necessary to connect a pull up resistor to the diods output.
So this is a ideal diode: There is no voltage drop across a forward-biased diode.
If the input is low also the output is low. In all other cases the output is in high z state.
If the input is low also the output is low. In all other cases the output is in high z state.
@@ -338,7 +340,8 @@
A simplified unidirectional diode, used to pull a wire to VDD. It is used to implement a wired OR.
In the simulation the diode behaves like an active gate with a trivalent truth table:
Is the input high, also the output is high. In all other cases (input is low or high z) the output is in high z state.
- So two antiparallel connected diodes can keep each other in high state, which is not possible with real diodes.
+ So two anti parallel connected diodes can keep each other in high state, which is not possible with real diodes.
+ To aviod such problems, it is necessary to connect a pull down resistor to the diods output.
This is an ideal diode: There is no voltage drop across a forward-biased diode.
If the input is high also the output is high. In all other cases the output is in high z state.
If the input is high also the output is high. In all other cases the output is in high z state.
@@ -473,6 +476,9 @@ allowed are {1} variables but {2} are found.
The result of the minimization is not correct!
The names of the variables may not be unique.
To many entries in the test data matrix.
+ Diode needs a pull up resistor at its output!
+ Diode needs a pull down resistor at its output!
+ Test signal {0} not found in the circuit!
Address Bits
Number of address bits used.
diff --git a/src/test/java/de/neemann/digital/core/pld/DirectionalDiodeTest.java b/src/test/java/de/neemann/digital/core/pld/DirectionalDiodeTest.java
deleted file mode 100644
index 4e3467947..000000000
--- a/src/test/java/de/neemann/digital/core/pld/DirectionalDiodeTest.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package de.neemann.digital.core.pld;
-
-import de.neemann.digital.core.ObservableValue;
-import de.neemann.digital.core.ObservableValues;
-import de.neemann.digital.core.element.ElementAttributes;
-import junit.framework.TestCase;
-
-/**
- * Created by hneemann on 01.11.16.
- */
-public class DirectionalDiodeTest extends TestCase {
-
- public void testDiodeForeward() throws Exception {
- ObservableValue a = new ObservableValue("a", 1);
-
- DiodeForeward diodeForeward = new DiodeForeward(new ElementAttributes());
- diodeForeward.setInputs(a.asList());
- diodeForeward.init(null);
-
- ObservableValues outputs = diodeForeward.getOutputs();
- assertEquals(1, outputs.size());
-
- ObservableValue output = outputs.get(0);
-
- a.setBool(true);
- assertEquals(false, output.isHighZ());
- assertEquals(1, output.getValue());
- a.setBool(false);
- assertEquals(true, output.isHighZ());
- }
-
- public void testDiodeBackward() throws Exception {
- ObservableValue a = new ObservableValue("a", 1);
-
- DiodeBackward diodeBackward = new DiodeBackward(new ElementAttributes());
- diodeBackward.setInputs(a.asList());
- diodeBackward.init(null);
-
- ObservableValues outputs = diodeBackward.getOutputs();
- assertEquals(1, outputs.size());
-
- ObservableValue output = outputs.get(0);
-
- a.setBool(true);
- assertEquals(true, output.isHighZ());
- a.setBool(false);
- assertEquals(false, output.isHighZ());
- assertEquals(0, output.getValue());
- }
-
-
-}
\ No newline at end of file
diff --git a/src/test/java/de/neemann/digital/integration/TestExamples.java b/src/test/java/de/neemann/digital/integration/TestExamples.java
index a119446c3..f03ca6d04 100644
--- a/src/test/java/de/neemann/digital/integration/TestExamples.java
+++ b/src/test/java/de/neemann/digital/integration/TestExamples.java
@@ -29,7 +29,7 @@ public class TestExamples extends TestCase {
public void testDistExamples() throws Exception {
File examples = new File(Resources.getRoot().getParentFile().getParentFile(), "/main/dig");
assertEquals(111, new FileScanner(this::check).scan(examples));
- assertEquals(71, testCasesInFiles);
+ assertEquals(72, testCasesInFiles);
}
/**
@@ -39,8 +39,8 @@ public class TestExamples extends TestCase {
*/
public void testTestExamples() throws Exception {
File examples = new File(Resources.getRoot(), "/dig/test");
- assertEquals(56, new FileScanner(this::check).scan(examples));
- assertEquals(52, testCasesInFiles);
+ assertEquals(55, new FileScanner(this::check).scan(examples));
+ assertEquals(51, testCasesInFiles);
}
diff --git a/src/test/resources/dig/test/AntiparallelDiodes.dig b/src/test/resources/dig/test/AntiparallelDiodes.dig_
similarity index 100%
rename from src/test/resources/dig/test/AntiparallelDiodes.dig
rename to src/test/resources/dig/test/AntiparallelDiodes.dig_
diff --git a/src/test/resources/dig/test/pld/DiodeBackward.dig b/src/test/resources/dig/test/pld/DiodeBackward.dig
index 1a41639be..cc2bca5d5 100644
--- a/src/test/resources/dig/test/pld/DiodeBackward.dig
+++ b/src/test/resources/dig/test/pld/DiodeBackward.dig
@@ -20,7 +20,7 @@
Y
-
+
Testcase
@@ -29,9 +29,9 @@
Testdata
A Y
-1 Z
+1 1
0 0
-Z Z
+Z 1
@@ -47,6 +47,11 @@ Z Z
+
+ PullUp
+
+
+
@@ -57,5 +62,13 @@ Z Z
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/test/resources/dig/test/pld/DiodeForeward.dig b/src/test/resources/dig/test/pld/DiodeForeward.dig
index 84c4d3c9f..ff957e8ff 100644
--- a/src/test/resources/dig/test/pld/DiodeForeward.dig
+++ b/src/test/resources/dig/test/pld/DiodeForeward.dig
@@ -30,7 +30,7 @@
Y
-
+
Testcase
@@ -40,14 +40,19 @@
A Y
1 1
-0 Z
-Z Z
+0 0
+Z 0
+
+ PullDown
+
+
+
@@ -58,5 +63,13 @@ Z Z
+
+
+
+
+
+
+
+
\ No newline at end of file