najaeda 0.2.8__cp312-cp312-macosx_11_0_arm64.whl → 0.2.9__cp312-cp312-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.

Binary file
najaeda/naja.so CHANGED
Binary file
najaeda/netlist.py CHANGED
@@ -220,6 +220,13 @@ class Net:
220
220
  else:
221
221
  return net_str
222
222
 
223
+ def delete(self):
224
+ if hasattr(self, "net"):
225
+ self.net.destroy()
226
+ else:
227
+ for net in self.net_concat:
228
+ net.destroy()
229
+
223
230
  def get_name(self) -> str:
224
231
  """
225
232
  :return: the name of this Net.
@@ -458,10 +465,6 @@ class Term:
458
465
  INOUT = naja.SNLTerm.Direction.InOut
459
466
 
460
467
  def __init__(self, path, term):
461
- # self.termIDs = []
462
- # if isinstance(term, naja.SNLBusTerm):
463
- # self.termIDs = [term.getID(), -1]
464
- # else:
465
468
  self.termIDs = [term.getID(), term.getBit()]
466
469
  self.pathIDs = path.copy()
467
470
 
@@ -743,9 +746,9 @@ class Term:
743
746
  """
744
747
  return self.__get_net(self.pathIDs, self.__get_snl_lower_bitnet)
745
748
 
746
- def get_net(self) -> Net:
749
+ def get_upper_net(self) -> Net:
747
750
  """
748
- :return: the net of the term.
751
+ :return: the upper net of the term.
749
752
  :rtype: Net
750
753
  :remark: If the term is a top level term, it will return None.
751
754
  """
@@ -817,8 +820,10 @@ class Term:
817
820
  )
818
821
  return None
819
822
 
820
- def disconnect(self):
821
- """Disconnect this term from its net."""
823
+ def disconnect_upper_net(self):
824
+ """Disconnect this term from its upper net."""
825
+ if self.get_instance().is_top():
826
+ raise ValueError("Cannot disconnect the upper net of a top level term")
822
827
  path = get_snl_path_from_id_list(self.pathIDs)
823
828
  self.__make_unique()
824
829
  inst = path.getTailInstance()
@@ -826,30 +831,44 @@ class Term:
826
831
  iterm = inst.getInstTerm(bit)
827
832
  iterm.setNet(None)
828
833
 
829
- def connect(self, net: Net):
830
- """Connect this term to the given Net.
834
+ def disconnect_lower_net(self):
835
+ """Disconnect this term from its lower net."""
836
+ self.__make_unique()
837
+ for bit in get_snl_term_for_ids(self.pathIDs, self.termIDs).getBits():
838
+ bit.setNet(None)
839
+
840
+ def connect_upper_net(self, net: Net):
841
+ """Connect this term to the given upper Net.
831
842
 
832
- :param Net net: the Net to connect to.
843
+ :param Net net: the upper Net to connect to.
833
844
  """
845
+ if self.get_instance().is_top():
846
+ raise ValueError("Cannot connect the upper net of a top level term")
834
847
  if self.get_width() != net.get_width():
835
848
  raise ValueError("Width mismatch")
836
- if self.get_instance().is_top():
837
- for bterm, bnet in zip(
838
- get_snl_term_for_ids(self.pathIDs, self.termIDs).getBits(),
839
- net.net.getBits(),
840
- ):
841
- logging.debug(f"Connecting {bterm} to {bnet}")
842
- bterm.setNet(bnet)
843
- else:
844
- self.__make_unique()
845
- path = get_snl_path_from_id_list(self.pathIDs)
846
- inst = path.getTailInstance()
847
- for bterm, bnet in zip(
848
- get_snl_term_for_ids(self.pathIDs, self.termIDs).getBits(),
849
- net.net.getBits(),
850
- ):
851
- iterm = inst.getInstTerm(bterm)
852
- iterm.setNet(bnet)
849
+ self.__make_unique()
850
+ path = get_snl_path_from_id_list(self.pathIDs)
851
+ inst = path.getTailInstance()
852
+ for bterm, bnet in zip(
853
+ get_snl_term_for_ids(self.pathIDs, self.termIDs).getBits(),
854
+ net.net.getBits(),
855
+ ):
856
+ iterm = inst.getInstTerm(bterm)
857
+ iterm.setNet(bnet)
858
+
859
+ def connect_lower_net(self, net: Net):
860
+ """Connect this term to the given lower Net.
861
+
862
+ :param Net net: the lower Net to connect to.
863
+ """
864
+ if self.get_width() != net.get_width():
865
+ raise ValueError("Width mismatch")
866
+ self.__make_unique()
867
+ for bterm, bnet in zip(
868
+ get_snl_term_for_ids(self.pathIDs, self.termIDs).getBits(),
869
+ net.net.getBits(),
870
+ ):
871
+ bterm.setNet(bnet)
853
872
 
854
873
  def get_truth_table(self):
855
874
  # check the index of the output
@@ -875,21 +894,6 @@ def get_instance_by_path(names: list):
875
894
  return get_top().get_child_instance(names)
876
895
 
877
896
 
878
- # def refresh_path(path: naja.SNLPath):
879
- # pathlist = path.getPathIDs()
880
- # assert len(pathlist) > 0
881
- # path = naja.SNLPath()
882
- # instance = None
883
- # top = naja.NLUniverse.get().getTopDesign()
884
- # design = top
885
- # for id in pathlist:
886
- # path = naja.SNLPath(path, design.getInstanceByID(id))
887
- # instance = design.getInstanceByID(id)
888
- # assert instance is not None
889
- # design = instance.getModel()
890
- # return path
891
-
892
-
893
897
  class Attribute:
894
898
  def __init__(self, snlAttribute):
895
899
  self.snlAttribute = snlAttribute
@@ -1106,6 +1110,27 @@ class Instance:
1106
1110
  model = childInst.getModel()
1107
1111
  return Instance(path)
1108
1112
 
1113
+ def get_child_instance_by_id(self, ids: Union[int, list[int]]):
1114
+ """
1115
+ :param ids: the ID of the child instance
1116
+ or the path to the child Instance as a list of IDs.
1117
+ :return: the child Instance at the given path or None if it does not exist.
1118
+ :rtype: Instance or None
1119
+ """
1120
+ if isinstance(ids, int):
1121
+ ids = [ids]
1122
+ if not ids:
1123
+ raise ValueError("IDs argument cannot be empty")
1124
+ model = self.__get_snl_model()
1125
+ path = self.pathIDs.copy()
1126
+ for id in ids:
1127
+ childInst = model.getInstanceByID(id)
1128
+ if childInst is None:
1129
+ return None
1130
+ path.append(childInst.getID())
1131
+ model = childInst.getModel()
1132
+ return Instance(path)
1133
+
1109
1134
  def get_child_instances(self):
1110
1135
  """Iterate over the child instances of this instance.
1111
1136
  Equivalent to go down one level in hierarchy.
@@ -1126,22 +1151,6 @@ class Instance:
1126
1151
  """
1127
1152
  return sum(1 for _ in self.__get_snl_model().getInstances())
1128
1153
 
1129
- # def get_flat_primitive_instances(self):
1130
- # FIXME: concat first local path with the path of the instance
1131
- # model = self.__get_snl_model()
1132
- # for inst in model.getInstances():
1133
- # path = naja.SNLPath(inst)
1134
- # stack = [[inst, path]]
1135
- # while stack:
1136
- # current = stack.pop()
1137
- # current_inst = current[0]
1138
- # current_path = current[1]
1139
- # for inst_child in current_inst.getModel().getInstances():
1140
- # path_child = naja.SNLPath(current_path, inst_child)
1141
- # if inst_child.getModel().isPrimitive():
1142
- # yield Instance(path_child)
1143
- # stack.append([inst_child, path_child])
1144
-
1145
1154
  def get_nets(self):
1146
1155
  """Iterate over all scalar nets and bus nets.
1147
1156
 
@@ -1363,30 +1372,6 @@ class Instance:
1363
1372
  """
1364
1373
  return sum(1 for _ in self.get_attributes())
1365
1374
 
1366
- def delete_instance(self, name: str):
1367
- """Delete the child instance with the given name."""
1368
- if name == "":
1369
- raise ValueError(
1370
- "Cannot delete instance with empty name. Try delete_instance_by_id instead."
1371
- )
1372
- init_path = get_snl_path_from_id_list(self.pathIDs)
1373
- path = naja.SNLPath(init_path, self.__get_snl_model().getInstance(name))
1374
- naja.SNLUniquifier(path)
1375
- if init_path.size() > 0:
1376
- # Delete the last instance in uniq_path
1377
- self.__get_snl_model().getInstance(name).destroy()
1378
-
1379
- def delete_instance_by_id(self, id: str):
1380
- """Delete the child instance with the given ID.
1381
-
1382
- :param str id: the ID of the Instance to delete.
1383
- """
1384
- init_path = get_snl_path_from_id_list(self.pathIDs)
1385
- path = naja.SNLPath(init_path, self.__get_snl_model().getInstanceByID(id))
1386
- naja.SNLUniquifier(path)
1387
- # Delete the last instance in uniq_path
1388
- self.__get_snl_model().getInstanceByID(id).destroy()
1389
-
1390
1375
  def get_design(self) -> "Instance":
1391
1376
  """
1392
1377
  :return: the Instance containing this instance.
@@ -1400,9 +1385,13 @@ class Instance:
1400
1385
 
1401
1386
  def delete(self):
1402
1387
  """Delete this instance."""
1388
+ if self.is_top():
1389
+ raise ValueError("Cannot delete the top instance")
1390
+ # FIXME: should be upper path ?
1403
1391
  path = get_snl_path_from_id_list(self.pathIDs)
1392
+ inst = get_snl_instance_from_id_list(self.pathIDs)
1404
1393
  naja.SNLUniquifier(path)
1405
- self.get_design().delete_instance_by_id(path.getTailInstance().getID())
1394
+ inst.destroy()
1406
1395
 
1407
1396
  def get_name(self) -> str:
1408
1397
  """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: najaeda
3
- Version: 0.2.8
3
+ Version: 0.2.9
4
4
  Summary: Naja EDA Python package
5
5
  Author-Email: Naja Authors <contact@keplertech.io>
6
6
  License: Apache License 2.0
@@ -1,17 +1,17 @@
1
- najaeda-0.2.8.dist-info/RECORD,,
2
- najaeda-0.2.8.dist-info/WHEEL,sha256=v7i1yNVEHWKlHHcCQ8SYkgpldhmAvPDAYWfI_XMFumo,114
3
- najaeda-0.2.8.dist-info/METADATA,sha256=8Mygr48MSZHYEDLMmGorD6ThHgIPBOlQaDRUebyqx9o,3655
4
- najaeda-0.2.8.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
5
- najaeda-0.2.8.dist-info/licenses/AUTHORS,sha256=7NYEGDAX_1QZvCCHfq8YVXC5ZbwH_pbNI8DcSmm70GU,377
6
- najaeda/netlist.py,sha256=e0sT0AB2f3rGjlmE2seVk4enTPMFpEf_q3RyHwrnDWc,64397
1
+ najaeda-0.2.9.dist-info/RECORD,,
2
+ najaeda-0.2.9.dist-info/WHEEL,sha256=a5hFNLnG478el62xhySpcm13yln7Jlz1BenyGRdoSlE,114
3
+ najaeda-0.2.9.dist-info/METADATA,sha256=GMUJC6rYW2tPNfdLcHNehuXdBa5yuOhnFaSFa8gwbek,3655
4
+ najaeda-0.2.9.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
5
+ najaeda-0.2.9.dist-info/licenses/AUTHORS,sha256=7NYEGDAX_1QZvCCHfq8YVXC5ZbwH_pbNI8DcSmm70GU,377
6
+ najaeda/netlist.py,sha256=iDaELvPq9irnAPmk6F7LqjP0W6w9uUpb3b_UG900Q-g,63744
7
7
  najaeda/libnaja_nl.dylib,sha256=5ATBPPpP1qXR6a81JgfZdQrFuz4LmzSIfL-wEINDD0g,774416
8
8
  najaeda/pandas_stats.py,sha256=yOb4ka965U7rN4D6AwvSGmRyeT_O7Ed-5cmT8BFbfeo,1070
9
9
  najaeda/_version.py,sha256=c-4hT20dyE-3BcdzOqR0vd92E7ydR5u2c-VmCc6oU8A,332
10
10
  najaeda/__init__.py,sha256=6QrOzlqTfd558FH9Zm6ve54IzkHaDJ8ZO8hTCaEwsL8,218
11
- najaeda/naja.so,sha256=8pJUlGuhj7pvNhO8dkVk4_74yPYcgZbblZ7Jz6bFf50,99440
11
+ najaeda/naja.so,sha256=PmhtMh32m5AU0AD91AT8K0VpTpvQ-XI4GuXVKskKuGs,99440
12
12
  najaeda/net_visitor.py,sha256=P_esjibYb-wBDuF-AyF7es9sJYw1Ha8RhTPu-qKe7G4,1940
13
13
  najaeda/libnaja_opt.dylib,sha256=vW8P49UplpYdjSxqU3TeaV2s9ck75Spq5ZcrN3ET0f4,212720
14
- najaeda/libnaja_python.dylib,sha256=nJ9I8AyQZ2HwvMe12EICNs8ZQBV6op5KDklyNDgPMo8,962016
14
+ najaeda/libnaja_python.dylib,sha256=UXpDqieLnQlJNx2IqnjV7PGogajfmazrA0wNGBEiqkM,962128
15
15
  najaeda/stats.py,sha256=g1F1CEBNVvGgzINOI7sK83123cCbclLDmyUjuep3-EU,16107
16
16
  najaeda/instance_visitor.py,sha256=JMsPSQaWNiDjxS05rxg83a0PIsrOIuTi9G35hkwdibs,1530
17
17
  najaeda/libnaja_bne.dylib,sha256=pLbGUnDr5PSGXbA8wKD-pqEyQIWHbiCb1icPpxRYrWE,136416
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: scikit-build-core 0.11.5
2
+ Generator: scikit-build-core 0.11.6
3
3
  Root-Is-Purelib: false
4
4
  Tag: cp312-cp312-macosx_11_0_arm64
5
5