naja-schematic 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.
@@ -0,0 +1,20 @@
1
+ *~
2
+ build*
3
+ *.swp
4
+ *.pyc
5
+ .DS_Store
6
+ .vscode/settings.json
7
+ imgui.ini
8
+ .cache/
9
+
10
+ # Private, local-only working notes (never shared/committed).
11
+ notes/
12
+ naja_sv_diagnostics.log
13
+
14
+ # Viewer bundle: built by CI (-DNAJA_SCHEMATIC_WASM_MODULE=ON), shipped in the wheel.
15
+ python/naja_schematic/static/naja-schematic.js
16
+ python/dist/
17
+ *.egg-info/
18
+ python/LICENSE
19
+ .pytest_cache/
20
+ __pycache__/
@@ -0,0 +1,204 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the
44
+ purposes of this License, Derivative Works shall not include works
45
+ that remain separable from, or merely link (or bind by name) to the
46
+ interfaces of, the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including the
49
+ original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright
52
+ owner or by an individual or Legal Entity authorized to submit on
53
+ behalf of the copyright owner. For the purposes of this definition,
54
+ "submitted" means any form of electronic, verbal, or written
55
+ communication sent to the Licensor or its representatives,
56
+ including but not limited to communication on electronic mailing
57
+ lists, source code control systems, and issue tracking systems
58
+ that are managed by, or on behalf of, the Licensor for the purpose
59
+ of discussing and improving the Work, but excluding communication
60
+ that is conspicuously marked or otherwise designated in writing
61
+ by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal
64
+ Entity on behalf of whom a Contribution has been received by
65
+ Licensor and subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have
78
+ made, use, offer to sell, sell, import, and otherwise transfer the
79
+ Work, where such license applies only to those patent claims
80
+ licensable by such Contributor that are necessarily infringed by
81
+ their Contribution(s) alone or by combination of their
82
+ Contribution(s) with the Work to which such Contribution(s) was
83
+ submitted. If You institute patent litigation against any entity
84
+ (including a cross-claim or counterclaim in a lawsuit) alleging
85
+ that the Work or a Contribution incorporated within the Work
86
+ constitutes direct or contributory patent infringement, then any
87
+ patent licenses granted to You under this License for that Work
88
+ shall terminate as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing
142
+ the origin of the Work and reproducing the content of the NOTICE
143
+ file.
144
+
145
+ 7. Disclaimer of Warranty. Unless required by applicable law or
146
+ agreed to in writing, Licensor provides the Work (and each
147
+ Contributor provides its Contributions) on an "AS IS" BASIS,
148
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
149
+ implied, including, without limitation, any warranties or
150
+ conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS
151
+ FOR A PARTICULAR PURPOSE. You are solely responsible for
152
+ determining the appropriateness of using or redistributing the
153
+ Work and assume any risks associated with Your exercise of
154
+ permissions under this License.
155
+
156
+ 8. Limitation of Liability. In no event and under no legal theory,
157
+ whether in tort (including negligence), contract, or otherwise,
158
+ unless required by applicable law (such as deliberate and grossly
159
+ negligent acts) or agreed to in writing, shall any Contributor be
160
+ liable to You for damages, including any direct, indirect, special,
161
+ incidental, or consequential damages of any character arising as a
162
+ result of this License or out of the use or inability to use the
163
+ Work (including but not limited to damages for loss of goodwill,
164
+ work stoppage, computer failure or malfunction, or any and all
165
+ other commercial damages or losses), even if such Contributor
166
+ has been advised of the possibility of such damages.
167
+
168
+ 9. Accepting Warranty or Additional Liability. While redistributing
169
+ the Work or Derivative Works thereof, You may choose to offer,
170
+ and charge a fee for, acceptance of support, warranty, indemnity,
171
+ or other liability obligations and/or rights consistent with this
172
+ License. However, in accepting such obligations, You may act only
173
+ on Your own behalf and on Your sole responsibility, not on behalf
174
+ of any other Contributor, and only if You agree to indemnify,
175
+ defend, and hold each Contributor harmless for any liability
176
+ incurred by, or claims asserted against, such Contributor by reason
177
+ of your accepting any such warranty or additional liability.
178
+
179
+ END OF TERMS AND CONDITIONS
180
+
181
+ APPENDIX: How to apply the Apache License to your work.
182
+
183
+ To apply the Apache License to your work, attach the following
184
+ boilerplate notice, with the fields enclosed by brackets "[]"
185
+ replaced with your own identifying information. (Don't include
186
+ the brackets!) The text should be enclosed in the appropriate
187
+ comment syntax for the file format. We also recommend that a
188
+ file or class name and description of purpose be included on the
189
+ same "printed page" as the copyright notice for easier
190
+ identification within third-party archives.
191
+
192
+ Copyright 2026 najaeda contributors
193
+
194
+ Licensed under the Apache License, Version 2.0 (the "License");
195
+ you may not use this file except in compliance with the License.
196
+ You may obtain a copy of the License at
197
+
198
+ http://www.apache.org/licenses/LICENSE-2.0
199
+
200
+ Unless required by applicable law or agreed to in writing, software
201
+ distributed under the License is distributed on an "AS IS" BASIS,
202
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
203
+ See the License for the specific language governing permissions and
204
+ limitations under the License.
@@ -0,0 +1,80 @@
1
+ Metadata-Version: 2.5
2
+ Name: naja-schematic
3
+ Version: 0.1.0
4
+ Summary: Interactive schematic viewer for najaeda netlists: in Jupyter/Colab notebooks or a browser
5
+ Project-URL: Homepage, https://github.com/najaeda/naja-schematic
6
+ Author-email: Naja Authors <contact@keplertech.io>
7
+ License-Expression: Apache-2.0
8
+ License-File: LICENSE
9
+ Classifier: Framework :: Jupyter
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Topic :: Scientific/Engineering :: Electronic Design Automation (EDA)
12
+ Requires-Python: >=3.10
13
+ Requires-Dist: anywidget>=0.9
14
+ Requires-Dist: najaeda>=0.7.25
15
+ Requires-Dist: websockets>=13
16
+ Provides-Extra: test
17
+ Requires-Dist: pytest; extra == 'test'
18
+ Description-Content-Type: text/markdown
19
+
20
+ # naja-schematic (Python package)
21
+
22
+ Interactive schematic viewer for [najaeda](https://pypi.org/project/najaeda/)
23
+ netlists: the [naja-schematic](https://github.com/najaeda/naja-schematic)
24
+ WASM viewer, packaged with the Python backend that answers it from a live
25
+ najaeda netlist.
26
+
27
+ ```bash
28
+ pip install naja-schematic
29
+ ```
30
+
31
+ ## In a notebook (Jupyter, Google Colab, VSCode)
32
+
33
+ ```python
34
+ from najaeda import netlist
35
+ import naja_schematic
36
+
37
+ netlist.load_primitives("xilinx")
38
+ top = netlist.load_verilog("design.v")
39
+
40
+ naja_schematic.show() # interactive view in the cell output
41
+ ```
42
+
43
+ The view is answered from the netlist in the running kernel, so it shows
44
+ the design as the notebook has built or edited it so far; call `show()`
45
+ again after an edit for a fresh view. Diagnoses (e.g. from a formal
46
+ equivalence check) can be overlaid:
47
+
48
+ ```python
49
+ view = naja_schematic.show()
50
+ view.annotate([{"kind": "instance", "path": ["u_sub"], "severity": "error",
51
+ "message": "not equivalent", "source": "kepler-formal"}])
52
+ view
53
+ ```
54
+
55
+ ## From a shell
56
+
57
+ ```bash
58
+ naja-schematic --verilog design.v --liberty cells.lib --open
59
+ naja-schematic --sv top.sv --top top --diagnosis report.json --open
60
+ ```
61
+
62
+ serves the viewer page and its WebSocket on `http://localhost:8081/` and
63
+ opens it in a browser. `--stdio` speaks the same protocol as JSON lines on
64
+ stdin/stdout instead, for a host (e.g. an editor extension) that relays
65
+ messages itself. `naja-schematic --help` lists every option.
66
+
67
+ ## Development
68
+
69
+ The viewer bundle (`naja_schematic/static/naja-schematic.js`) is built from
70
+ the C++ sources, not checked in. From the repository root:
71
+
72
+ ```bash
73
+ emcmake cmake -S . -B build-wasm-module -DCMAKE_BUILD_TYPE=Release -DNAJA_SCHEMATIC_WASM_MODULE=ON
74
+ cmake --build build-wasm-module
75
+ export NAJA_SCHEMATIC_BUNDLE=$PWD/build-wasm-module/naja-schematic.js # or copy it into static/
76
+ pip install -e "python[test]" && pytest python/tests
77
+ ```
78
+
79
+ Releases are built and published by `.github/workflows/python-package.yml`
80
+ on a `v<version>` tag (e.g. `v0.1.0`).
@@ -0,0 +1,61 @@
1
+ # naja-schematic (Python package)
2
+
3
+ Interactive schematic viewer for [najaeda](https://pypi.org/project/najaeda/)
4
+ netlists: the [naja-schematic](https://github.com/najaeda/naja-schematic)
5
+ WASM viewer, packaged with the Python backend that answers it from a live
6
+ najaeda netlist.
7
+
8
+ ```bash
9
+ pip install naja-schematic
10
+ ```
11
+
12
+ ## In a notebook (Jupyter, Google Colab, VSCode)
13
+
14
+ ```python
15
+ from najaeda import netlist
16
+ import naja_schematic
17
+
18
+ netlist.load_primitives("xilinx")
19
+ top = netlist.load_verilog("design.v")
20
+
21
+ naja_schematic.show() # interactive view in the cell output
22
+ ```
23
+
24
+ The view is answered from the netlist in the running kernel, so it shows
25
+ the design as the notebook has built or edited it so far; call `show()`
26
+ again after an edit for a fresh view. Diagnoses (e.g. from a formal
27
+ equivalence check) can be overlaid:
28
+
29
+ ```python
30
+ view = naja_schematic.show()
31
+ view.annotate([{"kind": "instance", "path": ["u_sub"], "severity": "error",
32
+ "message": "not equivalent", "source": "kepler-formal"}])
33
+ view
34
+ ```
35
+
36
+ ## From a shell
37
+
38
+ ```bash
39
+ naja-schematic --verilog design.v --liberty cells.lib --open
40
+ naja-schematic --sv top.sv --top top --diagnosis report.json --open
41
+ ```
42
+
43
+ serves the viewer page and its WebSocket on `http://localhost:8081/` and
44
+ opens it in a browser. `--stdio` speaks the same protocol as JSON lines on
45
+ stdin/stdout instead, for a host (e.g. an editor extension) that relays
46
+ messages itself. `naja-schematic --help` lists every option.
47
+
48
+ ## Development
49
+
50
+ The viewer bundle (`naja_schematic/static/naja-schematic.js`) is built from
51
+ the C++ sources, not checked in. From the repository root:
52
+
53
+ ```bash
54
+ emcmake cmake -S . -B build-wasm-module -DCMAKE_BUILD_TYPE=Release -DNAJA_SCHEMATIC_WASM_MODULE=ON
55
+ cmake --build build-wasm-module
56
+ export NAJA_SCHEMATIC_BUNDLE=$PWD/build-wasm-module/naja-schematic.js # or copy it into static/
57
+ pip install -e "python[test]" && pytest python/tests
58
+ ```
59
+
60
+ Releases are built and published by `.github/workflows/python-package.yml`
61
+ on a `v<version>` tag (e.g. `v0.1.0`).
@@ -0,0 +1,21 @@
1
+ """naja-schematic: interactive schematic viewer for najaeda netlists.
2
+
3
+ - In a notebook (Jupyter, Colab, VSCode): ``naja_schematic.show()`` displays
4
+ the design currently loaded with najaeda.
5
+ - From a shell: ``naja-schematic --verilog design.v --open`` serves the
6
+ viewer page and opens it in a browser.
7
+ """
8
+ __version__ = "0.1.0"
9
+
10
+ from .protocol import diagnosis_response, handle_request
11
+
12
+
13
+ def show(height=600, diagnosis=None):
14
+ """Display a view of the loaded design in the current notebook; see
15
+ naja_schematic.widget.show()."""
16
+ # Imported lazily: the CLI/server path doesn't need anywidget/IPython.
17
+ from .widget import show as _show
18
+ return _show(height=height, diagnosis=diagnosis)
19
+
20
+
21
+ __all__ = ["__version__", "show", "handle_request", "diagnosis_response"]
@@ -0,0 +1,3 @@
1
+ from .server import main
2
+
3
+ main()
@@ -0,0 +1,31 @@
1
+ """Locating the viewer files shipped in static/.
2
+
3
+ naja-schematic.js is the WASM viewer built as a single-file, modularized
4
+ Emscripten bundle (-DNAJA_SCHEMATIC_WASM_MODULE=ON); release wheels carry it
5
+ in static/, but it is a build product and not checked in. For a development
6
+ checkout, point NAJA_SCHEMATIC_BUNDLE at a locally built one instead.
7
+ """
8
+ import os
9
+ from pathlib import Path
10
+
11
+ STATIC_DIR = Path(__file__).parent / "static"
12
+ BUNDLE_NAME = "naja-schematic.js"
13
+
14
+ # The only files the HTTP server hands out (no path traversal to worry about).
15
+ _SERVED = {"index.html", BUNDLE_NAME}
16
+
17
+
18
+ def bundle_path():
19
+ """Path of the viewer bundle, or None if this install has none."""
20
+ override = os.environ.get("NAJA_SCHEMATIC_BUNDLE")
21
+ path = Path(override) if override else STATIC_DIR / BUNDLE_NAME
22
+ return path if path.is_file() else None
23
+
24
+
25
+ def static_file(name):
26
+ if name not in _SERVED:
27
+ return None
28
+ if name == BUNDLE_NAME:
29
+ return bundle_path()
30
+ path = STATIC_DIR / name
31
+ return path if path.is_file() else None