diff --git a/conformance/sv-tests/README.md b/conformance/sv-tests/README.md index 24dc1a681cb..42bd159f1b2 100644 --- a/conformance/sv-tests/README.md +++ b/conformance/sv-tests/README.md @@ -10,10 +10,13 @@ Each test has separate `2state` and `4state` rows (`test`, `state_mode`, `result The official runner owns metadata parsing, compatible-runner filtering, mode priority, library injection, timeouts, expected failures and simulation `:assert:` evaluation. The adapter declares only the driver’s supported -`parsing`, `elaboration` and `simulation` modes. It forwards source files, include -directories, defines, an optional explicit top and the selected state mode to -the Rust driver. Parsing mode stops after preprocessing and syntax parsing; it -does not build semantic module metadata, select a root, elaborate or simulate. +`preprocessing`, `parsing`, `elaboration` and `simulation` modes. It forwards +source files, include directories, defines, an optional explicit top and the +selected state mode to +the Rust driver. Preprocessing mode expands macros and includes, emits the +resulting text, and stops before syntax parsing or root selection. Parsing mode +stops after preprocessing and syntax parsing; it does not build semantic module +metadata, select a root, elaborate or simulate. The official mode priority still chooses elaboration for default cases and for cases that permit both parsing and elaboration. In elaboration and simulation modes, sources without a module still undergo preprocessing and parsing; root @@ -33,6 +36,13 @@ command-line defines apply to each file. | `fail` | the official runner emitted `FAIL` | | `skip` | the official runner skipped an incompatible test or unsupported mode | +All 90 preprocessing cases at the pinned revision now execute in both state +modes, leaving no skipped expectation rows. Each mode reports 89 passes and +one failure: `chapter-22/22.11--pragma-invalid.sv` expects a bare `` `pragma `` +to be rejected, but the preprocessor currently accepts it. This failure remains +visible in the baseline. Upstream preprocessing verdicts check process success +and expected failure; they do not compare the emitted text against a golden file. + The official runner’s process exit code is separate from the case verdict. The wrapper reads its `PASS`/`FAIL` log messages; it does not reconstruct their rules from tool exit codes or `should_fail` metadata. A negative test may pass diff --git a/conformance/sv-tests/expected.tsv b/conformance/sv-tests/expected.tsv index ed9a71b7f0d..6e6ddef53fa 100644 --- a/conformance/sv-tests/expected.tsv +++ b/conformance/sv-tests/expected.tsv @@ -823,36 +823,36 @@ chapter-21/21.7--dumpfile.sv 2state pass chapter-21/21.7--dumpfile.sv 4state pass chapter-21/21.7--dumpports.sv 2state fail chapter-21/21.7--dumpports.sv 4state fail -chapter-22/22.10--celldefine-basic-1.sv 2state skip -chapter-22/22.10--celldefine-basic-1.sv 4state skip -chapter-22/22.10--celldefine-basic-2.sv 2state skip -chapter-22/22.10--celldefine-basic-2.sv 4state skip -chapter-22/22.11--pragma-basic.sv 2state skip -chapter-22/22.11--pragma-basic.sv 4state skip -chapter-22/22.11--pragma-complex.sv 2state skip -chapter-22/22.11--pragma-complex.sv 4state skip -chapter-22/22.11--pragma-invalid.sv 2state skip -chapter-22/22.11--pragma-invalid.sv 4state skip -chapter-22/22.11--pragma-nested.sv 2state skip -chapter-22/22.11--pragma-nested.sv 4state skip -chapter-22/22.11--pragma-number-multi.sv 2state skip -chapter-22/22.11--pragma-number-multi.sv 4state skip -chapter-22/22.11--pragma-number.sv 2state skip -chapter-22/22.11--pragma-number.sv 4state skip -chapter-22/22.12--line-basic.sv 2state skip -chapter-22/22.12--line-basic.sv 4state skip -chapter-22/22.12--line-complex.sv 2state skip -chapter-22/22.12--line-complex.sv 4state skip -chapter-22/22.12--line-illegal-1.sv 2state skip -chapter-22/22.12--line-illegal-1.sv 4state skip -chapter-22/22.12--line-illegal-2.sv 2state skip -chapter-22/22.12--line-illegal-2.sv 4state skip -chapter-22/22.12--line-illegal-3.sv 2state skip -chapter-22/22.12--line-illegal-3.sv 4state skip -chapter-22/22.12--line-illegal-4.sv 2state skip -chapter-22/22.12--line-illegal-4.sv 4state skip -chapter-22/22.12--line-illegal-5.sv 2state skip -chapter-22/22.12--line-illegal-5.sv 4state skip +chapter-22/22.10--celldefine-basic-1.sv 2state pass +chapter-22/22.10--celldefine-basic-1.sv 4state pass +chapter-22/22.10--celldefine-basic-2.sv 2state pass +chapter-22/22.10--celldefine-basic-2.sv 4state pass +chapter-22/22.11--pragma-basic.sv 2state pass +chapter-22/22.11--pragma-basic.sv 4state pass +chapter-22/22.11--pragma-complex.sv 2state pass +chapter-22/22.11--pragma-complex.sv 4state pass +chapter-22/22.11--pragma-invalid.sv 2state fail +chapter-22/22.11--pragma-invalid.sv 4state fail +chapter-22/22.11--pragma-nested.sv 2state pass +chapter-22/22.11--pragma-nested.sv 4state pass +chapter-22/22.11--pragma-number-multi.sv 2state pass +chapter-22/22.11--pragma-number-multi.sv 4state pass +chapter-22/22.11--pragma-number.sv 2state pass +chapter-22/22.11--pragma-number.sv 4state pass +chapter-22/22.12--line-basic.sv 2state pass +chapter-22/22.12--line-basic.sv 4state pass +chapter-22/22.12--line-complex.sv 2state pass +chapter-22/22.12--line-complex.sv 4state pass +chapter-22/22.12--line-illegal-1.sv 2state pass +chapter-22/22.12--line-illegal-1.sv 4state pass +chapter-22/22.12--line-illegal-2.sv 2state pass +chapter-22/22.12--line-illegal-2.sv 4state pass +chapter-22/22.12--line-illegal-3.sv 2state pass +chapter-22/22.12--line-illegal-3.sv 4state pass +chapter-22/22.12--line-illegal-4.sv 2state pass +chapter-22/22.12--line-illegal-4.sv 4state pass +chapter-22/22.12--line-illegal-5.sv 2state pass +chapter-22/22.12--line-illegal-5.sv 4state pass chapter-22/22.3--resetall_basic.sv 2state pass chapter-22/22.3--resetall_basic.sv 4state pass chapter-22/22.3--resetall_illegal.sv 2state pass @@ -871,108 +871,108 @@ chapter-22/22.4--include_via_define.sv 2state pass chapter-22/22.4--include_via_define.sv 4state pass chapter-22/22.4--include_with_comment.sv 2state pass chapter-22/22.4--include_with_comment.sv 4state pass -chapter-22/22.5.1--define-expansion_1.sv 2state skip -chapter-22/22.5.1--define-expansion_1.sv 4state skip -chapter-22/22.5.1--define-expansion_10.sv 2state skip -chapter-22/22.5.1--define-expansion_10.sv 4state skip -chapter-22/22.5.1--define-expansion_11.sv 2state skip -chapter-22/22.5.1--define-expansion_11.sv 4state skip -chapter-22/22.5.1--define-expansion_12.sv 2state skip -chapter-22/22.5.1--define-expansion_12.sv 4state skip -chapter-22/22.5.1--define-expansion_13.sv 2state skip -chapter-22/22.5.1--define-expansion_13.sv 4state skip -chapter-22/22.5.1--define-expansion_14.sv 2state skip -chapter-22/22.5.1--define-expansion_14.sv 4state skip -chapter-22/22.5.1--define-expansion_15.sv 2state skip -chapter-22/22.5.1--define-expansion_15.sv 4state skip -chapter-22/22.5.1--define-expansion_16.sv 2state skip -chapter-22/22.5.1--define-expansion_16.sv 4state skip -chapter-22/22.5.1--define-expansion_17.sv 2state skip -chapter-22/22.5.1--define-expansion_17.sv 4state skip -chapter-22/22.5.1--define-expansion_18.sv 2state skip -chapter-22/22.5.1--define-expansion_18.sv 4state skip -chapter-22/22.5.1--define-expansion_19.sv 2state skip -chapter-22/22.5.1--define-expansion_19.sv 4state skip -chapter-22/22.5.1--define-expansion_2.sv 2state skip -chapter-22/22.5.1--define-expansion_2.sv 4state skip -chapter-22/22.5.1--define-expansion_20.sv 2state skip -chapter-22/22.5.1--define-expansion_20.sv 4state skip -chapter-22/22.5.1--define-expansion_21.sv 2state skip -chapter-22/22.5.1--define-expansion_21.sv 4state skip -chapter-22/22.5.1--define-expansion_22.sv 2state skip -chapter-22/22.5.1--define-expansion_22.sv 4state skip -chapter-22/22.5.1--define-expansion_23.sv 2state skip -chapter-22/22.5.1--define-expansion_23.sv 4state skip -chapter-22/22.5.1--define-expansion_24.sv 2state skip -chapter-22/22.5.1--define-expansion_24.sv 4state skip -chapter-22/22.5.1--define-expansion_25.sv 2state skip -chapter-22/22.5.1--define-expansion_25.sv 4state skip -chapter-22/22.5.1--define-expansion_26.sv 2state skip -chapter-22/22.5.1--define-expansion_26.sv 4state skip -chapter-22/22.5.1--define-expansion_3.sv 2state skip -chapter-22/22.5.1--define-expansion_3.sv 4state skip -chapter-22/22.5.1--define-expansion_4.sv 2state skip -chapter-22/22.5.1--define-expansion_4.sv 4state skip -chapter-22/22.5.1--define-expansion_5.sv 2state skip -chapter-22/22.5.1--define-expansion_5.sv 4state skip -chapter-22/22.5.1--define-expansion_6.sv 2state skip -chapter-22/22.5.1--define-expansion_6.sv 4state skip -chapter-22/22.5.1--define-expansion_7.sv 2state skip -chapter-22/22.5.1--define-expansion_7.sv 4state skip -chapter-22/22.5.1--define-expansion_8.sv 2state skip -chapter-22/22.5.1--define-expansion_8.sv 4state skip -chapter-22/22.5.1--define-expansion_9.sv 2state skip -chapter-22/22.5.1--define-expansion_9.sv 4state skip -chapter-22/22.5.1--define.sv 2state skip -chapter-22/22.5.1--define.sv 4state skip +chapter-22/22.5.1--define-expansion_1.sv 2state pass +chapter-22/22.5.1--define-expansion_1.sv 4state pass +chapter-22/22.5.1--define-expansion_10.sv 2state pass +chapter-22/22.5.1--define-expansion_10.sv 4state pass +chapter-22/22.5.1--define-expansion_11.sv 2state pass +chapter-22/22.5.1--define-expansion_11.sv 4state pass +chapter-22/22.5.1--define-expansion_12.sv 2state pass +chapter-22/22.5.1--define-expansion_12.sv 4state pass +chapter-22/22.5.1--define-expansion_13.sv 2state pass +chapter-22/22.5.1--define-expansion_13.sv 4state pass +chapter-22/22.5.1--define-expansion_14.sv 2state pass +chapter-22/22.5.1--define-expansion_14.sv 4state pass +chapter-22/22.5.1--define-expansion_15.sv 2state pass +chapter-22/22.5.1--define-expansion_15.sv 4state pass +chapter-22/22.5.1--define-expansion_16.sv 2state pass +chapter-22/22.5.1--define-expansion_16.sv 4state pass +chapter-22/22.5.1--define-expansion_17.sv 2state pass +chapter-22/22.5.1--define-expansion_17.sv 4state pass +chapter-22/22.5.1--define-expansion_18.sv 2state pass +chapter-22/22.5.1--define-expansion_18.sv 4state pass +chapter-22/22.5.1--define-expansion_19.sv 2state pass +chapter-22/22.5.1--define-expansion_19.sv 4state pass +chapter-22/22.5.1--define-expansion_2.sv 2state pass +chapter-22/22.5.1--define-expansion_2.sv 4state pass +chapter-22/22.5.1--define-expansion_20.sv 2state pass +chapter-22/22.5.1--define-expansion_20.sv 4state pass +chapter-22/22.5.1--define-expansion_21.sv 2state pass +chapter-22/22.5.1--define-expansion_21.sv 4state pass +chapter-22/22.5.1--define-expansion_22.sv 2state pass +chapter-22/22.5.1--define-expansion_22.sv 4state pass +chapter-22/22.5.1--define-expansion_23.sv 2state pass +chapter-22/22.5.1--define-expansion_23.sv 4state pass +chapter-22/22.5.1--define-expansion_24.sv 2state pass +chapter-22/22.5.1--define-expansion_24.sv 4state pass +chapter-22/22.5.1--define-expansion_25.sv 2state pass +chapter-22/22.5.1--define-expansion_25.sv 4state pass +chapter-22/22.5.1--define-expansion_26.sv 2state pass +chapter-22/22.5.1--define-expansion_26.sv 4state pass +chapter-22/22.5.1--define-expansion_3.sv 2state pass +chapter-22/22.5.1--define-expansion_3.sv 4state pass +chapter-22/22.5.1--define-expansion_4.sv 2state pass +chapter-22/22.5.1--define-expansion_4.sv 4state pass +chapter-22/22.5.1--define-expansion_5.sv 2state pass +chapter-22/22.5.1--define-expansion_5.sv 4state pass +chapter-22/22.5.1--define-expansion_6.sv 2state pass +chapter-22/22.5.1--define-expansion_6.sv 4state pass +chapter-22/22.5.1--define-expansion_7.sv 2state pass +chapter-22/22.5.1--define-expansion_7.sv 4state pass +chapter-22/22.5.1--define-expansion_8.sv 2state pass +chapter-22/22.5.1--define-expansion_8.sv 4state pass +chapter-22/22.5.1--define-expansion_9.sv 2state pass +chapter-22/22.5.1--define-expansion_9.sv 4state pass +chapter-22/22.5.1--define.sv 2state pass +chapter-22/22.5.1--define.sv 4state pass chapter-22/22.5.1--define_and_resetall.sv 2state pass chapter-22/22.5.1--define_and_resetall.sv 4state pass -chapter-22/22.5.1--include-define-expansion.sv 2state skip -chapter-22/22.5.1--include-define-expansion.sv 4state skip -chapter-22/22.5.2--undef-basic.sv 2state skip -chapter-22/22.5.2--undef-basic.sv 4state skip -chapter-22/22.5.2--undef-nonexisting.sv 2state skip -chapter-22/22.5.2--undef-nonexisting.sv 4state skip -chapter-22/22.5.3--undefineall-and-redefine.sv 2state skip -chapter-22/22.5.3--undefineall-and-redefine.sv 4state skip -chapter-22/22.5.3--undefineall-basic.sv 2state skip -chapter-22/22.5.3--undefineall-basic.sv 4state skip -chapter-22/22.6--ifdef-behavioral.sv 2state skip -chapter-22/22.6--ifdef-behavioral.sv 4state skip -chapter-22/22.6--ifdef-chained-nested.sv 2state skip -chapter-22/22.6--ifdef-chained-nested.sv 4state skip -chapter-22/22.6--ifdef-nested.sv 2state skip -chapter-22/22.6--ifdef-nested.sv 4state skip -chapter-22/22.7--timescale-basic-1.sv 2state skip -chapter-22/22.7--timescale-basic-1.sv 4state skip -chapter-22/22.7--timescale-basic-2.sv 2state skip -chapter-22/22.7--timescale-basic-2.sv 4state skip +chapter-22/22.5.1--include-define-expansion.sv 2state pass +chapter-22/22.5.1--include-define-expansion.sv 4state pass +chapter-22/22.5.2--undef-basic.sv 2state pass +chapter-22/22.5.2--undef-basic.sv 4state pass +chapter-22/22.5.2--undef-nonexisting.sv 2state pass +chapter-22/22.5.2--undef-nonexisting.sv 4state pass +chapter-22/22.5.3--undefineall-and-redefine.sv 2state pass +chapter-22/22.5.3--undefineall-and-redefine.sv 4state pass +chapter-22/22.5.3--undefineall-basic.sv 2state pass +chapter-22/22.5.3--undefineall-basic.sv 4state pass +chapter-22/22.6--ifdef-behavioral.sv 2state pass +chapter-22/22.6--ifdef-behavioral.sv 4state pass +chapter-22/22.6--ifdef-chained-nested.sv 2state pass +chapter-22/22.6--ifdef-chained-nested.sv 4state pass +chapter-22/22.6--ifdef-nested.sv 2state pass +chapter-22/22.6--ifdef-nested.sv 4state pass +chapter-22/22.7--timescale-basic-1.sv 2state pass +chapter-22/22.7--timescale-basic-1.sv 4state pass +chapter-22/22.7--timescale-basic-2.sv 2state pass +chapter-22/22.7--timescale-basic-2.sv 4state pass chapter-22/22.7--timescale-basic-3.sv 2state pass chapter-22/22.7--timescale-basic-3.sv 4state pass chapter-22/22.7--timescale-basic-4.sv 2state pass chapter-22/22.7--timescale-basic-4.sv 4state pass -chapter-22/22.7--timescale-module.sv 2state skip -chapter-22/22.7--timescale-module.sv 4state skip -chapter-22/22.7--timescale-reset.sv 2state skip -chapter-22/22.7--timescale-reset.sv 4state skip -chapter-22/22.8--default_nettype-redefinition.sv 2state skip -chapter-22/22.8--default_nettype-redefinition.sv 4state skip -chapter-22/22.8--default_nettype.sv 2state skip -chapter-22/22.8--default_nettype.sv 4state skip -chapter-22/22.9--unconnected_drive-basic-2.sv 2state skip -chapter-22/22.9--unconnected_drive-basic-2.sv 4state skip -chapter-22/22.9--unconnected_drive-basic.sv 2state skip -chapter-22/22.9--unconnected_drive-basic.sv 4state skip +chapter-22/22.7--timescale-module.sv 2state pass +chapter-22/22.7--timescale-module.sv 4state pass +chapter-22/22.7--timescale-reset.sv 2state pass +chapter-22/22.7--timescale-reset.sv 4state pass +chapter-22/22.8--default_nettype-redefinition.sv 2state pass +chapter-22/22.8--default_nettype-redefinition.sv 4state pass +chapter-22/22.8--default_nettype.sv 2state pass +chapter-22/22.8--default_nettype.sv 4state pass +chapter-22/22.9--unconnected_drive-basic-2.sv 2state pass +chapter-22/22.9--unconnected_drive-basic-2.sv 4state pass +chapter-22/22.9--unconnected_drive-basic.sv 2state pass +chapter-22/22.9--unconnected_drive-basic.sv 4state pass chapter-22/22.9--unconnected_drive-invalid-1.sv 2state pass chapter-22/22.9--unconnected_drive-invalid-1.sv 4state pass chapter-22/22.9--unconnected_drive-invalid-2.sv 2state pass chapter-22/22.9--unconnected_drive-invalid-2.sv 4state pass chapter-22/22.9--unconnected_drive-invalid-3.sv 2state pass chapter-22/22.9--unconnected_drive-invalid-3.sv 4state pass -chapter-22/dummy_include.sv 2state skip -chapter-22/dummy_include.sv 4state skip -chapter-22/include_directory/defs.sv 2state skip -chapter-22/include_directory/defs.sv 4state skip +chapter-22/dummy_include.sv 2state pass +chapter-22/dummy_include.sv 4state pass +chapter-22/include_directory/defs.sv 2state pass +chapter-22/include_directory/defs.sv 4state pass chapter-23/23.2--macromodule-definition.sv 2state pass chapter-23/23.2--macromodule-definition.sv 4state pass chapter-23/23.2--module-definition.sv 2state pass @@ -1041,16 +1041,16 @@ chapter-5/5.6.4--compiler-directives-include.sv 2state pass chapter-5/5.6.4--compiler-directives-include.sv 4state pass chapter-5/5.6.4--compiler-directives-pragma.sv 2state pass chapter-5/5.6.4--compiler-directives-pragma.sv 4state pass -chapter-5/5.6.4--compiler-directives-preprocessor-macro_0.sv 2state skip -chapter-5/5.6.4--compiler-directives-preprocessor-macro_0.sv 4state skip +chapter-5/5.6.4--compiler-directives-preprocessor-macro_0.sv 2state pass +chapter-5/5.6.4--compiler-directives-preprocessor-macro_0.sv 4state pass chapter-5/5.6.4--compiler-directives-preprocessor-macro_1.sv 2state pass chapter-5/5.6.4--compiler-directives-preprocessor-macro_1.sv 4state pass chapter-5/5.6.4--compiler-directives-resetall.sv 2state pass chapter-5/5.6.4--compiler-directives-resetall.sv 4state pass chapter-5/5.6.4--compiler-directives-timescale.sv 2state pass chapter-5/5.6.4--compiler-directives-timescale.sv 4state pass -chapter-5/5.6.4--compiler-directives-unconnected-drive.sv 2state skip -chapter-5/5.6.4--compiler-directives-unconnected-drive.sv 4state skip +chapter-5/5.6.4--compiler-directives-unconnected-drive.sv 2state pass +chapter-5/5.6.4--compiler-directives-unconnected-drive.sv 4state pass chapter-5/5.7.1--integers-left-padding-bit.sv 2state pass chapter-5/5.7.1--integers-left-padding-bit.sv 4state pass chapter-5/5.7.1--integers-left-padding.sv 2state pass @@ -1741,48 +1741,48 @@ generic/class/class_test_8.sv 2state pass generic/class/class_test_8.sv 4state pass generic/class/class_test_9.sv 2state pass generic/class/class_test_9.sv 4state pass -generic/desc/desc_test_0.sv 2state skip -generic/desc/desc_test_0.sv 4state skip -generic/desc/desc_test_1.sv 2state skip -generic/desc/desc_test_1.sv 4state skip -generic/desc/desc_test_10.sv 2state skip -generic/desc/desc_test_10.sv 4state skip -generic/desc/desc_test_15.sv 2state skip -generic/desc/desc_test_15.sv 4state skip -generic/desc/desc_test_16.sv 2state skip -generic/desc/desc_test_16.sv 4state skip -generic/desc/desc_test_17.sv 2state skip -generic/desc/desc_test_17.sv 4state skip -generic/desc/desc_test_18.sv 2state skip -generic/desc/desc_test_18.sv 4state skip -generic/desc/desc_test_2.sv 2state skip -generic/desc/desc_test_2.sv 4state skip -generic/desc/desc_test_3.sv 2state skip -generic/desc/desc_test_3.sv 4state skip -generic/desc/desc_test_4.sv 2state skip -generic/desc/desc_test_4.sv 4state skip -generic/desc/desc_test_5.sv 2state skip -generic/desc/desc_test_5.sv 4state skip -generic/desc/desc_test_6.sv 2state skip -generic/desc/desc_test_6.sv 4state skip -generic/desc/desc_test_7.sv 2state skip -generic/desc/desc_test_7.sv 4state skip -generic/desc/desc_test_8.sv 2state skip -generic/desc/desc_test_8.sv 4state skip -generic/desc/desc_test_9.sv 2state skip -generic/desc/desc_test_9.sv 4state skip -generic/empty/empty_test_0.sv 2state skip -generic/empty/empty_test_0.sv 4state skip -generic/empty/empty_test_1.sv 2state skip -generic/empty/empty_test_1.sv 4state skip -generic/empty/empty_test_2.sv 2state skip -generic/empty/empty_test_2.sv 4state skip -generic/empty/empty_test_3.sv 2state skip -generic/empty/empty_test_3.sv 4state skip -generic/empty/empty_test_4.sv 2state skip -generic/empty/empty_test_4.sv 4state skip -generic/empty/empty_test_5.sv 2state skip -generic/empty/empty_test_5.sv 4state skip +generic/desc/desc_test_0.sv 2state pass +generic/desc/desc_test_0.sv 4state pass +generic/desc/desc_test_1.sv 2state pass +generic/desc/desc_test_1.sv 4state pass +generic/desc/desc_test_10.sv 2state pass +generic/desc/desc_test_10.sv 4state pass +generic/desc/desc_test_15.sv 2state pass +generic/desc/desc_test_15.sv 4state pass +generic/desc/desc_test_16.sv 2state pass +generic/desc/desc_test_16.sv 4state pass +generic/desc/desc_test_17.sv 2state pass +generic/desc/desc_test_17.sv 4state pass +generic/desc/desc_test_18.sv 2state pass +generic/desc/desc_test_18.sv 4state pass +generic/desc/desc_test_2.sv 2state pass +generic/desc/desc_test_2.sv 4state pass +generic/desc/desc_test_3.sv 2state pass +generic/desc/desc_test_3.sv 4state pass +generic/desc/desc_test_4.sv 2state pass +generic/desc/desc_test_4.sv 4state pass +generic/desc/desc_test_5.sv 2state pass +generic/desc/desc_test_5.sv 4state pass +generic/desc/desc_test_6.sv 2state pass +generic/desc/desc_test_6.sv 4state pass +generic/desc/desc_test_7.sv 2state pass +generic/desc/desc_test_7.sv 4state pass +generic/desc/desc_test_8.sv 2state pass +generic/desc/desc_test_8.sv 4state pass +generic/desc/desc_test_9.sv 2state pass +generic/desc/desc_test_9.sv 4state pass +generic/empty/empty_test_0.sv 2state pass +generic/empty/empty_test_0.sv 4state pass +generic/empty/empty_test_1.sv 2state pass +generic/empty/empty_test_1.sv 4state pass +generic/empty/empty_test_2.sv 2state pass +generic/empty/empty_test_2.sv 4state pass +generic/empty/empty_test_3.sv 2state pass +generic/empty/empty_test_3.sv 4state pass +generic/empty/empty_test_4.sv 2state pass +generic/empty/empty_test_4.sv 4state pass +generic/empty/empty_test_5.sv 2state pass +generic/empty/empty_test_5.sv 4state pass generic/iface/iface_class_test_0.sv 2state pass generic/iface/iface_class_test_0.sv 4state pass generic/iface/iface_class_test_1.sv 2state pass @@ -1951,20 +1951,20 @@ generic/number/number_test_8.sv 2state pass generic/number/number_test_8.sv 4state pass generic/number/number_test_9.sv 2state pass generic/number/number_test_9.sv 4state pass -generic/preproc/preproc_test_0.sv 2state skip -generic/preproc/preproc_test_0.sv 4state skip -generic/preproc/preproc_test_2.sv 2state skip -generic/preproc/preproc_test_2.sv 4state skip -generic/preproc/preproc_test_4.sv 2state skip -generic/preproc/preproc_test_4.sv 4state skip -generic/preproc/preproc_test_5.sv 2state skip -generic/preproc/preproc_test_5.sv 4state skip -generic/preproc/preproc_test_6.sv 2state skip -generic/preproc/preproc_test_6.sv 4state skip -generic/preproc/preproc_test_7.sv 2state skip -generic/preproc/preproc_test_7.sv 4state skip -generic/preproc/preproc_test_8.sv 2state skip -generic/preproc/preproc_test_8.sv 4state skip +generic/preproc/preproc_test_0.sv 2state pass +generic/preproc/preproc_test_0.sv 4state pass +generic/preproc/preproc_test_2.sv 2state pass +generic/preproc/preproc_test_2.sv 4state pass +generic/preproc/preproc_test_4.sv 2state pass +generic/preproc/preproc_test_4.sv 4state pass +generic/preproc/preproc_test_5.sv 2state pass +generic/preproc/preproc_test_5.sv 4state pass +generic/preproc/preproc_test_6.sv 2state pass +generic/preproc/preproc_test_6.sv 4state pass +generic/preproc/preproc_test_7.sv 2state pass +generic/preproc/preproc_test_7.sv 4state pass +generic/preproc/preproc_test_8.sv 2state pass +generic/preproc/preproc_test_8.sv 4state pass generic/struct/struct_test_0.sv 2state pass generic/struct/struct_test_0.sv 4state pass generic/typedef/typedef_test_0.sv 2state pass diff --git a/conformance/sv-tests/runners/celox.py b/conformance/sv-tests/runners/celox.py index 8eff962dc17..14139297b86 100644 --- a/conformance/sv-tests/runners/celox.py +++ b/conformance/sv-tests/runners/celox.py @@ -14,7 +14,7 @@ def __init__(self): super().__init__( name="celox", executable=os.environ["CELOX_SV_TESTS_DRIVER"], - supported_features={"parsing", "elaboration", "simulation"}, + supported_features={"preprocessing", "parsing", "elaboration", "simulation"}, ) self.url = "https://github.com/celox-sim/celox" diff --git a/conformance/sv-tests/test_runner.py b/conformance/sv-tests/test_runner.py index 9a36b97b2b1..9a82bd03259 100644 --- a/conformance/sv-tests/test_runner.py +++ b/conformance/sv-tests/test_runner.py @@ -89,7 +89,10 @@ def test_official_skips_and_no_module_is_not_preemptively_skipped(self): row = self.case(":type: parsing\n") self.assertEqual((row["mode"], row["result"]), ("parsing", "pass")) self.assertEqual(self.case(":type: parsing\n:should_fail_because: syntax\n", "// EXIT: 1")["result"], "pass") - self.assertEqual(self.case(":type: preprocessing\n")["result"], "skip") + row = self.case(":type: preprocessing\n") + self.assertEqual((row["mode"], row["result"]), ("preprocessing", "pass")) + self.assertEqual(self.case(":type: preprocessing\n", "// EXIT: 1")["result"], "fail") + self.assertEqual(self.case(":type: preprocessing\n:should_fail_because: invalid\n", "// EXIT: 1")["result"], "pass") self.assertEqual(self.case(":compatible-runners: other\n")["result"], "skip") # The source has no module. Its diagnostic still reaches official judgement. row = self.case(body="// OUTPUT: no module diagnostic\n// EXIT: 1") diff --git a/crates/celox-frontend-core/src/symbolic/assembly.rs b/crates/celox-frontend-core/src/symbolic/assembly.rs index f29c6bf75c0..c41124ec1a4 100644 --- a/crates/celox-frontend-core/src/symbolic/assembly.rs +++ b/crates/celox-frontend-core/src/symbolic/assembly.rs @@ -691,6 +691,107 @@ pub type LoopMember = (ModuleId, VarAtomBase); /// [`schedule_symbolic_rtl`], which also reports the ranges the blocks of a /// combinational loop write when the scheduler rejects one. #[allow(clippy::too_many_arguments)] +/// The sensitivity atoms whose occurrences the processes and observers of +/// `comb_blocks` and `comb_observers` count, with their counters, in order of +/// discovery: the atoms they list, then the upstream atoms of transparent +/// copies into them. `same_kind` tells whether a copy carries occurrences +/// between two variables. +fn sensitivity_probes( + comb_blocks: &[LogicPath], + comb_observers: &[CombObserver], + arena: &SLTNodeArena, + same_kind: impl Fn(&AbsoluteAddr, &AbsoluteAddr) -> bool, +) -> Vec<(VarAtomBase, AbsoluteAddr)> { + let mut probes = Vec::new(); + let mut probed = HashSet::default(); + for path in comb_blocks { + if let LogicPathTarget::Process { + sensitivity_counters, + .. + } = &path.target + { + for &(source, counter) in sensitivity_counters { + if probed.insert((source, counter)) { + probes.push((source, counter)); + } + } + } + } + for observer in comb_observers { + for &(source, counter) in &observer.sensitivity_counters { + if probed.insert((source, counter)) { + probes.push((source, counter)); + } + } + } + add_copied_probes(&mut probes, &mut probed, comb_blocks, arena, same_kind); + probes +} + +/// Adds to `probes` the upstream atoms of the transparent copies of +/// `comb_blocks` into atoms of `probes`, transitively, each with the counter +/// of the atom it reaches. `probed` holds the entries of `probes`. +/// +/// A direct wire/port connection carries occurrences as well as its settled +/// value. Preserve them when a kernel writes the upstream object twice +/// before the copy path is evaluated. Only equal-width, unindexed copies are +/// transparent here; expressions remain scheduled combinational evaluations. +fn add_copied_probes( + probes: &mut Vec<(VarAtomBase, AbsoluteAddr)>, + probed: &mut HashSet<(VarAtomBase, AbsoluteAddr)>, + comb_blocks: &[LogicPath], + arena: &SLTNodeArena, + same_kind: impl Fn(&AbsoluteAddr, &AbsoluteAddr) -> bool, +) { + let mut copies_to: HashMap> = HashMap::default(); + for (path_index, path) in comb_blocks.iter().enumerate() { + if let LogicPathTarget::Var(target) = &path.target + && path.transparent_copy + { + copies_to.entry(target.id).or_default().push(path_index); + } + } + let mut next_probe = 0; + while next_probe < probes.len() { + let (source, counter) = probes[next_probe]; + next_probe += 1; + for &path_index in copies_to.get(&source.id).into_iter().flatten() { + let path = &comb_blocks[path_index]; + let LogicPathTarget::Var(target) = &path.target else { + unreachable!("copies_to holds variable targets"); + }; + if !target.access.overlaps(&source.access) { + continue; + } + let celox_slt::SLTNode::Input { + variable, + access, + index, + .. + } = arena.get(path.expr) + else { + continue; + }; + if !index.is_empty() + || !same_kind(variable, &target.id) + || access.msb - access.lsb != target.access.msb - target.access.lsb + { + continue; + } + let lsb = source.access.lsb.max(target.access.lsb); + let msb = source.access.msb.min(target.access.msb); + let upstream = VarAtomBase::new( + *variable, + access.lsb + lsb - target.access.lsb, + access.lsb + msb - target.access.lsb, + ); + if probed.insert((upstream, counter)) { + probes.push((upstream, counter)); + } + } + } +} + pub fn schedule_symbolic_rtl_reporting_loops( symbolic: SymbolicRtl, fused_ff_factory: Option<&dyn FusedFfLoweringFactory>, @@ -866,73 +967,12 @@ pub fn schedule_symbolic_rtl_reporting_loops( ); // Count sensitivity occurrences before any optimizer can coalesce // consecutive writes whose final value is unchanged. - let mut probes = Vec::new(); - for path in &comb_blocks { - if let LogicPathTarget::Process { - sensitivity_counters, - .. - } = &path.target - { - for &(source, counter) in sensitivity_counters { - if !probes.contains(&(source, counter)) { - probes.push((source, counter)); - } - } - } - } - for observer in &comb_observers { - for &(source, counter) in &observer.sensitivity_counters { - if !probes.contains(&(source, counter)) { - probes.push((source, counter)); - } - } - } - // A direct wire/port connection carries occurrences as well as its - // settled value. Preserve them when a kernel writes the upstream - // object twice before the copy path is evaluated. Only equal-width, - // unindexed copies are transparent here; expressions remain scheduled - // combinational evaluations. - let mut next_probe = 0; - while next_probe < probes.len() { - let (source, counter) = probes[next_probe]; - next_probe += 1; - for path in &comb_blocks { - let LogicPathTarget::Var(target) = &path.target else { - continue; - }; - if !path.transparent_copy - || target.id != source.id - || !target.access.overlaps(&source.access) - { - continue; - } - let celox_slt::SLTNode::Input { - variable, - access, - index, - .. - } = global_arena.get(path.expr) - else { - continue; - }; - if !index.is_empty() - || (four_state && variables[variable].1 != variables[&target.id].1) - || access.msb - access.lsb != target.access.msb - target.access.lsb - { - continue; - } - let lsb = source.access.lsb.max(target.access.lsb); - let msb = source.access.msb.min(target.access.msb); - let upstream = VarAtomBase::new( - *variable, - access.lsb + lsb - target.access.lsb, - access.lsb + msb - target.access.lsb, - ); - if !probes.contains(&(upstream, counter)) { - probes.push((upstream, counter)); - } - } - } + let probes = sensitivity_probes( + &comb_blocks, + &comb_observers, + &global_arena, + |source, target| !four_state || variables[source].1 == variables[target].1, + ); declaration_probes = probes.clone(); occurrence_probes = probes.clone(); // Signals a flip-flop evaluation may store twice in its working @@ -5697,3 +5737,153 @@ impl GateBuilder<'_> { } } } + +#[cfg(test)] +mod tests { + use super::*; + + fn addr(var: u32) -> AbsoluteAddr { + AbsoluteAddr { + instance_id: InstanceId(0), + var_id: SourceVarId(var), + } + } + + /// The previous propagation, which scans every path for each probe. + fn add_copied_probes_by_scan( + probes: &mut Vec<(VarAtomBase, AbsoluteAddr)>, + comb_blocks: &[LogicPath], + arena: &SLTNodeArena, + same_kind: impl Fn(&AbsoluteAddr, &AbsoluteAddr) -> bool, + ) { + let mut next_probe = 0; + while next_probe < probes.len() { + let (source, counter) = probes[next_probe]; + next_probe += 1; + for path in comb_blocks { + let LogicPathTarget::Var(target) = &path.target else { + continue; + }; + if !path.transparent_copy + || target.id != source.id + || !target.access.overlaps(&source.access) + { + continue; + } + let celox_slt::SLTNode::Input { + variable, + access, + index, + .. + } = arena.get(path.expr) + else { + continue; + }; + if !index.is_empty() + || !same_kind(variable, &target.id) + || access.msb - access.lsb != target.access.msb - target.access.lsb + { + continue; + } + let lsb = source.access.lsb.max(target.access.lsb); + let msb = source.access.msb.min(target.access.msb); + let upstream = VarAtomBase::new( + *variable, + access.lsb + lsb - target.access.lsb, + access.lsb + msb - target.access.lsb, + ); + if !probes.contains(&(upstream, counter)) { + probes.push((upstream, counter)); + } + } + } + } + + /// Indexing the transparent copies by target finds the probes the scan + /// of every path finds, in the same order. + #[test] + fn copied_probes_match_path_scan() { + let mut seed = 0x2545_f491_4f6c_dd1du64; + let mut next = |bound: usize| { + seed ^= seed << 13; + seed ^= seed >> 7; + seed ^= seed << 17; + (seed % bound as u64) as usize + }; + let mut copied = 0; + for _ in 0..50 { + let mut arena = SLTNodeArena::new(); + let mut comb_blocks = Vec::new(); + for _ in 0..60 { + let target_lsb = next(12); + let target_width = 1 + next(4); + let source_lsb = next(12); + // Mostly equal widths, so that most copies are transparent. + let source_width = if next(5) == 0 { + 1 + next(4) + } else { + target_width + }; + let expr = if next(8) == 0 { + arena + .alloc(celox_slt::SLTNode::Constant( + BigUint::from(0u32), + BigUint::from(0u32), + source_width, + false, + )) + .unwrap() + } else { + arena + .alloc(celox_slt::SLTNode::Input { + variable: addr(next(12) as u32), + signed: false, + index: Vec::new(), + access: BitAccess::new(source_lsb, source_lsb + source_width - 1), + }) + .unwrap() + }; + comb_blocks.push(LogicPath { + target: LogicPathTarget::Var(VarAtomBase::new( + addr(next(12) as u32), + target_lsb, + target_lsb + target_width - 1, + )), + transparent_copy: next(6) != 0, + sources: HashSet::default(), + previous_sources: HashSet::default(), + address_sources: HashSet::default(), + local_inputs: Vec::new(), + order_before: HashSet::default(), + comb_capture_enable_sites: Vec::new(), + comb_capture_enable_always: false, + pre_lower_nodes: Vec::new(), + expr, + }); + } + let mut probes = Vec::new(); + for _ in 0..4 { + let lsb = next(14); + let probe = ( + VarAtomBase::new(addr(next(12) as u32), lsb, lsb + next(3)), + addr(100 + next(3) as u32), + ); + if !probes.contains(&probe) { + probes.push(probe); + } + } + // Variables 0..6 are four-state and the others two-state. + let same_kind = + |a: &AbsoluteAddr, b: &AbsoluteAddr| (a.var_id.0 < 6) == (b.var_id.0 < 6); + let mut expected = probes.clone(); + add_copied_probes_by_scan(&mut expected, &comb_blocks, &arena, same_kind); + let mut probed = probes.iter().copied().collect(); + add_copied_probes(&mut probes, &mut probed, &comb_blocks, &arena, same_kind); + assert_eq!(probes, expected); + assert_eq!(probed.len(), probes.len()); + copied += probes.len(); + } + // The cases find copies, beyond the 4 initial probes each. + assert!(copied > 50 * 4 + 50, "{copied} probes"); + } +} diff --git a/crates/celox/examples/sv_tests.rs b/crates/celox/examples/sv_tests.rs index 8ff75d497fd..80b5fe80b36 100644 --- a/crates/celox/examples/sv_tests.rs +++ b/crates/celox/examples/sv_tests.rs @@ -4,7 +4,7 @@ //! sv-tests. This process reports only compiler/simulator success or failure. //! //! ```text -//! sv_tests --mode parsing|elaboration|simulation --state-mode 2state|4state \ +//! sv_tests --mode preprocessing|parsing|elaboration|simulation --state-mode 2state|4state \ //! [--top NAME] [--define NAME[=VALUE]] [--include DIR] -- FILE... //! ``` @@ -14,6 +14,7 @@ use std::{collections::BTreeSet, env, path::PathBuf, process::ExitCode}; #[derive(Clone, Copy, Debug, PartialEq, Eq)] enum Mode { + Preprocessing, Parsing, Elaboration, Simulation, @@ -52,6 +53,7 @@ fn parse_options(args: &[String]) -> Result { match arg.as_str() { "--mode" if mode.is_none() => { mode = Some(match value.as_str() { + "preprocessing" => Mode::Preprocessing, "parsing" => Mode::Parsing, "elaboration" => Mode::Elaboration, "simulation" => Mode::Simulation, @@ -143,6 +145,12 @@ fn run(options: &Options) -> Result<(), String> { .map_err(|error| error.to_string()) }) .collect::>()?; + if options.mode == Mode::Preprocessing { + for text in &texts { + print!("{text}"); + } + return Ok(()); + } let sources: Vec<_> = texts .iter() .zip(&options.files) @@ -164,7 +172,9 @@ fn run(options: &Options) -> Result<(), String> { .map_err(|error| error.to_string())?; let top = select_top(&parsed, options.top.as_deref())?; match options.mode { - Mode::Parsing => unreachable!("parsing returned before root selection"), + Mode::Preprocessing | Mode::Parsing => { + unreachable!("preprocessing and parsing returned before root selection") + } // A Simulator rejects designs with processes, which it does not run. Mode::Elaboration => celox::Simulation::from_sv_sources(sources, &top) .four_state(options.four_state) @@ -242,7 +252,7 @@ fn main() -> ExitCode { Ok(options) => options, Err(error) => { eprintln!( - "{error}\nusage: sv_tests --mode parsing|elaboration|simulation --state-mode 2state|4state [--top NAME] [--define NAME[=VALUE]] [--include DIR] -- FILE..." + "{error}\nusage: sv_tests --mode preprocessing|parsing|elaboration|simulation --state-mode 2state|4state [--top NAME] [--define NAME[=VALUE]] [--include DIR] -- FILE..." ); return ExitCode::from(2); } @@ -295,7 +305,7 @@ mod tests { assert_eq!(o.includes, [PathBuf::from("headers")]); assert_eq!(o.files, [PathBuf::from("a.sv"), PathBuf::from("b.sv")]); for args in [ - vec!["--mode", "preprocessing", "--state-mode", "2state", "a.sv"], + vec!["--mode", "unknown", "--state-mode", "2state", "a.sv"], vec!["--mode", "elaboration", "--state-mode", "both", "a.sv"], vec![ "--mode", @@ -356,6 +366,28 @@ mod tests { } } + #[test] + fn preprocessing_stops_before_syntax_and_reports_directive_errors() { + let dir = tempfile::tempdir().unwrap(); + let path = fixture( + dir.path(), + "tokens.sv", + "`define WORD expanded\n`WORD\nmodule unfinished;", + ); + let mut opts = fixture_options(vec![path], Mode::Preprocessing); + run(&opts).unwrap(); + opts.mode = Mode::Parsing; + assert!(run(&opts).is_err()); + let path = fixture(dir.path(), "invalid.sv", "`include \"missing.svh\"\n"); + assert!(run(&fixture_options(vec![path], Mode::Preprocessing)).is_err()); + assert_eq!( + options(&["--mode", "preprocessing", "--state-mode", "2state", "a.sv"]) + .unwrap() + .mode, + Mode::Preprocessing + ); + } + #[test] fn parsing_stops_before_metadata_roots_elaboration_and_simulation() { let dir = tempfile::tempdir().unwrap();