From 90b749f82675db64b84a76343adab7efb18dd88b Mon Sep 17 00:00:00 2001 From: hneemann Date: Sat, 13 May 2017 13:38:59 +0200 Subject: [PATCH] added some 74xx circuits --- distribution/Assembly.xml | 1 + src/main/dig/74xx/lib/74138.dig | 426 ++++++++++++++++++ src/main/dig/74xx/lib/74139.dig | 424 +++++++++++++++++ src/main/dig/74xx/lib/74238.dig | 350 ++++++++++++++ src/main/dig/74xx/lib/ReadMe.txt | 7 + .../components/progress/ProgressConsole.java | 67 +++ .../components/progress/ProgressDialog.java | 48 ++ .../components/progress/ProgressListener.java | 25 + .../components/progress/ProgressThread.java | 36 ++ .../gui/components/progress/package-info.java | 5 + .../digital/integration/TestExamples.java | 2 +- 11 files changed, 1390 insertions(+), 1 deletion(-) create mode 100644 src/main/dig/74xx/lib/74138.dig create mode 100644 src/main/dig/74xx/lib/74139.dig create mode 100644 src/main/dig/74xx/lib/74238.dig create mode 100644 src/main/dig/74xx/lib/ReadMe.txt create mode 100644 src/main/java/de/neemann/digital/gui/components/progress/ProgressConsole.java create mode 100644 src/main/java/de/neemann/digital/gui/components/progress/ProgressDialog.java create mode 100644 src/main/java/de/neemann/digital/gui/components/progress/ProgressListener.java create mode 100644 src/main/java/de/neemann/digital/gui/components/progress/ProgressThread.java create mode 100644 src/main/java/de/neemann/digital/gui/components/progress/package-info.java diff --git a/distribution/Assembly.xml b/distribution/Assembly.xml index aae241f46..a8dbce89c 100644 --- a/distribution/Assembly.xml +++ b/distribution/Assembly.xml @@ -37,6 +37,7 @@ /examples/74xx/ **/*.dig + **/*.txt diff --git a/src/main/dig/74xx/lib/74138.dig b/src/main/dig/74xx/lib/74138.dig new file mode 100644 index 000000000..058bd6c8d --- /dev/null +++ b/src/main/dig/74xx/lib/74138.dig @@ -0,0 +1,426 @@ + + + 1 + + + isDIL + true + + + Description + 3-line to 8-line decoder/demultiplexer + + + lockedMode + true + + + + + Demultiplexer + + + Selector Bits + 3 + + + + + + Splitter + + + Input Splitting + 1,1,1 + + + Output Splitting + 3 + + + + + + In + + + Label + A + + + pinNumber + 1 + + + + + + In + + + Label + C + + + pinNumber + 3 + + + + + + In + + + Label + B + + + pinNumber + 2 + + + + + + And + + + Inputs + 3 + + + + + + In + + + Label + G + + + pinNumber + 6 + + + + + + Not + + + + + In + + + Label + ~GB + + + pinNumber + 5 + + + + + + Not + + + + + In + + + Label + ~GA + + + pinNumber + 4 + + + + + + Not + + + + + Not + + + + + Not + + + + + Not + + + + + Not + + + + + Not + + + + + Not + + + + + Not + + + + + Out + + + Label + ~Y0 + + + pinNumber + 15 + + + + + + Out + + + Label + ~Y1 + + + pinNumber + 14 + + + + + + Out + + + Label + ~Y2 + + + pinNumber + 13 + + + + + + Out + + + Label + ~Y3 + + + pinNumber + 12 + + + + + + Out + + + Label + ~Y4 + + + pinNumber + 11 + + + + + + Out + + + Label + ~Y5 + + + pinNumber + 10 + + + + + + Out + + + Label + ~Y6 + + + pinNumber + 9 + + + + + + Out + + + Label + ~Y7 + + + pinNumber + 7 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/dig/74xx/lib/74139.dig b/src/main/dig/74xx/lib/74139.dig new file mode 100644 index 000000000..ab3f28194 --- /dev/null +++ b/src/main/dig/74xx/lib/74139.dig @@ -0,0 +1,424 @@ + + + 1 + + + isDIL + true + + + Description + 3-line to 8-line decoder/demultiplexer + + + + + Demultiplexer + + + Selector Bits + 2 + + + + + + Splitter + + + Input Splitting + 1,1 + + + Output Splitting + 2 + + + + + + In + + + Label + 1A + + + pinNumber + 2 + + + + + + In + + + Label + 1B + + + pinNumber + 3 + + + + + + In + + + Label + ~1G + + + pinNumber + 1 + + + + + + Not + + + + + Not + + + + + Not + + + + + Not + + + + + Not + + + + + Out + + + Label + ~1Y0 + + + pinNumber + 4 + + + + + + Out + + + Label + ~1Y1 + + + pinNumber + 5 + + + + + + Out + + + Label + ~1Y2 + + + pinNumber + 6 + + + + + + Out + + + Label + ~1Y3 + + + pinNumber + 7 + + + + + + Demultiplexer + + + Selector Bits + 2 + + + + + + Splitter + + + Input Splitting + 1,1 + + + Output Splitting + 2 + + + + + + In + + + Label + 2A + + + pinNumber + 14 + + + + + + In + + + Label + 2B + + + pinNumber + 13 + + + + + + In + + + Label + ~2G + + + pinNumber + 15 + + + + + + Not + + + + + Not + + + + + Not + + + + + Not + + + + + Not + + + + + Out + + + Label + ~2Y0 + + + pinNumber + 12 + + + + + + Out + + + Label + ~2Y1 + + + pinNumber + 11 + + + + + + Out + + + Label + ~2Y2 + + + pinNumber + 10 + + + + + + Out + + + Label + ~2Y3 + + + pinNumber + 9 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/dig/74xx/lib/74238.dig b/src/main/dig/74xx/lib/74238.dig new file mode 100644 index 000000000..62e65c628 --- /dev/null +++ b/src/main/dig/74xx/lib/74238.dig @@ -0,0 +1,350 @@ + + + 1 + + + isDIL + true + + + Description + 3-line to 8-line decoder/demultiplexer + + + + + Demultiplexer + + + Selector Bits + 3 + + + + + + Splitter + + + Input Splitting + 1,1,1 + + + Output Splitting + 3 + + + + + + In + + + Label + A + + + pinNumber + 1 + + + + + + In + + + Label + C + + + pinNumber + 3 + + + + + + In + + + Label + B + + + pinNumber + 2 + + + + + + And + + + Inputs + 3 + + + + + + In + + + Label + G + + + pinNumber + 6 + + + + + + Not + + + + + In + + + Label + ~GB + + + pinNumber + 5 + + + + + + Not + + + + + In + + + Label + ~GA + + + pinNumber + 4 + + + + + + Out + + + Label + ~Y0 + + + pinNumber + 15 + + + + + + Out + + + Label + ~Y1 + + + pinNumber + 14 + + + + + + Out + + + Label + ~Y2 + + + pinNumber + 13 + + + + + + Out + + + Label + ~Y3 + + + pinNumber + 12 + + + + + + Out + + + Label + ~Y4 + + + pinNumber + 11 + + + + + + Out + + + Label + ~Y5 + + + pinNumber + 10 + + + + + + Out + + + Label + ~Y6 + + + pinNumber + 9 + + + + + + Out + + + Label + ~Y7 + + + pinNumber + 7 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/dig/74xx/lib/ReadMe.txt b/src/main/dig/74xx/lib/ReadMe.txt new file mode 100644 index 000000000..7cdbe00f0 --- /dev/null +++ b/src/main/dig/74xx/lib/ReadMe.txt @@ -0,0 +1,7 @@ +If you add components, I would be glad if you would send +me the new components, so I can add them to the library. +So the library becomes more and more complete over time. + +Simply open a GitHub issue and attach the new components or +send a pull request (https://github.com/hneemann/Digital). + diff --git a/src/main/java/de/neemann/digital/gui/components/progress/ProgressConsole.java b/src/main/java/de/neemann/digital/gui/components/progress/ProgressConsole.java new file mode 100644 index 000000000..790e4b038 --- /dev/null +++ b/src/main/java/de/neemann/digital/gui/components/progress/ProgressConsole.java @@ -0,0 +1,67 @@ +package de.neemann.digital.gui.components.progress; + +/** + * ProgressConsole prints the progess to stdout. + * Created by hneemann on 14.03.17. + */ +public class ProgressConsole implements ProgressListener { + + private final String name; + private int max; + private int pos; + private int lastOut; + + /** + * Creates a new instance + */ + public ProgressConsole() { + name = null; + } + + /** + * Creates a new instance + * + * @param max the max progress value + * @param name the name of this listener. Is printed in front of each line + */ + public ProgressConsole(int max, String name) { + this.max = max; + this.name = name; + } + + + /** + * Creates a new instance + * + * @param max the max progress value + */ + public ProgressConsole(int max) { + this.max = max; + name = null; + } + + @Override + public void setStart(int max) { + this.max = max; + pos = 0; + } + + @Override + public void inc() { + pos++; + + int out = (pos * 100) / max; + if (out != lastOut) { + lastOut = out; + if (name == null) + System.out.println("\r" + lastOut + "%"); + else + System.out.println("\r" + name + " " + lastOut + "%"); + } + } + + @Override + public void finish() { + System.out.println(); + } +} diff --git a/src/main/java/de/neemann/digital/gui/components/progress/ProgressDialog.java b/src/main/java/de/neemann/digital/gui/components/progress/ProgressDialog.java new file mode 100644 index 000000000..3879f34b8 --- /dev/null +++ b/src/main/java/de/neemann/digital/gui/components/progress/ProgressDialog.java @@ -0,0 +1,48 @@ +package de.neemann.digital.gui.components.progress; + +import javax.swing.*; +import java.awt.*; + +/** + * A simple progress listener. + * Created by hneemann on 04.03.17. + */ +public class ProgressDialog extends JDialog implements ProgressListener { + private final JProgressBar bar; + private int val; + + /** + * Creates a new instance + * + * @param parent the parent dialog + */ + public ProgressDialog(Dialog parent) { + super(parent, true); + setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); + + bar = new JProgressBar(); + getContentPane().add(bar); + pack(); + setLocationRelativeTo(parent); + } + + + @Override + public void setStart(int max) { + bar.setMaximum(max); + setVisible(true); + val = 0; + } + + @Override + public void inc() { + val++; + bar.setValue(val); + System.out.println(val); + } + + @Override + public void finish() { + dispose(); + } +} diff --git a/src/main/java/de/neemann/digital/gui/components/progress/ProgressListener.java b/src/main/java/de/neemann/digital/gui/components/progress/ProgressListener.java new file mode 100644 index 000000000..0f31410ac --- /dev/null +++ b/src/main/java/de/neemann/digital/gui/components/progress/ProgressListener.java @@ -0,0 +1,25 @@ +package de.neemann.digital.gui.components.progress; + +/** + * A Simple progress listener + * Created by hneemann on 04.03.17. + */ +public interface ProgressListener { + /** + * Called at start + * + * @param max the number of steps + */ + void setStart(int max); + + /** + * A single step. + * Is called max times. + */ + void inc(); + + /** + * process has finished + */ + void finish(); +} diff --git a/src/main/java/de/neemann/digital/gui/components/progress/ProgressThread.java b/src/main/java/de/neemann/digital/gui/components/progress/ProgressThread.java new file mode 100644 index 000000000..4dc7d88e0 --- /dev/null +++ b/src/main/java/de/neemann/digital/gui/components/progress/ProgressThread.java @@ -0,0 +1,36 @@ +package de.neemann.digital.gui.components.progress; + +import javax.swing.*; + +/** + * ProgressThread delegates the method calls to its parents using + * {@link SwingUtilities#invokeLater(Runnable)}. + * Created by hneemann on 04.03.17. + */ +public class ProgressThread implements ProgressListener { + private final ProgressListener parent; + + /** + * Create a new instance + * + * @param parent the {@link ProgressListener} to delegate the method calls to. + */ + public ProgressThread(ProgressListener parent) { + this.parent = parent; + } + + @Override + public void setStart(int max) { + SwingUtilities.invokeLater(() -> parent.setStart(max)); + } + + @Override + public void inc() { + SwingUtilities.invokeLater(parent::inc); + } + + @Override + public void finish() { + SwingUtilities.invokeLater(parent::finish); + } +} diff --git a/src/main/java/de/neemann/digital/gui/components/progress/package-info.java b/src/main/java/de/neemann/digital/gui/components/progress/package-info.java new file mode 100644 index 000000000..9e817f943 --- /dev/null +++ b/src/main/java/de/neemann/digital/gui/components/progress/package-info.java @@ -0,0 +1,5 @@ +/** + * Classes ti implement a progress listener. + * Created by hneemann on 11.03.17. + */ +package de.neemann.digital.gui.components.progress; diff --git a/src/test/java/de/neemann/digital/integration/TestExamples.java b/src/test/java/de/neemann/digital/integration/TestExamples.java index bf97e0dd8..dd6bd6ce2 100644 --- a/src/test/java/de/neemann/digital/integration/TestExamples.java +++ b/src/test/java/de/neemann/digital/integration/TestExamples.java @@ -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(137, new FileScanner(this::check).scan(examples)); + assertEquals(140, new FileScanner(this::check).scan(examples)); assertEquals(74, testCasesInFiles); }