optivlsi 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 (52) hide show
  1. optivlsi-0.1.0/LICENSE +21 -0
  2. optivlsi-0.1.0/MANIFEST.in +7 -0
  3. optivlsi-0.1.0/PKG-INFO +161 -0
  4. optivlsi-0.1.0/README.md +129 -0
  5. optivlsi-0.1.0/examples/__init__.py +1 -0
  6. optivlsi-0.1.0/examples/bdd_demo.py +22 -0
  7. optivlsi-0.1.0/examples/bellman_ford_demo.py +23 -0
  8. optivlsi-0.1.0/examples/dijkstra_demo.py +26 -0
  9. optivlsi-0.1.0/examples/kruskal_demo.py +23 -0
  10. optivlsi-0.1.0/examples/lee_demo.py +15 -0
  11. optivlsi-0.1.0/examples/prim_demo.py +23 -0
  12. optivlsi-0.1.0/examples/simulation_demo.py +23 -0
  13. optivlsi-0.1.0/optivlsi/__init__.py +10 -0
  14. optivlsi-0.1.0/optivlsi/bdd/__init__.py +67 -0
  15. optivlsi-0.1.0/optivlsi/bdd/algorithms.py +173 -0
  16. optivlsi-0.1.0/optivlsi/bellman_ford/__init__.py +76 -0
  17. optivlsi-0.1.0/optivlsi/bellman_ford/algorithms.py +159 -0
  18. optivlsi-0.1.0/optivlsi/dijkstra/__init__.py +87 -0
  19. optivlsi-0.1.0/optivlsi/dijkstra/algorithms.py +201 -0
  20. optivlsi-0.1.0/optivlsi/kruskal/__init__.py +75 -0
  21. optivlsi-0.1.0/optivlsi/kruskal/algorithms.py +177 -0
  22. optivlsi-0.1.0/optivlsi/lee/__init__.py +73 -0
  23. optivlsi-0.1.0/optivlsi/lee/algorithms.py +192 -0
  24. optivlsi-0.1.0/optivlsi/prim/__init__.py +70 -0
  25. optivlsi-0.1.0/optivlsi/prim/algorithms.py +168 -0
  26. optivlsi-0.1.0/optivlsi/simulation/__init__.py +5 -0
  27. optivlsi-0.1.0/optivlsi/simulation/compiled_code/__init__.py +46 -0
  28. optivlsi-0.1.0/optivlsi/simulation/compiled_code/simulator.py +273 -0
  29. optivlsi-0.1.0/optivlsi/simulation/compiled_code_numba/__init__.py +33 -0
  30. optivlsi-0.1.0/optivlsi/simulation/compiled_code_numba/simulator.py +264 -0
  31. optivlsi-0.1.0/optivlsi/simulation/event_driven/__init__.py +57 -0
  32. optivlsi-0.1.0/optivlsi/simulation/event_driven/simulator.py +306 -0
  33. optivlsi-0.1.0/optivlsi/utils/__init__.py +8 -0
  34. optivlsi-0.1.0/optivlsi/utils/graph.py +67 -0
  35. optivlsi-0.1.0/optivlsi.egg-info/PKG-INFO +161 -0
  36. optivlsi-0.1.0/optivlsi.egg-info/SOURCES.txt +50 -0
  37. optivlsi-0.1.0/optivlsi.egg-info/dependency_links.txt +1 -0
  38. optivlsi-0.1.0/optivlsi.egg-info/requires.txt +11 -0
  39. optivlsi-0.1.0/optivlsi.egg-info/top_level.txt +1 -0
  40. optivlsi-0.1.0/pyproject.toml +53 -0
  41. optivlsi-0.1.0/setup.cfg +4 -0
  42. optivlsi-0.1.0/tests/__init__.py +0 -0
  43. optivlsi-0.1.0/tests/conftest.py +116 -0
  44. optivlsi-0.1.0/tests/test_bdd.py +54 -0
  45. optivlsi-0.1.0/tests/test_bellman_ford.py +73 -0
  46. optivlsi-0.1.0/tests/test_benchmarks.py +163 -0
  47. optivlsi-0.1.0/tests/test_compiled_code_sim.py +92 -0
  48. optivlsi-0.1.0/tests/test_dijkstra.py +61 -0
  49. optivlsi-0.1.0/tests/test_event_driven_sim.py +64 -0
  50. optivlsi-0.1.0/tests/test_kruskal.py +76 -0
  51. optivlsi-0.1.0/tests/test_lee.py +59 -0
  52. optivlsi-0.1.0/tests/test_prim.py +62 -0
optivlsi-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Rohan Rajesh Kalbag, Neeraj Prabhu
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,7 @@
1
+ include README.md
2
+ include LICENSE
3
+ include pyproject.toml
4
+ recursive-include optivlsi *.py
5
+ recursive-include tests *.py
6
+ recursive-include examples *.py
7
+ recursive-include docs *.mdinclude LICENSE
@@ -0,0 +1,161 @@
1
+ Metadata-Version: 2.4
2
+ Name: optivlsi
3
+ Version: 0.1.0
4
+ Summary: High-performance VLSI CAD algorithms with Numba-accelerated implementations
5
+ Author: Rohan Rajesh Kalbag, Neeraj Prabhu
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/rohankalbag/optiVLSI
8
+ Project-URL: Repository, https://github.com/rohankalbag/optiVLSI.git
9
+ Keywords: vlsi,cad,graph-algorithms,numba,networkx
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Science/Research
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.9
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Topic :: Scientific/Engineering :: Electronic Design Automation (EDA)
18
+ Requires-Python: >=3.9
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Requires-Dist: numpy>=1.23.5
22
+ Requires-Dist: numba>=0.56.4
23
+ Requires-Dist: networkx>=3.0
24
+ Requires-Dist: matplotlib>=3.7.1
25
+ Requires-Dist: pandas>=2.0.0
26
+ Requires-Dist: scipy>=1.10.1
27
+ Provides-Extra: dev
28
+ Requires-Dist: pytest>=7.4; extra == "dev"
29
+ Requires-Dist: pytest-cov>=4.1; extra == "dev"
30
+ Requires-Dist: pytest-benchmark>=4.0; extra == "dev"
31
+ Dynamic: license-file
32
+
33
+ # optiVLSI
34
+
35
+ optiVLSI is a Python package that implements a collection of classic graph and circuit algorithms, including:
36
+
37
+ - Bellman‑Ford
38
+ - Dijkstra
39
+ - Prim
40
+ - Kruskal
41
+ - Lee (maze solver)
42
+ - BDD (binary decision diagrams)
43
+ - Simulation engines (compiled‑code and event‑driven)
44
+
45
+ The project has been refactored into a proper Python package with a modern `pyproject.toml`, type hints, comprehensive tests, documentation, and CI/CD pipelines.
46
+
47
+ ## Quick Start
48
+
49
+ ```bash
50
+ # Install the package
51
+ pip install optivlsi
52
+
53
+ # Run a quick demo
54
+ python -m optivlsi.lee.algorithms.lee_algorithm
55
+ ```
56
+
57
+ ## Documentation
58
+
59
+ - [API Reference](docs/api.md)
60
+ - [Algorithms Overview](docs/algorithms.md)
61
+ - [Benchmarks](docs/benchmarks.md)
62
+
63
+ ## Contributing
64
+
65
+ See the [CONTRIBUTING.md](CONTRIBUTING.md) file for guidelines.
66
+
67
+ ## Implemented Algorithms
68
+
69
+ ### Graph Algorithms
70
+ | Algorithm | Package | Variants |
71
+ |-----------|---------|----------|
72
+ | Bellman-Ford Shortest Path | `optivlsi.bellman_ford` | Pythonic, NetworkX, Numba |
73
+ | Dijkstra Shortest Path | `optivlsi.dijkstra` | Pythonic, NetworkX, Numba |
74
+ | Kruskal Minimum Spanning Tree | `optivlsi.kruskal` | Pythonic (DSU), NetworkX, Numba |
75
+ | Prim Minimum Spanning Tree | `optivlsi.prim` | Pythonic, NetworkX, Numba |
76
+
77
+ ### Routing
78
+ | Algorithm | Package | Variants |
79
+ |-----------|---------|----------|
80
+ | Lee Maze Routing | `optivlsi.lee` | Pythonic BFS, NetworkX, Numba |
81
+
82
+ ### Digital Circuit Simulation
83
+ | Algorithm | Package | Variants |
84
+ |-----------|---------|----------|
85
+ | Compiled-Code Simulator | `optivlsi.simulation.compiled_code` | Gate classes, Numba |
86
+ | Event-Driven Simulator | `optivlsi.simulation.event_driven` | Event propagation, Numba |
87
+
88
+ ### Binary Decision Diagrams
89
+ | Algorithm | Package | Variants |
90
+ |-----------|---------|----------|
91
+ | ROBDD | `optivlsi.bdd` | Python, Numba |
92
+
93
+ ## Running Tests
94
+
95
+ ```bash
96
+ # Run all tests
97
+ pytest
98
+
99
+ # Run with coverage
100
+ pytest --cov=optivlsi --cov-report=term
101
+
102
+ # Run benchmarks
103
+ pytest tests/test_benchmarks.py --benchmark-only
104
+ ```
105
+
106
+ ## Documentation
107
+
108
+ Full documentation is available in the [docs/](docs/) directory:
109
+
110
+ - [API Reference](docs/api.md)
111
+ - [Algorithm Details](docs/algorithms.md)
112
+
113
+ Detailed research paper: [OptiVLSI.pdf](OptiVLSI.pdf)
114
+
115
+ ## Benchmarking
116
+
117
+ Each algorithm module includes an `automate.py` file for automan-based benchmarking across various problem sizes. The package also provides pytest-benchmark integration for performance regression detection.
118
+
119
+ ## Optimization Tools Used
120
+
121
+ - **Numba**: All algorithms have Numba-accelerated variants with JIT compilation
122
+ - **Automan**: Automated simulation and benchmarking infrastructure
123
+ - **NetworkX**: Reference implementations using standard graph library
124
+
125
+ ## Project Structure
126
+
127
+ ```
128
+ optivlsi/ # Main package
129
+ ├── bellman_ford/ # Bellman-Ford algorithm
130
+ ├── dijkstra/ # Dijkstra's algorithm
131
+ ├── kruskal/ # Kruskal's MST
132
+ ├── prim/ # Prim's MST
133
+ ├── lee/ # Lee maze routing
134
+ ├── simulation/
135
+ │ ├── compiled_code/ # Compiled-code simulator
136
+ │ ├── compiled_code_numba/# Numba-accelerated variant
137
+ │ └── event_driven/ # Event-driven simulator
138
+ ├── bdd/ # ROBDD
139
+ └── utils/ # Shared utilities
140
+ bellman-ford/ # Original standalone modules
141
+ dijkstra/ # (preserved for reproducibility)
142
+ kruskal/ #
143
+ prim/ #
144
+ lee-algorithm/ #
145
+ compiled-code-simulator/ #
146
+ event-driven-sim/ #
147
+ ROBDD/ #
148
+ ```
149
+
150
+ ## Original Research
151
+
152
+ This open-source codebase started as a course project for **AE6102 - Parallel Scientific Computing and Visualization** at IIT Bombay. The original standalone research modules are preserved in their respective directories.
153
+
154
+ ## Collaborators
155
+
156
+ - Rohan Rajesh Kalbag
157
+ - Neeraj Prabhu
158
+
159
+ ## License
160
+
161
+ MIT
@@ -0,0 +1,129 @@
1
+ # optiVLSI
2
+
3
+ optiVLSI is a Python package that implements a collection of classic graph and circuit algorithms, including:
4
+
5
+ - Bellman‑Ford
6
+ - Dijkstra
7
+ - Prim
8
+ - Kruskal
9
+ - Lee (maze solver)
10
+ - BDD (binary decision diagrams)
11
+ - Simulation engines (compiled‑code and event‑driven)
12
+
13
+ The project has been refactored into a proper Python package with a modern `pyproject.toml`, type hints, comprehensive tests, documentation, and CI/CD pipelines.
14
+
15
+ ## Quick Start
16
+
17
+ ```bash
18
+ # Install the package
19
+ pip install optivlsi
20
+
21
+ # Run a quick demo
22
+ python -m optivlsi.lee.algorithms.lee_algorithm
23
+ ```
24
+
25
+ ## Documentation
26
+
27
+ - [API Reference](docs/api.md)
28
+ - [Algorithms Overview](docs/algorithms.md)
29
+ - [Benchmarks](docs/benchmarks.md)
30
+
31
+ ## Contributing
32
+
33
+ See the [CONTRIBUTING.md](CONTRIBUTING.md) file for guidelines.
34
+
35
+ ## Implemented Algorithms
36
+
37
+ ### Graph Algorithms
38
+ | Algorithm | Package | Variants |
39
+ |-----------|---------|----------|
40
+ | Bellman-Ford Shortest Path | `optivlsi.bellman_ford` | Pythonic, NetworkX, Numba |
41
+ | Dijkstra Shortest Path | `optivlsi.dijkstra` | Pythonic, NetworkX, Numba |
42
+ | Kruskal Minimum Spanning Tree | `optivlsi.kruskal` | Pythonic (DSU), NetworkX, Numba |
43
+ | Prim Minimum Spanning Tree | `optivlsi.prim` | Pythonic, NetworkX, Numba |
44
+
45
+ ### Routing
46
+ | Algorithm | Package | Variants |
47
+ |-----------|---------|----------|
48
+ | Lee Maze Routing | `optivlsi.lee` | Pythonic BFS, NetworkX, Numba |
49
+
50
+ ### Digital Circuit Simulation
51
+ | Algorithm | Package | Variants |
52
+ |-----------|---------|----------|
53
+ | Compiled-Code Simulator | `optivlsi.simulation.compiled_code` | Gate classes, Numba |
54
+ | Event-Driven Simulator | `optivlsi.simulation.event_driven` | Event propagation, Numba |
55
+
56
+ ### Binary Decision Diagrams
57
+ | Algorithm | Package | Variants |
58
+ |-----------|---------|----------|
59
+ | ROBDD | `optivlsi.bdd` | Python, Numba |
60
+
61
+ ## Running Tests
62
+
63
+ ```bash
64
+ # Run all tests
65
+ pytest
66
+
67
+ # Run with coverage
68
+ pytest --cov=optivlsi --cov-report=term
69
+
70
+ # Run benchmarks
71
+ pytest tests/test_benchmarks.py --benchmark-only
72
+ ```
73
+
74
+ ## Documentation
75
+
76
+ Full documentation is available in the [docs/](docs/) directory:
77
+
78
+ - [API Reference](docs/api.md)
79
+ - [Algorithm Details](docs/algorithms.md)
80
+
81
+ Detailed research paper: [OptiVLSI.pdf](OptiVLSI.pdf)
82
+
83
+ ## Benchmarking
84
+
85
+ Each algorithm module includes an `automate.py` file for automan-based benchmarking across various problem sizes. The package also provides pytest-benchmark integration for performance regression detection.
86
+
87
+ ## Optimization Tools Used
88
+
89
+ - **Numba**: All algorithms have Numba-accelerated variants with JIT compilation
90
+ - **Automan**: Automated simulation and benchmarking infrastructure
91
+ - **NetworkX**: Reference implementations using standard graph library
92
+
93
+ ## Project Structure
94
+
95
+ ```
96
+ optivlsi/ # Main package
97
+ ├── bellman_ford/ # Bellman-Ford algorithm
98
+ ├── dijkstra/ # Dijkstra's algorithm
99
+ ├── kruskal/ # Kruskal's MST
100
+ ├── prim/ # Prim's MST
101
+ ├── lee/ # Lee maze routing
102
+ ├── simulation/
103
+ │ ├── compiled_code/ # Compiled-code simulator
104
+ │ ├── compiled_code_numba/# Numba-accelerated variant
105
+ │ └── event_driven/ # Event-driven simulator
106
+ ├── bdd/ # ROBDD
107
+ └── utils/ # Shared utilities
108
+ bellman-ford/ # Original standalone modules
109
+ dijkstra/ # (preserved for reproducibility)
110
+ kruskal/ #
111
+ prim/ #
112
+ lee-algorithm/ #
113
+ compiled-code-simulator/ #
114
+ event-driven-sim/ #
115
+ ROBDD/ #
116
+ ```
117
+
118
+ ## Original Research
119
+
120
+ This open-source codebase started as a course project for **AE6102 - Parallel Scientific Computing and Visualization** at IIT Bombay. The original standalone research modules are preserved in their respective directories.
121
+
122
+ ## Collaborators
123
+
124
+ - Rohan Rajesh Kalbag
125
+ - Neeraj Prabhu
126
+
127
+ ## License
128
+
129
+ MIT
@@ -0,0 +1 @@
1
+ """Example scripts demonstrating optiVLSI algorithm usage."""
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env python3
2
+ """Example: Build and evaluate a Reduced Ordered Binary Decision Diagram."""
3
+
4
+ from optivlsi.bdd.algorithms import evaluate_expression
5
+
6
+ # Boolean expression: x & y
7
+ # Truth table: 00->0, 01->0, 10->0, 11->1
8
+ exp = "x & y"
9
+ for x in [0, 1]:
10
+ for y in [0, 1]:
11
+ result = evaluate_expression({x, y}, exp)
12
+ print(f"x={x}, y={y} -> {exp} = {result}")
13
+
14
+ print()
15
+
16
+ # Another expression: (a & b) | c
17
+ exp2 = "(a & b) | c"
18
+ for a in [0, 1]:
19
+ for b in [0, 1]:
20
+ for c in [0, 1]:
21
+ result = evaluate_expression({a, b, c}, exp2)
22
+ print(f"a={a}, b={b}, c={c} -> {exp2} = {result}")
@@ -0,0 +1,23 @@
1
+ """Example: Bellman-Ford shortest path algorithm."""
2
+
3
+ import numpy as np
4
+ from optivlsi.bellman_ford import bellman_ford, bellman_ford_networkx, bellman_ford_numba
5
+
6
+ nodes = np.array([0, 1, 2, 3, 4], dtype=np.int64)
7
+ edges = np.array([
8
+ [0, 1, 5],
9
+ [0, 2, 3],
10
+ [1, 3, 6],
11
+ [1, 2, 2],
12
+ [2, 4, 4],
13
+ [3, 4, 1],
14
+ ], dtype=np.int64)
15
+
16
+ status, path = bellman_ford(nodes, edges, 0, 4)
17
+ print(f"Pythonic result: status={status}, path={path}")
18
+
19
+ status, path = bellman_ford_networkx(nodes, edges, 0, 4)
20
+ print(f"NetworkX result: status={status}, path={path}")
21
+
22
+ status, path = bellman_ford_numba(nodes, edges, 0, 4)
23
+ print(f"Numba result: status={status}, path={path}")
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env python3
2
+ """Example: Dijkstra shortest path on a directed graph."""
3
+
4
+ import numpy as np
5
+ from optivlsi.dijkstra import dijkstra, dijkstra_networkx
6
+
7
+ # Small directed graph: 6 nodes, weighted edges
8
+ nodes = np.array([0, 1, 2, 3, 4, 5], dtype=np.int64)
9
+ edges = np.array([
10
+ [0, 1, 4],
11
+ [0, 2, 2],
12
+ [1, 3, 5],
13
+ [2, 3, 1],
14
+ [2, 4, 7],
15
+ [3, 5, 3],
16
+ [4, 5, 1],
17
+ ], dtype=np.int64)
18
+
19
+ # Dijkstra from node 0 to node 5
20
+ status, path = dijkstra(nodes, edges, 0, 5)
21
+ print(f"Dijkstra path from 0 to 5: {path}")
22
+
23
+ # Also try NetworkX variant
24
+ status_nx, path_nx = dijkstra_networkx(nodes, edges, 0, 5)
25
+ print(f"NetworkX Dijkstra path: {path_nx}")
26
+ print(f"Paths match: {path == path_nx}")
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env python3
2
+ """Example: Kruskal minimum spanning tree on an undirected graph."""
3
+
4
+ import numpy as np
5
+ from optivlsi.kruskal import kruskal, kruskal_networkx
6
+
7
+ # Small undirected graph: 4 nodes
8
+ nodes = np.array([0, 1, 2, 3], dtype=np.int64)
9
+ edges = np.array([
10
+ [0, 1, 10],
11
+ [0, 2, 6],
12
+ [0, 3, 5],
13
+ [1, 3, 15],
14
+ [2, 3, 4],
15
+ ], dtype=np.int64)
16
+
17
+ mst_edges, mst_weight = kruskal(nodes, edges)
18
+ print(f"Kruskal MST edges: {mst_edges}")
19
+ print(f"Kruskal MST weight: {mst_weight}")
20
+
21
+ mst_edges_nx, mst_weight_nx = kruskal_networkx(nodes, edges)
22
+ print(f"NetworkX MST weight: {mst_weight_nx}")
23
+ print(f"Weights match: {mst_weight == mst_weight_nx}")
@@ -0,0 +1,15 @@
1
+ """Example: Lee maze routing algorithm."""
2
+
3
+ import numpy as np
4
+ from optivlsi.lee import lee
5
+
6
+ # Create a 5x5 maze with some obstacles
7
+ maze = np.zeros((5, 5), dtype=np.int64)
8
+ # Add some obstacles
9
+ maze[1, 1] = 1
10
+ maze[1, 2] = 1
11
+ maze[2, 2] = 1
12
+ maze[3, 2] = 1
13
+
14
+ distance = lee(maze, 0, 0, 4, 4)
15
+ print(f"Shortest path distance: {distance}")
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env python3
2
+ """Example: Prim minimum spanning tree on an undirected graph."""
3
+
4
+ import numpy as np
5
+ from optivlsi.prim import prim, prim_networkx
6
+
7
+ # Small undirected graph: 4 nodes
8
+ nodes = np.array([0, 1, 2, 3], dtype=np.int64)
9
+ edges = np.array([
10
+ [0, 1, 10],
11
+ [0, 2, 6],
12
+ [0, 3, 5],
13
+ [1, 3, 15],
14
+ [2, 3, 4],
15
+ ], dtype=np.int64)
16
+
17
+ mst_edges, mst_weight = prim(nodes, edges)
18
+ print(f"Prim MST edges: {mst_edges}")
19
+ print(f"Prim MST weight: {mst_weight}")
20
+
21
+ mst_edges_nx, mst_weight_nx = prim_networkx(nodes, edges)
22
+ print(f"NetworkX Prim weight: {mst_weight_nx}")
23
+ print(f"Weights match: {mst_weight == mst_weight_nx}")
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env python3
2
+ """Example: Digital circuit simulation using compiled-code simulator."""
3
+
4
+ from optivlsi.simulation.compiled_code.simulator import (
5
+ generate_circuit, simulate
6
+ )
7
+ from itertools import product
8
+
9
+ # Build a full adder circuit from benchmark file
10
+ circuit_path = "compiled-code-simulator/benchmarks/fulladder.txt"
11
+ circuit = generate_circuit(circuit_path)
12
+
13
+ # Get input/output nodes
14
+ from optivlsi.simulation.compiled_code.simulator import get_input_output_nodes
15
+ inputs, outputs = get_input_output_nodes(circuit_path)
16
+
17
+ print(f"Inputs: {inputs}, Outputs: {outputs}")
18
+
19
+ # Simulate all input combinations
20
+ for bits in product([0, 1], repeat=len(inputs)):
21
+ testvector = {inputs[i]: bits[i] for i in range(len(inputs))}
22
+ result = simulate(testvector, circuit)
23
+ print(f"Input {bits} -> Output {result}")
@@ -0,0 +1,10 @@
1
+ """
2
+ optiVLSI - High-performance VLSI CAD algorithms with Numba-accelerated implementations.
3
+
4
+ optiVLSI provides optimized implementations of VLSI CAD algorithms including graph algorithms
5
+ (Bellman-Ford, Dijkstra, Kruskal, Prim), maze routing (Lee algorithm), digital circuit simulation
6
+ (compiled-code and event-driven), and Reduced Ordered Binary Decision Diagrams (ROBDD).
7
+ Each algorithm is available in Pythonic, NetworkX, and Numba-accelerated variants.
8
+ """
9
+
10
+ __version__ = "0.1.0"
@@ -0,0 +1,67 @@
1
+ """
2
+ Reduced Ordered Binary Decision Diagram (ROBDD) implementations.
3
+
4
+ Provides:
5
+ - build(): Build a BDD from a logical expression
6
+ - evaluate(): Evaluate a BDD for given variable assignments
7
+ - evaluate_numba(): Numba-accelerated evaluation
8
+ """
9
+
10
+ import numpy as np
11
+
12
+ from .algorithms import (
13
+ evaluate_expression,
14
+ evaluate_expression2 as _evaluate_expression_numba,
15
+ main as _build_bdd,
16
+ main_numba as _build_bdd_numba,
17
+ int_to_binary,
18
+ )
19
+
20
+
21
+ # Global state used by the original implementation
22
+ order = ""
23
+ inp = ""
24
+ ord1 = None
25
+ inp1 = None
26
+
27
+
28
+ def build(expression, variable_order):
29
+ """Build a BDD from a logical expression.
30
+
31
+ Args:
32
+ expression: String logical expression (e.g., "a.b + ~a.b").
33
+ variable_order: String of variable ordering (e.g., "ab").
34
+
35
+ Returns:
36
+ BDD representation as a list.
37
+ """
38
+ global order, inp, ord1, inp1
39
+ order = variable_order
40
+ inp = expression
41
+
42
+ inp1_list = []
43
+ for ch in inp:
44
+ inp1_list.append(ord(ch))
45
+ inp1 = np.array(inp1_list, dtype=np.int32)
46
+
47
+ ord1_list = []
48
+ for ch in order:
49
+ ord1_list.append(ord(ch))
50
+ ord1 = np.array(ord1_list, dtype=np.int32)
51
+
52
+ # Set globals in the algorithms module directly
53
+ import optivlsi.bdd.algorithms as bdd_algo
54
+ bdd_algo.order = variable_order
55
+ bdd_algo.inp = expression
56
+ bdd_algo.ord1 = ord1
57
+ bdd_algo.inp1 = inp1
58
+
59
+ _build_bdd()
60
+ return _build_bdd_numba()
61
+
62
+
63
+ __all__ = [
64
+ "build",
65
+ "evaluate_expression",
66
+ "int_to_binary",
67
+ ]