najaeda 0.1.4__cp311-cp311-macosx_11_0_arm64.whl → 0.1.5__cp311-cp311-macosx_11_0_arm64.whl

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.

Potentially problematic release.


This version of najaeda might be problematic. Click here for more details.

@@ -0,0 +1,45 @@
1
+ # SPDX-FileCopyrightText: 2024 The Naja authors
2
+ # <https://github.com/najaeda/naja/blob/main/AUTHORS>
3
+ #
4
+ # SPDX-License-Identifier: Apache-2.0
5
+
6
+ from typing import Callable
7
+ from najaeda import netlist
8
+
9
+
10
+ class VisitorConfig:
11
+ def __init__(
12
+ self,
13
+ enter_condition: Callable[[netlist.Instance], bool] = lambda node: True,
14
+ callback: Callable[[netlist.Instance], None] = lambda node: None,
15
+ ):
16
+ """
17
+ :param enter_condition: A function that determines whether to visit
18
+ the children of an instance.
19
+ :param callback: The callback to be executed when an instance is visited.
20
+ """
21
+ self.callback = callback
22
+ self.enter_condition = enter_condition
23
+
24
+
25
+ class Visitor:
26
+ def __init__(self, instance: netlist.Instance):
27
+ """
28
+ :param netlist: The hierarchical netlist to be traversed.
29
+ """
30
+ self.instance = instance
31
+
32
+ def visit(self, instance: netlist.Instance, config: VisitorConfig):
33
+ """
34
+ Recursively visits nodes in the netlist hierarchy.
35
+
36
+ :param instance: The current node in the netlist instance hierarchy.
37
+ :param config: VisitorConfig object defining conditions and callbacks.
38
+ """
39
+ # Execute the callback
40
+ config.callback(instance)
41
+
42
+ # Check if we should proceed to children
43
+ if config.enter_condition(instance):
44
+ for child in instance.get_child_instances():
45
+ self.visit(child, config)
Binary file
najaeda/netlist.py CHANGED
@@ -35,13 +35,13 @@ class Equipotential:
35
35
 
36
36
  def get_top_terms(self):
37
37
  for term in self.equi.getTerms():
38
- yield Term(snl.SNLPath(), term.getBitTerm())
38
+ yield Term(snl.SNLPath(), term)
39
39
 
40
40
  def get_all_leaf_readers(self):
41
41
  for term in self.equi.getInstTermOccurrences():
42
42
  direction = term.getInstTerm().getDirection()
43
43
  if direction != snl.SNLTerm.Direction.Output:
44
- if term.getInstTerm().getInstance().getModel().isPrimitive():
44
+ if term.getInstTerm().getInstance().getModel().isLeaf():
45
45
  yield Term(
46
46
  snl.SNLPath(term.getPath(), term.getInstTerm().getInstance()),
47
47
  term.getInstTerm().getBitTerm(),
@@ -161,14 +161,14 @@ class Net:
161
161
  path = snl.SNLPath(self.path, term.getInstance())
162
162
  yield Term(path, term.getBitTerm())
163
163
 
164
- def get_terms(self):
164
+ def get_design_terms(self):
165
165
  if hasattr(self, "net_concat"):
166
166
  raise ValueError("Cannot get terms from a net_concat")
167
167
  for term in self.net.getBitTerms():
168
168
  yield Term(self.path, term)
169
169
 
170
- def get_components(self):
171
- for term in itertools.chain(self.get_terms(), self.get_inst_terms()):
170
+ def get_terms(self):
171
+ for term in itertools.chain(self.get_design_terms(), self.get_inst_terms()):
172
172
  yield term
173
173
 
174
174
 
@@ -452,6 +452,10 @@ class Instance:
452
452
  """Return True if this is a blackbox."""
453
453
  return self.__get_snl_model().isBlackBox()
454
454
 
455
+ def is_leaf(self) -> bool:
456
+ """Return True if this is a leaf."""
457
+ return self.__get_snl_model().isLeaf()
458
+
455
459
  def is_const0(self) -> bool:
456
460
  """Return True if this is a constant 0 generator."""
457
461
  return self.__get_snl_model().isConst0()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: najaeda
3
- Version: 0.1.4
3
+ Version: 0.1.5
4
4
  Summary: Naja EDA Python package
5
5
  Author-Email: Naja Authors <contact@keplertech.io>
6
6
  License: Apache License 2.0
@@ -61,11 +61,10 @@ easily extended in the future. Don't hesitate to reach out if you need help.
61
61
  netlist.load_primitives('xilinx')
62
62
  benchmarks = path.join('..','benchmarks')
63
63
  top = netlist.load_verilog([path.join(benchmarks, 'verilog', 'arm_core_netlist.v')])
64
- #
65
64
 
66
65
  Print all the instances in the netlist
67
66
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
68
- Next example shows how to browse all the netlist and print all its content.
67
+ Next example shows how to browse all the netlist and print all its content recursively.
69
68
 
70
69
  .. code-block:: python
71
70
 
@@ -74,13 +73,30 @@ Next example shows how to browse all the netlist and print all its content.
74
73
  print(f"{child_instance}:{child_instance.get_model_name()}")
75
74
  print_netlist(child_instance)
76
75
 
76
+ Similar to the previous example, but utilizing an instance visitor.
77
+ This approach allows you to perform operations on each instance while
78
+ also defining conditions for stopping or continuing exploration.
79
+
80
+ .. code-block:: python
81
+
82
+ def print_instance(instance):
83
+ print(f"{instance}:{instance.get_model_name()}")
84
+ visitor_config = instance_visitor.VisitorConfig(callback=print_instance)
85
+ instance_visitor.Visitor(top).visit(top, visitor_config)
86
+
77
87
  Documentation
78
88
  -------------
79
89
  najaeda is a work in progress, and the documentation is still under development.
80
90
 
81
91
  Naja documentation is available on the `Naja GitHub repository <https://github.com/najaeda/naja>`_.
82
92
 
83
- License
93
+ Support
84
94
  -------
95
+ Please put up issues on the Delocate issue tracker.
96
+ If you encounter any issues or have questions, please report them on the
97
+ `Naja issue tracker <https://github.com/najaeda/naja/issues>`_.
85
98
 
86
- This project is licensed under the Apache License 2.0. See the `LICENSE <https://github.com/najaeda/naja/blob/main/LICENSE>`_ file for details.
99
+ License
100
+ -------
101
+ This project is licensed under the Apache License 2.0.
102
+ See the `LICENSE <https://github.com/najaeda/naja/blob/main/LICENSE>`_ file for details.
@@ -0,0 +1,13 @@
1
+ najaeda-0.1.5.dist-info/RECORD,,
2
+ najaeda-0.1.5.dist-info/WHEEL,sha256=vqMBchNIsmW0K9HInUQuY_xePW9YD3coNJy6G1Yfto8,114
3
+ najaeda-0.1.5.dist-info/METADATA,sha256=WuZMeLEC6yRy9aEA4UiQ5Bg9RA_NtPplvGclOEt6h7c,3511
4
+ najaeda-0.1.5.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
5
+ najaeda-0.1.5.dist-info/licenses/AUTHORS,sha256=7NYEGDAX_1QZvCCHfq8YVXC5ZbwH_pbNI8DcSmm70GU,377
6
+ najaeda/netlist.py,sha256=jzpnmhGdkXRmSYmMNv3YGe3KC9BB9eoQc0Y3zlMh3ag,25748
7
+ najaeda/libnaja_snl_python.dylib,sha256=IIq8xHbA3cIuR-YutApeWRx5ZcCmwJWggHjGKjm7drg,740160
8
+ najaeda/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
+ najaeda/libnaja_snl.dylib,sha256=8Ei7KKU0b14IqlvH_8yQSSCpH0rjbxpeRaXgyfSemMY,574112
10
+ najaeda/snl.so,sha256=d9W9rNMzNl0T88DpH7thDuP3NK6nyVgJYXYKx3Uxm7I,97888
11
+ najaeda/instance_visitor.py,sha256=HrrOnCSuw5Lh1HSp2R-ckYP4gEbqdxp_rw3Sl0GpGHE,1479
12
+ najaeda/primitives/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
+ najaeda/primitives/xilinx.py,sha256=fuu4KxEIuC0ueCK4C_gds6hzgtJsLE3tjDtOHtY9McM,25947
@@ -1,12 +0,0 @@
1
- najaeda-0.1.4.dist-info/RECORD,,
2
- najaeda-0.1.4.dist-info/WHEEL,sha256=vqMBchNIsmW0K9HInUQuY_xePW9YD3coNJy6G1Yfto8,114
3
- najaeda-0.1.4.dist-info/METADATA,sha256=rpver3Febf2UhLXS-HAceNHU3YnNLGKde1icywDK_-Y,2842
4
- najaeda-0.1.4.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
5
- najaeda-0.1.4.dist-info/licenses/AUTHORS,sha256=7NYEGDAX_1QZvCCHfq8YVXC5ZbwH_pbNI8DcSmm70GU,377
6
- najaeda/netlist.py,sha256=ena4A9S1UxQV-pO1XWxO_qbG-4ELnorKInJgX0zN3M0,25633
7
- najaeda/libnaja_snl_python.dylib,sha256=PvesumeH7pjidMQSU_i0UYsSvca4fnHw2tEkptLURvg,740160
8
- najaeda/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
- najaeda/libnaja_snl.dylib,sha256=8Ei7KKU0b14IqlvH_8yQSSCpH0rjbxpeRaXgyfSemMY,574112
10
- najaeda/snl.so,sha256=d9W9rNMzNl0T88DpH7thDuP3NK6nyVgJYXYKx3Uxm7I,97888
11
- najaeda/primitives/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
- najaeda/primitives/xilinx.py,sha256=fuu4KxEIuC0ueCK4C_gds6hzgtJsLE3tjDtOHtY9McM,25947