docs/test_vector.md
The Test Vector feature allows you to verify your circuits by running automated tests defined in text files. This document describes the enhanced Test Vector functionality, including sequential testing and special values.
The Test Vector window allows you to load a test vector from a file, and Logisim will automatically run tests on the current circuit. The Test Vector module runs a separate copy of the circuit simulator, so it does not interfere with the simulation in the project window.
Any incorrect outputs will be flagged in red. Hover the mouse over the red box to see what the output should have been, according to the test vector. Rows with incorrect outputs are sorted to the top of the window.
Each row in the Test Vector window has two buttons that allow you to manually interact with individual tests:
"Show" button (first column): This button previews the circuit state without checking outputs.
The Show button does not verify outputs against expected values - it only shows what the circuit state would be.
"Set" button (second column): This button sets input values and may execute tests.
Highlighting behavior:
The file format is simple. You can use the Logging module (with "Include Header Line" selected in the file output tab) to get started, since in most cases the Logging module outputs the same format as used by the Test Vector module.
Here is an example test vector file:
# my test vector for add32
A[32] B[32] C[32] Cin Cout
00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 0 0
-2 0x00000005 3 0 0
0 0o0003 3 0 0
Format Rules:
Value Formats:
_) anywhere in numeric values to improve readability.
Underscores are ignored during parsing. Examples:
0x0000_1111 (hex)0o1234_5670 (octal)1111_0000 (binary)1_234 or -5_000 (decimal)Don't Care Bits:
101xx is a five bit binary value with the last two bits unspecified0x1ax5 is a hex value with four unspecified bitsThe Test Vector feature supports both combinational and sequential circuit testing.
By default, tests are combinational: the circuit is reset before each test, ensuring each test is independent. This is the traditional behavior and works for all circuits.
For sequential circuits (like counters, state machines, etc.), you can specify test sequences using special header columns:
<set>: Defines the sequence ID - tests with the same set number belong to the same sequence and run together.
The circuit state is preserved between steps in the same set. Tests default to set 0 if not specified.<seq>: Defines the step number within a set - this determines the execution order of tests within the same set.
Tests are executed in order of their <seq> value within each <set>.
Tests with <seq> of 0 or missing are treated as combinational (circuit resets between tests, even if they share the same set).Example of Sequential Test:
# Sequential test for a counter
Clock Reset Count <set> <seq>
0 0 0 1 1
1 0 0 1 2
0 0 1 1 3
1 0 1 1 4
0 0 2 1 5
1 0 2 1 6
0 1 0 2 1
In this example:
<set> 1 with <seq> values 1-6,
so they form one sequence that runs in order (seq 1, then 2, then 3, etc.) without resetting between steps<set> 2, so it starts a new sequence and the circuit is reset before it runsSequence Execution Rules:
<set> number belong to the same sequence<seq> value (seq 1, then 2, then 3, etc.)<set> number)<seq> = 0 or missing are always combinational (reset between tests, even within the same set)The Test Vector format supports two special values for more flexible testing:
<DC>)When used for an output pin, this value always passes regardless of the actual output. This is useful when you don't care about certain outputs during a test.
<DC>, <dc>, <Dc> all workExample:
Input Enable Output <set> <seq>
1 1 <DC> 0 0
In this test, any output value will pass because it's marked as don't care.
<float>)When used for an input pin, this drives a floating (high-impedance) value. When used for an output pin, this expects the output to be floating (UNKNOWN value).
<float>, <FLOAT>, <Float> all workExample:
Input Enable Output <set> <seq>
<float> 0 <float> 0 0
In this test:
Here is a complete example combining all features:
# Mixed combinational and sequential tests
A B C Out <set> <seq>
0 0 0 0 0 0
0 0 1 1 0 0
1 1 0 1 0 0
0 1 0 0 0 1
1 1 1 1 0 1
0 0 0 <DC> 0 1
1 0 1 <float> 0 2
Explanation:
<DC> for the output, so any output value passes<float> for the output, expecting a floating valueTo facilitate automated testing, the test vector feature can be run from the command line:
logisim --test-vector <circuit_name> <test_vector_file> <project.circ>
Or using the JAR file:
java -jar logisim-evolution.jar --test-vector <circuit_name> <test_vector_file> <project.circ>
Arguments:
<circuit_name>: The name of the circuit to test (must match a circuit in the project file)<test_vector_file>: Path to the test vector file (e.g., TestsDLatch.txt)<project.circ>: Path to the Logisim project file containing the circuitExample:
java -jar logisim-evolution.jar --test-vector dlatch TestsRegisterFile.txt /home/user/Computer.circ
The command will:
All existing test vector files continue to work without modification. The new features are optional:
<set> and <seq> columns are not present, all tests are combinational (default behavior)<DC> and <float> are not used, normal value comparison applies<DC> for outputs you're not currently verifying<float> to test circuits with tri-state outputs or high-impedance states<set> column to group related tests, even though it doesn't affect execution