eda-netlist-parser 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.
- eda_netlist_parser-0.1.0/LICENSE +21 -0
- eda_netlist_parser-0.1.0/PKG-INFO +137 -0
- eda_netlist_parser-0.1.0/README.md +86 -0
- eda_netlist_parser-0.1.0/eda_netlist_parser.egg-info/PKG-INFO +137 -0
- eda_netlist_parser-0.1.0/eda_netlist_parser.egg-info/SOURCES.txt +17 -0
- eda_netlist_parser-0.1.0/eda_netlist_parser.egg-info/dependency_links.txt +1 -0
- eda_netlist_parser-0.1.0/eda_netlist_parser.egg-info/entry_points.txt +2 -0
- eda_netlist_parser-0.1.0/eda_netlist_parser.egg-info/requires.txt +7 -0
- eda_netlist_parser-0.1.0/eda_netlist_parser.egg-info/top_level.txt +1 -0
- eda_netlist_parser-0.1.0/netlist_parser/__init__.py +20 -0
- eda_netlist_parser-0.1.0/netlist_parser/__main__.py +117 -0
- eda_netlist_parser-0.1.0/netlist_parser/parser.py +546 -0
- eda_netlist_parser-0.1.0/netlist_parser/utils.py +18 -0
- eda_netlist_parser-0.1.0/pyproject.toml +45 -0
- eda_netlist_parser-0.1.0/setup.cfg +4 -0
- eda_netlist_parser-0.1.0/tests/test_cli.py +91 -0
- eda_netlist_parser-0.1.0/tests/test_exceptions.py +43 -0
- eda_netlist_parser-0.1.0/tests/test_integration.py +111 -0
- eda_netlist_parser-0.1.0/tests/test_parser.py +153 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Rohaan Scherpbier
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: eda-netlist-parser
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Pure-Python parser for SPICE-family netlist files (.spi, .cir, .cdl, .scs, .spf)
|
|
5
|
+
License: MIT License
|
|
6
|
+
|
|
7
|
+
Copyright (c) 2025 Rohaan Scherpbier
|
|
8
|
+
|
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
in the Software without restriction, including without limitation the rights
|
|
12
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
furnished to do so, subject to the following conditions:
|
|
15
|
+
|
|
16
|
+
The above copyright notice and this permission notice shall be included in all
|
|
17
|
+
copies or substantial portions of the Software.
|
|
18
|
+
|
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
+
SOFTWARE.
|
|
26
|
+
|
|
27
|
+
Project-URL: Homepage, https://github.com/rohaansch/netlist-parser
|
|
28
|
+
Keywords: EDA,SPICE,netlist,CDL,Spectre,VLSI,semiconductor,simulation
|
|
29
|
+
Classifier: Development Status :: 3 - Alpha
|
|
30
|
+
Classifier: Intended Audience :: Developers
|
|
31
|
+
Classifier: Intended Audience :: Science/Research
|
|
32
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
33
|
+
Classifier: Programming Language :: Python :: 3
|
|
34
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
35
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
36
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
37
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
38
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
39
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
40
|
+
Classifier: Topic :: Scientific/Engineering :: Electronic Design Automation (EDA)
|
|
41
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
42
|
+
Requires-Python: >=3.7
|
|
43
|
+
Description-Content-Type: text/markdown
|
|
44
|
+
License-File: LICENSE
|
|
45
|
+
Provides-Extra: color
|
|
46
|
+
Requires-Dist: termcolor>=1.1; extra == "color"
|
|
47
|
+
Provides-Extra: dev
|
|
48
|
+
Requires-Dist: pytest>=7; extra == "dev"
|
|
49
|
+
Requires-Dist: termcolor>=1.1; extra == "dev"
|
|
50
|
+
Dynamic: license-file
|
|
51
|
+
|
|
52
|
+
# eda-netlist-parser
|
|
53
|
+
|
|
54
|
+
A pure-Python parser for SPICE-family netlist files: `.spi`, `.cir`, `.cdl`, `.scs`, `.spf`, `.sp`, `.hsp`.
|
|
55
|
+
|
|
56
|
+
[](https://github.com/rohaansch/netlist-parser/actions/workflows/ci.yml)
|
|
57
|
+
[](https://pypi.org/project/eda-netlist-parser/)
|
|
58
|
+
[](LICENSE)
|
|
59
|
+
|
|
60
|
+
## Installation
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
pip install eda-netlist-parser
|
|
64
|
+
# optional colored terminal output:
|
|
65
|
+
pip install eda-netlist-parser[color]
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
[](https://pypi.org/project/eda-netlist-parser/)
|
|
69
|
+
[](https://pypi.org/project/eda-netlist-parser/)
|
|
70
|
+
|
|
71
|
+
## Quick start
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
from netlist_parser import NetlistParser, NetlistError
|
|
75
|
+
|
|
76
|
+
parser = NetlistParser()
|
|
77
|
+
|
|
78
|
+
try:
|
|
79
|
+
netlist = parser.parse("design.spi")
|
|
80
|
+
except NetlistError as e:
|
|
81
|
+
print(f"Error: {e}")
|
|
82
|
+
|
|
83
|
+
for cell in netlist.cells:
|
|
84
|
+
print(cell.name, cell.ports)
|
|
85
|
+
for inst in cell.instances:
|
|
86
|
+
print(" ", inst.name, inst.code, inst.device_name)
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Importing
|
|
90
|
+
|
|
91
|
+
```python
|
|
92
|
+
from netlist_parser import NetlistParser
|
|
93
|
+
from netlist_parser import NetlistParser, Netlist, NetlistCell, DeviceInstance
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## API
|
|
97
|
+
|
|
98
|
+
### `NetlistParser(internal=False)`
|
|
99
|
+
|
|
100
|
+
| Method | Returns | Description |
|
|
101
|
+
|--------|---------|-------------|
|
|
102
|
+
| `parse(filename)` | `Netlist` | Parse a single file |
|
|
103
|
+
| `read(path, data=None)` | varies | Parse file or directory |
|
|
104
|
+
|
|
105
|
+
`read()` data modes:
|
|
106
|
+
|
|
107
|
+
| `data=` | Returns |
|
|
108
|
+
|---------|---------|
|
|
109
|
+
| `None` | `Netlist` |
|
|
110
|
+
| `'cells'` | `Set[str]` |
|
|
111
|
+
| `'ports'` | `Dict[str, List[str]]` |
|
|
112
|
+
| `'devices'` | `Dict[str, Set[str]]` |
|
|
113
|
+
| `'device-params'` | `Dict[str, Dict]` |
|
|
114
|
+
| `'resistors'` | `Dict[str, List]` |
|
|
115
|
+
| `'capacitors'` | `Dict[str, List]` |
|
|
116
|
+
|
|
117
|
+
### Classes
|
|
118
|
+
|
|
119
|
+
- `Netlist` — full file data: `.cells`, `.version`, `.resistance`, `.capacitance`, `.layer_map`
|
|
120
|
+
- `NetlistCell` — one subckt: `.name`, `.ports`, `.instances`, `.substitute`
|
|
121
|
+
- `DeviceInstance` — one line: `.name`, `.code`, `.nodes`, `.device_name`, `.number`, `.parameters`
|
|
122
|
+
- `NetlistError` — raised on file errors
|
|
123
|
+
|
|
124
|
+
## CLI
|
|
125
|
+
|
|
126
|
+
```
|
|
127
|
+
netlist-parser sample.spi # summary
|
|
128
|
+
netlist-parser sample.spi --cells # list cell names
|
|
129
|
+
netlist-parser sample.spi --ports # cell → ports
|
|
130
|
+
netlist-parser sample.spi --devices # cell → device names
|
|
131
|
+
netlist-parser sample.spi --cell inv_x1 # one cell detail
|
|
132
|
+
netlist-parser --version
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## License
|
|
136
|
+
|
|
137
|
+
[MIT](LICENSE)
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# eda-netlist-parser
|
|
2
|
+
|
|
3
|
+
A pure-Python parser for SPICE-family netlist files: `.spi`, `.cir`, `.cdl`, `.scs`, `.spf`, `.sp`, `.hsp`.
|
|
4
|
+
|
|
5
|
+
[](https://github.com/rohaansch/netlist-parser/actions/workflows/ci.yml)
|
|
6
|
+
[](https://pypi.org/project/eda-netlist-parser/)
|
|
7
|
+
[](LICENSE)
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pip install eda-netlist-parser
|
|
13
|
+
# optional colored terminal output:
|
|
14
|
+
pip install eda-netlist-parser[color]
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
[](https://pypi.org/project/eda-netlist-parser/)
|
|
18
|
+
[](https://pypi.org/project/eda-netlist-parser/)
|
|
19
|
+
|
|
20
|
+
## Quick start
|
|
21
|
+
|
|
22
|
+
```python
|
|
23
|
+
from netlist_parser import NetlistParser, NetlistError
|
|
24
|
+
|
|
25
|
+
parser = NetlistParser()
|
|
26
|
+
|
|
27
|
+
try:
|
|
28
|
+
netlist = parser.parse("design.spi")
|
|
29
|
+
except NetlistError as e:
|
|
30
|
+
print(f"Error: {e}")
|
|
31
|
+
|
|
32
|
+
for cell in netlist.cells:
|
|
33
|
+
print(cell.name, cell.ports)
|
|
34
|
+
for inst in cell.instances:
|
|
35
|
+
print(" ", inst.name, inst.code, inst.device_name)
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Importing
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
from netlist_parser import NetlistParser
|
|
42
|
+
from netlist_parser import NetlistParser, Netlist, NetlistCell, DeviceInstance
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## API
|
|
46
|
+
|
|
47
|
+
### `NetlistParser(internal=False)`
|
|
48
|
+
|
|
49
|
+
| Method | Returns | Description |
|
|
50
|
+
|--------|---------|-------------|
|
|
51
|
+
| `parse(filename)` | `Netlist` | Parse a single file |
|
|
52
|
+
| `read(path, data=None)` | varies | Parse file or directory |
|
|
53
|
+
|
|
54
|
+
`read()` data modes:
|
|
55
|
+
|
|
56
|
+
| `data=` | Returns |
|
|
57
|
+
|---------|---------|
|
|
58
|
+
| `None` | `Netlist` |
|
|
59
|
+
| `'cells'` | `Set[str]` |
|
|
60
|
+
| `'ports'` | `Dict[str, List[str]]` |
|
|
61
|
+
| `'devices'` | `Dict[str, Set[str]]` |
|
|
62
|
+
| `'device-params'` | `Dict[str, Dict]` |
|
|
63
|
+
| `'resistors'` | `Dict[str, List]` |
|
|
64
|
+
| `'capacitors'` | `Dict[str, List]` |
|
|
65
|
+
|
|
66
|
+
### Classes
|
|
67
|
+
|
|
68
|
+
- `Netlist` — full file data: `.cells`, `.version`, `.resistance`, `.capacitance`, `.layer_map`
|
|
69
|
+
- `NetlistCell` — one subckt: `.name`, `.ports`, `.instances`, `.substitute`
|
|
70
|
+
- `DeviceInstance` — one line: `.name`, `.code`, `.nodes`, `.device_name`, `.number`, `.parameters`
|
|
71
|
+
- `NetlistError` — raised on file errors
|
|
72
|
+
|
|
73
|
+
## CLI
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
netlist-parser sample.spi # summary
|
|
77
|
+
netlist-parser sample.spi --cells # list cell names
|
|
78
|
+
netlist-parser sample.spi --ports # cell → ports
|
|
79
|
+
netlist-parser sample.spi --devices # cell → device names
|
|
80
|
+
netlist-parser sample.spi --cell inv_x1 # one cell detail
|
|
81
|
+
netlist-parser --version
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## License
|
|
85
|
+
|
|
86
|
+
[MIT](LICENSE)
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: eda-netlist-parser
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Pure-Python parser for SPICE-family netlist files (.spi, .cir, .cdl, .scs, .spf)
|
|
5
|
+
License: MIT License
|
|
6
|
+
|
|
7
|
+
Copyright (c) 2025 Rohaan Scherpbier
|
|
8
|
+
|
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
in the Software without restriction, including without limitation the rights
|
|
12
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
furnished to do so, subject to the following conditions:
|
|
15
|
+
|
|
16
|
+
The above copyright notice and this permission notice shall be included in all
|
|
17
|
+
copies or substantial portions of the Software.
|
|
18
|
+
|
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
+
SOFTWARE.
|
|
26
|
+
|
|
27
|
+
Project-URL: Homepage, https://github.com/rohaansch/netlist-parser
|
|
28
|
+
Keywords: EDA,SPICE,netlist,CDL,Spectre,VLSI,semiconductor,simulation
|
|
29
|
+
Classifier: Development Status :: 3 - Alpha
|
|
30
|
+
Classifier: Intended Audience :: Developers
|
|
31
|
+
Classifier: Intended Audience :: Science/Research
|
|
32
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
33
|
+
Classifier: Programming Language :: Python :: 3
|
|
34
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
35
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
36
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
37
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
38
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
39
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
40
|
+
Classifier: Topic :: Scientific/Engineering :: Electronic Design Automation (EDA)
|
|
41
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
42
|
+
Requires-Python: >=3.7
|
|
43
|
+
Description-Content-Type: text/markdown
|
|
44
|
+
License-File: LICENSE
|
|
45
|
+
Provides-Extra: color
|
|
46
|
+
Requires-Dist: termcolor>=1.1; extra == "color"
|
|
47
|
+
Provides-Extra: dev
|
|
48
|
+
Requires-Dist: pytest>=7; extra == "dev"
|
|
49
|
+
Requires-Dist: termcolor>=1.1; extra == "dev"
|
|
50
|
+
Dynamic: license-file
|
|
51
|
+
|
|
52
|
+
# eda-netlist-parser
|
|
53
|
+
|
|
54
|
+
A pure-Python parser for SPICE-family netlist files: `.spi`, `.cir`, `.cdl`, `.scs`, `.spf`, `.sp`, `.hsp`.
|
|
55
|
+
|
|
56
|
+
[](https://github.com/rohaansch/netlist-parser/actions/workflows/ci.yml)
|
|
57
|
+
[](https://pypi.org/project/eda-netlist-parser/)
|
|
58
|
+
[](LICENSE)
|
|
59
|
+
|
|
60
|
+
## Installation
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
pip install eda-netlist-parser
|
|
64
|
+
# optional colored terminal output:
|
|
65
|
+
pip install eda-netlist-parser[color]
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
[](https://pypi.org/project/eda-netlist-parser/)
|
|
69
|
+
[](https://pypi.org/project/eda-netlist-parser/)
|
|
70
|
+
|
|
71
|
+
## Quick start
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
from netlist_parser import NetlistParser, NetlistError
|
|
75
|
+
|
|
76
|
+
parser = NetlistParser()
|
|
77
|
+
|
|
78
|
+
try:
|
|
79
|
+
netlist = parser.parse("design.spi")
|
|
80
|
+
except NetlistError as e:
|
|
81
|
+
print(f"Error: {e}")
|
|
82
|
+
|
|
83
|
+
for cell in netlist.cells:
|
|
84
|
+
print(cell.name, cell.ports)
|
|
85
|
+
for inst in cell.instances:
|
|
86
|
+
print(" ", inst.name, inst.code, inst.device_name)
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Importing
|
|
90
|
+
|
|
91
|
+
```python
|
|
92
|
+
from netlist_parser import NetlistParser
|
|
93
|
+
from netlist_parser import NetlistParser, Netlist, NetlistCell, DeviceInstance
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## API
|
|
97
|
+
|
|
98
|
+
### `NetlistParser(internal=False)`
|
|
99
|
+
|
|
100
|
+
| Method | Returns | Description |
|
|
101
|
+
|--------|---------|-------------|
|
|
102
|
+
| `parse(filename)` | `Netlist` | Parse a single file |
|
|
103
|
+
| `read(path, data=None)` | varies | Parse file or directory |
|
|
104
|
+
|
|
105
|
+
`read()` data modes:
|
|
106
|
+
|
|
107
|
+
| `data=` | Returns |
|
|
108
|
+
|---------|---------|
|
|
109
|
+
| `None` | `Netlist` |
|
|
110
|
+
| `'cells'` | `Set[str]` |
|
|
111
|
+
| `'ports'` | `Dict[str, List[str]]` |
|
|
112
|
+
| `'devices'` | `Dict[str, Set[str]]` |
|
|
113
|
+
| `'device-params'` | `Dict[str, Dict]` |
|
|
114
|
+
| `'resistors'` | `Dict[str, List]` |
|
|
115
|
+
| `'capacitors'` | `Dict[str, List]` |
|
|
116
|
+
|
|
117
|
+
### Classes
|
|
118
|
+
|
|
119
|
+
- `Netlist` — full file data: `.cells`, `.version`, `.resistance`, `.capacitance`, `.layer_map`
|
|
120
|
+
- `NetlistCell` — one subckt: `.name`, `.ports`, `.instances`, `.substitute`
|
|
121
|
+
- `DeviceInstance` — one line: `.name`, `.code`, `.nodes`, `.device_name`, `.number`, `.parameters`
|
|
122
|
+
- `NetlistError` — raised on file errors
|
|
123
|
+
|
|
124
|
+
## CLI
|
|
125
|
+
|
|
126
|
+
```
|
|
127
|
+
netlist-parser sample.spi # summary
|
|
128
|
+
netlist-parser sample.spi --cells # list cell names
|
|
129
|
+
netlist-parser sample.spi --ports # cell → ports
|
|
130
|
+
netlist-parser sample.spi --devices # cell → device names
|
|
131
|
+
netlist-parser sample.spi --cell inv_x1 # one cell detail
|
|
132
|
+
netlist-parser --version
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## License
|
|
136
|
+
|
|
137
|
+
[MIT](LICENSE)
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
eda_netlist_parser.egg-info/PKG-INFO
|
|
5
|
+
eda_netlist_parser.egg-info/SOURCES.txt
|
|
6
|
+
eda_netlist_parser.egg-info/dependency_links.txt
|
|
7
|
+
eda_netlist_parser.egg-info/entry_points.txt
|
|
8
|
+
eda_netlist_parser.egg-info/requires.txt
|
|
9
|
+
eda_netlist_parser.egg-info/top_level.txt
|
|
10
|
+
netlist_parser/__init__.py
|
|
11
|
+
netlist_parser/__main__.py
|
|
12
|
+
netlist_parser/parser.py
|
|
13
|
+
netlist_parser/utils.py
|
|
14
|
+
tests/test_cli.py
|
|
15
|
+
tests/test_exceptions.py
|
|
16
|
+
tests/test_integration.py
|
|
17
|
+
tests/test_parser.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
netlist_parser
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"""netlist_parser — Pure-Python parser for SPICE-family netlist files."""
|
|
2
|
+
|
|
3
|
+
from .parser import (
|
|
4
|
+
NetlistError,
|
|
5
|
+
Netlist,
|
|
6
|
+
NetlistCell,
|
|
7
|
+
DeviceInstance,
|
|
8
|
+
NetlistParser,
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
__version__ = "0.1.0"
|
|
12
|
+
|
|
13
|
+
__all__ = [
|
|
14
|
+
"NetlistParser",
|
|
15
|
+
"Netlist",
|
|
16
|
+
"NetlistCell",
|
|
17
|
+
"DeviceInstance",
|
|
18
|
+
"NetlistError",
|
|
19
|
+
"__version__",
|
|
20
|
+
]
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"""CLI entry point: python -m netlist_parser or netlist-parser (installed script)."""
|
|
2
|
+
|
|
3
|
+
import argparse
|
|
4
|
+
import sys
|
|
5
|
+
|
|
6
|
+
from .parser import NetlistParser, NetlistError
|
|
7
|
+
from . import __version__
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def main() -> None:
|
|
11
|
+
ap = argparse.ArgumentParser(
|
|
12
|
+
prog="netlist-parser",
|
|
13
|
+
description="Parse a SPICE-family netlist file and print its content.",
|
|
14
|
+
epilog=(
|
|
15
|
+
"Examples:\n"
|
|
16
|
+
" netlist-parser sample.spi\n"
|
|
17
|
+
" netlist-parser sample.spi --cells\n"
|
|
18
|
+
" netlist-parser sample.spi --ports\n"
|
|
19
|
+
" netlist-parser sample.spi --devices\n"
|
|
20
|
+
" netlist-parser sample.spi --cell inv_x1\n"
|
|
21
|
+
" netlist-parser --version\n"
|
|
22
|
+
),
|
|
23
|
+
formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
24
|
+
)
|
|
25
|
+
ap.add_argument("path", nargs="?", help="Path to a netlist file")
|
|
26
|
+
ap.add_argument(
|
|
27
|
+
"--cells",
|
|
28
|
+
action="store_true",
|
|
29
|
+
help="Print cell names defined in the file",
|
|
30
|
+
)
|
|
31
|
+
ap.add_argument(
|
|
32
|
+
"--ports",
|
|
33
|
+
action="store_true",
|
|
34
|
+
help="Print each cell and its port list",
|
|
35
|
+
)
|
|
36
|
+
ap.add_argument(
|
|
37
|
+
"--devices",
|
|
38
|
+
action="store_true",
|
|
39
|
+
help="Print each cell and the device names it uses",
|
|
40
|
+
)
|
|
41
|
+
ap.add_argument(
|
|
42
|
+
"--cell",
|
|
43
|
+
metavar="NAME",
|
|
44
|
+
help="Print detailed info for a specific cell",
|
|
45
|
+
)
|
|
46
|
+
ap.add_argument(
|
|
47
|
+
"--version",
|
|
48
|
+
action="store_true",
|
|
49
|
+
help="Print package version and exit",
|
|
50
|
+
)
|
|
51
|
+
args = ap.parse_args()
|
|
52
|
+
|
|
53
|
+
if args.version:
|
|
54
|
+
print(__version__)
|
|
55
|
+
return
|
|
56
|
+
|
|
57
|
+
if not args.path:
|
|
58
|
+
ap.error("the following arguments are required: path")
|
|
59
|
+
|
|
60
|
+
parser = NetlistParser()
|
|
61
|
+
try:
|
|
62
|
+
netlist = parser.parse(args.path)
|
|
63
|
+
except NetlistError as exc:
|
|
64
|
+
print(f"Error: {exc}", file=sys.stderr)
|
|
65
|
+
sys.exit(1)
|
|
66
|
+
|
|
67
|
+
if args.cells:
|
|
68
|
+
for cell in netlist.cells:
|
|
69
|
+
print(cell.name)
|
|
70
|
+
return
|
|
71
|
+
|
|
72
|
+
if args.ports:
|
|
73
|
+
for cell in netlist.cells:
|
|
74
|
+
ports = " ".join(cell.ports)
|
|
75
|
+
print(f"{cell.name}: {ports}")
|
|
76
|
+
return
|
|
77
|
+
|
|
78
|
+
if args.devices:
|
|
79
|
+
for cell in netlist.cells:
|
|
80
|
+
device_names = sorted(
|
|
81
|
+
{inst.device_name for inst in cell.instances if inst.device_name}
|
|
82
|
+
)
|
|
83
|
+
print(f"{cell.name}: {', '.join(device_names)}")
|
|
84
|
+
return
|
|
85
|
+
|
|
86
|
+
if args.cell:
|
|
87
|
+
target = args.cell
|
|
88
|
+
for cell in netlist.cells:
|
|
89
|
+
if cell.name == target:
|
|
90
|
+
print(f"Cell: {cell.name}")
|
|
91
|
+
print(f" Ports: {' '.join(cell.ports)}")
|
|
92
|
+
print(f" Instances ({len(cell.instances)}):")
|
|
93
|
+
for inst in cell.instances:
|
|
94
|
+
line = f" {inst.name} code={inst.code}"
|
|
95
|
+
if inst.device_name:
|
|
96
|
+
line += f" device={inst.device_name}"
|
|
97
|
+
if inst.number:
|
|
98
|
+
line += f" number={inst.number}"
|
|
99
|
+
if inst.nodes:
|
|
100
|
+
line += f" nodes={inst.nodes}"
|
|
101
|
+
if inst.parameters:
|
|
102
|
+
line += f" params={inst.parameters}"
|
|
103
|
+
print(line)
|
|
104
|
+
return
|
|
105
|
+
print(f"Error: cell '{target}' not found in {args.path}", file=sys.stderr)
|
|
106
|
+
sys.exit(1)
|
|
107
|
+
|
|
108
|
+
# Default: summary
|
|
109
|
+
print(f"File: {args.path}")
|
|
110
|
+
print(f"Format: {netlist.version}")
|
|
111
|
+
print(f"Cells ({len(netlist.cells)}):")
|
|
112
|
+
for cell in netlist.cells:
|
|
113
|
+
print(f" {cell.name} ports={len(cell.ports)} instances={len(cell.instances)}")
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
if __name__ == "__main__":
|
|
117
|
+
main()
|