najaeda 0.1.2__cp313-cp313t-macosx_11_0_arm64.whl → 0.1.4__cp313-cp313t-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/netlist.py CHANGED
@@ -4,6 +4,9 @@
4
4
  # SPDX-License-Identifier: Apache-2.0
5
5
 
6
6
  import itertools
7
+ import time
8
+ import logging
9
+
7
10
  from najaeda import snl
8
11
 
9
12
 
@@ -46,102 +49,121 @@ class Equipotential:
46
49
 
47
50
 
48
51
  class Net:
49
- def __init__(self, path, net):
52
+ def __init__(self, path, net=None, net_concat=None):
53
+ if net is not None and net_concat is not None:
54
+ raise ValueError(
55
+ "Only one of `net` or `net_concat` should be provided, not both."
56
+ )
50
57
  self.path = path
51
- self.net = net
52
-
53
- def __eq__(self, value):
54
- return self.net == value.net and self.path == value.path
55
-
56
- def __ne__(self, value):
57
- return not self == value
58
-
59
- def __lt__(self, value):
60
- if self.path != value.path:
61
- return self.path < value.path
62
- return self.net < value.net
63
-
64
- def __le__(self, value):
65
- if self.path != value.path:
66
- return self.path < value.path
67
- return self.net <= value.net
58
+ if net is not None:
59
+ self.net = net
60
+ elif net_concat is not None:
61
+ self.net_concat = net_concat
68
62
 
69
- def __gt__(self, value):
70
- if self.path != value.path:
71
- return self.path > value.path
72
- return self.net > value.net
63
+ def __eq__(self, other):
64
+ if not isinstance(other, Net):
65
+ return NotImplemented
66
+ return vars(self) == vars(other)
73
67
 
74
- def __ge__(self, value):
75
- if self.path != value.path:
76
- return self.path > value.path
77
- return self.net >= value.net
68
+ def __ne__(self, other):
69
+ eq_result = self.__eq__(other)
70
+ if eq_result is NotImplemented:
71
+ return NotImplemented
72
+ return not eq_result
78
73
 
79
74
  def __str__(self):
75
+ if hasattr(self, "net"):
76
+ net_str = str(self.net)
77
+ elif hasattr(self, "net_concat"):
78
+ net_str = "{" + ",".join(map(str, self.net_concat)) + "}"
80
79
  if self.path.size() > 0:
81
- return f"{self.path}/{self.net}"
82
- return f"{self.net}"
83
-
84
- def __repr__(self):
85
- return f"Net({self.path}, {self.net})"
80
+ return f"{self.path}/{net_str}"
81
+ return net_str
86
82
 
87
83
  def get_name(self) -> str:
88
84
  """Return the name of the net."""
89
- return self.net.getName()
85
+ if hasattr(self, "net"):
86
+ return self.net.getName()
87
+ return "{" + ",".join(map(str, self.net_concat)) + "}"
90
88
 
91
89
  def get_msb(self) -> int:
92
90
  """Return the most significant bit of the net if it is a bus."""
93
- if isinstance(self.net, snl.SNLBusNet):
91
+ if hasattr(self, "net") and isinstance(self.net, snl.SNLBusNet):
94
92
  return self.net.getMSB()
95
93
  return None
96
94
 
97
95
  def get_lsb(self) -> int:
98
96
  """Return the least significant bit of the net if it is a bus."""
99
- if isinstance(self.net, snl.SNLBusNet):
97
+ if hasattr(self, "net") and isinstance(self.net, snl.SNLBusNet):
100
98
  return self.net.getLSB()
101
99
  return None
102
100
 
103
101
  def is_bus(self) -> bool:
104
102
  """Return True if the net is a bus."""
105
- return isinstance(self.net, snl.SNLBusNet)
103
+ return hasattr(self, "net") and isinstance(self.net, snl.SNLBusNet)
106
104
 
107
105
  def is_bus_bit(self) -> bool:
108
106
  """Return True if the net is a bit of a bus."""
109
- return isinstance(self.net, snl.SNLBusNetBit)
107
+ return hasattr(self, "net") and isinstance(self.net, snl.SNLBusNetBit)
110
108
 
111
109
  def is_scalar(self) -> bool:
112
110
  """Return True if the net is a scalar."""
113
- return isinstance(self.net, snl.SNLScalarNet)
111
+ return hasattr(self, "net") and isinstance(self.net, snl.SNLScalarNet)
114
112
 
115
113
  def is_bit(self) -> bool:
116
114
  """Return True if the net is a bit."""
117
115
  return self.is_scalar() or self.is_bus_bit()
118
116
 
119
- def is_constant(self) -> bool:
117
+ def is_concat(self) -> bool:
118
+ """Return True if the net is a concatenation."""
119
+ return hasattr(self, "net_concat")
120
+
121
+ def is_const(self) -> bool:
120
122
  """Return True if the net is a constant generator."""
121
- return self.net.isConstant()
123
+ if hasattr(self, "net"):
124
+ return self.net.isConstant()
125
+ for net in self.net_concat:
126
+ if not net.isConstant():
127
+ return False
128
+ return True
122
129
 
123
130
  def get_width(self) -> int:
124
131
  """Return the width of the net."""
125
- return self.net.getWidth()
132
+ if hasattr(self, "net"):
133
+ return self.net.getWidth()
134
+ return sum(1 for _ in self.net_concat)
126
135
 
127
136
  def get_bits(self):
128
- if isinstance(self.net, snl.SNLBusNet):
129
- for bit in self.net.getBits():
130
- yield Net(self.path, bit)
137
+ if hasattr(self, "net"):
138
+ if isinstance(self.net, snl.SNLBusNet):
139
+ for bit in self.net.getBits():
140
+ yield Net(self.path, bit)
141
+ else:
142
+ yield self
131
143
  else:
132
- yield self
144
+ for net in self.net_concat:
145
+ yield net
133
146
 
134
147
  def get_bit(self, index: int):
135
- if isinstance(self.net, snl.SNLBusNet):
136
- return Net(self.path, self.net.getBit(index))
148
+ if hasattr(self, "net"):
149
+ if isinstance(self.net, snl.SNLBusNet):
150
+ return Net(self.path, self.net.getBit(index))
151
+ else:
152
+ return None
153
+ if 0 <= index < len(self.net_concat):
154
+ return Net(self.path, self.net_concat[index])
137
155
  return None
138
156
 
139
157
  def get_inst_terms(self):
158
+ if hasattr(self, "net_concat"):
159
+ raise ValueError("Cannot get inst terms from a net_concat")
140
160
  for term in self.net.getInstTerms():
141
161
  path = snl.SNLPath(self.path, term.getInstance())
142
162
  yield Term(path, term.getBitTerm())
143
163
 
144
164
  def get_terms(self):
165
+ if hasattr(self, "net_concat"):
166
+ raise ValueError("Cannot get terms from a net_concat")
145
167
  for term in self.net.getBitTerms():
146
168
  yield Term(self.path, term)
147
169
 
@@ -151,9 +173,9 @@ class Net:
151
173
 
152
174
 
153
175
  class Term:
154
- Input = snl.SNLTerm.Direction.Input
155
- Output = snl.SNLTerm.Direction.Output
156
- InOut = snl.SNLTerm.Direction.InOut
176
+ INPUT = snl.SNLTerm.Direction.Input
177
+ OUTPUT = snl.SNLTerm.Direction.Output
178
+ INOUT = snl.SNLTerm.Direction.InOut
157
179
 
158
180
  def __init__(self, path, term):
159
181
  self.path = path
@@ -179,15 +201,19 @@ class Term:
179
201
  def __ge__(self, other) -> bool:
180
202
  return not self < other
181
203
 
182
- def __str__(self) -> str:
183
- return str(self.path) + "." + self.term.getName()
204
+ def __str__(self):
205
+ if self.path.size() == 0:
206
+ return self.term.getName()
207
+ else:
208
+ return f"{self.path}/{self.term}"
184
209
 
185
210
  def __repr__(self) -> str:
186
211
  return f"Term({self.path}, {self.term})"
187
212
 
188
213
  def __make_unique(self):
189
- if self.path.size() > 0:
190
- snl.SNLUniquifier(self.path)
214
+ if self.path.size() > 1:
215
+ path = self.path.getHeadPath()
216
+ snl.SNLUniquifier(path)
191
217
  if self.is_bus_bit():
192
218
  term = (
193
219
  self.path.getTailInstance().getModel().getTerm(self.term.getName())
@@ -237,24 +263,74 @@ class Term:
237
263
  def get_direction(self) -> snl.SNLTerm.Direction:
238
264
  """Return the direction of the term."""
239
265
  if self.term.getDirection() == snl.SNLTerm.Direction.Input:
240
- return Term.Input
266
+ return Term.INPUT
241
267
  elif self.term.getDirection() == snl.SNLTerm.Direction.Output:
242
- return Term.Output
268
+ return Term.OUTPUT
243
269
  elif self.term.getDirection() == snl.SNLTerm.Direction.InOut:
244
- return Term.InOut
270
+ return Term.INOUT
245
271
 
246
- def get_net(self) -> Net:
247
- if isinstance(self.term, snl.SNLBusTerm):
248
- return None # FIXME xtof in the future
249
- net = None
272
+ def __get_snl_bitnet(self, bit) -> Net:
273
+ # single bit
250
274
  if self.path.size() > 0:
251
- instTerm = self.path.getTailInstance().getInstTerm(self.term)
252
- net = instTerm.getNet()
275
+ instTerm = self.path.getTailInstance().getInstTerm(bit)
276
+ return instTerm.getNet()
277
+ else:
278
+ return bit.getNet()
279
+
280
+ def __get_snl_lower_bitnet(self, bit) -> Net:
281
+ return bit.getNet()
282
+
283
+ def __get_snl_busnet(self, snl_nets) -> snl.SNLBusNet:
284
+ # iterate on all elements of the list and check if
285
+ # a full SNLBusNet can be reconstructed
286
+ snl_bus_net = None
287
+ for i in range(len(snl_nets)):
288
+ snl_net = snl_nets[i]
289
+ if not isinstance(snl_net, snl.SNLBusNetBit):
290
+ return None
291
+ bit_bus = snl_net.getBus()
292
+ if bit_bus.getWidth() != len(snl_nets):
293
+ return None
294
+ if snl_bus_net is None:
295
+ snl_bus_net = bit_bus
296
+ if snl_bus_net != bit_bus:
297
+ return None
298
+ if snl_bus_net.getBitAtPosition(i) != snl_net:
299
+ return None
300
+ return snl_bus_net
301
+
302
+ def __get_net(self, path, snl_term_net_accessor) -> Net:
303
+ if isinstance(self.term, snl.SNLBusTerm):
304
+ snl_nets = []
305
+ for bit in self.term.getBits():
306
+ snl_net = snl_term_net_accessor(bit)
307
+ snl_nets.append(snl_net)
308
+ snl_bus_net = self.__get_snl_busnet(snl_nets)
309
+ if snl_bus_net is not None:
310
+ return Net(path, snl_bus_net)
311
+ else:
312
+ if all(element is not None for element in snl_nets):
313
+ return Net(path, net_concat=snl_nets)
253
314
  else:
254
- net = get_top().model.getTerm(self.term.getName()).getNet()
255
- return Net(self.path, net)
315
+ snl_net = snl_term_net_accessor(self.term)
316
+ if snl_net is not None:
317
+ return Net(path, snl_net)
318
+ return None
319
+
320
+ def get_lower_net(self) -> Net:
321
+ """Return the lower net of the term."""
322
+ return self.__get_net(self.path, self.__get_snl_lower_bitnet)
323
+
324
+ def get_net(self) -> Net:
325
+ """Return the net of the term."""
326
+ if self.path.empty():
327
+ return None
328
+ # path is one level up
329
+ path = self.path.getHeadPath()
330
+ return self.__get_net(path, self.__get_snl_bitnet)
256
331
 
257
332
  def get_instance(self):
333
+ """Return the instance of the term."""
258
334
  return Instance(self.path)
259
335
 
260
336
  def get_flat_fanout(self):
@@ -295,6 +371,7 @@ class Term:
295
371
  raise ValueError("Width mismatch")
296
372
  if self.get_instance().is_top():
297
373
  for bterm, bnet in zip(self.term.getBits(), net.net.getBits()):
374
+ logging.debug(f"Connecting {bterm} to {bnet}")
298
375
  bterm.setNet(bnet)
299
376
  else:
300
377
  self.__make_unique()
@@ -348,8 +425,15 @@ class Instance:
348
425
  def __eq__(self, other) -> bool:
349
426
  return self.path == other.path
350
427
 
351
- def __str__(self) -> str:
352
- return str(self.path)
428
+ def __str__(self):
429
+ if self.is_top():
430
+ top = self.__get_snl_model()
431
+ if top is not None:
432
+ return top.getName()
433
+ else:
434
+ return ""
435
+ else:
436
+ return str(self.path)
353
437
 
354
438
  def __repr__(self) -> str:
355
439
  return f"Instance({self.path})"
@@ -396,8 +480,6 @@ class Instance:
396
480
 
397
481
  def __find_snl_model(self, name: str) -> snl.SNLDesign:
398
482
  u = snl.SNLUniverse.get()
399
- if u is None:
400
- return None
401
483
  for db in u.getUserDBs():
402
484
  for lib in db.getLibraries():
403
485
  found_model = lib.getDesign(name)
@@ -419,15 +501,21 @@ class Instance:
419
501
  def get_number_of_child_instances(self) -> int:
420
502
  return sum(1 for _ in self.__get_snl_model().getInstances())
421
503
 
422
- def get_terms(self):
423
- for term in self.__get_snl_model().getTerms():
424
- yield Term(self.path, term)
425
-
426
- def get_term(self, name: str) -> Term:
427
- term = self.__get_snl_model().getTerm(name)
428
- if term is not None:
429
- return Term(self.path, self.__get_snl_model().getTerm(name))
430
- return None
504
+ # def get_flat_primitive_instances(self):
505
+ # FIXME: concat first local path with the path of the instance
506
+ # model = self.__get_snl_model()
507
+ # for inst in model.getInstances():
508
+ # path = snl.SNLPath(inst)
509
+ # stack = [[inst, path]]
510
+ # while stack:
511
+ # current = stack.pop()
512
+ # current_inst = current[0]
513
+ # current_path = current[1]
514
+ # for inst_child in current_inst.getModel().getInstances():
515
+ # path_child = snl.SNLPath(current_path, inst_child)
516
+ # if inst_child.getModel().isPrimitive():
517
+ # yield Instance(path_child)
518
+ # stack.append([inst_child, path_child])
431
519
 
432
520
  def get_nets(self):
433
521
  for net in self.__get_snl_model().getNets():
@@ -448,8 +536,23 @@ class Instance:
448
536
  return None
449
537
 
450
538
  def is_primitive(self) -> bool:
539
+ """Return True if this is a primitive."""
451
540
  return self.__get_snl_model().isPrimitive()
452
541
 
542
+ def get_terms(self):
543
+ for term in self.__get_snl_model().getTerms():
544
+ yield Term(self.path, term)
545
+
546
+ def get_flat_terms(self):
547
+ for term in self.__get_snl_model().getBitTerms():
548
+ yield Term(self.path, term)
549
+
550
+ def get_term(self, name: str) -> Term:
551
+ term = self.__get_snl_model().getTerm(name)
552
+ if term is not None:
553
+ return Term(self.path, self.__get_snl_model().getTerm(name))
554
+ return None
555
+
453
556
  def get_input_terms(self):
454
557
  for term in self.__get_snl_model().getTerms():
455
558
  if term.getDirection() == snl.SNLTerm.Direction.Input:
@@ -531,9 +634,10 @@ class Instance:
531
634
  def create_input_term(self, name: str) -> Term:
532
635
  return self.create_term(name, snl.SNLTerm.Direction.Input)
533
636
 
534
- def create_bus_term(
535
- self, name: str, msb: int, lsb: int, direction: snl.SNLTerm.Direction
536
- ) -> Term:
637
+ def create_inout_term(self, name: str) -> Term:
638
+ return self.create_term(name, snl.SNLTerm.Direction.InOut)
639
+
640
+ def create_bus_term(self, name: str, msb: int, lsb: int, direction) -> Term:
537
641
  if self.path.size() > 0:
538
642
  path = self.path
539
643
  snl.SNLUniquifier(path)
@@ -542,6 +646,9 @@ class Instance:
542
646
  newSNLTerm = snl.SNLBusTerm.create(design, direction, msb, lsb, name)
543
647
  return Term(self.path, newSNLTerm)
544
648
 
649
+ def create_inout_bus_term(self, name: str, msb: int, lsb: int) -> Term:
650
+ return self.create_bus_term(name, msb, lsb, snl.SNLTerm.Direction.InOut)
651
+
545
652
  def create_output_bus_term(self, name: str, msb: int, lsb: int) -> Term:
546
653
  return self.create_bus_term(name, msb, lsb, snl.SNLTerm.Direction.Output)
547
654
 
@@ -594,14 +701,29 @@ def create_top(name: str) -> Instance:
594
701
 
595
702
 
596
703
  def load_verilog(files: list):
704
+ start_time = time.time()
705
+ logging.info(f"Loading verilog: {', '.join(files)}")
597
706
  get_top_db().loadVerilog(files)
707
+ execution_time = time.time() - start_time
708
+ logging.info(f"Loading done in {execution_time:.2f} seconds")
598
709
  return get_top()
599
710
 
600
711
 
601
712
  def load_liberty(files: list):
713
+ logging.info(f"Loading liberty: {', '.join(files)}")
602
714
  get_top_db().loadLibertyPrimitives(files)
603
715
 
604
716
 
717
+ def load_primitives(name: str):
718
+ if name == "xilinx":
719
+ logging.info("Loading xilinx primitives")
720
+ from najaeda.primitives import xilinx
721
+
722
+ xilinx.load(get_top_db())
723
+ else:
724
+ raise ValueError(f"Unknown primitives library: {name}")
725
+
726
+
605
727
  def get_primitives_library() -> snl.SNLLibrary:
606
728
  lib = get_top_db().getLibrary("PRIMS")
607
729
  if lib is None:
@@ -621,20 +743,3 @@ def get_model_name(id: tuple[int, int, int]) -> str:
621
743
  if model:
622
744
  return model.getName()
623
745
  return None
624
-
625
-
626
- def get_all_primitive_instances():
627
- top = snl.SNLUniverse.get().getTopDesign()
628
-
629
- for inst in top.getInstances():
630
- path = snl.SNLPath(inst)
631
- stack = [[inst, path]]
632
- while stack:
633
- current = stack.pop()
634
- current_inst = current[0]
635
- current_path = current[1]
636
- for inst_child in current_inst.getModel().getInstances():
637
- path_child = snl.SNLPath(current_path, inst_child)
638
- if inst_child.getModel().isPrimitive():
639
- yield Instance(path_child)
640
- stack.append([inst_child, path_child])
File without changes
@@ -0,0 +1,452 @@
1
+ # SPDX-FileCopyrightText: 2024 The Naja authors <https://github.com/najaeda/naja/blob/main/AUTHORS>
2
+ #
3
+ # SPDX-License-Identifier: Apache-2.0
4
+
5
+ from najaeda import snl
6
+
7
+
8
+ def constructIBUF(lib):
9
+ ibuf = snl.SNLDesign.createPrimitive(lib, "IBUF")
10
+ i = snl.SNLScalarTerm.create(ibuf, snl.SNLTerm.Direction.Input, "I")
11
+ o = snl.SNLScalarTerm.create(ibuf, snl.SNLTerm.Direction.Output, "O")
12
+ ibuf.addCombinatorialArcs(i, o)
13
+
14
+
15
+ def constructOBUF(lib):
16
+ obuf = snl.SNLDesign.createPrimitive(lib, "OBUF")
17
+ i = snl.SNLScalarTerm.create(obuf, snl.SNLTerm.Direction.Input, "I")
18
+ o = snl.SNLScalarTerm.create(obuf, snl.SNLTerm.Direction.Output, "O")
19
+ obuf.addCombinatorialArcs(i, o)
20
+
21
+
22
+ def constructBUFG(lib):
23
+ bufg = snl.SNLDesign.createPrimitive(lib, "BUFG")
24
+ i = snl.SNLScalarTerm.create(bufg, snl.SNLTerm.Direction.Input, "I")
25
+ o = snl.SNLScalarTerm.create(bufg, snl.SNLTerm.Direction.Output, "O")
26
+ bufg.addCombinatorialArcs(i, o)
27
+
28
+
29
+ def constructDSP48E1(lib):
30
+ dsp48e1 = snl.SNLDesign.createPrimitive(lib, "DSP48E1")
31
+ snl.SNLBusTerm.create(dsp48e1, snl.SNLTerm.Direction.Output, 29, 0, "ACOUT")
32
+ snl.SNLBusTerm.create(dsp48e1, snl.SNLTerm.Direction.Output, 17, 0, "BCOUT")
33
+ snl.SNLScalarTerm.create(dsp48e1, snl.SNLTerm.Direction.Output, "CARRYCASCOUT")
34
+ snl.SNLScalarTerm.create(dsp48e1, snl.SNLTerm.Direction.Input, "MULTSIGNOUT")
35
+ snl.SNLBusTerm.create(dsp48e1, snl.SNLTerm.Direction.Input, 47, 0, "PCOUT")
36
+ snl.SNLScalarTerm.create(dsp48e1, snl.SNLTerm.Direction.Output, "OVERFLOW")
37
+ snl.SNLScalarTerm.create(dsp48e1, snl.SNLTerm.Direction.Output, "PATTERNBDETECT")
38
+ snl.SNLScalarTerm.create(dsp48e1, snl.SNLTerm.Direction.Output, "PATTERNDETECT")
39
+ snl.SNLScalarTerm.create(dsp48e1, snl.SNLTerm.Direction.Output, "UNDERFLOW")
40
+ snl.SNLBusTerm.create(dsp48e1, snl.SNLTerm.Direction.Output, 3, 0, "CARRYOUT")
41
+ snl.SNLBusTerm.create(dsp48e1, snl.SNLTerm.Direction.Output, 47, 0, "P")
42
+ snl.SNLBusTerm.create(dsp48e1, snl.SNLTerm.Direction.Input, 29, 0, "ACIN")
43
+ snl.SNLBusTerm.create(dsp48e1, snl.SNLTerm.Direction.Input, 17, 0, "BCIN")
44
+ snl.SNLScalarTerm.create(dsp48e1, snl.SNLTerm.Direction.Input, "CARRYCASCIN")
45
+ snl.SNLScalarTerm.create(dsp48e1, snl.SNLTerm.Direction.Input, "MULTSIGNIN")
46
+ snl.SNLBusTerm.create(dsp48e1, snl.SNLTerm.Direction.Input, 47, 0, "PCIN")
47
+ snl.SNLBusTerm.create(dsp48e1, snl.SNLTerm.Direction.Input, 3, 0, "ALUMODE")
48
+ snl.SNLBusTerm.create(dsp48e1, snl.SNLTerm.Direction.Input, 2, 0, "CARRYINSEL")
49
+ snl.SNLScalarTerm.create(dsp48e1, snl.SNLTerm.Direction.Input, "CLK")
50
+ snl.SNLBusTerm.create(dsp48e1, snl.SNLTerm.Direction.Input, 4, 0, "INMODE")
51
+ snl.SNLBusTerm.create(dsp48e1, snl.SNLTerm.Direction.Input, 6, 0, "OPMODE")
52
+ snl.SNLBusTerm.create(dsp48e1, snl.SNLTerm.Direction.Input, 29, 0, "A")
53
+ snl.SNLBusTerm.create(dsp48e1, snl.SNLTerm.Direction.Input, 17, 0, "B")
54
+ snl.SNLBusTerm.create(dsp48e1, snl.SNLTerm.Direction.Input, 47, 0, "C")
55
+ snl.SNLScalarTerm.create(dsp48e1, snl.SNLTerm.Direction.Input, "CARRYIN")
56
+ snl.SNLBusTerm.create(dsp48e1, snl.SNLTerm.Direction.Input, 24, 0, "D")
57
+ snl.SNLScalarTerm.create(dsp48e1, snl.SNLTerm.Direction.Input, "CEA1")
58
+ snl.SNLScalarTerm.create(dsp48e1, snl.SNLTerm.Direction.Input, "CEA2")
59
+ snl.SNLScalarTerm.create(dsp48e1, snl.SNLTerm.Direction.Input, "CEAD")
60
+ snl.SNLScalarTerm.create(dsp48e1, snl.SNLTerm.Direction.Input, "CEALUMODE")
61
+ snl.SNLScalarTerm.create(dsp48e1, snl.SNLTerm.Direction.Input, "CEB1")
62
+ snl.SNLScalarTerm.create(dsp48e1, snl.SNLTerm.Direction.Input, "CEB2")
63
+ snl.SNLScalarTerm.create(dsp48e1, snl.SNLTerm.Direction.Input, "CEC")
64
+ snl.SNLScalarTerm.create(dsp48e1, snl.SNLTerm.Direction.Input, "CECARRYIN")
65
+ snl.SNLScalarTerm.create(dsp48e1, snl.SNLTerm.Direction.Input, "CECTRL")
66
+ snl.SNLScalarTerm.create(dsp48e1, snl.SNLTerm.Direction.Input, "CED")
67
+ snl.SNLScalarTerm.create(dsp48e1, snl.SNLTerm.Direction.Input, "CEINMODE")
68
+ snl.SNLScalarTerm.create(dsp48e1, snl.SNLTerm.Direction.Input, "CEM")
69
+ snl.SNLScalarTerm.create(dsp48e1, snl.SNLTerm.Direction.Input, "CEP")
70
+ snl.SNLScalarTerm.create(dsp48e1, snl.SNLTerm.Direction.Input, "RSTA")
71
+ snl.SNLScalarTerm.create(dsp48e1, snl.SNLTerm.Direction.Input, "RSTALLCARRYIN")
72
+ snl.SNLScalarTerm.create(dsp48e1, snl.SNLTerm.Direction.Input, "RSTALUMODE")
73
+ snl.SNLScalarTerm.create(dsp48e1, snl.SNLTerm.Direction.Input, "RSTB")
74
+ snl.SNLScalarTerm.create(dsp48e1, snl.SNLTerm.Direction.Input, "RSTC")
75
+ snl.SNLScalarTerm.create(dsp48e1, snl.SNLTerm.Direction.Input, "RSTCTRL")
76
+ snl.SNLScalarTerm.create(dsp48e1, snl.SNLTerm.Direction.Input, "RSTD")
77
+ snl.SNLScalarTerm.create(dsp48e1, snl.SNLTerm.Direction.Input, "RSTINMODE")
78
+ snl.SNLScalarTerm.create(dsp48e1, snl.SNLTerm.Direction.Input, "RSTM")
79
+ snl.SNLScalarTerm.create(dsp48e1, snl.SNLTerm.Direction.Input, "RSTP")
80
+ snl.SNLParameter.create_decimal(dsp48e1, "ACASCREG", 1)
81
+ snl.SNLParameter.create_decimal(dsp48e1, "ADREG", 1)
82
+ snl.SNLParameter.create_string(dsp48e1, "A_INPUT", "DIRECT")
83
+ snl.SNLParameter.create_decimal(dsp48e1, "ALUMODEREG", 1)
84
+ snl.SNLParameter.create_decimal(dsp48e1, "AREG", 1)
85
+ snl.SNLParameter.create_decimal(dsp48e1, "BCASCREG", 1)
86
+ snl.SNLParameter.create_string(dsp48e1, "B_INPUT", "DIRECT")
87
+ snl.SNLParameter.create_decimal(dsp48e1, "BREG", 1)
88
+ snl.SNLParameter.create_decimal(dsp48e1, "CARRYINREG", 1)
89
+ snl.SNLParameter.create_decimal(dsp48e1, "CARRYINSELREG", 1)
90
+ snl.SNLParameter.create_decimal(dsp48e1, "CREG", 1)
91
+ snl.SNLParameter.create_decimal(dsp48e1, "DREG", 1)
92
+ snl.SNLParameter.create_decimal(dsp48e1, "INMODEREG", 1)
93
+ snl.SNLParameter.create_decimal(dsp48e1, "MREG", 1)
94
+ snl.SNLParameter.create_decimal(dsp48e1, "OPMODEREG", 1)
95
+ snl.SNLParameter.create_decimal(dsp48e1, "PREG", 1)
96
+ snl.SNLParameter.create_boolean(dsp48e1, "USE_DPORT", False)
97
+ snl.SNLParameter.create_string(dsp48e1, "USE_MULT", "MULTIPLY")
98
+ snl.SNLParameter.create_string(dsp48e1, "USE_SIMD", "ONE48")
99
+
100
+
101
+ def constructINV(lib):
102
+ inv = snl.SNLDesign.createPrimitive(lib, "INV")
103
+ i = snl.SNLScalarTerm.create(inv, snl.SNLTerm.Direction.Input, "I")
104
+ o = snl.SNLScalarTerm.create(inv, snl.SNLTerm.Direction.Output, "O")
105
+ snl.SNLDesign.addCombinatorialArcs(i, o)
106
+
107
+
108
+ def constructCARRY4(lib):
109
+ carry4 = snl.SNLDesign.createPrimitive(lib, "CARRY4")
110
+ o = snl.SNLBusTerm.create(carry4, snl.SNLTerm.Direction.Output, 3, 0, "O")
111
+ co = snl.SNLBusTerm.create(carry4, snl.SNLTerm.Direction.Output, 3, 0, "CO")
112
+ di = snl.SNLBusTerm.create(carry4, snl.SNLTerm.Direction.Input, 3, 0, "DI")
113
+ s = snl.SNLBusTerm.create(carry4, snl.SNLTerm.Direction.Input, 3, 0, "S")
114
+ cyinit = snl.SNLScalarTerm.create(carry4, snl.SNLTerm.Direction.Input, "CYINIT")
115
+ ci = snl.SNLScalarTerm.create(carry4, snl.SNLTerm.Direction.Input, "CI")
116
+ o_bits = [b for b in o.getBits()]
117
+ co_bits = [b for b in co.getBits()]
118
+ di_bits = [b for b in di.getBits()]
119
+ s_bits = [b for b in s.getBits()]
120
+ # cyinit and ci are in combinatorial dependency with o and co outputs
121
+ snl.SNLDesign.addCombinatorialArcs([cyinit, ci], [o, co])
122
+ snl.SNLDesign.addCombinatorialArcs(s_bits[0], [o, co])
123
+ snl.SNLDesign.addCombinatorialArcs(s_bits[1], [o_bits[1], o_bits[2], o_bits[3]])
124
+ snl.SNLDesign.addCombinatorialArcs(s_bits[1], [co_bits[1], co_bits[2], co_bits[3]])
125
+ snl.SNLDesign.addCombinatorialArcs(s_bits[2], [o_bits[2], o_bits[3]])
126
+ snl.SNLDesign.addCombinatorialArcs(s_bits[2], [co_bits[2], co_bits[3]])
127
+ snl.SNLDesign.addCombinatorialArcs(s_bits[3], o_bits[3])
128
+ snl.SNLDesign.addCombinatorialArcs(s_bits[3], co_bits[3])
129
+ snl.SNLDesign.addCombinatorialArcs(di_bits[0], [o_bits[1], o_bits[2], o_bits[3]])
130
+ snl.SNLDesign.addCombinatorialArcs(di_bits[0], co)
131
+ snl.SNLDesign.addCombinatorialArcs(di_bits[1], [o_bits[2], o_bits[3]])
132
+ snl.SNLDesign.addCombinatorialArcs(di_bits[1], [co_bits[1], co_bits[2], co_bits[3]])
133
+ snl.SNLDesign.addCombinatorialArcs(di_bits[2], o_bits[3])
134
+ snl.SNLDesign.addCombinatorialArcs(di_bits[2], [co_bits[2], co_bits[3]])
135
+ snl.SNLDesign.addCombinatorialArcs(di_bits[3], co_bits[3])
136
+
137
+
138
+ def constructLUT1(lib):
139
+ lut1 = snl.SNLDesign.createPrimitive(lib, "LUT1")
140
+ i0 = snl.SNLScalarTerm.create(lut1, snl.SNLTerm.Direction.Input, "I0")
141
+ o = snl.SNLScalarTerm.create(lut1, snl.SNLTerm.Direction.Output, "O")
142
+ snl.SNLDesign.addCombinatorialArcs(i0, o)
143
+ snl.SNLParameter.create_binary(lut1, "INIT", 2, 0b00)
144
+
145
+
146
+ def constructLUT2(lib):
147
+ lut2 = snl.SNLDesign.createPrimitive(lib, "LUT2")
148
+ i0 = snl.SNLScalarTerm.create(lut2, snl.SNLTerm.Direction.Input, "I0")
149
+ i1 = snl.SNLScalarTerm.create(lut2, snl.SNLTerm.Direction.Input, "I1")
150
+ o = snl.SNLScalarTerm.create(lut2, snl.SNLTerm.Direction.Output, "O")
151
+ snl.SNLDesign.addCombinatorialArcs([i0, i1], o)
152
+ snl.SNLParameter.create_binary(lut2, "INIT", 4, 0x0)
153
+
154
+
155
+ def constructLUT3(lib):
156
+ lut3 = snl.SNLDesign.createPrimitive(lib, "LUT3")
157
+ i0 = snl.SNLScalarTerm.create(lut3, snl.SNLTerm.Direction.Input, "I0")
158
+ i1 = snl.SNLScalarTerm.create(lut3, snl.SNLTerm.Direction.Input, "I1")
159
+ i2 = snl.SNLScalarTerm.create(lut3, snl.SNLTerm.Direction.Input, "I2")
160
+ o = snl.SNLScalarTerm.create(lut3, snl.SNLTerm.Direction.Output, "O")
161
+ snl.SNLDesign.addCombinatorialArcs([i0, i1, i2], o)
162
+ snl.SNLParameter.create_binary(lut3, "INIT", 8, 0x00)
163
+
164
+
165
+ def constructLUT4(lib):
166
+ lut4 = snl.SNLDesign.createPrimitive(lib, "LUT4")
167
+ i0 = snl.SNLScalarTerm.create(lut4, snl.SNLTerm.Direction.Input, "I0")
168
+ i1 = snl.SNLScalarTerm.create(lut4, snl.SNLTerm.Direction.Input, "I1")
169
+ i2 = snl.SNLScalarTerm.create(lut4, snl.SNLTerm.Direction.Input, "I2")
170
+ i3 = snl.SNLScalarTerm.create(lut4, snl.SNLTerm.Direction.Input, "I3")
171
+ o = snl.SNLScalarTerm.create(lut4, snl.SNLTerm.Direction.Output, "O")
172
+ snl.SNLDesign.addCombinatorialArcs([i0, i1, i2, i3], o)
173
+ snl.SNLParameter.create_binary(lut4, "INIT", 16, 0x0000)
174
+
175
+
176
+ def constructLUT5(lib):
177
+ lut5 = snl.SNLDesign.createPrimitive(lib, "LUT5")
178
+ i0 = snl.SNLScalarTerm.create(lut5, snl.SNLTerm.Direction.Input, "I0")
179
+ i1 = snl.SNLScalarTerm.create(lut5, snl.SNLTerm.Direction.Input, "I1")
180
+ i2 = snl.SNLScalarTerm.create(lut5, snl.SNLTerm.Direction.Input, "I2")
181
+ i3 = snl.SNLScalarTerm.create(lut5, snl.SNLTerm.Direction.Input, "I3")
182
+ i4 = snl.SNLScalarTerm.create(lut5, snl.SNLTerm.Direction.Input, "I4")
183
+ o = snl.SNLScalarTerm.create(lut5, snl.SNLTerm.Direction.Output, "O")
184
+ snl.SNLDesign.addCombinatorialArcs([i0, i1, i2, i3, i4], o)
185
+ snl.SNLParameter.create_binary(lut5, "INIT", 32, 0x00000000)
186
+
187
+
188
+ def constructLUT6(lib):
189
+ lut6 = snl.SNLDesign.createPrimitive(lib, "LUT6")
190
+ i0 = snl.SNLScalarTerm.create(lut6, snl.SNLTerm.Direction.Input, "I0")
191
+ i1 = snl.SNLScalarTerm.create(lut6, snl.SNLTerm.Direction.Input, "I1")
192
+ i2 = snl.SNLScalarTerm.create(lut6, snl.SNLTerm.Direction.Input, "I2")
193
+ i3 = snl.SNLScalarTerm.create(lut6, snl.SNLTerm.Direction.Input, "I3")
194
+ i4 = snl.SNLScalarTerm.create(lut6, snl.SNLTerm.Direction.Input, "I4")
195
+ i5 = snl.SNLScalarTerm.create(lut6, snl.SNLTerm.Direction.Input, "I5")
196
+ o = snl.SNLScalarTerm.create(lut6, snl.SNLTerm.Direction.Output, "O")
197
+ snl.SNLDesign.addCombinatorialArcs([i0, i1, i2, i3, i4, i5], o)
198
+ snl.SNLParameter.create_binary(lut6, "INIT", 64, 0x0000000000000000)
199
+
200
+
201
+ def constructMUXF7(lib):
202
+ muxf7 = snl.SNLDesign.createPrimitive(lib, "MUXF7")
203
+ i0 = snl.SNLScalarTerm.create(muxf7, snl.SNLTerm.Direction.Input, "I0")
204
+ i1 = snl.SNLScalarTerm.create(muxf7, snl.SNLTerm.Direction.Input, "I1")
205
+ o = snl.SNLScalarTerm.create(muxf7, snl.SNLTerm.Direction.Output, "O")
206
+ s = snl.SNLScalarTerm.create(muxf7, snl.SNLTerm.Direction.Input, "S")
207
+ snl.SNLDesign.addCombinatorialArcs([i0, i1, s], o)
208
+
209
+
210
+ def constructMUXF8(lib):
211
+ muxf8 = snl.SNLDesign.createPrimitive(lib, "MUXF8")
212
+ i0 = snl.SNLScalarTerm.create(muxf8, snl.SNLTerm.Direction.Input, "I0")
213
+ i1 = snl.SNLScalarTerm.create(muxf8, snl.SNLTerm.Direction.Input, "I1")
214
+ o = snl.SNLScalarTerm.create(muxf8, snl.SNLTerm.Direction.Output, "O")
215
+ s = snl.SNLScalarTerm.create(muxf8, snl.SNLTerm.Direction.Input, "S")
216
+ snl.SNLDesign.addCombinatorialArcs([i0, i1, s], o)
217
+
218
+
219
+ def constructSRL16E(lib):
220
+ srl16e = snl.SNLDesign.createPrimitive(lib, "SRL16E")
221
+ snl.SNLScalarTerm.create(srl16e, snl.SNLTerm.Direction.Input, "CE")
222
+ snl.SNLScalarTerm.create(srl16e, snl.SNLTerm.Direction.Input, "CLK")
223
+ snl.SNLScalarTerm.create(srl16e, snl.SNLTerm.Direction.Input, "D")
224
+ snl.SNLScalarTerm.create(srl16e, snl.SNLTerm.Direction.Output, "Q")
225
+ snl.SNLScalarTerm.create(srl16e, snl.SNLTerm.Direction.Input, "A0")
226
+ snl.SNLScalarTerm.create(srl16e, snl.SNLTerm.Direction.Input, "A1")
227
+ snl.SNLScalarTerm.create(srl16e, snl.SNLTerm.Direction.Input, "A2")
228
+ snl.SNLScalarTerm.create(srl16e, snl.SNLTerm.Direction.Input, "A3")
229
+ snl.SNLParameter.create_binary(srl16e, "INIT", 16, 0x0000)
230
+ snl.SNLParameter.create_binary(srl16e, "IS_CLK_INVERTED", 1, 0)
231
+
232
+
233
+ def constructFDCE(lib):
234
+ fdce = snl.SNLDesign.createPrimitive(lib, "FDCE")
235
+ q = snl.SNLScalarTerm.create(fdce, snl.SNLTerm.Direction.Output, "Q")
236
+ c = snl.SNLScalarTerm.create(fdce, snl.SNLTerm.Direction.Input, "C")
237
+ ce = snl.SNLScalarTerm.create(fdce, snl.SNLTerm.Direction.Input, "CE")
238
+ clr = snl.SNLScalarTerm.create(fdce, snl.SNLTerm.Direction.Input, "CLR")
239
+ d = snl.SNLScalarTerm.create(fdce, snl.SNLTerm.Direction.Input, "D")
240
+ snl.SNLParameter.create_binary(fdce, "INIT", 1, 0b0)
241
+ snl.SNLDesign.addInputsToClockArcs([ce, clr, d], c)
242
+ snl.SNLDesign.addClockToOutputsArcs(c, q)
243
+
244
+
245
+ def constructFDPE(lib):
246
+ fdpe = snl.SNLDesign.createPrimitive(lib, "FDPE")
247
+ q = snl.SNLScalarTerm.create(fdpe, snl.SNLTerm.Direction.Output, "Q")
248
+ c = snl.SNLScalarTerm.create(fdpe, snl.SNLTerm.Direction.Input, "C")
249
+ ce = snl.SNLScalarTerm.create(fdpe, snl.SNLTerm.Direction.Input, "CE")
250
+ pre = snl.SNLScalarTerm.create(fdpe, snl.SNLTerm.Direction.Input, "PRE")
251
+ d = snl.SNLScalarTerm.create(fdpe, snl.SNLTerm.Direction.Input, "D")
252
+ snl.SNLParameter.create_binary(fdpe, "INIT", 1, 0b1)
253
+ snl.SNLDesign.addInputsToClockArcs([ce, pre, d], c)
254
+ snl.SNLDesign.addClockToOutputsArcs(c, q)
255
+
256
+
257
+ def constructFDRE(lib):
258
+ fdre = snl.SNLDesign.createPrimitive(lib, "FDRE")
259
+ q = snl.SNLScalarTerm.create(fdre, snl.SNLTerm.Direction.Output, "Q")
260
+ c = snl.SNLScalarTerm.create(fdre, snl.SNLTerm.Direction.Input, "C")
261
+ ce = snl.SNLScalarTerm.create(fdre, snl.SNLTerm.Direction.Input, "CE")
262
+ r = snl.SNLScalarTerm.create(fdre, snl.SNLTerm.Direction.Input, "R")
263
+ d = snl.SNLScalarTerm.create(fdre, snl.SNLTerm.Direction.Input, "D")
264
+ snl.SNLParameter.create_binary(fdre, "INIT", 1, 0b0)
265
+ snl.SNLDesign.addInputsToClockArcs([ce, r, d], c)
266
+ snl.SNLDesign.addClockToOutputsArcs(c, q)
267
+
268
+
269
+ def constructFDSE(lib):
270
+ fdse = snl.SNLDesign.createPrimitive(lib, "FDSE")
271
+ q = snl.SNLScalarTerm.create(fdse, snl.SNLTerm.Direction.Output, "Q")
272
+ c = snl.SNLScalarTerm.create(fdse, snl.SNLTerm.Direction.Input, "C")
273
+ ce = snl.SNLScalarTerm.create(fdse, snl.SNLTerm.Direction.Input, "CE")
274
+ s = snl.SNLScalarTerm.create(fdse, snl.SNLTerm.Direction.Input, "S")
275
+ d = snl.SNLScalarTerm.create(fdse, snl.SNLTerm.Direction.Input, "D")
276
+ snl.SNLParameter.create_binary(fdse, "INIT", 1, 0b0)
277
+ snl.SNLDesign.addInputsToClockArcs([ce, s, d], c)
278
+ snl.SNLDesign.addClockToOutputsArcs(c, q)
279
+
280
+
281
+ def constructRAM32M(lib):
282
+ ram32m = snl.SNLDesign.createPrimitive(lib, "RAM32M")
283
+ snl.SNLBusTerm.create(ram32m, snl.SNLTerm.Direction.Output, 1, 0, "DOA")
284
+ snl.SNLBusTerm.create(ram32m, snl.SNLTerm.Direction.Output, 1, 0, "DOB")
285
+ snl.SNLBusTerm.create(ram32m, snl.SNLTerm.Direction.Output, 1, 0, "DOC")
286
+ snl.SNLBusTerm.create(ram32m, snl.SNLTerm.Direction.Output, 1, 0, "DOD")
287
+ snl.SNLBusTerm.create(ram32m, snl.SNLTerm.Direction.Input, 4, 0, "ADDRA")
288
+ snl.SNLBusTerm.create(ram32m, snl.SNLTerm.Direction.Input, 4, 0, "ADDRB")
289
+ snl.SNLBusTerm.create(ram32m, snl.SNLTerm.Direction.Input, 4, 0, "ADDRC")
290
+ snl.SNLBusTerm.create(ram32m, snl.SNLTerm.Direction.Input, 4, 0, "ADDRD")
291
+ snl.SNLBusTerm.create(ram32m, snl.SNLTerm.Direction.Input, 1, 0, "DIA")
292
+ snl.SNLBusTerm.create(ram32m, snl.SNLTerm.Direction.Input, 1, 0, "DIB")
293
+ snl.SNLBusTerm.create(ram32m, snl.SNLTerm.Direction.Input, 1, 0, "DIC")
294
+ snl.SNLBusTerm.create(ram32m, snl.SNLTerm.Direction.Input, 1, 0, "DID")
295
+ snl.SNLScalarTerm.create(ram32m, snl.SNLTerm.Direction.Input, "WCLK")
296
+ snl.SNLScalarTerm.create(ram32m, snl.SNLTerm.Direction.Input, "WE")
297
+ snl.SNLParameter.create_binary(ram32m, "INIT_A", 64, 0)
298
+ snl.SNLParameter.create_binary(ram32m, "INIT_B", 64, 0)
299
+ snl.SNLParameter.create_binary(ram32m, "INIT_C", 64, 0)
300
+ snl.SNLParameter.create_binary(ram32m, "INIT_D", 64, 0)
301
+
302
+
303
+ def constructRAM64M(lib):
304
+ ram64m = snl.SNLDesign.createPrimitive(lib, "RAM64M")
305
+ snl.SNLScalarTerm.create(ram64m, snl.SNLTerm.Direction.Output, "DOA")
306
+ snl.SNLScalarTerm.create(ram64m, snl.SNLTerm.Direction.Output, "DOB")
307
+ snl.SNLScalarTerm.create(ram64m, snl.SNLTerm.Direction.Output, "DOC")
308
+ snl.SNLScalarTerm.create(ram64m, snl.SNLTerm.Direction.Output, "DOD")
309
+ snl.SNLBusTerm.create(ram64m, snl.SNLTerm.Direction.Input, 5, 0, "ADDRA")
310
+ snl.SNLBusTerm.create(ram64m, snl.SNLTerm.Direction.Input, 5, 0, "ADDRB")
311
+ snl.SNLBusTerm.create(ram64m, snl.SNLTerm.Direction.Input, 5, 0, "ADDRC")
312
+ snl.SNLBusTerm.create(ram64m, snl.SNLTerm.Direction.Input, 5, 0, "ADDRD")
313
+ snl.SNLScalarTerm.create(ram64m, snl.SNLTerm.Direction.Input, "DIA")
314
+ snl.SNLScalarTerm.create(ram64m, snl.SNLTerm.Direction.Input, "DIB")
315
+ snl.SNLScalarTerm.create(ram64m, snl.SNLTerm.Direction.Input, "DIC")
316
+ snl.SNLScalarTerm.create(ram64m, snl.SNLTerm.Direction.Input, "DID")
317
+ snl.SNLScalarTerm.create(ram64m, snl.SNLTerm.Direction.Input, "WCLK")
318
+ snl.SNLScalarTerm.create(ram64m, snl.SNLTerm.Direction.Input, "WE")
319
+ snl.SNLParameter.create_binary(ram64m, "INIT_A", 64, 0)
320
+ snl.SNLParameter.create_binary(ram64m, "INIT_B", 64, 0)
321
+ snl.SNLParameter.create_binary(ram64m, "INIT_C", 64, 0)
322
+ snl.SNLParameter.create_binary(ram64m, "INIT_D", 64, 0)
323
+
324
+
325
+ def constructRAMB18E1(lib):
326
+ ramb18e1 = snl.SNLDesign.createPrimitive(lib, "RAMB18E1")
327
+ snl.SNLBusTerm.create(ramb18e1, snl.SNLTerm.Direction.Input, 13, 0, "ADDRARDADDR")
328
+ snl.SNLBusTerm.create(ramb18e1, snl.SNLTerm.Direction.Input, 13, 0, "ADDRBWRADDR")
329
+ snl.SNLScalarTerm.create(ramb18e1, snl.SNLTerm.Direction.Input, "CLKARDCLK")
330
+ snl.SNLScalarTerm.create(ramb18e1, snl.SNLTerm.Direction.Input, "CLKBWRCLK")
331
+ snl.SNLBusTerm.create(ramb18e1, snl.SNLTerm.Direction.Input, 15, 0, "DIADI")
332
+ snl.SNLBusTerm.create(ramb18e1, snl.SNLTerm.Direction.Input, 15, 0, "DIBDI")
333
+ snl.SNLBusTerm.create(ramb18e1, snl.SNLTerm.Direction.Input, 1, 0, "DIPADIP")
334
+ snl.SNLBusTerm.create(ramb18e1, snl.SNLTerm.Direction.Input, 1, 0, "DIPBDIP")
335
+ snl.SNLBusTerm.create(ramb18e1, snl.SNLTerm.Direction.Output, 15, 0, "DOADO")
336
+ snl.SNLBusTerm.create(ramb18e1, snl.SNLTerm.Direction.Output, 15, 0, "DOBDO")
337
+ snl.SNLBusTerm.create(ramb18e1, snl.SNLTerm.Direction.Output, 1, 0, "DOPADOP")
338
+ snl.SNLBusTerm.create(ramb18e1, snl.SNLTerm.Direction.Output, 1, 0, "DOPBDOP")
339
+ snl.SNLScalarTerm.create(ramb18e1, snl.SNLTerm.Direction.Input, "ENARDEN")
340
+ snl.SNLScalarTerm.create(ramb18e1, snl.SNLTerm.Direction.Input, "ENBWREN")
341
+ snl.SNLScalarTerm.create(ramb18e1, snl.SNLTerm.Direction.Input, "REGCEAREGCE")
342
+ snl.SNLScalarTerm.create(ramb18e1, snl.SNLTerm.Direction.Input, "REGCEB")
343
+ snl.SNLScalarTerm.create(ramb18e1, snl.SNLTerm.Direction.Input, "RSTRAMARSTRAM")
344
+ snl.SNLScalarTerm.create(ramb18e1, snl.SNLTerm.Direction.Input, "RSTRAMB")
345
+ snl.SNLScalarTerm.create(ramb18e1, snl.SNLTerm.Direction.Input, "RSTREGARSTREG")
346
+ snl.SNLScalarTerm.create(ramb18e1, snl.SNLTerm.Direction.Input, "RSTREGB")
347
+ snl.SNLBusTerm.create(ramb18e1, snl.SNLTerm.Direction.Input, 1, 0, "WEA")
348
+ snl.SNLBusTerm.create(ramb18e1, snl.SNLTerm.Direction.Input, 3, 0, "WEBWE")
349
+ snl.SNLParameter.create_decimal(ramb18e1, "DOA_REG", 0)
350
+ snl.SNLParameter.create_decimal(ramb18e1, "DOB_REG", 0)
351
+ snl.SNLParameter.create_binary(ramb18e1, "INIT_A", 18, 0x00000)
352
+ snl.SNLParameter.create_binary(ramb18e1, "INIT_B", 18, 0x00000)
353
+ for i in range(64):
354
+ paramName = "INIT_" + hex(i)[2:].zfill(2).upper()
355
+ snl.SNLParameter.create_binary(ramb18e1, paramName, 256, 0)
356
+ for i in range(8):
357
+ paramName = "INITP_" + hex(i)[2:].zfill(2).upper()
358
+ snl.SNLParameter.create_binary(ramb18e1, paramName, 256, 0)
359
+ snl.SNLParameter.create_string(ramb18e1, "RAM_MODE", "TDP")
360
+ snl.SNLParameter.create_decimal(ramb18e1, "READ_WIDTH_A", 0)
361
+ snl.SNLParameter.create_decimal(ramb18e1, "READ_WIDTH_B", 0)
362
+ snl.SNLParameter.create_binary(ramb18e1, "SRVAL_A", 18, 0)
363
+ snl.SNLParameter.create_binary(ramb18e1, "SRVAL_B", 18, 0)
364
+ snl.SNLParameter.create_string(ramb18e1, "WRITE_MODE_A", "WRITE_FIRST")
365
+ snl.SNLParameter.create_string(ramb18e1, "WRITE_MODE_B", "WRITE_FIRST")
366
+ snl.SNLParameter.create_decimal(ramb18e1, "WRITE_WIDTH_A", 0)
367
+ snl.SNLParameter.create_decimal(ramb18e1, "WRITE_WIDTH_B", 0)
368
+
369
+
370
+ def constructRAMB36E1(lib):
371
+ ramb36e1 = snl.SNLDesign.createPrimitive(lib, "RAMB36E1")
372
+ snl.SNLBusTerm.create(ramb36e1, snl.SNLTerm.Direction.Input, 15, 0, "ADDRARDADDR")
373
+ snl.SNLBusTerm.create(ramb36e1, snl.SNLTerm.Direction.Input, 15, 0, "ADDRBWRADDR")
374
+ snl.SNLScalarTerm.create(ramb36e1, snl.SNLTerm.Direction.Input, "CASCADEINA")
375
+ snl.SNLScalarTerm.create(ramb36e1, snl.SNLTerm.Direction.Input, "CASCADEINB")
376
+ snl.SNLScalarTerm.create(ramb36e1, snl.SNLTerm.Direction.Output, "CASCADEOUTA")
377
+ snl.SNLScalarTerm.create(ramb36e1, snl.SNLTerm.Direction.Output, "CASCADEOUTB")
378
+ snl.SNLScalarTerm.create(ramb36e1, snl.SNLTerm.Direction.Input, "CLKARDCLK")
379
+ snl.SNLScalarTerm.create(ramb36e1, snl.SNLTerm.Direction.Input, "CLKBWRCLK")
380
+ snl.SNLScalarTerm.create(ramb36e1, snl.SNLTerm.Direction.Output, "DBITERR")
381
+ snl.SNLBusTerm.create(ramb36e1, snl.SNLTerm.Direction.Input, 31, 0, "DIADI")
382
+ snl.SNLBusTerm.create(ramb36e1, snl.SNLTerm.Direction.Input, 31, 0, "DIBDI")
383
+ snl.SNLBusTerm.create(ramb36e1, snl.SNLTerm.Direction.Input, 3, 0, "DIPADIP")
384
+ snl.SNLBusTerm.create(ramb36e1, snl.SNLTerm.Direction.Input, 3, 0, "DIPBDIP")
385
+ snl.SNLBusTerm.create(ramb36e1, snl.SNLTerm.Direction.Output, 31, 0, "DOADO")
386
+ snl.SNLBusTerm.create(ramb36e1, snl.SNLTerm.Direction.Output, 31, 0, "DOBDO")
387
+ snl.SNLBusTerm.create(ramb36e1, snl.SNLTerm.Direction.Output, 3, 0, "DOPADOP")
388
+ snl.SNLBusTerm.create(ramb36e1, snl.SNLTerm.Direction.Output, 3, 0, "DOPBDOP")
389
+ snl.SNLBusTerm.create(ramb36e1, snl.SNLTerm.Direction.Output, 7, 0, "ECCPARITY")
390
+ snl.SNLScalarTerm.create(ramb36e1, snl.SNLTerm.Direction.Input, "ENARDEN")
391
+ snl.SNLScalarTerm.create(ramb36e1, snl.SNLTerm.Direction.Input, "ENBWREN")
392
+ snl.SNLScalarTerm.create(ramb36e1, snl.SNLTerm.Direction.Input, "INJECTDBITERR")
393
+ snl.SNLScalarTerm.create(ramb36e1, snl.SNLTerm.Direction.Input, "INJECTSBITERR")
394
+ snl.SNLBusTerm.create(ramb36e1, snl.SNLTerm.Direction.Output, 8, 0, "RDADDRECC")
395
+ snl.SNLScalarTerm.create(ramb36e1, snl.SNLTerm.Direction.Input, "REGCEAREGCE")
396
+ snl.SNLScalarTerm.create(ramb36e1, snl.SNLTerm.Direction.Input, "REGCEB")
397
+ snl.SNLScalarTerm.create(ramb36e1, snl.SNLTerm.Direction.Input, "RSTRAMARSTRAM")
398
+ snl.SNLScalarTerm.create(ramb36e1, snl.SNLTerm.Direction.Input, "RSTRAMB")
399
+ snl.SNLScalarTerm.create(ramb36e1, snl.SNLTerm.Direction.Input, "RSTREGARSTREG")
400
+ snl.SNLScalarTerm.create(ramb36e1, snl.SNLTerm.Direction.Input, "RSTREGB")
401
+ snl.SNLScalarTerm.create(ramb36e1, snl.SNLTerm.Direction.Output, "SBITERR")
402
+ snl.SNLBusTerm.create(ramb36e1, snl.SNLTerm.Direction.Input, 3, 0, "WEA")
403
+ snl.SNLBusTerm.create(ramb36e1, snl.SNLTerm.Direction.Input, 7, 0, "WEBWE")
404
+
405
+ snl.SNLParameter.create_decimal(ramb36e1, "DOA_REG", 0)
406
+ snl.SNLParameter.create_decimal(ramb36e1, "DOB_REG", 0)
407
+ snl.SNLParameter.create_binary(ramb36e1, "INIT_A", 36, 0)
408
+ snl.SNLParameter.create_binary(ramb36e1, "INIT_B", 36, 0)
409
+ for i in range(128):
410
+ paramName = "INIT_" + hex(i)[2:].zfill(2).upper()
411
+ snl.SNLParameter.create_binary(ramb36e1, paramName, 256, 0)
412
+ snl.SNLParameter.create_string(ramb36e1, "RAM_EXTENSION_A", "NONE")
413
+ snl.SNLParameter.create_string(ramb36e1, "RAM_EXTENSION_B", "NONE")
414
+ for i in range(16):
415
+ paramName = "INITP_" + hex(i)[2:].zfill(2).upper()
416
+ snl.SNLParameter.create_binary(ramb36e1, paramName, 256, 0)
417
+ snl.SNLParameter.create_string(ramb36e1, "RAM_MODE", "TDP")
418
+ snl.SNLParameter.create_decimal(ramb36e1, "READ_WIDTH_A", 0)
419
+ snl.SNLParameter.create_decimal(ramb36e1, "READ_WIDTH_B", 0)
420
+ snl.SNLParameter.create_decimal(ramb36e1, "WRITE_WIDTH_A", 0)
421
+ snl.SNLParameter.create_decimal(ramb36e1, "WRITE_WIDTH_B", 0)
422
+ snl.SNLParameter.create_binary(ramb36e1, "SRVAL_A", 36, 0)
423
+ snl.SNLParameter.create_binary(ramb36e1, "SRVAL_B", 36, 0)
424
+ snl.SNLParameter.create_string(ramb36e1, "WRITE_MODE_A", "WRITE_FIRST")
425
+ snl.SNLParameter.create_string(ramb36e1, "WRITE_MODE_B", "WRITE_FIRST")
426
+
427
+
428
+ def load(db):
429
+ lib = snl.SNLLibrary.createPrimitives(db, "xilinx")
430
+ constructIBUF(lib)
431
+ constructOBUF(lib)
432
+ constructBUFG(lib)
433
+ constructDSP48E1(lib)
434
+ constructINV(lib)
435
+ constructCARRY4(lib)
436
+ constructLUT1(lib)
437
+ constructLUT2(lib)
438
+ constructLUT3(lib)
439
+ constructLUT4(lib)
440
+ constructLUT5(lib)
441
+ constructLUT6(lib)
442
+ constructMUXF7(lib)
443
+ constructMUXF8(lib)
444
+ constructSRL16E(lib)
445
+ constructFDCE(lib)
446
+ constructFDPE(lib)
447
+ constructFDRE(lib)
448
+ constructFDSE(lib)
449
+ constructRAM32M(lib)
450
+ constructRAM64M(lib)
451
+ constructRAMB18E1(lib)
452
+ constructRAMB36E1(lib)
najaeda/snl.so CHANGED
Binary file
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: najaeda
3
- Version: 0.1.2
3
+ Version: 0.1.4
4
4
  Summary: Naja EDA Python package
5
5
  Author-Email: Naja Authors <contact@keplertech.io>
6
6
  License: Apache License 2.0
@@ -11,15 +11,8 @@ Description-Content-Type: text/x-rst
11
11
  Naja EDA Python Package
12
12
  =======================
13
13
 
14
- Naja EDA is a Python package that provides data structures and APIs for developing post-synthesis Electronic Design Automation (EDA) algorithms. It serves as the Python counterpart to the `Naja C++ project <https://github.com/najaeda/naja>`_.
15
-
16
- Features
17
- --------
18
-
19
- - **Netlist Simplification**: Perform constant propagation and dead logic elimination.
20
- - **Logic Replication**: Facilitate duplication of logic elements for optimization.
21
- - **Netlist Partitioning**: Divide netlists into manageable sections.
22
- - **Place and Route Support**: Assist in ASIC and FPGA design flows.
14
+ Naja EDA is a Python package that provides data structures and APIs for developing post-synthesis Electronic Design Automation (EDA) algorithms.
15
+ It serves as the Python counterpart to the `Naja C++ project <https://github.com/najaeda/naja>`_.
23
16
 
24
17
  Installation
25
18
  ------------
@@ -32,24 +25,48 @@ Install Naja EDA using pip:
32
25
 
33
26
  Examples
34
27
  --------
28
+
29
+ Load a design from a liberty file and a Verilog file
30
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
35
31
  Following snippet shows how to load primitive cells from a liberty file and
36
32
  a netlist from a Verilog file.
33
+
37
34
  .. code-block:: python
38
35
 
39
- from os import path
40
- from najaeda import netlist
41
-
42
36
  benchmarks = path.join('..','benchmarks')
43
- liberty_files = ['NangateOpenCellLibrary_typical.lib', 'fakeram45_1024x32.lib', 'fakeram45_64x32.lib']
37
+ liberty_files = [
38
+ 'NangateOpenCellLibrary_typical.lib',
39
+ 'fakeram45_1024x32.lib',
40
+ 'fakeram45_64x32.lib'
41
+ ]
44
42
  liberty_files = list(map(lambda p:path.join(benchmarks, 'liberty', p), liberty_files))
45
43
 
46
44
  netlist.load_liberty(liberty_files)
47
45
  top = netlist.load_verilog([path.join(benchmarks, 'verilog', 'tinyrocket.v')])
48
46
 
49
- #dump verilog
50
- top.dump_verilog('tinyrocket_naja.v')
47
+ top.dump_verilog('.', 'tinyrocket_naja.v')
48
+
49
+ Load a design with pre-existing libraries
50
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
51
+ In FPGA design environments, Liberty files are often unavailable.
52
+ To address this, the following example demonstrates how to load primitives
53
+ without relying on Liberty files.
51
54
 
55
+ najaeda comes with pre-configured libraries to simplify this process.
56
+ Currently, it includes support for partial Xilinx primitives, but this can be
57
+ easily extended in the future. Don't hesitate to reach out if you need help.
58
+
59
+ .. code-block:: python
60
+
61
+ netlist.load_primitives('xilinx')
62
+ benchmarks = path.join('..','benchmarks')
63
+ top = netlist.load_verilog([path.join(benchmarks, 'verilog', 'arm_core_netlist.v')])
64
+ #
65
+
66
+ Print all the instances in the netlist
67
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
52
68
  Next example shows how to browse all the netlist and print all its content.
69
+
53
70
  .. code-block:: python
54
71
 
55
72
  def print_netlist(instance):
@@ -59,8 +76,9 @@ Next example shows how to browse all the netlist and print all its content.
59
76
 
60
77
  Documentation
61
78
  -------------
79
+ najaeda is a work in progress, and the documentation is still under development.
62
80
 
63
- Comprehensive documentation is available on the `Naja GitHub repository <https://github.com/najaeda/naja>`_.
81
+ Naja documentation is available on the `Naja GitHub repository <https://github.com/najaeda/naja>`_.
64
82
 
65
83
  License
66
84
  -------
@@ -0,0 +1,12 @@
1
+ najaeda-0.1.4.dist-info/RECORD,,
2
+ najaeda-0.1.4.dist-info/WHEEL,sha256=WOiMFvo9bzNKIh5Rxx7xDwR4DzXJ4VAFWxSvvQdE_uA,115
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=0uzkylAN7mfQQL_oXx0b476SaB2mGyrJXhsxI8nVuhs,740272
8
+ najaeda/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
+ najaeda/libnaja_snl.dylib,sha256=8Ei7KKU0b14IqlvH_8yQSSCpH0rjbxpeRaXgyfSemMY,574112
10
+ najaeda/snl.so,sha256=Og454YB20jBXM9_5w2YG0e-yDHX95KaJxdGK-6FvjW4,97888
11
+ najaeda/primitives/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
+ najaeda/primitives/xilinx.py,sha256=fuu4KxEIuC0ueCK4C_gds6hzgtJsLE3tjDtOHtY9McM,25947
@@ -3,4 +3,5 @@
3
3
  # This does not necessarily list everyone who has contributed code, since in
4
4
  # some cases, their employer may be the copyright holder. To see the full list
5
5
  # of contributors, see the revision history in source control.
6
- Christophe Alexandre <christophe.alex@gmail.com>
6
+ Christophe Alexandre <christophe.alexandre@keplertech.io>
7
+ Noam Cohen <noam.cohen@keplertech.io>
najaeda/.dylibs/PythonT DELETED
Binary file
@@ -1,11 +0,0 @@
1
- najaeda-0.1.2.dist-info/RECORD,,
2
- najaeda-0.1.2.dist-info/WHEEL,sha256=WOiMFvo9bzNKIh5Rxx7xDwR4DzXJ4VAFWxSvvQdE_uA,115
3
- najaeda-0.1.2.dist-info/METADATA,sha256=agjVbL5DID69VNnjngj23q1t-TEOHBaCUhMnhIGEjZI,2267
4
- najaeda-0.1.2.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
5
- najaeda-0.1.2.dist-info/licenses/AUTHORS,sha256=e4DCPGHo6wKMyQz24V59EP7zMwalK-KBDBHHlMLFxHY,330
6
- najaeda/netlist.py,sha256=usJ__3Vh_A8GFK7xUdhwJSdsTc7DWhaIF3Ptp3dfuZU,21251
7
- najaeda/libnaja_snl_python.dylib,sha256=X7DlbBDkBvAT2MFrb47L27aU6SuNF8lr0YTAGLW4pAw,739984
8
- najaeda/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
- najaeda/libnaja_snl.dylib,sha256=8Ei7KKU0b14IqlvH_8yQSSCpH0rjbxpeRaXgyfSemMY,574112
10
- najaeda/snl.so,sha256=Pm6IrWbo5sJ7VbokbTf36Q_tVlttrtXkNT4A_b4X1Pg,97888
11
- najaeda/.dylibs/PythonT,sha256=PKxrOOyA9Wrc11wkOBZVdQachBkACXp9879F1jMycxc,13116640