Skip to content

Commit 533abc2

Browse files
committed
Add support for multi-file designs
This commit removes requirement of providing single-file as an input to sv-bugpoint. Now, user can provide multiple input files and they are passed to test script as separate arguments. Each file is minimalized separately until we can't remove any node from any file. It adds `-f` flag that accepts command file with additional parameters for sv-bugpoint and `-y` flag that includes add (System)Verilog files from given folder. Signed-off-by: Kamil Rakoczy <krakoczy@antmicro.com>
1 parent 9e15f30 commit 533abc2

39 files changed

Lines changed: 700 additions & 257 deletions

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ FetchContent_Declare(
1212
FetchContent_MakeAvailable(slang)
1313

1414
add_executable(sv-bugpoint source/SvBugpoint.cpp source/Utils.cpp source/PairRemovers.cpp source/BodyRemover.cpp
15-
source/BodyPartsRemover.cpp source/DeclRemover.cpp source/InstantationRemover.cpp source/BindRemover.cpp source/ModportRemover.cpp source/ContAssignRemover.cpp source/ParamAssignRemover.cpp
15+
source/BodyPartsRemover.cpp source/DeclRemover.cpp source/InstantationRemover.cpp source/BindRemover.cpp source/ModportRemover.cpp source/ContAssignRemover.cpp source/ParamAssignRemover.cpp source/ModuleRemover.cpp
1616
source/StatementsRemover.cpp source/MemberRemover.cpp source/ImportsRemover.cpp source/TypeSimplifier.cpp)
1717

1818
target_link_libraries(sv-bugpoint PRIVATE slang::slang)

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,25 +40,27 @@ First, you need to prepare:
4040
It should exit with 0 if the assertion is successful.
4141
For reference, see [`examples/caliptra_verilation_err/sv-bugpoint-check.sh`](examples/caliptra_verilation_err/sv-bugpoint-check.sh) and [`examples/caliptra_vcd/sv-bugpoint-check.sh`](examples/caliptra_vcd/sv-bugpoint-check.sh).
4242
The script can be written in any language you are comfortable with, it just needs to be an executable. See the Python example: [`examples/caliptra_verilation_err/sv-bugpoint-check.py`](examples/caliptra_verilation_err/sv-bugpoint-check.py).
43-
- SystemVerilog code that `sv-bugpoint` will attempt to minimize. In order to get one from a multi-file design,
44-
you can use a preprocessor of your choice (e.g `verilator -E -P [other flags...] > sv-bugpoint-input.sv`).
43+
- SystemVerilog code that `sv-bugpoint` will attempt to minimize.
4544

4645
After that, run:
4746

4847
```sh
49-
sv-bugpoint <OUT_DIR> <CHECK_SCRIPT> <INPUT_SV>
48+
sv-bugpoint <OUT_DIR> <CHECK_SCRIPT> <INPUT_SV> [<INPUT_SV>]
5049
```
5150

5251
The output directory will be populated with:
53-
- `sv-bugpoint-minimized.sv` - minimized code that satisfies the assertion checked by the provided script,
52+
- `sv-bugpoint-minimized.sv` - minimized code that satisfies the assertion checked by the provided script. It contains concatenated output of every input file,
53+
- `sv-bugpoint-<INPUT_SV>` - minimalized code for each input file,
5454
- `tmp/<INPUT_SV>` - a copy of the previous file with a removal attempt applied, to be checked with the provided script,
55-
- `sv-bugpoint-trace` - verbose, tab-delimited trace with stats and additional info about each removal attempt ([example](examples/caliptra_verilation_err/sv-bugpoint-trace)).
55+
- `sv-bugpoint-trace<INPUT_SV>` - verbose, tab-delimited trace with stats and additional info about each removal attempt ([example](examples/caliptra_verilation_err/sv-bugpoint-trace)).
5656
It can be turned into a concise, high-level summary with the [`sv-bugpoint-trace_summary script`](scripts/sv-bugpoint-trace_summary) ([example](examples/caliptra_verilation_err/sv-bugpoint-trace_summarized)).
5757

5858
There are flags that enable additional dumps:
5959
- `--save-intermediates` saves each removal attempt in `<OUT_DIR>/intermediates/attempt<index>.sv`.
6060
- `--dump-trees` saves dumps of Slang's AST.
6161

62+
To get more information about available flags, run `sv-bugpoint --help`.
63+
6264
### Automatically generating check scripts
6365

6466
If your goal is to debug Verilator, the [`sv-bugpoint-verilator-gen` script](scripts/sv-bugpoint-verilator-gen) can automatically generate an input test case and a check script template for you.

source/BindRemover.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ class BindRemover : public OneTimeRewriter<BindRemover> {
1111

1212
template bool rewriteLoop<BindRemover>(std::shared_ptr<SyntaxTree>& tree,
1313
std::string stageName,
14-
std::string passIdx);
14+
std::string passIdx,
15+
SvBugpoint* svBugpoint);

source/BodyPartsRemover.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@ class BodyPartsRemover : public OneTimeRewriter<BodyPartsRemover> {
1919

2020
template bool rewriteLoop<BodyPartsRemover>(std::shared_ptr<SyntaxTree>& tree,
2121
std::string stageName,
22-
std::string passIdx);
22+
std::string passIdx,
23+
SvBugpoint* svBugpoint);

source/BodyRemover.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,5 @@ class BodyRemover : public OneTimeRewriter<BodyRemover> {
2626

2727
template bool rewriteLoop<BodyRemover>(std::shared_ptr<SyntaxTree>& tree,
2828
std::string stageName,
29-
std::string passIdx);
29+
std::string passIdx,
30+
SvBugpoint* svBugpoint);

source/ContAssignRemover.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ class ContAssignRemover : public OneTimeRewriter<ContAssignRemover> {
1111

1212
template bool rewriteLoop<ContAssignRemover>(std::shared_ptr<SyntaxTree>& tree,
1313
std::string stageName,
14-
std::string passIdx);
14+
std::string passIdx,
15+
SvBugpoint* svBugpoint);

source/DeclRemover.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,5 @@ class DeclRemover : public OneTimeRewriter<DeclRemover> {
5656

5757
template bool rewriteLoop<DeclRemover>(std::shared_ptr<SyntaxTree>& tree,
5858
std::string stageName,
59-
std::string passIdx);
59+
std::string passIdx,
60+
SvBugpoint* svBugpoint);

source/ImportsRemover.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ class ImportsRemover : public OneTimeRewriter<ImportsRemover> {
1111

1212
template bool rewriteLoop<ImportsRemover>(std::shared_ptr<SyntaxTree>& tree,
1313
std::string stageName,
14-
std::string passIdx);
14+
std::string passIdx,
15+
SvBugpoint* svBugpoint);

source/InstantationRemover.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ class InstantationRemover : public OneTimeRewriter<InstantationRemover> {
1111

1212
template bool rewriteLoop<InstantationRemover>(std::shared_ptr<SyntaxTree>& tree,
1313
std::string stageName,
14-
std::string passIdx);
14+
std::string passIdx,
15+
SvBugpoint* svBugpoint);

source/MemberRemover.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,5 @@ class MemberRemover : public OneTimeRewriter<MemberRemover> {
4343

4444
template bool rewriteLoop<MemberRemover>(std::shared_ptr<SyntaxTree>& tree,
4545
std::string stageName,
46-
std::string passIdx);
46+
std::string passIdx,
47+
SvBugpoint* svBugpoint);

0 commit comments

Comments
 (0)