Test Vector Window

From the Test vector window you can load a test vector from a file and Logisim will run tests on the current circuit. There is only one test vector window for the project and the table will change to reflect the simulated circuit in the project window. Note however that the test vector module runs a separate copy of the circuit simulator and therefore does not interfere with the simulation in the project window and is not influenced by this simulation.

For the example, we will test the circuit below. This circuit gives the results of five logic functions from two inputs. It contains an error because the bottom NAND gate should be an AND gate.

#########

The vector test file looks like this.

A B O_Nor O_Nand O_Xor O_Or O_And O_AB[2]
0 0 1 1 0 0 0 00
0 1 0 1 1 1 0 01
1 0 0 1 1 1 0 10
1 1 0 0 0 1 1 11

To run the test, select the menu |  Simulate  ||  Test vector  | then use the Load Vector button. Select the vector file you built. The simulation is executed immediately and a table is displayed with the result.

#########

Any incorrect output will be flagged in red. Rows with incorrect outputs are sorted at the top of the window.

The vector file format is simple. The first line contains the column headings which correspond to the names of the signals. If the bit width is greater than 1 then it is necessary to specify it in square brackets. Example C[8]. The data for each test situation is in the following rows. Blank lines are ignored. Anything after a "#" character is a comment.

The remaining lines list each value separated by a space or a tab. Values ​​can be hexadecimal, octal, binary, or signed decimal. Hexadecimal values ​​must have the prefix "0x". Octal values ​​must have the prefix "0o". Binary and decimal numbers are distinguished by the number of digits: binary values ​​must always have exactly as many digits as the width of the column; decimal values ​​must not have a leading zero and may have a negative sign.

Here is an example of a test vector file:

#test vector for adder 4bit 
A[4] B[4] O[4] C_in C_out
0000 0000 0000 0 0
0000 0000 0001 1 0
0xf 0xf 0000 1 0
0xf 0xf 0001 1 1

Depending on the representation of hexadecimal, octal, or binary values, the lowercase letter "x" is used to specify four, three, or one "unimportant" bits. For example, a value of 101xx is a five-bit binary value, with the last two bits unspecified, and 0x1ax5 is a hexadecimal value with two unspecified four-bit bits. Such wildcards cannot be used in decimal notation.

Command line: To facilitate automated testing, the test vector functionality can be run from the command line as follows:

java -jar logisim-evolution.jar -w <circuitname>
   <vector.txt> <project.circ>
The result of a successful test will be sent to standard output (stdout), for example
Loading test vector "testv1b.txt" ...
Running 4 vectors ...
1 
2 
3 
4 

Passed : 4, Failed : 0
	  
and in case of failure
Loading test vector "testv1a.txt" ...
Running 4 vectors ...
1 
2 
3 

  ob = 0 (expected 1)
4 

  ob = 1 (expected 0)

Passed : 2, Error: 2
	  
Note: In the error output (stderr) we will read this:
Error on test vector 3:
Error on test vector 4:
       

Next: User's Guide.