improved description of test vectors

This commit is contained in:
hneemann 2017-01-03 13:18:46 +01:00
parent 9f079883a6
commit fb7e0f50e4
4 changed files with 105 additions and 32 deletions

View File

@ -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);

View File

@ -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());

View File

@ -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"</string>
<string name="msg_testVectorHelpTitle">Testvektoren</string>
<string name="msg_testVectorHelp">Die erste Zeile muss, durch ein Leerzeichen getrennt, die
<string name="msg_testVectorHelp"><![CDATA[<html><body>
<p>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.</p>
<p>Ein Test für einen 2-Bit Zähler könnte damit wie folgt aussehen:</p>
<p>
<code>
C Q1 Q0<br/>
0 0 0<br/>
C 0 1<br/>
C 1 0<br/>
C 1 1<br/>
C 0 0
</code>
</p>
<p>
Gestartet werden die Tests über Start->Tests ausführen.
</p>
<p>
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.</p>
Gestartet werden die Tests über Start->Tests ausführen.</string>
<p>Im folgenden ein Beispiel, welches einen 4-Bit Addierer testet:</p>
<p>
<code>
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<br/>
for(256) 0 bits(4,n>>4) bits(4,n) bits(5,(n>>4)+(n&15))<br/>
for(256) 1 bits(4,n>>4) bits(4,n) bits(5,(n>>4)+(n&15)+1)
</code>
</p>
<p>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.</p>
</body></html>]]></string>
</resources>

View File

@ -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"</string>
<string name="msg_testVectorHelpTitle">Test vectors</string>
<string name="msg_testVectorHelp">The first line has to contain the names of inputs and outputs.
<string name="msg_testVectorHelp"><![CDATA[<html><body>
<p>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.</p>
So a test for a 2-bit counter could look like this:
<p>So a test for a 2-bit counter could look like this:</p>
C Q1 Q0
0 0 0
C 0 1
C 1 0
C 1 1
<p><code>
C Q1 Q0<br/>
0 0 0<br/>
C 0 1<br/>
C 1 0<br/>
C 1 1<br/>
C 0 0
</code></p>
The tests are executed by Run->Run Tests.</string>
<p>The tests are executed by Run->Run Tests.</p>
<p>
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].</p>
<p>The following is an example that tests a 4-bit adder:</p>
<p>
<code>
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<br/>
for(256) 0 bits(4,n>>4) bits(4,n) bits(5,(n>>4)+(n&15))<br/>
for(256) 1 bits(4,n>>4) bits(4,n) bits(5,(n>>4)+(n&15)+1)
</code>
</p>
<p>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.</p>
</body></html>]]></string>
</resources>