mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-30 16:30:04 -04:00
added consistency check for 74xx circuits
This commit is contained in:
parent
cb11ce8cca
commit
e6d50cc87d
@ -6,6 +6,10 @@
|
||||
<string>isDIL</string>
|
||||
<boolean>true</boolean>
|
||||
</entry>
|
||||
<entry>
|
||||
<string>Description</string>
|
||||
<string>Dual 4-bit D-type latches</string>
|
||||
</entry>
|
||||
<entry>
|
||||
<string>lockedMode</string>
|
||||
<boolean>true</boolean>
|
||||
|
@ -8,7 +8,7 @@
|
||||
</entry>
|
||||
<entry>
|
||||
<string>Description</string>
|
||||
<string>3-line to 8-line decoder/demultiplexer</string>
|
||||
<string>3-line to 8-line decoder/demultiplexer, inverted out</string>
|
||||
</entry>
|
||||
<entry>
|
||||
<string>lockedMode</string>
|
||||
|
@ -8,7 +8,11 @@
|
||||
</entry>
|
||||
<entry>
|
||||
<string>Description</string>
|
||||
<string>3-line to 8-line decoder/demultiplexer</string>
|
||||
<string>Dual 2-line to 4-line decoder/demultiplexer</string>
|
||||
</entry>
|
||||
<entry>
|
||||
<string>lockedMode</string>
|
||||
<boolean>true</boolean>
|
||||
</entry>
|
||||
</attributes>
|
||||
<visualElements>
|
||||
|
1016
src/main/dig/74xx/lib/74147.dig
Normal file
1016
src/main/dig/74xx/lib/74147.dig
Normal file
File diff suppressed because it is too large
Load Diff
@ -20,6 +20,10 @@ counter; synchronous reset</string>
|
||||
<alpha>255</alpha>
|
||||
</awt-color>
|
||||
</entry>
|
||||
<entry>
|
||||
<string>lockedMode</string>
|
||||
<boolean>true</boolean>
|
||||
</entry>
|
||||
</attributes>
|
||||
<visualElements>
|
||||
<visualElement>
|
||||
|
@ -6,6 +6,10 @@
|
||||
<string>isDIL</string>
|
||||
<boolean>true</boolean>
|
||||
</entry>
|
||||
<entry>
|
||||
<string>Description</string>
|
||||
<string>8-BIT SHIFT REGISTERS</string>
|
||||
</entry>
|
||||
<entry>
|
||||
<string>lockedMode</string>
|
||||
<boolean>true</boolean>
|
||||
|
@ -10,6 +10,10 @@
|
||||
<string>Description</string>
|
||||
<string>3-line to 8-line decoder/demultiplexer</string>
|
||||
</entry>
|
||||
<entry>
|
||||
<string>lockedMode</string>
|
||||
<boolean>true</boolean>
|
||||
</entry>
|
||||
</attributes>
|
||||
<visualElements>
|
||||
<visualElement>
|
||||
|
@ -10,6 +10,10 @@
|
||||
<string>Description</string>
|
||||
<string>DUAL 5-INPUT NOR GATE</string>
|
||||
</entry>
|
||||
<entry>
|
||||
<string>lockedMode</string>
|
||||
<boolean>true</boolean>
|
||||
</entry>
|
||||
</attributes>
|
||||
<visualElements>
|
||||
<visualElement>
|
||||
|
@ -8,7 +8,11 @@
|
||||
</entry>
|
||||
<entry>
|
||||
<string>Description</string>
|
||||
<string>BCD to 7-segment decoder</string>
|
||||
<string>BCD to 7-segment decoder, active high</string>
|
||||
</entry>
|
||||
<entry>
|
||||
<string>lockedMode</string>
|
||||
<boolean>true</boolean>
|
||||
</entry>
|
||||
</attributes>
|
||||
<visualElements>
|
||||
|
@ -8,7 +8,11 @@
|
||||
</entry>
|
||||
<entry>
|
||||
<string>Description</string>
|
||||
<string>BCD to 7-segment decoder</string>
|
||||
<string>BCD to 7-segment decoder, active low</string>
|
||||
</entry>
|
||||
<entry>
|
||||
<string>lockedMode</string>
|
||||
<boolean>true</boolean>
|
||||
</entry>
|
||||
</attributes>
|
||||
<visualElements>
|
||||
|
@ -10,6 +10,10 @@
|
||||
<string>Description</string>
|
||||
<string>2-Input/3-Input And-Or invert Gate</string>
|
||||
</entry>
|
||||
<entry>
|
||||
<string>lockedMode</string>
|
||||
<boolean>true</boolean>
|
||||
</entry>
|
||||
</attributes>
|
||||
<visualElements>
|
||||
<visualElement>
|
||||
|
@ -10,6 +10,10 @@
|
||||
<string>Description</string>
|
||||
<string>DUAL J-K FLIP-FLOPS WITH PRESET AND CLEAR</string>
|
||||
</entry>
|
||||
<entry>
|
||||
<string>lockedMode</string>
|
||||
<boolean>true</boolean>
|
||||
</entry>
|
||||
</attributes>
|
||||
<visualElements>
|
||||
<visualElement>
|
||||
|
@ -44,7 +44,7 @@ public class FileScanner {
|
||||
if (f.getName().endsWith(".dig")) {
|
||||
try {
|
||||
test.check(f);
|
||||
} catch (Exception e) {
|
||||
} catch (Throwable e) {
|
||||
errors.add(new Error(f, e));
|
||||
}
|
||||
count++;
|
||||
@ -62,9 +62,9 @@ public class FileScanner {
|
||||
private static class Error {
|
||||
|
||||
private final File f;
|
||||
private final Exception e;
|
||||
private final Throwable e;
|
||||
|
||||
private Error(File f, Exception e) {
|
||||
private Error(File f, Throwable e) {
|
||||
this.f = f;
|
||||
this.e = e;
|
||||
}
|
||||
|
79
src/test/java/de/neemann/digital/integration/Test74xx.java
Normal file
79
src/test/java/de/neemann/digital/integration/Test74xx.java
Normal file
@ -0,0 +1,79 @@
|
||||
package de.neemann.digital.integration;
|
||||
|
||||
import de.neemann.digital.core.NodeException;
|
||||
import de.neemann.digital.core.element.Keys;
|
||||
import de.neemann.digital.core.io.In;
|
||||
import de.neemann.digital.core.io.Out;
|
||||
import de.neemann.digital.draw.elements.Circuit;
|
||||
import de.neemann.digital.draw.elements.PinException;
|
||||
import de.neemann.digital.draw.elements.VisualElement;
|
||||
import de.neemann.digital.draw.library.ElementNotFoundException;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
||||
/**
|
||||
* Tests the files in the 74xx/lib folder for consistency.
|
||||
* Created by hneemann on 13.05.17.
|
||||
*/
|
||||
public class Test74xx extends TestCase {
|
||||
private HashMap<String, File> descrMap;
|
||||
|
||||
public void test74xx() throws Exception {
|
||||
File examples = new File(Resources.getRoot().getParentFile().getParentFile(), "/main/dig/74xx/lib");
|
||||
descrMap = new HashMap<>();
|
||||
new FileScanner(this::check).scan(examples);
|
||||
}
|
||||
|
||||
private void check(File dig) throws PinException, NodeException, ElementNotFoundException, IOException {
|
||||
System.out.println(dig);
|
||||
Circuit circuit = new ToBreakRunner(dig).getCircuit();
|
||||
assertTrue("is not DIL", circuit.getAttributes().get(Keys.IS_DIL));
|
||||
assertTrue("is not locked", circuit.getAttributes().get(Keys.LOCKED_MODE));
|
||||
|
||||
final String descr = circuit.getAttributes().get(Keys.DESCRIPTION);
|
||||
assertTrue("missing description", descr.length() > 0);
|
||||
|
||||
File f = descrMap.get(descr);
|
||||
if (f != null)
|
||||
fail("duplicate description '"+descr+"' in " + f + " and " + dig);
|
||||
descrMap.put(descr, dig);
|
||||
|
||||
PinChecker pc = new PinChecker();
|
||||
for (VisualElement e : circuit.getElements()) {
|
||||
if (e.equalsDescription(In.DESCRIPTION))
|
||||
pc.checkPin(e);
|
||||
if (e.equalsDescription(Out.DESCRIPTION))
|
||||
pc.checkPin(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private class PinChecker {
|
||||
private final HashSet<Integer> pinMap;
|
||||
private final HashSet<String> nameMap;
|
||||
|
||||
private PinChecker() {
|
||||
pinMap = new HashSet<>();
|
||||
nameMap = new HashSet<>();
|
||||
}
|
||||
|
||||
private void checkPin(VisualElement e) {
|
||||
int pn = e.getElementAttributes().get(Keys.PINNUMBER);
|
||||
final String label = e.getElementAttributes().getLabel();
|
||||
assertTrue("missing pin number: " + label, pn != 0);
|
||||
|
||||
assertFalse("non unique pin number: " + pn, pinMap.contains(pn));
|
||||
pinMap.add(pn);
|
||||
|
||||
assertFalse("non unique pin name: " + label, nameMap.contains(label));
|
||||
nameMap.add(label);
|
||||
|
||||
assertTrue("missing pin label", label.length() > 0);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -28,7 +28,7 @@ public class TestExamples extends TestCase {
|
||||
*/
|
||||
public void testDistExamples() throws Exception {
|
||||
File examples = new File(Resources.getRoot().getParentFile().getParentFile(), "/main/dig");
|
||||
assertEquals(144, new FileScanner(this::check).scan(examples));
|
||||
assertEquals(145, new FileScanner(this::check).scan(examples));
|
||||
assertEquals(74, testCasesInFiles);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user