najaeda 0.1.8__cp311-cp311-macosx_11_0_arm64.whl → 0.1.9__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.
- najaeda/docs/.readthedocs.yaml +2 -7
- najaeda/docs/source/api.rst +2 -2
- najaeda/docs/source/conf.py +21 -4
- najaeda/docs/source/equipotential.rst +0 -5
- najaeda/docs/source/examples.rst.in +66 -0
- najaeda/docs/source/index.rst +3 -1
- najaeda/docs/source/instance.rst +4 -8
- najaeda/docs/source/introduction.rst +53 -0
- najaeda/docs/source/net.rst +6 -6
- najaeda/docs/source/preprocessor.py +73 -0
- najaeda/docs/source/term.rst +6 -6
- najaeda/docs/source/visitors.rst +13 -0
- najaeda/instance_visitor.py +12 -20
- najaeda/libnaja_snl_python.dylib +0 -0
- najaeda/netlist.py +409 -91
- najaeda/stats.py +1 -1
- {najaeda-0.1.8.dist-info → najaeda-0.1.9.dist-info}/METADATA +3 -3
- najaeda-0.1.9.dist-info/RECORD +27 -0
- najaeda/docs/Makefile +0 -20
- najaeda/docs/make.bat +0 -35
- najaeda-0.1.8.dist-info/RECORD +0 -25
- {najaeda-0.1.8.dist-info → najaeda-0.1.9.dist-info}/WHEEL +0 -0
- {najaeda-0.1.8.dist-info → najaeda-0.1.9.dist-info}/licenses/AUTHORS +0 -0
- {najaeda-0.1.8.dist-info → najaeda-0.1.9.dist-info}/licenses/LICENSE +0 -0
najaeda/netlist.py
CHANGED
|
@@ -7,10 +7,10 @@ import itertools
|
|
|
7
7
|
import time
|
|
8
8
|
import logging
|
|
9
9
|
import hashlib
|
|
10
|
-
# import json
|
|
11
|
-
from najaeda import snl
|
|
12
10
|
import struct
|
|
13
11
|
|
|
12
|
+
from najaeda import snl
|
|
13
|
+
|
|
14
14
|
|
|
15
15
|
def consistent_hash(obj):
|
|
16
16
|
def default_serializer(o):
|
|
@@ -23,15 +23,16 @@ def consistent_hash(obj):
|
|
|
23
23
|
|
|
24
24
|
def hash_value(value):
|
|
25
25
|
if isinstance(value, int):
|
|
26
|
-
return struct.pack(
|
|
26
|
+
return struct.pack("!q", value)
|
|
27
27
|
else:
|
|
28
28
|
raise TypeError(f"Unsupported type: {type(value)}")
|
|
29
29
|
|
|
30
30
|
def hash_object(o):
|
|
31
31
|
if isinstance(o, (list, tuple)):
|
|
32
|
-
return b
|
|
32
|
+
return b"".join(hash_object(i) for i in o)
|
|
33
33
|
else:
|
|
34
34
|
return hash_value(o)
|
|
35
|
+
|
|
35
36
|
serialized_obj = default_serializer(obj)
|
|
36
37
|
obj_bytes = hash_object(serialized_obj)
|
|
37
38
|
return int(hashlib.sha256(obj_bytes).hexdigest(), 16)
|
|
@@ -88,8 +89,7 @@ class Equipotential:
|
|
|
88
89
|
inst_term = term
|
|
89
90
|
path = get_snl_path_from_id_list(inst_term.pathIDs)
|
|
90
91
|
ito = snl.SNLNetComponentOccurrence(
|
|
91
|
-
path.getHeadPath(),
|
|
92
|
-
path.getTailInstance().getInstTerm(snl_term)
|
|
92
|
+
path.getHeadPath(), path.getTailInstance().getInstTerm(snl_term)
|
|
93
93
|
)
|
|
94
94
|
self.equi = snl.SNLEquipotential(ito)
|
|
95
95
|
|
|
@@ -97,9 +97,15 @@ class Equipotential:
|
|
|
97
97
|
return self.equi == value.equi
|
|
98
98
|
|
|
99
99
|
def dump_dot(self, path: str):
|
|
100
|
+
"""Dump the dot file of this equipotential."""
|
|
100
101
|
self.equi.dumpDotFile(path)
|
|
101
102
|
|
|
102
103
|
def get_inst_terms(self):
|
|
104
|
+
"""Iterate over the instance terminals of this equipotential.
|
|
105
|
+
|
|
106
|
+
:return: an iterator over the instance terminals of this equipotential.
|
|
107
|
+
:rtype: Iterator[Term]
|
|
108
|
+
"""
|
|
103
109
|
if self.equi is not None:
|
|
104
110
|
for term in self.equi.getInstTermOccurrences():
|
|
105
111
|
yield Term(
|
|
@@ -108,6 +114,11 @@ class Equipotential:
|
|
|
108
114
|
)
|
|
109
115
|
|
|
110
116
|
def get_top_terms(self):
|
|
117
|
+
"""Iterate over the top terminals of this equipotential.
|
|
118
|
+
|
|
119
|
+
:return: an iterator over the top terminals of this equipotential.
|
|
120
|
+
:rtype: Iterator[Term]
|
|
121
|
+
"""
|
|
111
122
|
if self.equi is not None:
|
|
112
123
|
for term in self.equi.getTerms():
|
|
113
124
|
yield Term([], term)
|
|
@@ -119,7 +130,9 @@ class Equipotential:
|
|
|
119
130
|
if direction != snl.SNLTerm.Direction.Output:
|
|
120
131
|
if term.getInstTerm().getInstance().getModel().isLeaf():
|
|
121
132
|
yield Term(
|
|
122
|
-
snl.SNLPath(
|
|
133
|
+
snl.SNLPath(
|
|
134
|
+
term.getPath(), term.getInstTerm().getInstance()
|
|
135
|
+
),
|
|
123
136
|
term.getInstTerm().getBitTerm(),
|
|
124
137
|
)
|
|
125
138
|
|
|
@@ -130,7 +143,9 @@ class Equipotential:
|
|
|
130
143
|
if direction != snl.SNLTerm.Direction.Input:
|
|
131
144
|
if term.getInstTerm().getInstance().getModel().isLeaf():
|
|
132
145
|
yield Term(
|
|
133
|
-
snl.SNLPath(
|
|
146
|
+
snl.SNLPath(
|
|
147
|
+
term.getPath(), term.getInstTerm().getInstance()
|
|
148
|
+
),
|
|
134
149
|
term.getInstTerm().getBitTerm(),
|
|
135
150
|
)
|
|
136
151
|
|
|
@@ -189,45 +204,72 @@ class Net:
|
|
|
189
204
|
return net_str
|
|
190
205
|
|
|
191
206
|
def get_name(self) -> str:
|
|
192
|
-
"""
|
|
207
|
+
"""
|
|
208
|
+
:return: the name of this Net.
|
|
209
|
+
:rtype: str
|
|
210
|
+
"""
|
|
193
211
|
if hasattr(self, "net"):
|
|
194
212
|
return self.net.getName()
|
|
195
213
|
return "{" + ",".join(map(str, self.net_concat)) + "}"
|
|
196
214
|
|
|
197
215
|
def get_msb(self) -> int:
|
|
198
|
-
"""
|
|
216
|
+
"""
|
|
217
|
+
:return: the most significant bit of the net if it is a bus.
|
|
218
|
+
:rtype: int
|
|
219
|
+
"""
|
|
199
220
|
if hasattr(self, "net") and isinstance(self.net, snl.SNLBusNet):
|
|
200
221
|
return self.net.getMSB()
|
|
201
222
|
return None
|
|
202
223
|
|
|
203
224
|
def get_lsb(self) -> int:
|
|
204
|
-
"""
|
|
225
|
+
"""
|
|
226
|
+
:return: the least significant bit of the net if it is a bus.
|
|
227
|
+
:rtype: int
|
|
228
|
+
"""
|
|
205
229
|
if hasattr(self, "net") and isinstance(self.net, snl.SNLBusNet):
|
|
206
230
|
return self.net.getLSB()
|
|
207
231
|
return None
|
|
208
232
|
|
|
209
233
|
def is_bus(self) -> bool:
|
|
210
|
-
"""
|
|
234
|
+
"""
|
|
235
|
+
:return: True if the net is a bus.
|
|
236
|
+
:rtype: bool
|
|
237
|
+
"""
|
|
211
238
|
return hasattr(self, "net") and isinstance(self.net, snl.SNLBusNet)
|
|
212
239
|
|
|
213
240
|
def is_bus_bit(self) -> bool:
|
|
214
|
-
"""
|
|
241
|
+
"""
|
|
242
|
+
:return: True if the net is a bit of a bus.
|
|
243
|
+
:rtype: bool
|
|
244
|
+
"""
|
|
215
245
|
return hasattr(self, "net") and isinstance(self.net, snl.SNLBusNetBit)
|
|
216
246
|
|
|
217
247
|
def is_scalar(self) -> bool:
|
|
218
|
-
"""
|
|
248
|
+
"""
|
|
249
|
+
:return: True if the net is a scalar.
|
|
250
|
+
:rtype: bool
|
|
251
|
+
"""
|
|
219
252
|
return hasattr(self, "net") and isinstance(self.net, snl.SNLScalarNet)
|
|
220
253
|
|
|
221
254
|
def is_bit(self) -> bool:
|
|
222
|
-
"""
|
|
255
|
+
"""
|
|
256
|
+
:return: True if the net is a bit.
|
|
257
|
+
:rtype: bool
|
|
258
|
+
"""
|
|
223
259
|
return self.is_scalar() or self.is_bus_bit()
|
|
224
260
|
|
|
225
261
|
def is_concat(self) -> bool:
|
|
226
|
-
"""
|
|
262
|
+
"""
|
|
263
|
+
:return: True if the net is a concatenation.
|
|
264
|
+
:rtype: bool
|
|
265
|
+
"""
|
|
227
266
|
return hasattr(self, "net_concat")
|
|
228
267
|
|
|
229
268
|
def is_const(self) -> bool:
|
|
230
|
-
"""
|
|
269
|
+
"""
|
|
270
|
+
:return: True if the net is a constant generator.
|
|
271
|
+
:rtype: bool
|
|
272
|
+
"""
|
|
231
273
|
if hasattr(self, "net"):
|
|
232
274
|
return self.net.isConstant()
|
|
233
275
|
for net in self.net_concat:
|
|
@@ -236,12 +278,20 @@ class Net:
|
|
|
236
278
|
return True
|
|
237
279
|
|
|
238
280
|
def get_width(self) -> int:
|
|
239
|
-
"""
|
|
281
|
+
"""
|
|
282
|
+
:return: the width of the net.
|
|
283
|
+
:rtype: int
|
|
284
|
+
"""
|
|
240
285
|
if hasattr(self, "net"):
|
|
241
286
|
return self.net.getWidth()
|
|
242
287
|
return sum(1 for _ in self.net_concat)
|
|
243
288
|
|
|
244
289
|
def get_bits(self):
|
|
290
|
+
"""Iterate over the bits of this Net.
|
|
291
|
+
The iterator will return itself if the Net is scalar.
|
|
292
|
+
:return: an iterator over the bits of this Net.
|
|
293
|
+
:rtype: Iterator[Net]
|
|
294
|
+
"""
|
|
245
295
|
if hasattr(self, "net"):
|
|
246
296
|
if isinstance(self.net, snl.SNLBusNet):
|
|
247
297
|
for bit in self.net.getBits():
|
|
@@ -253,6 +303,11 @@ class Net:
|
|
|
253
303
|
yield net
|
|
254
304
|
|
|
255
305
|
def get_bit(self, index: int):
|
|
306
|
+
"""
|
|
307
|
+
:param int index: the index of the bit to get.
|
|
308
|
+
:return: the Net bit at the given index or None if it does not exist.
|
|
309
|
+
:rtype: Net
|
|
310
|
+
"""
|
|
256
311
|
if hasattr(self, "net"):
|
|
257
312
|
if isinstance(self.net, snl.SNLBusNet):
|
|
258
313
|
return Net(self.pathIDs, self.net.getBit(index))
|
|
@@ -263,6 +318,10 @@ class Net:
|
|
|
263
318
|
return None
|
|
264
319
|
|
|
265
320
|
def get_inst_terms(self):
|
|
321
|
+
"""
|
|
322
|
+
:return: an iterator over the instance terminals of the net.
|
|
323
|
+
:rtype: Iterator[Term]
|
|
324
|
+
"""
|
|
266
325
|
if hasattr(self, "net_concat"):
|
|
267
326
|
raise ValueError("Cannot get inst terms from a net_concat")
|
|
268
327
|
for term in self.net.getInstTerms():
|
|
@@ -271,12 +330,20 @@ class Net:
|
|
|
271
330
|
yield Term(path, term.getBitTerm())
|
|
272
331
|
|
|
273
332
|
def get_design_terms(self):
|
|
333
|
+
"""
|
|
334
|
+
:return: an iterator over the design terminals of the net.
|
|
335
|
+
:rtype: Iterator[Term]
|
|
336
|
+
"""
|
|
274
337
|
if hasattr(self, "net_concat"):
|
|
275
338
|
raise ValueError("Cannot get terms from a net_concat")
|
|
276
339
|
for term in self.net.getBitTerms():
|
|
277
340
|
yield Term(self.pathIDs, term)
|
|
278
341
|
|
|
279
342
|
def get_terms(self):
|
|
343
|
+
"""
|
|
344
|
+
:return: an iterator over the terminals of the net.
|
|
345
|
+
:rtype: Iterator[Term]
|
|
346
|
+
"""
|
|
280
347
|
for term in itertools.chain(self.get_design_terms(), self.get_inst_terms()):
|
|
281
348
|
yield term
|
|
282
349
|
|
|
@@ -352,7 +419,9 @@ class Term:
|
|
|
352
419
|
if path.size() == 0:
|
|
353
420
|
return get_snl_term_for_ids(self.pathIDs, self.termIDs).getName()
|
|
354
421
|
else:
|
|
355
|
-
return
|
|
422
|
+
return (
|
|
423
|
+
f"{path}/{get_snl_term_for_ids(self.pathIDs, self.termIDs).getName()}"
|
|
424
|
+
)
|
|
356
425
|
|
|
357
426
|
def __repr__(self) -> str:
|
|
358
427
|
path = get_snl_path_from_id_list(self.pathIDs)
|
|
@@ -365,43 +434,76 @@ class Term:
|
|
|
365
434
|
snl.SNLUniquifier(path)
|
|
366
435
|
|
|
367
436
|
def is_bus(self) -> bool:
|
|
368
|
-
"""
|
|
369
|
-
return
|
|
437
|
+
"""
|
|
438
|
+
:return: True if the term is a bus.
|
|
439
|
+
:rtype: bool
|
|
440
|
+
"""
|
|
441
|
+
return isinstance(
|
|
442
|
+
get_snl_term_for_ids(self.pathIDs, self.termIDs), snl.SNLBusTerm
|
|
443
|
+
)
|
|
370
444
|
|
|
371
445
|
def is_bus_bit(self) -> bool:
|
|
372
|
-
"""
|
|
373
|
-
return
|
|
446
|
+
"""
|
|
447
|
+
:return: True if the term is a bit of a bus.
|
|
448
|
+
:rtype: bool
|
|
449
|
+
"""
|
|
450
|
+
return isinstance(
|
|
451
|
+
get_snl_term_for_ids(self.pathIDs, self.termIDs), snl.SNLBusTermBit
|
|
452
|
+
)
|
|
374
453
|
|
|
375
454
|
def is_scalar(self) -> bool:
|
|
376
|
-
"""
|
|
377
|
-
return
|
|
455
|
+
"""
|
|
456
|
+
:return: True if the term is a scalar.
|
|
457
|
+
:rtype: bool
|
|
458
|
+
"""
|
|
459
|
+
return isinstance(
|
|
460
|
+
get_snl_term_for_ids(self.pathIDs, self.termIDs), snl.SNLScalarTerm
|
|
461
|
+
)
|
|
378
462
|
|
|
379
463
|
def is_bit(self) -> bool:
|
|
380
|
-
"""
|
|
464
|
+
"""
|
|
465
|
+
:return: True if the term is a bit.
|
|
466
|
+
:rtype: bool
|
|
467
|
+
"""
|
|
381
468
|
return self.is_scalar() or self.is_bus_bit()
|
|
382
469
|
|
|
383
470
|
def get_msb(self) -> int:
|
|
384
|
-
"""
|
|
471
|
+
"""
|
|
472
|
+
:return: the most significant bit of the term if it is a bus.
|
|
473
|
+
:rtype: int or None
|
|
474
|
+
"""
|
|
385
475
|
if isinstance(get_snl_term_for_ids(self.pathIDs, self.termIDs), snl.SNLBusTerm):
|
|
386
476
|
return get_snl_term_for_ids(self.pathIDs, self.termIDs).getMSB()
|
|
387
477
|
return None
|
|
388
478
|
|
|
389
479
|
def get_lsb(self) -> int:
|
|
390
|
-
"""
|
|
480
|
+
"""
|
|
481
|
+
:return: the least significant bit of the term if it is a bus.
|
|
482
|
+
:rtype: int or None
|
|
483
|
+
"""
|
|
391
484
|
if isinstance(get_snl_term_for_ids(self.pathIDs, self.termIDs), snl.SNLBusTerm):
|
|
392
485
|
return get_snl_term_for_ids(self.pathIDs, self.termIDs).getLSB()
|
|
393
486
|
return None
|
|
394
487
|
|
|
395
488
|
def get_width(self) -> int:
|
|
396
|
-
"""
|
|
489
|
+
"""
|
|
490
|
+
:return: the width of the term. 1 if scalar.
|
|
491
|
+
:rtype: int
|
|
492
|
+
"""
|
|
397
493
|
return get_snl_term_for_ids(self.pathIDs, self.termIDs).getWidth()
|
|
398
494
|
|
|
399
495
|
def get_name(self) -> str:
|
|
400
|
-
"""
|
|
496
|
+
"""
|
|
497
|
+
:return: the name of the term.
|
|
498
|
+
:rtype: str
|
|
499
|
+
"""
|
|
401
500
|
return get_snl_term_for_ids(self.pathIDs, self.termIDs).getName()
|
|
402
501
|
|
|
403
502
|
def get_direction(self) -> snl.SNLTerm.Direction:
|
|
404
|
-
"""
|
|
503
|
+
"""
|
|
504
|
+
:return: the direction of the term.
|
|
505
|
+
:rtype: snl.SNLTerm.Direction
|
|
506
|
+
"""
|
|
405
507
|
snlterm = get_snl_term_for_ids(self.pathIDs, self.termIDs)
|
|
406
508
|
if snlterm.getDirection() == snl.SNLTerm.Direction.Input:
|
|
407
509
|
return Term.INPUT
|
|
@@ -454,17 +556,25 @@ class Term:
|
|
|
454
556
|
if all(element is not None for element in snl_nets):
|
|
455
557
|
return Net(path, net_concat=snl_nets)
|
|
456
558
|
else:
|
|
457
|
-
snl_net = snl_term_net_accessor(
|
|
559
|
+
snl_net = snl_term_net_accessor(
|
|
560
|
+
get_snl_term_for_ids(self.pathIDs, self.termIDs)
|
|
561
|
+
)
|
|
458
562
|
if snl_net is not None:
|
|
459
563
|
return Net(path, snl_net)
|
|
460
564
|
return None
|
|
461
565
|
|
|
462
566
|
def get_lower_net(self) -> Net:
|
|
463
|
-
"""
|
|
567
|
+
"""
|
|
568
|
+
:return: the lower net of the term.
|
|
569
|
+
:rtype: Net
|
|
570
|
+
"""
|
|
464
571
|
return self.__get_net(self.pathIDs, self.__get_snl_lower_bitnet)
|
|
465
572
|
|
|
466
573
|
def get_net(self) -> Net:
|
|
467
|
-
"""
|
|
574
|
+
"""
|
|
575
|
+
:return: the net of the term.
|
|
576
|
+
:rtype: Net
|
|
577
|
+
"""
|
|
468
578
|
head_path = self.pathIDs.copy()
|
|
469
579
|
if len(head_path) == 0:
|
|
470
580
|
return None
|
|
@@ -473,7 +583,10 @@ class Term:
|
|
|
473
583
|
return self.__get_net(head_path, self.__get_snl_bitnet)
|
|
474
584
|
|
|
475
585
|
def get_instance(self):
|
|
476
|
-
"""
|
|
586
|
+
"""
|
|
587
|
+
:return: the instance of this Term.
|
|
588
|
+
:rtype: Instance
|
|
589
|
+
"""
|
|
477
590
|
return Instance(self.pathIDs)
|
|
478
591
|
|
|
479
592
|
def get_flat_fanout(self):
|
|
@@ -483,16 +596,27 @@ class Term:
|
|
|
483
596
|
return Equipotential(self)
|
|
484
597
|
|
|
485
598
|
def is_input(self) -> bool:
|
|
486
|
-
"""
|
|
599
|
+
"""
|
|
600
|
+
:return: True if the term is an input.
|
|
601
|
+
:rtype: bool
|
|
602
|
+
"""
|
|
487
603
|
snlterm = get_snl_term_for_ids(self.pathIDs, self.termIDs)
|
|
488
604
|
return snlterm.getDirection() == snl.SNLTerm.Direction.Input
|
|
489
605
|
|
|
490
606
|
def is_output(self) -> bool:
|
|
491
|
-
"""
|
|
607
|
+
"""
|
|
608
|
+
:return: True if the term is an output.
|
|
609
|
+
:rtype: bool
|
|
610
|
+
"""
|
|
492
611
|
snlterm = get_snl_term_for_ids(self.pathIDs, self.termIDs)
|
|
493
612
|
return snlterm.getDirection() == snl.SNLTerm.Direction.Output
|
|
494
613
|
|
|
495
614
|
def get_bits(self):
|
|
615
|
+
"""
|
|
616
|
+
:return: an iterator over the bits of the term.
|
|
617
|
+
If the term is scalar, it will return an iterator over itself.
|
|
618
|
+
:rtype: Iterator[Term]
|
|
619
|
+
"""
|
|
496
620
|
if isinstance(get_snl_term_for_ids(self.pathIDs, self.termIDs), snl.SNLBusTerm):
|
|
497
621
|
for bit in get_snl_term_for_ids(self.pathIDs, self.termIDs).getBits():
|
|
498
622
|
yield Term(self.pathIDs, bit)
|
|
@@ -500,12 +624,20 @@ class Term:
|
|
|
500
624
|
yield self
|
|
501
625
|
|
|
502
626
|
def get_bit(self, index: int):
|
|
627
|
+
"""
|
|
628
|
+
:param int index: the index of the bit to get.
|
|
629
|
+
:return: the Term bit at the given index or None if it does not exist.
|
|
630
|
+
:rtype: Term or None
|
|
631
|
+
"""
|
|
503
632
|
if isinstance(get_snl_term_for_ids(self.pathIDs, self.termIDs), snl.SNLBusTerm):
|
|
504
|
-
return Term(
|
|
505
|
-
|
|
633
|
+
return Term(
|
|
634
|
+
self.pathIDs,
|
|
635
|
+
get_snl_term_for_ids(self.pathIDs, self.termIDs).getBit(index),
|
|
636
|
+
)
|
|
506
637
|
return None
|
|
507
638
|
|
|
508
639
|
def disconnect(self):
|
|
640
|
+
"""Disconnect this term from its net."""
|
|
509
641
|
path = get_snl_path_from_id_list(self.pathIDs)
|
|
510
642
|
self.__make_unique()
|
|
511
643
|
inst = path.getTailInstance()
|
|
@@ -514,21 +646,27 @@ class Term:
|
|
|
514
646
|
iterm.setNet(None)
|
|
515
647
|
|
|
516
648
|
def connect(self, net: Net):
|
|
649
|
+
"""Connect this term to the given Net.
|
|
650
|
+
|
|
651
|
+
:param Net net: the Net to connect to.
|
|
652
|
+
"""
|
|
517
653
|
if self.get_width() != net.get_width():
|
|
518
654
|
raise ValueError("Width mismatch")
|
|
519
655
|
if self.get_instance().is_top():
|
|
520
|
-
for bterm, bnet in zip(
|
|
521
|
-
|
|
522
|
-
|
|
656
|
+
for bterm, bnet in zip(
|
|
657
|
+
get_snl_term_for_ids(self.pathIDs, self.termIDs).getBits(),
|
|
658
|
+
net.net.getBits(),
|
|
659
|
+
):
|
|
523
660
|
logging.debug(f"Connecting {bterm} to {bnet}")
|
|
524
661
|
bterm.setNet(bnet)
|
|
525
662
|
else:
|
|
526
663
|
self.__make_unique()
|
|
527
664
|
path = get_snl_path_from_id_list(self.pathIDs)
|
|
528
665
|
inst = path.getTailInstance()
|
|
529
|
-
for bterm, bnet in zip(
|
|
530
|
-
|
|
531
|
-
|
|
666
|
+
for bterm, bnet in zip(
|
|
667
|
+
get_snl_term_for_ids(self.pathIDs, self.termIDs).getBits(),
|
|
668
|
+
net.net.getBits(),
|
|
669
|
+
):
|
|
532
670
|
iterm = inst.getInstTerm(bterm)
|
|
533
671
|
iterm.setNet(bnet)
|
|
534
672
|
|
|
@@ -598,6 +736,11 @@ class Instance:
|
|
|
598
736
|
return consistent_hash(self.pathIDs)
|
|
599
737
|
|
|
600
738
|
def get_leaf_children(self):
|
|
739
|
+
"""Iterate over the leaf children of this Instance.
|
|
740
|
+
Equivalent to the underlying leaves of the instanciation tree.
|
|
741
|
+
:return: an iterator over the leaf children Instance of this Instance.
|
|
742
|
+
:rtype: Iterator[Instance]
|
|
743
|
+
"""
|
|
601
744
|
initial_path = get_snl_path_from_id_list(self.pathIDs)
|
|
602
745
|
for inst in self.__get_snl_model().getInstances():
|
|
603
746
|
if inst.getModel().isLeaf():
|
|
@@ -615,42 +758,72 @@ class Instance:
|
|
|
615
758
|
stack.append([inst_child, path_child])
|
|
616
759
|
|
|
617
760
|
def is_top(self) -> bool:
|
|
618
|
-
"""
|
|
761
|
+
"""
|
|
762
|
+
:return: True if this is the top design.
|
|
763
|
+
:rtype: bool
|
|
764
|
+
"""
|
|
619
765
|
return len(self.pathIDs) == 0
|
|
620
766
|
|
|
621
767
|
def is_assign(self) -> bool:
|
|
768
|
+
"""Example: (assign a=b) will create an instance of assign connecting
|
|
769
|
+
the wire a to the output of the assign and b to the input.
|
|
770
|
+
|
|
771
|
+
:return: True if this is an assign. Assigns are represented with
|
|
772
|
+
anonymous Assign instances.
|
|
773
|
+
:rtype: bool
|
|
774
|
+
"""
|
|
622
775
|
return self.__get_snl_model().isAssign()
|
|
623
776
|
|
|
624
777
|
def is_blackbox(self) -> bool:
|
|
625
|
-
"""
|
|
778
|
+
"""
|
|
779
|
+
:return: True if this is a blackbox.
|
|
780
|
+
:rtype: bool
|
|
781
|
+
"""
|
|
626
782
|
return self.__get_snl_model().isBlackBox()
|
|
627
783
|
|
|
628
784
|
def is_leaf(self) -> bool:
|
|
629
|
-
"""
|
|
785
|
+
"""
|
|
786
|
+
:return: True if this is a leaf.
|
|
787
|
+
:rtype: bool
|
|
788
|
+
"""
|
|
630
789
|
return self.__get_snl_model().isLeaf()
|
|
631
790
|
|
|
632
791
|
def is_const0(self) -> bool:
|
|
633
|
-
"""
|
|
792
|
+
"""
|
|
793
|
+
:return: True if this is a constant 0 generator.
|
|
794
|
+
:rtype: bool
|
|
795
|
+
"""
|
|
634
796
|
return self.__get_snl_model().isConst0()
|
|
635
797
|
|
|
636
798
|
def is_const1(self) -> bool:
|
|
637
|
-
"""
|
|
799
|
+
"""
|
|
800
|
+
:return: True if this is a constant 1 generator.
|
|
801
|
+
:rtype: bool
|
|
802
|
+
"""
|
|
638
803
|
return self.__get_snl_model().isConst1()
|
|
639
804
|
|
|
640
805
|
def is_const(self) -> bool:
|
|
641
|
-
"""
|
|
806
|
+
"""
|
|
807
|
+
:return: True if this is a constant generator.
|
|
808
|
+
:rtype: bool
|
|
809
|
+
"""
|
|
642
810
|
return self.__get_snl_model().isConst()
|
|
643
811
|
|
|
644
812
|
def is_buf(self) -> bool:
|
|
645
|
-
"""
|
|
813
|
+
"""
|
|
814
|
+
:return: True if this is a buffer.
|
|
815
|
+
:rtype: bool
|
|
816
|
+
"""
|
|
646
817
|
return self.__get_snl_model().isBuf()
|
|
647
818
|
|
|
648
819
|
def is_inv(self) -> bool:
|
|
649
|
-
"""
|
|
820
|
+
"""
|
|
821
|
+
:return: True if this is an inverter.
|
|
822
|
+
:rtype: bool
|
|
823
|
+
"""
|
|
650
824
|
return self.__get_snl_model().isInv()
|
|
651
825
|
|
|
652
826
|
def __get_snl_model(self):
|
|
653
|
-
"""Return the model of the instance."""
|
|
654
827
|
if self.is_top():
|
|
655
828
|
return snl.SNLUniverse.get().getTopDesign()
|
|
656
829
|
instance = get_snl_instance_from_id_list(self.pathIDs)
|
|
@@ -673,7 +846,11 @@ class Instance:
|
|
|
673
846
|
self.__get_snl_model().dumpContextDotFile(path)
|
|
674
847
|
|
|
675
848
|
def get_child_instance(self, name: str):
|
|
676
|
-
"""
|
|
849
|
+
"""
|
|
850
|
+
:param str name: the name of the child Instance to get.
|
|
851
|
+
:return: the child Instance with the given name or None if it does not exist.
|
|
852
|
+
:rtype: Instance or None
|
|
853
|
+
"""
|
|
677
854
|
childInst = self.__get_snl_model().getInstance(name)
|
|
678
855
|
if childInst is None:
|
|
679
856
|
return None
|
|
@@ -682,12 +859,22 @@ class Instance:
|
|
|
682
859
|
return Instance(path)
|
|
683
860
|
|
|
684
861
|
def get_child_instances(self):
|
|
862
|
+
"""Iterate over the child instances of this instance.
|
|
863
|
+
Equivalent to go down one level in hierarchy.
|
|
864
|
+
|
|
865
|
+
:return: an iterator over the child instances of this instance.
|
|
866
|
+
:rtype: Iterator[Instance]
|
|
867
|
+
"""
|
|
685
868
|
for inst in self.__get_snl_model().getInstances():
|
|
686
869
|
path = self.pathIDs.copy()
|
|
687
870
|
path.append(inst.getID())
|
|
688
871
|
yield Instance(path)
|
|
689
872
|
|
|
690
873
|
def get_number_of_child_instances(self) -> int:
|
|
874
|
+
"""
|
|
875
|
+
:return: the number of child instances of this instance.
|
|
876
|
+
:rtype: int
|
|
877
|
+
"""
|
|
691
878
|
return sum(1 for _ in self.__get_snl_model().getInstances())
|
|
692
879
|
|
|
693
880
|
# def get_flat_primitive_instances(self):
|
|
@@ -707,15 +894,19 @@ class Instance:
|
|
|
707
894
|
# stack.append([inst_child, path_child])
|
|
708
895
|
|
|
709
896
|
def get_nets(self):
|
|
710
|
-
"""
|
|
711
|
-
|
|
897
|
+
"""Iterate over all scalar nets and bus nets.
|
|
898
|
+
|
|
899
|
+
:return: an iterator over the nets of this Instance.
|
|
900
|
+
:rtype: Iterator[Net]
|
|
712
901
|
"""
|
|
713
902
|
for net in self.__get_snl_model().getNets():
|
|
714
903
|
yield Net(self.pathIDs, net)
|
|
715
904
|
|
|
716
905
|
def get_flat_nets(self):
|
|
717
|
-
"""
|
|
718
|
-
|
|
906
|
+
"""Iterate over all scalar nets and bus net bits.
|
|
907
|
+
|
|
908
|
+
:return: an iterator over the flat nets of this Instance.
|
|
909
|
+
:rtype: Iterator[Net]
|
|
719
910
|
"""
|
|
720
911
|
for net in self.__get_snl_model().getNets():
|
|
721
912
|
if isinstance(net, snl.SNLBusNet):
|
|
@@ -725,48 +916,69 @@ class Instance:
|
|
|
725
916
|
yield Net(self.pathIDs, net)
|
|
726
917
|
|
|
727
918
|
def get_net(self, name: str) -> Net:
|
|
728
|
-
"""
|
|
919
|
+
"""
|
|
920
|
+
:param str name: the name of the Net to get.
|
|
921
|
+
:return: the Net with the given name or None if it does not exist.
|
|
922
|
+
:rtype: Net or None
|
|
923
|
+
"""
|
|
729
924
|
net = self.__get_snl_model().getNet(name)
|
|
730
925
|
if net is not None:
|
|
731
926
|
return Net(self.pathIDs, net)
|
|
732
927
|
return None
|
|
733
928
|
|
|
734
929
|
def is_primitive(self) -> bool:
|
|
735
|
-
"""
|
|
930
|
+
"""
|
|
931
|
+
:return: True if this is a primitive.
|
|
932
|
+
:rtype: bool
|
|
933
|
+
"""
|
|
736
934
|
return self.__get_snl_model().isPrimitive()
|
|
737
935
|
|
|
738
936
|
def get_terms(self):
|
|
739
|
-
"""
|
|
740
|
-
|
|
937
|
+
"""Iterate over all scalar terms and bus terms of this Instance.
|
|
938
|
+
|
|
939
|
+
:return: the terms of this Instance.
|
|
940
|
+
:rtype: Iterator[Term]
|
|
741
941
|
"""
|
|
742
942
|
for term in self.__get_snl_model().getTerms():
|
|
743
943
|
yield Term(self.pathIDs, term)
|
|
744
944
|
|
|
745
945
|
def get_flat_terms(self):
|
|
746
|
-
"""
|
|
747
|
-
|
|
946
|
+
"""Iterate over all scalar terms and bus term bits.
|
|
947
|
+
|
|
948
|
+
:return: the flat terms of this Instance.
|
|
949
|
+
:rtype: Iterator[Term]
|
|
748
950
|
"""
|
|
749
951
|
for term in self.__get_snl_model().getBitTerms():
|
|
750
952
|
yield Term(self.pathIDs, term)
|
|
751
953
|
|
|
752
954
|
def get_term(self, name: str) -> Term:
|
|
753
|
-
"""
|
|
955
|
+
"""
|
|
956
|
+
:param str name: the name of the Term to get.
|
|
957
|
+
:return: the Term with the given name.
|
|
958
|
+
:rtype: Term or None
|
|
959
|
+
"""
|
|
754
960
|
term = self.__get_snl_model().getTerm(name)
|
|
755
961
|
if term is not None:
|
|
756
962
|
return Term(self.pathIDs, self.__get_snl_model().getTerm(name))
|
|
757
963
|
return None
|
|
758
964
|
|
|
759
965
|
def get_input_terms(self):
|
|
760
|
-
"""
|
|
761
|
-
|
|
966
|
+
"""Iterate over all scalar input terms and bus input terms
|
|
967
|
+
of this Instance.
|
|
968
|
+
|
|
969
|
+
:return: the input terms of this Instance.
|
|
970
|
+
:rtype: Iterator[Term]
|
|
762
971
|
"""
|
|
763
972
|
for term in self.__get_snl_model().getTerms():
|
|
764
973
|
if term.getDirection() != snl.SNLTerm.Direction.Output:
|
|
765
974
|
yield Term(self.pathIDs, term)
|
|
766
975
|
|
|
767
976
|
def get_flat_input_terms(self):
|
|
768
|
-
"""
|
|
769
|
-
|
|
977
|
+
"""Iterate over all scalar input terms and bus input term bits
|
|
978
|
+
of this Instance.
|
|
979
|
+
|
|
980
|
+
:return: the flat input terms of this Instance.
|
|
981
|
+
:rtype: Iterator[Term]
|
|
770
982
|
"""
|
|
771
983
|
for term in self.__get_snl_model().getTerms():
|
|
772
984
|
if term.getDirection() != snl.SNLTerm.Direction.Output:
|
|
@@ -777,8 +989,11 @@ class Instance:
|
|
|
777
989
|
yield Term(self.pathIDs, term)
|
|
778
990
|
|
|
779
991
|
def get_output_terms(self):
|
|
780
|
-
"""
|
|
781
|
-
|
|
992
|
+
"""Iterate over all scalar output terms and bus output terms
|
|
993
|
+
of this Instance.
|
|
994
|
+
|
|
995
|
+
:return: the output terms of this Instance.
|
|
996
|
+
:rtype: Iterator[Term]
|
|
782
997
|
"""
|
|
783
998
|
for term in self.__get_snl_model().getTerms():
|
|
784
999
|
if term.getDirection() != snl.SNLTerm.Direction.Input:
|
|
@@ -810,7 +1025,10 @@ class Instance:
|
|
|
810
1025
|
self.__get_snl_model().getInstance(name).destroy()
|
|
811
1026
|
|
|
812
1027
|
def delete_instance_by_id(self, id: str):
|
|
813
|
-
"""Delete the child instance with the given ID.
|
|
1028
|
+
"""Delete the child instance with the given ID.
|
|
1029
|
+
|
|
1030
|
+
:param str id: the ID of the Instance to delete.
|
|
1031
|
+
"""
|
|
814
1032
|
init_path = get_snl_path_from_id_list(self.pathIDs)
|
|
815
1033
|
path = snl.SNLPath(init_path, self.__get_snl_model().getInstanceByID(id))
|
|
816
1034
|
snl.SNLUniquifier(path)
|
|
@@ -818,7 +1036,10 @@ class Instance:
|
|
|
818
1036
|
self.__get_snl_model().getInstanceByID(id).destroy()
|
|
819
1037
|
|
|
820
1038
|
def get_design(self):
|
|
821
|
-
"""
|
|
1039
|
+
"""
|
|
1040
|
+
:return: the Instance containing this instance.
|
|
1041
|
+
:rtype: Instance
|
|
1042
|
+
"""
|
|
822
1043
|
path = self.pathIDs.copy()
|
|
823
1044
|
if len(self.pathIDs) == 1:
|
|
824
1045
|
return get_top()
|
|
@@ -832,7 +1053,10 @@ class Instance:
|
|
|
832
1053
|
self.get_design().delete_instance_by_id(path.getTailInstance().getID())
|
|
833
1054
|
|
|
834
1055
|
def get_name(self) -> str:
|
|
835
|
-
"""
|
|
1056
|
+
"""
|
|
1057
|
+
:return: the name of the instance or name of the top is this is the top.
|
|
1058
|
+
:rtype: str
|
|
1059
|
+
"""
|
|
836
1060
|
path = get_snl_path_from_id_list(self.pathIDs)
|
|
837
1061
|
if self.is_top():
|
|
838
1062
|
return self.get_model_name()
|
|
@@ -840,16 +1064,29 @@ class Instance:
|
|
|
840
1064
|
return path.getTailInstance().getName()
|
|
841
1065
|
|
|
842
1066
|
def get_model_name(self) -> str:
|
|
843
|
-
"""
|
|
1067
|
+
"""
|
|
1068
|
+
:return: the name of the model of the instance
|
|
1069
|
+
or name of the top is this is the top.
|
|
1070
|
+
:rtype: str
|
|
1071
|
+
"""
|
|
844
1072
|
return self.__get_snl_model().getName()
|
|
845
1073
|
|
|
846
1074
|
def get_model_id(self) -> tuple[int, int, int]:
|
|
847
|
-
"""
|
|
1075
|
+
"""
|
|
1076
|
+
:return: the ID of the model of this Instance
|
|
1077
|
+
or ID of the top if this is the top.
|
|
1078
|
+
"""
|
|
848
1079
|
model = self.__get_snl_model()
|
|
849
1080
|
return model.getDB().getID(), model.getLibrary().getID(), model.getID()
|
|
850
1081
|
|
|
851
1082
|
def create_child_instance(self, model: str, name: str):
|
|
852
|
-
"""Create a child instance with the given model and name.
|
|
1083
|
+
"""Create a child instance with the given model and name.
|
|
1084
|
+
|
|
1085
|
+
:param str model: the name of the model of the instance to create.
|
|
1086
|
+
:param str name: the name of the instance to create.
|
|
1087
|
+
:return: the created Instance.
|
|
1088
|
+
:rtype: Instance
|
|
1089
|
+
"""
|
|
853
1090
|
path = get_snl_path_from_id_list(self.pathIDs)
|
|
854
1091
|
if path.size() > 0:
|
|
855
1092
|
snl.SNLUniquifier(path)
|
|
@@ -865,7 +1102,12 @@ class Instance:
|
|
|
865
1102
|
return Instance(path)
|
|
866
1103
|
|
|
867
1104
|
def create_term(self, name: str, direction: snl.SNLTerm.Direction) -> Term:
|
|
868
|
-
"""Create a Term
|
|
1105
|
+
"""Create a Term in this Instance with the given name and direction.
|
|
1106
|
+
|
|
1107
|
+
:param str name: the name of the Term to create.
|
|
1108
|
+
:param snl.SNLTerm.Direction direction: the direction of the Term to create.
|
|
1109
|
+
:return: the created Term.
|
|
1110
|
+
"""
|
|
869
1111
|
path = get_snl_path_from_id_list(self.pathIDs)
|
|
870
1112
|
if path.size() > 0:
|
|
871
1113
|
snl.SNLUniquifier(path)
|
|
@@ -875,19 +1117,40 @@ class Instance:
|
|
|
875
1117
|
return Term(path, newSNLTerm)
|
|
876
1118
|
|
|
877
1119
|
def create_output_term(self, name: str) -> Term:
|
|
878
|
-
"""Create an output Term in this Instance with the given name.
|
|
1120
|
+
"""Create an output Term in this Instance with the given name.
|
|
1121
|
+
|
|
1122
|
+
:param str name: the name of the Term to create.
|
|
1123
|
+
:return: the created Term.
|
|
1124
|
+
:rtype: Term
|
|
1125
|
+
"""
|
|
879
1126
|
return self.create_term(name, snl.SNLTerm.Direction.Output)
|
|
880
1127
|
|
|
881
1128
|
def create_input_term(self, name: str) -> Term:
|
|
882
|
-
"""Create an input Term in this Instance with the given name.
|
|
1129
|
+
"""Create an input Term in this Instance with the given name.
|
|
1130
|
+
|
|
1131
|
+
:param str name: the name of the Term to create.
|
|
1132
|
+
:return: the created Term.
|
|
1133
|
+
:rtype: Term
|
|
1134
|
+
"""
|
|
883
1135
|
return self.create_term(name, snl.SNLTerm.Direction.Input)
|
|
884
1136
|
|
|
885
1137
|
def create_inout_term(self, name: str) -> Term:
|
|
886
|
-
"""Create an inout Term in this Instance with the given name.
|
|
1138
|
+
"""Create an inout Term in this Instance with the given name.
|
|
1139
|
+
|
|
1140
|
+
:param str name: the name of the Term to create.
|
|
1141
|
+
:return: the created Term.
|
|
1142
|
+
:rtype: Term
|
|
1143
|
+
"""
|
|
887
1144
|
return self.create_term(name, snl.SNLTerm.Direction.InOut)
|
|
888
1145
|
|
|
889
1146
|
def create_bus_term(self, name: str, msb: int, lsb: int, direction) -> Term:
|
|
890
|
-
"""Create a bus Term in this Instance with the given name, msb, lsb and direction.
|
|
1147
|
+
"""Create a bus Term in this Instance with the given name, msb, lsb and direction.
|
|
1148
|
+
:param str name: the name of the Term to create.
|
|
1149
|
+
:param int msb: the most significant bit of the Term to create.
|
|
1150
|
+
:param int lsb: the least significant bit of the Term to create.
|
|
1151
|
+
:param snl.SNLTerm.Direction direction: the direction of the Term to create.
|
|
1152
|
+
:return: the created Term.
|
|
1153
|
+
"""
|
|
891
1154
|
path = get_snl_path_from_id_list(self.pathIDs)
|
|
892
1155
|
if path.size() > 0:
|
|
893
1156
|
snl.SNLUniquifier(path)
|
|
@@ -897,19 +1160,45 @@ class Instance:
|
|
|
897
1160
|
return Term(path, newSNLTerm)
|
|
898
1161
|
|
|
899
1162
|
def create_inout_bus_term(self, name: str, msb: int, lsb: int) -> Term:
|
|
900
|
-
"""Create an inout bus Term in this Instance with the given name, msb and lsb.
|
|
1163
|
+
"""Create an inout bus Term in this Instance with the given name, msb and lsb.
|
|
1164
|
+
|
|
1165
|
+
:param str name: the name of the Term to create.
|
|
1166
|
+
:param int msb: the most significant bit of the Term to create.
|
|
1167
|
+
:param int lsb: the least significant bit of the Term to create.
|
|
1168
|
+
:return: the created Term.
|
|
1169
|
+
:rtype: Term
|
|
1170
|
+
"""
|
|
901
1171
|
return self.create_bus_term(name, msb, lsb, snl.SNLTerm.Direction.InOut)
|
|
902
1172
|
|
|
903
1173
|
def create_output_bus_term(self, name: str, msb: int, lsb: int) -> Term:
|
|
904
|
-
"""Create an output bus Term in this Instance with the given name, msb and lsb.
|
|
1174
|
+
"""Create an output bus Term in this Instance with the given name, msb and lsb.
|
|
1175
|
+
|
|
1176
|
+
:param str name: the name of the Term to create.
|
|
1177
|
+
:param int msb: the most significant bit of the Term to create.
|
|
1178
|
+
:param int lsb: the least significant bit of the Term to create.
|
|
1179
|
+
:return: the created Term.
|
|
1180
|
+
:rtype: Term
|
|
1181
|
+
"""
|
|
905
1182
|
return self.create_bus_term(name, msb, lsb, snl.SNLTerm.Direction.Output)
|
|
906
1183
|
|
|
907
1184
|
def create_input_bus_term(self, name: str, msb: int, lsb: int) -> Term:
|
|
908
|
-
"""Create an input bus Term in this Instance with the given name, msb and lsb.
|
|
1185
|
+
"""Create an input bus Term in this Instance with the given name, msb and lsb.
|
|
1186
|
+
|
|
1187
|
+
:param str name: the name of the Term to create.
|
|
1188
|
+
:param int msb: the most significant bit of the Term to create.
|
|
1189
|
+
:param int lsb: the least significant bit of the Term to create.
|
|
1190
|
+
:return: the created Term.
|
|
1191
|
+
:rtype: Term
|
|
1192
|
+
"""
|
|
909
1193
|
return self.create_bus_term(name, msb, lsb, snl.SNLTerm.Direction.Input)
|
|
910
1194
|
|
|
911
1195
|
def create_net(self, name: str) -> Net:
|
|
912
|
-
"""Create a scalar Net in this Instance with the given name.
|
|
1196
|
+
"""Create a scalar Net in this Instance with the given name.
|
|
1197
|
+
|
|
1198
|
+
:param str name: the name of the Net to create.
|
|
1199
|
+
:return: the created Net.
|
|
1200
|
+
:rtype: Net
|
|
1201
|
+
"""
|
|
913
1202
|
path = get_snl_path_from_id_list(self.pathIDs)
|
|
914
1203
|
if path.size() > 0:
|
|
915
1204
|
snl.SNLUniquifier(path)
|
|
@@ -919,7 +1208,14 @@ class Instance:
|
|
|
919
1208
|
return Net(path, newSNLNet)
|
|
920
1209
|
|
|
921
1210
|
def create_bus_net(self, name: str, msb: int, lsb: int) -> Net:
|
|
922
|
-
"""Create a bus Net in this Instance with the given name, msb and lsb.
|
|
1211
|
+
"""Create a bus Net in this Instance with the given name, msb and lsb.
|
|
1212
|
+
|
|
1213
|
+
:param str name: the name of the Net to create.
|
|
1214
|
+
:param int msb: the most significant bit of the Net to create.
|
|
1215
|
+
:param int lsb: the least significant bit of the Net to create.
|
|
1216
|
+
:return: the created Net.
|
|
1217
|
+
:rtype: Net
|
|
1218
|
+
"""
|
|
923
1219
|
path = get_snl_path_from_id_list(self.pathIDs)
|
|
924
1220
|
if path.size() > 0:
|
|
925
1221
|
snl.SNLUniquifier(path)
|
|
@@ -929,7 +1225,11 @@ class Instance:
|
|
|
929
1225
|
return Net(path, newSNLNet)
|
|
930
1226
|
|
|
931
1227
|
def dump_verilog(self, path: str, name: str):
|
|
932
|
-
"""Dump the verilog of this instance.
|
|
1228
|
+
"""Dump the verilog of this instance.
|
|
1229
|
+
|
|
1230
|
+
:param str path: the path where to dump the verilog.
|
|
1231
|
+
:param str name: the name of the verilog file.
|
|
1232
|
+
"""
|
|
933
1233
|
self.__get_snl_model().dumpVerilog(path, name)
|
|
934
1234
|
|
|
935
1235
|
|
|
@@ -943,10 +1243,20 @@ def get_top_db() -> snl.SNLDB:
|
|
|
943
1243
|
|
|
944
1244
|
|
|
945
1245
|
def get_top():
|
|
1246
|
+
"""
|
|
1247
|
+
:return: the top Instance.
|
|
1248
|
+
:rtype: Instance
|
|
1249
|
+
"""
|
|
946
1250
|
return Instance(snl.SNLPath())
|
|
947
1251
|
|
|
948
1252
|
|
|
949
1253
|
def create_top(name: str) -> Instance:
|
|
1254
|
+
"""Create a top instance with the given name.
|
|
1255
|
+
|
|
1256
|
+
:param str name: the name of the top instance to create.
|
|
1257
|
+
:return: the created top Instance.
|
|
1258
|
+
:rtype: Instance
|
|
1259
|
+
"""
|
|
950
1260
|
# init
|
|
951
1261
|
db = get_top_db()
|
|
952
1262
|
# create top design
|
|
@@ -966,11 +1276,15 @@ def load_verilog(files: list):
|
|
|
966
1276
|
|
|
967
1277
|
|
|
968
1278
|
def load_liberty(files: list):
|
|
969
|
-
logging.info(f"Loading liberty: {', '.join(files)}")
|
|
1279
|
+
logging.info(f"Loading liberty files: {', '.join(files)}")
|
|
970
1280
|
get_top_db().loadLibertyPrimitives(files)
|
|
971
1281
|
|
|
972
1282
|
|
|
973
1283
|
def load_primitives(name: str):
|
|
1284
|
+
"""Loads a primitive library embedded in najaeda.
|
|
1285
|
+
Currently supported libraries are:
|
|
1286
|
+
- xilinx
|
|
1287
|
+
"""
|
|
974
1288
|
if name == "xilinx":
|
|
975
1289
|
logging.info("Loading xilinx primitives")
|
|
976
1290
|
from najaeda.primitives import xilinx
|
|
@@ -988,7 +1302,11 @@ def get_primitives_library() -> snl.SNLLibrary:
|
|
|
988
1302
|
|
|
989
1303
|
|
|
990
1304
|
def get_model_name(id: tuple[int, int, int]) -> str:
|
|
991
|
-
"""
|
|
1305
|
+
"""
|
|
1306
|
+
:param tuple[int, int, int] id: the id of the model.
|
|
1307
|
+
:return: the name of the model given its id or None if it does not exist.
|
|
1308
|
+
:rtype: str or None
|
|
1309
|
+
"""
|
|
992
1310
|
u = snl.SNLUniverse.get()
|
|
993
1311
|
if u:
|
|
994
1312
|
db = u.getDB(id[0])
|