svcc 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. svcc-0.1.0/Cargo.toml +52 -0
  2. svcc-0.1.0/LICENSE +17 -0
  3. svcc-0.1.0/PKG-INFO +112 -0
  4. svcc-0.1.0/README.md +92 -0
  5. svcc-0.1.0/bindings/python/Cargo.lock +564 -0
  6. svcc-0.1.0/bindings/python/Cargo.toml +19 -0
  7. svcc-0.1.0/bindings/python/LICENSE +17 -0
  8. svcc-0.1.0/bindings/python/README.md +92 -0
  9. svcc-0.1.0/bindings/python/src/lib.rs +80 -0
  10. svcc-0.1.0/crates/svcc/Cargo.toml +32 -0
  11. svcc-0.1.0/crates/svcc/LICENSE +17 -0
  12. svcc-0.1.0/crates/svcc/README.md +91 -0
  13. svcc-0.1.0/crates/svcc/src/cosim.rs +704 -0
  14. svcc-0.1.0/crates/svcc/src/lib.rs +178 -0
  15. svcc-0.1.0/crates/svcc/src/main.rs +841 -0
  16. svcc-0.1.0/crates/svcc/src/prove.rs +394 -0
  17. svcc-0.1.0/crates/svcc-emit-sc/Cargo.toml +15 -0
  18. svcc-0.1.0/crates/svcc-emit-sc/LICENSE +17 -0
  19. svcc-0.1.0/crates/svcc-emit-sc/README.md +9 -0
  20. svcc-0.1.0/crates/svcc-emit-sc/src/hdl_emit.rs +2265 -0
  21. svcc-0.1.0/crates/svcc-emit-sc/src/lib.rs +1141 -0
  22. svcc-0.1.0/crates/svcc-emit-sv/Cargo.toml +20 -0
  23. svcc-0.1.0/crates/svcc-emit-sv/LICENSE +17 -0
  24. svcc-0.1.0/crates/svcc-emit-sv/README.md +9 -0
  25. svcc-0.1.0/crates/svcc-emit-sv/src/hdl_emit.rs +1105 -0
  26. svcc-0.1.0/crates/svcc-emit-sv/src/lib.rs +738 -0
  27. svcc-0.1.0/crates/svcc-equiv/Cargo.toml +22 -0
  28. svcc-0.1.0/crates/svcc-equiv/LICENSE +17 -0
  29. svcc-0.1.0/crates/svcc-equiv/README.md +9 -0
  30. svcc-0.1.0/crates/svcc-equiv/src/lib.rs +873 -0
  31. svcc-0.1.0/crates/svcc-equiv/src/pair.rs +965 -0
  32. svcc-0.1.0/crates/svcc-equiv/src/sec.rs +24 -0
  33. svcc-0.1.0/crates/svcc-front-sc/Cargo.toml +20 -0
  34. svcc-0.1.0/crates/svcc-front-sc/LICENSE +17 -0
  35. svcc-0.1.0/crates/svcc-front-sc/README.md +9 -0
  36. svcc-0.1.0/crates/svcc-front-sc/src/cxx.rs +894 -0
  37. svcc-0.1.0/crates/svcc-front-sc/src/cxx_sem.rs +2055 -0
  38. svcc-0.1.0/crates/svcc-front-sc/src/hdl_lift.rs +1240 -0
  39. svcc-0.1.0/crates/svcc-front-sc/src/lib.rs +1451 -0
  40. svcc-0.1.0/crates/svcc-front-sv/Cargo.toml +16 -0
  41. svcc-0.1.0/crates/svcc-front-sv/LICENSE +17 -0
  42. svcc-0.1.0/crates/svcc-front-sv/README.md +9 -0
  43. svcc-0.1.0/crates/svcc-front-sv/src/crv_parser.rs +844 -0
  44. svcc-0.1.0/crates/svcc-front-sv/src/hdl_lower.rs +3896 -0
  45. svcc-0.1.0/crates/svcc-front-sv/src/lib.rs +1559 -0
  46. svcc-0.1.0/crates/svcc-ir/Cargo.toml +16 -0
  47. svcc-0.1.0/crates/svcc-ir/LICENSE +17 -0
  48. svcc-0.1.0/crates/svcc-ir/README.md +9 -0
  49. svcc-0.1.0/crates/svcc-ir/src/hdl.rs +583 -0
  50. svcc-0.1.0/crates/svcc-ir/src/lib.rs +867 -0
  51. svcc-0.1.0/crates/svcc-passes/Cargo.toml +15 -0
  52. svcc-0.1.0/crates/svcc-passes/LICENSE +17 -0
  53. svcc-0.1.0/crates/svcc-passes/README.md +9 -0
  54. svcc-0.1.0/crates/svcc-passes/src/lib.rs +697 -0
  55. svcc-0.1.0/crates/svcc-svlang/Cargo.toml +23 -0
  56. svcc-0.1.0/crates/svcc-svlang/LICENSE +17 -0
  57. svcc-0.1.0/crates/svcc-svlang/README.md +9 -0
  58. svcc-0.1.0/crates/svcc-svlang/src/lib.rs +225 -0
  59. svcc-0.1.0/pyproject.toml +37 -0
svcc-0.1.0/Cargo.toml ADDED
@@ -0,0 +1,52 @@
1
+ [workspace]
2
+ resolver = "2"
3
+ members = [
4
+ "crates/svcc-ir",
5
+ "crates/svcc-svlang",
6
+ "crates/svcc-front-sv",
7
+ "crates/svcc-front-sc",
8
+ "crates/svcc-passes",
9
+ "crates/svcc-equiv",
10
+ "crates/svcc-emit-sc",
11
+ "crates/svcc-emit-sv",
12
+ "crates/svcc",
13
+ ]
14
+
15
+ [workspace.package]
16
+ version = "0.1.0"
17
+ edition = "2021"
18
+ rust-version = "1.82"
19
+ license = "Apache-2.0"
20
+ repository = "https://github.com/mayurkubavat/svcc"
21
+ authors = ["Mayur Kubavat"]
22
+ keywords = ["systemverilog", "systemc", "rtl", "eda", "verification"]
23
+ categories = ["development-tools", "compilers", "simulation"]
24
+
25
+ [workspace.dependencies]
26
+ # Pinned IEEE 1800-2023 SystemVerilog front-end & UVM design model (svlang 0.5.1 from crates.io)
27
+ svlang = "0.5.1"
28
+ svlang-model = "0.5.1"
29
+ svlang-lint = "0.5.1"
30
+
31
+ # Internal workspace crates
32
+ svcc-ir = { path = "crates/svcc-ir", version = "0.1.0" }
33
+ svcc-svlang = { path = "crates/svcc-svlang", version = "0.1.0" }
34
+ svcc-front-sv = { path = "crates/svcc-front-sv", version = "0.1.0" }
35
+ svcc-front-sc = { path = "crates/svcc-front-sc", version = "0.1.0" }
36
+ svcc-passes = { path = "crates/svcc-passes", version = "0.1.0" }
37
+ svcc-equiv = { path = "crates/svcc-equiv", version = "0.1.0" }
38
+ svcc-emit-sc = { path = "crates/svcc-emit-sc", version = "0.1.0" }
39
+ svcc-emit-sv = { path = "crates/svcc-emit-sv", version = "0.1.0" }
40
+
41
+ # Serialization for IR snapshots, telemetry, and benchmark logs
42
+ serde = { version = "1.0", features = ["derive"] }
43
+ serde_json = "1.0"
44
+
45
+ [profile.release]
46
+ lto = "thin"
47
+ codegen-units = 1
48
+ strip = "symbols"
49
+
50
+ [profile.dist]
51
+ inherits = "release"
52
+ lto = "thin"
svcc-0.1.0/LICENSE ADDED
@@ -0,0 +1,17 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ Copyright 2026 Mayur Kubavat
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
svcc-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,112 @@
1
+ Metadata-Version: 2.4
2
+ Name: svcc
3
+ Version: 0.1.0
4
+ Classifier: Development Status :: 3 - Alpha
5
+ Classifier: Intended Audience :: Developers
6
+ Classifier: Intended Audience :: Science/Research
7
+ Classifier: Programming Language :: Rust
8
+ Classifier: Programming Language :: Python :: Implementation :: CPython
9
+ Classifier: Topic :: Scientific/Engineering :: Electronic Design Automation (EDA)
10
+ License-File: LICENSE
11
+ Summary: SystemVerilog RTL to SystemC conversion with Z3 equivalence checks (Python bindings)
12
+ Keywords: systemverilog,systemc,uvm,eda,formal-verification,rtl
13
+ Author: Mayur Kubavat
14
+ License-Expression: Apache-2.0
15
+ Requires-Python: >=3.9
16
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
17
+ Project-URL: Documentation, https://github.com/mayurkubavat/svcc/blob/main/docs/rtl_subset.md
18
+ Project-URL: Repository, https://github.com/mayurkubavat/svcc
19
+
20
+ # svcc (Python)
21
+
22
+ SystemVerilog to SystemC conversion for RTL, with formal checks of the result.
23
+
24
+ **Status: 0.1, early release.** The RTL conversion path is the part of `svcc` that has been
25
+ checked on real designs. Read "What is checked" and "Known limits" before relying on it.
26
+
27
+ ## What it does
28
+
29
+ - `rtl_to_sc` (CLI `svcc rtl2sc`): converts synthesizable SystemVerilog RTL to C++17 SystemC (`SC_MODULE`s).
30
+ The design is elaborated by [`svlang`](https://crates.io/crates/svlang); every expression
31
+ carries its width and signedness, and the emitter truncates explicitly wherever C++ would
32
+ compute in a wider type.
33
+ - `rtl_prove_json` (CLI `svcc rtl-prove`): proves the generated SystemC equal to the source with Z3. The generated
34
+ header is read back with C++ arithmetic rules, so a C++ width error is a counterexample.
35
+ - CLI only, `svcc rtl-cosim`: compiles the generated SystemC against a real SystemC library and runs it
36
+ against Verilator on the same random stimulus. This is simulation evidence, not a proof.
37
+ - `prove_sec_json` (CLI `svcc prove-sec`): sequential equivalence between two RTL designs, or between an untimed
38
+ C++ function and pipelined RTL some cycles later (C2RTL).
39
+
40
+ The accepted subset and the mapping are in
41
+ [`docs/rtl_subset.md`](https://github.com/mayurkubavat/svcc/blob/main/docs/rtl_subset.md);
42
+ what each check proves and assumes is in
43
+ [`docs/formal_gates.md`](https://github.com/mayurkubavat/svcc/blob/main/docs/formal_gates.md).
44
+
45
+ ## Install
46
+
47
+ ```bash
48
+ pip install svcc
49
+ ```
50
+
51
+ Wheels are built for CPython 3.9 and later (abi3). The proof functions need `z3` on `PATH`.
52
+ The `svcc` command-line tool, including `rtl-cosim`, is in the Rust crate
53
+ (`cargo install svcc`).
54
+
55
+ ```python
56
+ import json, svcc
57
+
58
+ src = open("counter.sv").read()
59
+ header = svcc.rtl_to_sc("counter.sv", src, ["counter"]) # C++17 SystemC text
60
+ for item in json.loads(svcc.rtl_prove_json("counter.sv", src)):
61
+ print(item) # Proved / Skipped / NotCovered
62
+ ```
63
+
64
+ Errors (a construct outside the subset, a parse error) raise `ValueError` with the source
65
+ location. Also available: `sv_to_sc`, `sc_to_sv`, `prove_equivalent_json`, `prove_sec_json`,
66
+ and `svcc.__version__`.
67
+
68
+ ## What is checked
69
+
70
+ - **Fail closed.** A construct outside the subset is an error with a source location, not
71
+ a guess. Skipped constructs (`initial` blocks, assertions, system tasks) are reported as
72
+ notes.
73
+ - **Proof.** For a design in the proof model, the generated SystemC is proved equal to the
74
+ source for all runs from equal start states (by induction), or for a bounded number of
75
+ cycles when induction does not close. Designs outside the model are reported as NOT
76
+ COVERED (exit code 3), never as passing.
77
+ - **Real designs.** Every module of 15 open-source designs (2,184 modules, among them ibex,
78
+ cv32e40p, cva6, OpenTitan, Caliptra, common_cells) was tried as a top. 1,191 converted;
79
+ all of them compile against SystemC, and 1,170 match Verilator over 3,000 random steps.
80
+ The remaining differences are listed in the repository
81
+ (`benchmarks/results/rtl_stress.md`); the ones that were `svcc`'s mapping of derived
82
+ clocks are now rejected with an error.
83
+
84
+ ## Known limits
85
+
86
+ - **Two-state.** `x` and `z` read as 0, in the conversion and in the proof. A design that
87
+ relies on X behaviour is outside the model.
88
+ - **Clocks.** A register may be clocked by an input port, a plain copy of it, or a register
89
+ output (a divider written with nonblocking assignments). A gated clock, a clock made by
90
+ other logic, or a clock written with a blocking assignment is rejected: SystemC would run
91
+ it one delta cycle late. Signals written by blocks on different clocks are rejected.
92
+ - **Proof model.** One clock; an asynchronous reset is treated as taking effect at the clock
93
+ step. Designs with several clocks are simulated, not proved.
94
+ - **Front end.** `svlang` is the meaning of SystemVerilog for both the conversion and the
95
+ proof, so an `svlang` defect can affect both sides of a proof alike. This release uses
96
+ svlang 0.5.1, which fixes the three elaboration defects the stress run found.
97
+ - **Not supported:** interfaces, `inout`, unpacked structs, hierarchical references, tasks,
98
+ `foreach`, arrays local to a process, gate primitives, among others (see the subset page).
99
+ - **Known differences on real designs.** In the 2,184-module stress run, the modules that
100
+ still differ from Verilator are `popcount` and `prim_pad_attr` (the Verilator reference
101
+ is wrong or sees different source), `stream_mux` with a placeholder parameter of 0
102
+ (undefined in two-state), and `fpnew_cast_multi` / `fpnew_opgroup_block` from cvfpu, which
103
+ are not yet explained. (`lfsr` and `cc_lfsr` differed because of an svlang defect fixed
104
+ in svlang 0.5.1, which this release uses; they now match.)
105
+ - **Other directions.** The UVM/verification-class translation (`sv2sc`, `sc2sv`) and the
106
+ SystemC-to-SystemVerilog direction ship in this package but have not had the same scrutiny
107
+ on real code as the RTL path. Treat their output as a starting point.
108
+
109
+ ## License
110
+
111
+ Apache-2.0. Copyright 2026 Mayur Kubavat.
112
+
svcc-0.1.0/README.md ADDED
@@ -0,0 +1,92 @@
1
+ # svcc (Python)
2
+
3
+ SystemVerilog to SystemC conversion for RTL, with formal checks of the result.
4
+
5
+ **Status: 0.1, early release.** The RTL conversion path is the part of `svcc` that has been
6
+ checked on real designs. Read "What is checked" and "Known limits" before relying on it.
7
+
8
+ ## What it does
9
+
10
+ - `rtl_to_sc` (CLI `svcc rtl2sc`): converts synthesizable SystemVerilog RTL to C++17 SystemC (`SC_MODULE`s).
11
+ The design is elaborated by [`svlang`](https://crates.io/crates/svlang); every expression
12
+ carries its width and signedness, and the emitter truncates explicitly wherever C++ would
13
+ compute in a wider type.
14
+ - `rtl_prove_json` (CLI `svcc rtl-prove`): proves the generated SystemC equal to the source with Z3. The generated
15
+ header is read back with C++ arithmetic rules, so a C++ width error is a counterexample.
16
+ - CLI only, `svcc rtl-cosim`: compiles the generated SystemC against a real SystemC library and runs it
17
+ against Verilator on the same random stimulus. This is simulation evidence, not a proof.
18
+ - `prove_sec_json` (CLI `svcc prove-sec`): sequential equivalence between two RTL designs, or between an untimed
19
+ C++ function and pipelined RTL some cycles later (C2RTL).
20
+
21
+ The accepted subset and the mapping are in
22
+ [`docs/rtl_subset.md`](https://github.com/mayurkubavat/svcc/blob/main/docs/rtl_subset.md);
23
+ what each check proves and assumes is in
24
+ [`docs/formal_gates.md`](https://github.com/mayurkubavat/svcc/blob/main/docs/formal_gates.md).
25
+
26
+ ## Install
27
+
28
+ ```bash
29
+ pip install svcc
30
+ ```
31
+
32
+ Wheels are built for CPython 3.9 and later (abi3). The proof functions need `z3` on `PATH`.
33
+ The `svcc` command-line tool, including `rtl-cosim`, is in the Rust crate
34
+ (`cargo install svcc`).
35
+
36
+ ```python
37
+ import json, svcc
38
+
39
+ src = open("counter.sv").read()
40
+ header = svcc.rtl_to_sc("counter.sv", src, ["counter"]) # C++17 SystemC text
41
+ for item in json.loads(svcc.rtl_prove_json("counter.sv", src)):
42
+ print(item) # Proved / Skipped / NotCovered
43
+ ```
44
+
45
+ Errors (a construct outside the subset, a parse error) raise `ValueError` with the source
46
+ location. Also available: `sv_to_sc`, `sc_to_sv`, `prove_equivalent_json`, `prove_sec_json`,
47
+ and `svcc.__version__`.
48
+
49
+ ## What is checked
50
+
51
+ - **Fail closed.** A construct outside the subset is an error with a source location, not
52
+ a guess. Skipped constructs (`initial` blocks, assertions, system tasks) are reported as
53
+ notes.
54
+ - **Proof.** For a design in the proof model, the generated SystemC is proved equal to the
55
+ source for all runs from equal start states (by induction), or for a bounded number of
56
+ cycles when induction does not close. Designs outside the model are reported as NOT
57
+ COVERED (exit code 3), never as passing.
58
+ - **Real designs.** Every module of 15 open-source designs (2,184 modules, among them ibex,
59
+ cv32e40p, cva6, OpenTitan, Caliptra, common_cells) was tried as a top. 1,191 converted;
60
+ all of them compile against SystemC, and 1,170 match Verilator over 3,000 random steps.
61
+ The remaining differences are listed in the repository
62
+ (`benchmarks/results/rtl_stress.md`); the ones that were `svcc`'s mapping of derived
63
+ clocks are now rejected with an error.
64
+
65
+ ## Known limits
66
+
67
+ - **Two-state.** `x` and `z` read as 0, in the conversion and in the proof. A design that
68
+ relies on X behaviour is outside the model.
69
+ - **Clocks.** A register may be clocked by an input port, a plain copy of it, or a register
70
+ output (a divider written with nonblocking assignments). A gated clock, a clock made by
71
+ other logic, or a clock written with a blocking assignment is rejected: SystemC would run
72
+ it one delta cycle late. Signals written by blocks on different clocks are rejected.
73
+ - **Proof model.** One clock; an asynchronous reset is treated as taking effect at the clock
74
+ step. Designs with several clocks are simulated, not proved.
75
+ - **Front end.** `svlang` is the meaning of SystemVerilog for both the conversion and the
76
+ proof, so an `svlang` defect can affect both sides of a proof alike. This release uses
77
+ svlang 0.5.1, which fixes the three elaboration defects the stress run found.
78
+ - **Not supported:** interfaces, `inout`, unpacked structs, hierarchical references, tasks,
79
+ `foreach`, arrays local to a process, gate primitives, among others (see the subset page).
80
+ - **Known differences on real designs.** In the 2,184-module stress run, the modules that
81
+ still differ from Verilator are `popcount` and `prim_pad_attr` (the Verilator reference
82
+ is wrong or sees different source), `stream_mux` with a placeholder parameter of 0
83
+ (undefined in two-state), and `fpnew_cast_multi` / `fpnew_opgroup_block` from cvfpu, which
84
+ are not yet explained. (`lfsr` and `cc_lfsr` differed because of an svlang defect fixed
85
+ in svlang 0.5.1, which this release uses; they now match.)
86
+ - **Other directions.** The UVM/verification-class translation (`sv2sc`, `sc2sv`) and the
87
+ SystemC-to-SystemVerilog direction ship in this package but have not had the same scrutiny
88
+ on real code as the RTL path. Treat their output as a starting point.
89
+
90
+ ## License
91
+
92
+ Apache-2.0. Copyright 2026 Mayur Kubavat.