diff --git a/src/main/java/de/neemann/digital/gui/components/table/ShowStringDialog.java b/src/main/java/de/neemann/digital/gui/components/table/ShowStringDialog.java index 8080c0a7b..129c164d3 100644 --- a/src/main/java/de/neemann/digital/gui/components/table/ShowStringDialog.java +++ b/src/main/java/de/neemann/digital/gui/components/table/ShowStringDialog.java @@ -1,6 +1,7 @@ package de.neemann.digital.gui.components.table; import javax.swing.*; +import javax.swing.text.JTextComponent; import java.awt.*; /** @@ -14,32 +15,50 @@ public class ShowStringDialog extends JDialog { * Creates a new instance * * @param parent the parent - * @param str the pin map to show + * @param str the text to show */ public ShowStringDialog(JFrame parent, String title, String str) { super(parent, title); - init(parent, str); + init(parent, str, false); } /** * Creates a new instance * * @param parent the parent - * @param str the pin map to show + * @param str the text to show */ public ShowStringDialog(JDialog parent, String title, String str) { - super(parent, title); - init(parent, str); + this(parent, title, str, false); } - private void init(Component parent, String str) { + /** + * Creates a new instance + * + * @param parent the parent + * @param str the text to show + * @param html is the string a html string? + */ + public ShowStringDialog(JDialog parent, String title, String str, boolean html) { + super(parent, title); + init(parent, str, html); + } + + private void init(Component parent, String str, boolean html) { setDefaultCloseOperation(DISPOSE_ON_CLOSE); - JTextArea text = new JTextArea(str); - text.setEditable(false); - text.setFont(new JLabel().getFont()); - text.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); - getContentPane().add(new JScrollPane(text)); + JTextComponent textComp; + if (html) { + textComp = new JEditorPane("text/html", str); + textComp.setCaretPosition(0); + textComp.setPreferredSize(new Dimension(600, 800)); + } else { + textComp = new JTextArea(str); + textComp.setFont(new JLabel().getFont()); + } + textComp.setEditable(false); + textComp.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); + getContentPane().add(new JScrollPane(textComp)); pack(); setLocationRelativeTo(parent); diff --git a/src/main/java/de/neemann/digital/gui/components/testing/TestDataDialog.java b/src/main/java/de/neemann/digital/gui/components/testing/TestDataDialog.java index eef6c96a9..5e34e697f 100644 --- a/src/main/java/de/neemann/digital/gui/components/testing/TestDataDialog.java +++ b/src/main/java/de/neemann/digital/gui/components/testing/TestDataDialog.java @@ -62,7 +62,7 @@ public class TestDataDialog extends JDialog { new ShowStringDialog( TestDataDialog.this, Lang.get("msg_testVectorHelpTitle"), - Lang.get("msg_testVectorHelp")) + Lang.get("msg_testVectorHelp"), true) .setVisible(true); } }.createJButton()); diff --git a/src/main/resources/lang/lang_de.xml b/src/main/resources/lang/lang_de.xml index f503f71ec..c89b80d41 100644 --- a/src/main/resources/lang/lang_de.xml +++ b/src/main/resources/lang/lang_de.xml @@ -679,23 +679,51 @@ Mehrere Ausdrücke können durch "," oder ";" getrennt werden. Sollen die Ausdrücke benannt werden, kann die let-Anweisung verwendet werden: "let U=A+B, let V=A*B" Testvektoren - Die erste Zeile muss, durch ein Leerzeichen getrennt, die + +

Die erste Zeile muss, durch ein Leerzeichen getrennt, die Ein- und Ausgänge auflisten. In den folgenden Zeilen stehen dann die Sollwerte. Dabei steht ein 'X' für Don't Care, und ein 'Z' für hochohmig. Wird der Wert 'C' verwendet, werden zunächst alle anderen Werte gesetzt, dann wird ein Taktzyklus durchgeführt, und erst daran anschließend werden die Werte verglichen. Auf diese Weise können Schaltwerke einfacher getestet werden. -Eine Zeile, die mit einem Doppelkreuz ('#') beginnt ist ein Kommentar. - -Ein Test für einen 2-Bit Zähler könnte damit wie folgt aussehen: - -C Q1 Q0 -0 0 0 -C 0 1 -C 1 0 -C 1 1 +Eine Zeile, die mit einem Doppelkreuz ('#') beginnt ist ein Kommentar.

+

Ein Test für einen 2-Bit Zähler könnte damit wie folgt aussehen:

+

+ +C Q1 Q0
+0 0 0
+C 0 1
+C 1 0
+C 1 1
C 0 0 +
+

+

+Gestartet werden die Tests über Start->Tests ausführen. +

+

+Um vereinfacht sehr viele Tests durchzuführen existiert die 'for([n])' Anweisung: +Beginnt eine Zeile mit 'for([n])' werden [n] Testzeilen erzeugt. Dabei kann die +Variable 'n' verwendet werden, um die Testdaten zu erzeugen. Bei 'for(16)' werden +16 Zeilen erzeugt, wobei n von 0 bis 15 läuft. Wenn es mehrere Bit-Eingänge gibt, +und diese sollen gemeinsam auf einen binären Wert gesetzt werden, vereinfacht dies die +bits([bits],[value]) Anweisung. Mit dieser werden [bits] Bits des Wertes [value] erzeugt.

-Gestartet werden die Tests über Start->Tests ausführen.
+

Im folgenden ein Beispiel, welches einen 4-Bit Addierer testet:

+ +

+ + C_i-1 A_3 A_2 A_1 A_0 B_3 B_2 B_1 B_0 C_i S_3 S_2 S_1 S_0
+for(256) 0 bits(4,n>>4) bits(4,n) bits(5,(n>>4)+(n&15))
+for(256) 1 bits(4,n>>4) bits(4,n) bits(5,(n>>4)+(n&15)+1) +
+

+

Die Eingangssignale sind das Carry-In (C_i-1) und die acht Eingangsbits A_3-A_0 +und B_3-B_0. Erzeugt werden die jeweils 4 Eingangsbits mit der 'bits'Anweisung. +Das Ergebnis (C_i,S_3-S_0) wird ebenfalls durch eine 'bits'-Anweisung erzeugt. +Das ganze geschieht einmal mit C_i-1=0 und in der nächsten Zeile mit C_i-1=1. +Auf diese Weise werden 512 Testzeilen erzeugt, welche alle möglichen +Eingangskonfigurationen abdecken.

+]]>
\ No newline at end of file diff --git a/src/main/resources/lang/lang_en.xml b/src/main/resources/lang/lang_en.xml index a849ef110..3334d258e 100644 --- a/src/main/resources/lang/lang_en.xml +++ b/src/main/resources/lang/lang_en.xml @@ -668,22 +668,48 @@ Multiple expressions can be separated by "," or ";". If you want to name the expressions you can use the let-command: "let U=A+B, let V=A*B" Test vectors - The first line has to contain the names of inputs and outputs. + +

The first line has to contain the names of inputs and outputs. The following lines contain the expected values. A 'X' represents a don't care, and a 'Z' represents a high Z value. If a 'C' is used, at first all other values are set, after that a clock cycle is performed and than the values are compared. So it's easier to test sequential logic. -A line which starts with a number sign ('#') is a comment. +A line which starts with a number sign ('#') is a comment.

-So a test for a 2-bit counter could look like this: +

So a test for a 2-bit counter could look like this:

-C Q1 Q0 -0 0 0 -C 0 1 -C 1 0 -C 1 1 +

+C Q1 Q0
+0 0 0
+C 0 1
+C 1 0
+C 1 1
C 0 0 +

-The tests are executed by Run->Run Tests.
+

The tests are executed by Run->Run Tests.

+

+To make it easier to create a lot of test vectors there is the 'for([n])' statement: +If a line begins with 'for ([n])', [n] test lines are generated. The +Variable 'n' can be used to generate the test data. With 'for (16)' +16 lines are created, where n goes from 0 to 15. If there are multiple bit inputs, +and these are to be set together to a binary value, this can be done with the +'bits([bits], [value])' statement. This is used to create [bits] bits of the value [value].

+ +

The following is an example that tests a 4-bit adder:

+ +

+ + C_i-1 A_3 A_2 A_1 A_0 B_3 B_2 B_1 B_0 C_i S_3 S_2 S_1 S_0
+for(256) 0 bits(4,n>>4) bits(4,n) bits(5,(n>>4)+(n&15))
+for(256) 1 bits(4,n>>4) bits(4,n) bits(5,(n>>4)+(n&15)+1) +
+

+

The input signals are the carry-in (C_i-1) and the eight input bits A_3-A_0 and B_3-B_0. +The 4 input bits are generated with the 'bits' instruction. The result (C_i, S_3-S_0) is also generated +by a 'bits' instruction. +This happens once with C_i-1 = 0 and in the next line with C_i-1 = 1. +In this way, 512 test rows are generated which cover all possible input configurations.

+]]>
\ No newline at end of file