najaeda 0.1.23__cp313-cp313t-macosx_11_0_arm64.whl → 0.1.25__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.

@@ -23,8 +23,7 @@ With **najaeda**, it is possible to:
23
23
  * **Prototype EDA Ideas Quickly**:
24
24
  * Use an intuitive API to experiment with new EDA concepts and workflows.
25
25
  * **Develop Custom EDA Tools**:
26
- * Build fast, tailored tools for solving specific challenges
27
- without relying on costly, proprietary EDA software.
26
+ * Build fast, tailored tools for solving specific challenges without relying on costly, proprietary EDA software.
28
27
 
29
28
  **najaeda** empowers developers to innovate, adapt, and accelerate
30
29
  their EDA processes with minimal overhead.
@@ -34,6 +33,15 @@ Information about the **najaeda** PyPI package is available at https://pypi.org/
34
33
  If you want more details about the underlying **naja** C++ library,
35
34
  please visit the **naja** GitHub repository at https://github.com/najaeda/naja .
36
35
 
36
+ Quick Start
37
+ ===========
38
+
39
+ To get started with **najaeda**, try out the interactive notebook in Google Colab:
40
+
41
+ .. image:: https://colab.research.google.com/assets/colab-badge.svg
42
+ :target: https://colab.research.google.com/github/najaeda/najaeda-tutorials/blob/main/notebooks/01_getting_started.ipynb
43
+ :alt: Open in Colab
44
+
37
45
  Installation
38
46
  ------------
39
47
  **najaeda** can be easily installed using pip:
najaeda/libnaja_bne.dylib CHANGED
Binary file
najaeda/libnaja_nl.dylib CHANGED
Binary file
najaeda/libnaja_opt.dylib CHANGED
Binary file
Binary file
najaeda/naja.so CHANGED
Binary file
najaeda/netlist.py CHANGED
@@ -12,6 +12,7 @@ import sys
12
12
  import os
13
13
  from enum import Enum
14
14
  from typing import Union, List
15
+ from dataclasses import dataclass
15
16
 
16
17
  from najaeda import naja
17
18
 
@@ -363,7 +364,10 @@ class Net:
363
364
  return sum(1 for _ in self.get_inst_terms())
364
365
 
365
366
  def get_design_terms(self):
366
- """
367
+ """Return an iterator over the design terminals of the net.
368
+ This includes only the terminals that are part of the current design.
369
+ The iterator will yield Term objects bit per bit.
370
+
367
371
  :return: an iterator over the design terminals of the net.
368
372
  :rtype: Iterator[Term]
369
373
  """
@@ -372,8 +376,18 @@ class Net:
372
376
  for term in self.net.getBitTerms():
373
377
  yield Term(self.pathIDs, term)
374
378
 
375
- def get_terms(self):
379
+ def count_design_terms(self) -> int:
380
+ """Count the design terminals of this net.
381
+
382
+ :return: the number of design terminals of this net.
383
+ :rtype: int
376
384
  """
385
+ return sum(1 for _ in self.get_design_terms())
386
+
387
+ def get_terms(self):
388
+ """Return an iterator over the terminals of the net.
389
+ This includes both design and instance terminals.
390
+
377
391
  :return: an iterator over the terminals of the net.
378
392
  :rtype: Iterator[Term]
379
393
  """
@@ -415,9 +429,11 @@ def get_snl_term_for_ids_with_path(path, termIDs):
415
429
 
416
430
 
417
431
  class Term:
418
- INPUT = naja.SNLTerm.Direction.Input
419
- OUTPUT = naja.SNLTerm.Direction.Output
420
- INOUT = naja.SNLTerm.Direction.InOut
432
+ class Direction(Enum):
433
+ """Enum for the direction of a term."""
434
+ INPUT = naja.SNLTerm.Direction.Input
435
+ OUTPUT = naja.SNLTerm.Direction.Output
436
+ INOUT = naja.SNLTerm.Direction.InOut
421
437
 
422
438
  def __init__(self, path, term):
423
439
  # self.termIDs = []
@@ -558,18 +574,18 @@ class Term:
558
574
  """
559
575
  return get_snl_term_for_ids(self.pathIDs, self.termIDs).getName()
560
576
 
561
- def get_direction(self) -> naja.SNLTerm.Direction:
577
+ def get_direction(self) -> Direction:
562
578
  """
563
579
  :return: the direction of the term.
564
- :rtype: naja.SNLTerm.Direction
580
+ :rtype: Term.Direction
565
581
  """
566
582
  snlterm = get_snl_term_for_ids(self.pathIDs, self.termIDs)
567
583
  if snlterm.getDirection() == naja.SNLTerm.Direction.Input:
568
- return Term.INPUT
584
+ return Term.Direction.INPUT
569
585
  elif snlterm.getDirection() == naja.SNLTerm.Direction.Output:
570
- return Term.OUTPUT
586
+ return Term.Direction.OUTPUT
571
587
  elif snlterm.getDirection() == naja.SNLTerm.Direction.InOut:
572
- return Term.INOUT
588
+ return Term.Direction.INOUT
573
589
 
574
590
  def __get_snl_bitnet(self, bit) -> Net:
575
591
  # single bit
@@ -633,6 +649,7 @@ class Term:
633
649
  """
634
650
  :return: the net of the term.
635
651
  :rtype: Net
652
+ :remark: If the term is a top level term, it will return None.
636
653
  """
637
654
  head_path = self.pathIDs.copy()
638
655
  if len(head_path) == 0:
@@ -962,17 +979,25 @@ class Instance:
962
979
  def dump_context_dot(self, path: str):
963
980
  self.__get_snl_model().dumpContextDotFile(path)
964
981
 
965
- def get_child_instance(self, name: str):
982
+ def get_child_instance(self, names: Union[str, list]):
966
983
  """
967
- :param str name: the name of the child Instance to get.
968
- :return: the child Instance with the given name or None if it does not exist.
984
+ :param names: the name of the child instance
985
+ or the path to the child Instance as a list of names.
986
+ :return: the child Instance at the given path or None if it does not exist.
969
987
  :rtype: Instance or None
970
988
  """
971
- childInst = self.__get_snl_model().getInstance(name)
972
- if childInst is None:
973
- return None
989
+ if isinstance(names, str):
990
+ names = [names]
991
+ if not names:
992
+ raise ValueError("Names argument cannot be empty")
993
+ model = self.__get_snl_model()
974
994
  path = self.pathIDs.copy()
975
- path.append(childInst.getID())
995
+ for name in names:
996
+ childInst = model.getInstance(name)
997
+ if childInst is None:
998
+ return None
999
+ path.append(childInst.getID())
1000
+ model = childInst.getModel()
976
1001
  return Instance(path)
977
1002
 
978
1003
  def get_child_instances(self):
@@ -1300,11 +1325,11 @@ class Instance:
1300
1325
  path = naja.SNLPath(path, newSNLInstance)
1301
1326
  return Instance(path)
1302
1327
 
1303
- def create_term(self, name: str, direction: naja.SNLTerm.Direction) -> Term:
1328
+ def create_term(self, name: str, direction: Term.Direction) -> Term:
1304
1329
  """Create a Term in this Instance with the given name and direction.
1305
1330
 
1306
1331
  :param str name: the name of the Term to create.
1307
- :param naja.SNLTerm.Direction direction: the direction of the Term to create.
1332
+ :param Term.Direction direction: the direction of the Term to create.
1308
1333
  :return: the created Term.
1309
1334
  """
1310
1335
  path = get_snl_path_from_id_list(self.pathIDs)
@@ -1312,7 +1337,7 @@ class Instance:
1312
1337
  naja.SNLUniquifier(path)
1313
1338
  path = get_snl_path_from_id_list(self.pathIDs)
1314
1339
  design = self.__get_snl_model()
1315
- newSNLTerm = naja.SNLScalarTerm.create(design, direction, name)
1340
+ newSNLTerm = naja.SNLScalarTerm.create(design, direction.value, name)
1316
1341
  return Term(path.getPathIDs(), newSNLTerm)
1317
1342
 
1318
1343
  def create_output_term(self, name: str) -> Term:
@@ -1322,7 +1347,7 @@ class Instance:
1322
1347
  :return: the created Term.
1323
1348
  :rtype: Term
1324
1349
  """
1325
- return self.create_term(name, naja.SNLTerm.Direction.Output)
1350
+ return self.create_term(name, Term.Direction.OUTPUT)
1326
1351
 
1327
1352
  def create_input_term(self, name: str) -> Term:
1328
1353
  """Create an input Term in this Instance with the given name.
@@ -1331,7 +1356,7 @@ class Instance:
1331
1356
  :return: the created Term.
1332
1357
  :rtype: Term
1333
1358
  """
1334
- return self.create_term(name, naja.SNLTerm.Direction.Input)
1359
+ return self.create_term(name, Term.Direction.INPUT)
1335
1360
 
1336
1361
  def create_inout_term(self, name: str) -> Term:
1337
1362
  """Create an inout Term in this Instance with the given name.
@@ -1340,22 +1365,22 @@ class Instance:
1340
1365
  :return: the created Term.
1341
1366
  :rtype: Term
1342
1367
  """
1343
- return self.create_term(name, naja.SNLTerm.Direction.InOut)
1368
+ return self.create_term(name, Term.Direction.INOUT)
1344
1369
 
1345
- def create_bus_term(self, name: str, msb: int, lsb: int, direction) -> Term:
1370
+ def create_bus_term(self, name: str, msb: int, lsb: int, direction: Term.Direction) -> Term:
1346
1371
  """Create a bus Term in this Instance with the given name, msb, lsb and direction.
1347
1372
 
1348
1373
  :param str name: the name of the Term to create.
1349
1374
  :param int msb: the most significant bit of the Term to create.
1350
1375
  :param int lsb: the least significant bit of the Term to create.
1351
- :param naja.SNLTerm.Direction direction: the direction of the Term to create.
1376
+ :param Term.Direction direction: the direction of the Term to create.
1352
1377
  :return: the created Term.
1353
1378
  """
1354
1379
  path = get_snl_path_from_id_list(self.pathIDs)
1355
1380
  if path.size() > 0:
1356
1381
  naja.SNLUniquifier(path)
1357
1382
  design = self.__get_snl_model()
1358
- newSNLTerm = naja.SNLBusTerm.create(design, direction, msb, lsb, name)
1383
+ newSNLTerm = naja.SNLBusTerm.create(design, direction.value, msb, lsb, name)
1359
1384
  return Term(self.pathIDs, newSNLTerm)
1360
1385
 
1361
1386
  def create_inout_bus_term(self, name: str, msb: int, lsb: int) -> Term:
@@ -1367,7 +1392,7 @@ class Instance:
1367
1392
  :return: the created Term.
1368
1393
  :rtype: Term
1369
1394
  """
1370
- return self.create_bus_term(name, msb, lsb, naja.SNLTerm.Direction.InOut)
1395
+ return self.create_bus_term(name, msb, lsb, Term.Direction.INOUT)
1371
1396
 
1372
1397
  def create_output_bus_term(self, name: str, msb: int, lsb: int) -> Term:
1373
1398
  """Create an output bus Term in this Instance with the given name, msb and lsb.
@@ -1378,7 +1403,7 @@ class Instance:
1378
1403
  :return: the created Term.
1379
1404
  :rtype: Term
1380
1405
  """
1381
- return self.create_bus_term(name, msb, lsb, naja.SNLTerm.Direction.Output)
1406
+ return self.create_bus_term(name, msb, lsb, Term.Direction.OUTPUT)
1382
1407
 
1383
1408
  def create_input_bus_term(self, name: str, msb: int, lsb: int) -> Term:
1384
1409
  """Create an input bus Term in this Instance with the given name, msb and lsb.
@@ -1389,7 +1414,7 @@ class Instance:
1389
1414
  :return: the created Term.
1390
1415
  :rtype: Term
1391
1416
  """
1392
- return self.create_bus_term(name, msb, lsb, naja.SNLTerm.Direction.Input)
1417
+ return self.create_bus_term(name, msb, lsb, Term.Direction.INPUT)
1393
1418
 
1394
1419
  def create_net(self, name: str) -> Net:
1395
1420
  """Create a scalar Net in this Instance with the given name.
@@ -1423,13 +1448,21 @@ class Instance:
1423
1448
  newSNLNet = naja.SNLBusNet.create(model, msb, lsb, name)
1424
1449
  return Net(path, newSNLNet)
1425
1450
 
1426
- def dump_verilog(self, path: str, name: str):
1451
+ def dump_verilog(self, path: str):
1427
1452
  """Dump the verilog of this instance.
1428
1453
 
1429
- :param str path: the path where to dump the verilog.
1430
- :param str name: the name of the verilog file.
1454
+ :param str path: the file path where to dump the verilog.
1455
+ :rtype: None
1456
+ :raises ValueError: if the path does not end with .v.
1457
+ :raises FileNotFoundError: if the directory of the path does not exist.
1431
1458
  """
1432
- self.__get_snl_model().dumpVerilog(path, name)
1459
+ # path should be a file path of the form "path/to/file.v"
1460
+ if not path.endswith(".v"):
1461
+ raise ValueError("The path must end with .v")
1462
+ dir_path = os.path.dirname(path) or "."
1463
+ if not os.path.exists(dir_path):
1464
+ raise FileNotFoundError(f"The directory {dir_path} does not exist")
1465
+ self.__get_snl_model().dumpVerilog(dir_path, os.path.basename(path))
1433
1466
 
1434
1467
  def get_truth_table(self):
1435
1468
  """
@@ -1448,6 +1481,15 @@ def __get_top_db() -> naja.NLDB:
1448
1481
  return naja.NLUniverse.get().getTopDB()
1449
1482
 
1450
1483
 
1484
+ def reset():
1485
+ """Reset the environment by deleting everything.
1486
+ :rtype: None
1487
+ """
1488
+ u = naja.NLUniverse.get()
1489
+ if u is not None:
1490
+ u.destroy()
1491
+
1492
+
1451
1493
  def get_top():
1452
1494
  """
1453
1495
  :return: the top Instance.
@@ -1472,16 +1514,20 @@ def create_top(name: str) -> Instance:
1472
1514
  return Instance()
1473
1515
 
1474
1516
 
1517
+ @dataclass
1475
1518
  class VerilogConfig:
1476
- def __init__(self, keep_assigns=True):
1477
- self.keep_assigns = keep_assigns
1519
+ keep_assigns: bool = True
1520
+ allow_unknown_designs: bool = False
1478
1521
 
1479
1522
 
1480
1523
  def load_verilog(files: Union[str, List[str]], config: VerilogConfig = None) -> Instance:
1481
1524
  """Load verilog files into the top design.
1525
+
1482
1526
  :param files: a list of verilog files to load or a single file.
1483
1527
  :param config: the configuration to use when loading the files.
1484
1528
  :return: the top Instance.
1529
+ :rtype: Instance
1530
+ :raises Exception: if no files are provided.
1485
1531
  """
1486
1532
  if isinstance(files, str):
1487
1533
  files = [files]
@@ -1491,7 +1537,11 @@ def load_verilog(files: Union[str, List[str]], config: VerilogConfig = None) ->
1491
1537
  config = VerilogConfig() # Use default settings
1492
1538
  start_time = time.time()
1493
1539
  logging.info(f"Loading verilog: {', '.join(files)}")
1494
- __get_top_db().loadVerilog(files, keep_assigns=config.keep_assigns)
1540
+ __get_top_db().loadVerilog(
1541
+ files,
1542
+ keep_assigns=config.keep_assigns,
1543
+ allow_unknown_designs=config.allow_unknown_designs
1544
+ )
1495
1545
  execution_time = time.time() - start_time
1496
1546
  logging.info(f"Loading done in {execution_time:.2f} seconds")
1497
1547
  return get_top()
@@ -1499,7 +1549,10 @@ def load_verilog(files: Union[str, List[str]], config: VerilogConfig = None) ->
1499
1549
 
1500
1550
  def load_liberty(files: Union[str, List[str]]):
1501
1551
  """Load liberty files.
1552
+
1502
1553
  :param files: a list of liberty files to load or a single file.
1554
+ :rtype: None
1555
+ :raises Exception: if no liberty files are provided.
1503
1556
  """
1504
1557
  if isinstance(files, str):
1505
1558
  files = [files]
@@ -1515,11 +1568,17 @@ def load_primitives(name: str):
1515
1568
  Currently supported libraries are:
1516
1569
 
1517
1570
  - xilinx
1571
+ - yosys
1572
+ :param str name: the name of the primitives library to load.
1573
+ :raises ValueError: if the name is not recognized.
1574
+ :rtype: None
1518
1575
  """
1519
1576
  if name == "xilinx":
1520
1577
  from najaeda.primitives import xilinx
1521
-
1522
1578
  xilinx.load(__get_top_db())
1579
+ elif name == "yosys":
1580
+ from najaeda.primitives import yosys
1581
+ yosys.load(__get_top_db())
1523
1582
  else:
1524
1583
  raise ValueError(f"Unknown primitives library: {name}")
1525
1584
 
@@ -1572,14 +1631,18 @@ def get_model_name(id: tuple[int, int, int]) -> str:
1572
1631
 
1573
1632
 
1574
1633
  def apply_dle():
1575
- """Apply the DLE (Dead Logic Elimination) to the top design."""
1634
+ """Apply the DLE (Dead Logic Elimination) to the top design.
1635
+ :rtype: None
1636
+ """
1576
1637
  top = naja.NLUniverse.get().getTopDesign()
1577
1638
  if top is not None:
1578
1639
  naja.NLUniverse.get().applyDLE()
1579
1640
 
1580
1641
 
1581
1642
  def apply_constant_propagation():
1582
- """Apply constant propagation to the top design."""
1643
+ """Apply constant propagation to the top design.
1644
+ :rtype: None
1645
+ """
1583
1646
  top = naja.NLUniverse.get().getTopDesign()
1584
1647
  if top is not None:
1585
1648
  naja.NLUniverse.get().applyConstantPropagation()
@@ -0,0 +1,189 @@
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
+ import logging
6
+ from najaeda import naja
7
+
8
+
9
+ def constructAND(lib):
10
+ and2 = naja.SNLDesign.createPrimitive(lib, "$_AND_")
11
+ naja.SNLScalarTerm.create(and2, naja.SNLTerm.Direction.Input, "A")
12
+ naja.SNLScalarTerm.create(and2, naja.SNLTerm.Direction.Input, "B")
13
+ naja.SNLScalarTerm.create(and2, naja.SNLTerm.Direction.Output, "Y")
14
+ and2.setTruthTable(0x8)
15
+
16
+
17
+ def constructOR(lib):
18
+ or2 = naja.SNLDesign.createPrimitive(lib, "$_OR_")
19
+ naja.SNLScalarTerm.create(or2, naja.SNLTerm.Direction.Input, "A")
20
+ naja.SNLScalarTerm.create(or2, naja.SNLTerm.Direction.Input, "B")
21
+ naja.SNLScalarTerm.create(or2, naja.SNLTerm.Direction.Output, "Y")
22
+ or2.setTruthTable(0xE)
23
+
24
+
25
+ def constructXOR(lib):
26
+ xor2 = naja.SNLDesign.createPrimitive(lib, "$_XOR_")
27
+ naja.SNLScalarTerm.create(xor2, naja.SNLTerm.Direction.Input, "A")
28
+ naja.SNLScalarTerm.create(xor2, naja.SNLTerm.Direction.Input, "B")
29
+ naja.SNLScalarTerm.create(xor2, naja.SNLTerm.Direction.Output, "Y")
30
+ xor2.setTruthTable(0x6)
31
+
32
+
33
+ def constructMUX(lib):
34
+ mux2 = naja.SNLDesign.createPrimitive(lib, "$_MUX_")
35
+ naja.SNLScalarTerm.create(mux2, naja.SNLTerm.Direction.Input, "A")
36
+ naja.SNLScalarTerm.create(mux2, naja.SNLTerm.Direction.Input, "B")
37
+ naja.SNLScalarTerm.create(mux2, naja.SNLTerm.Direction.Input, "S")
38
+ naja.SNLScalarTerm.create(mux2, naja.SNLTerm.Direction.Output, "Y")
39
+ mux2.setTruthTable(0xCA)
40
+
41
+
42
+ def constructNOT(lib):
43
+ not_gate = naja.SNLDesign.createPrimitive(lib, "$_NOT_")
44
+ naja.SNLScalarTerm.create(not_gate, naja.SNLTerm.Direction.Input, "A")
45
+ naja.SNLScalarTerm.create(not_gate, naja.SNLTerm.Direction.Output, "Y")
46
+ not_gate.setTruthTable(0b01)
47
+
48
+
49
+ def constructDFFP(lib):
50
+ dffp = naja.SNLDesign.createPrimitive(lib, "$_DFF_P_")
51
+ naja.SNLScalarTerm.create(dffp, naja.SNLTerm.Direction.Input, "C")
52
+ naja.SNLScalarTerm.create(dffp, naja.SNLTerm.Direction.Input, "D")
53
+ naja.SNLScalarTerm.create(dffp, naja.SNLTerm.Direction.Output, "Q")
54
+
55
+
56
+ def constructDFFE_PP(lib):
57
+ dffe_pp = naja.SNLDesign.createPrimitive(lib, "$_DFFE_PP_")
58
+ naja.SNLScalarTerm.create(dffe_pp, naja.SNLTerm.Direction.Input, "C")
59
+ naja.SNLScalarTerm.create(dffe_pp, naja.SNLTerm.Direction.Input, "D")
60
+ naja.SNLScalarTerm.create(dffe_pp, naja.SNLTerm.Direction.Input, "E")
61
+ naja.SNLScalarTerm.create(dffe_pp, naja.SNLTerm.Direction.Output, "Q")
62
+
63
+
64
+ def constructDFFE_PN(lib):
65
+ dffe_pn = naja.SNLDesign.createPrimitive(lib, "$_DFFE_PN_")
66
+ naja.SNLScalarTerm.create(dffe_pn, naja.SNLTerm.Direction.Input, "C")
67
+ naja.SNLScalarTerm.create(dffe_pn, naja.SNLTerm.Direction.Input, "D")
68
+ naja.SNLScalarTerm.create(dffe_pn, naja.SNLTerm.Direction.Input, "E")
69
+ naja.SNLScalarTerm.create(dffe_pn, naja.SNLTerm.Direction.Output, "Q")
70
+
71
+
72
+ def constructDFF_PP0(lib):
73
+ dffe_pp0 = naja.SNLDesign.createPrimitive(lib, "$_DFF_PP0_")
74
+ naja.SNLScalarTerm.create(dffe_pp0, naja.SNLTerm.Direction.Input, "C")
75
+ naja.SNLScalarTerm.create(dffe_pp0, naja.SNLTerm.Direction.Input, "D")
76
+ naja.SNLScalarTerm.create(dffe_pp0, naja.SNLTerm.Direction.Output, "Q")
77
+ naja.SNLScalarTerm.create(dffe_pp0, naja.SNLTerm.Direction.Input, "R")
78
+
79
+
80
+ def constructDFF_PP1(lib):
81
+ dffe_pp1 = naja.SNLDesign.createPrimitive(lib, "$_DFF_PP1_")
82
+ naja.SNLScalarTerm.create(dffe_pp1, naja.SNLTerm.Direction.Input, "C")
83
+ naja.SNLScalarTerm.create(dffe_pp1, naja.SNLTerm.Direction.Input, "D")
84
+ naja.SNLScalarTerm.create(dffe_pp1, naja.SNLTerm.Direction.Output, "Q")
85
+ naja.SNLScalarTerm.create(dffe_pp1, naja.SNLTerm.Direction.Input, "R")
86
+
87
+
88
+ def constructDFFE_PP0P(lib):
89
+ dffe_pp0p = naja.SNLDesign.createPrimitive(lib, "$_DFFE_PP0P_")
90
+ naja.SNLScalarTerm.create(dffe_pp0p, naja.SNLTerm.Direction.Input, "C")
91
+ naja.SNLScalarTerm.create(dffe_pp0p, naja.SNLTerm.Direction.Input, "D")
92
+ naja.SNLScalarTerm.create(dffe_pp0p, naja.SNLTerm.Direction.Input, "E")
93
+ naja.SNLScalarTerm.create(dffe_pp0p, naja.SNLTerm.Direction.Output, "Q")
94
+ naja.SNLScalarTerm.create(dffe_pp0p, naja.SNLTerm.Direction.Input, "R")
95
+
96
+
97
+ def constructDFFE_PP1P(lib):
98
+ dffe_pp1p = naja.SNLDesign.createPrimitive(lib, "$_DFFE_PP1P_")
99
+ naja.SNLScalarTerm.create(dffe_pp1p, naja.SNLTerm.Direction.Input, "C")
100
+ naja.SNLScalarTerm.create(dffe_pp1p, naja.SNLTerm.Direction.Input, "D")
101
+ naja.SNLScalarTerm.create(dffe_pp1p, naja.SNLTerm.Direction.Input, "E")
102
+ naja.SNLScalarTerm.create(dffe_pp1p, naja.SNLTerm.Direction.Output, "Q")
103
+ naja.SNLScalarTerm.create(dffe_pp1p, naja.SNLTerm.Direction.Input, "R")
104
+
105
+
106
+ def constructDFFE_PP0N(lib):
107
+ dffe_pp0n = naja.SNLDesign.createPrimitive(lib, "$_DFFE_PP0N_")
108
+ naja.SNLScalarTerm.create(dffe_pp0n, naja.SNLTerm.Direction.Input, "C")
109
+ naja.SNLScalarTerm.create(dffe_pp0n, naja.SNLTerm.Direction.Input, "D")
110
+ naja.SNLScalarTerm.create(dffe_pp0n, naja.SNLTerm.Direction.Input, "E")
111
+ naja.SNLScalarTerm.create(dffe_pp0n, naja.SNLTerm.Direction.Output, "Q")
112
+ naja.SNLScalarTerm.create(dffe_pp0n, naja.SNLTerm.Direction.Input, "R")
113
+
114
+
115
+ def constructSDFF_PP0(lib):
116
+ sdff_pp0 = naja.SNLDesign.createPrimitive(lib, "$_SDFF_PP0_")
117
+ naja.SNLScalarTerm.create(sdff_pp0, naja.SNLTerm.Direction.Input, "C")
118
+ naja.SNLScalarTerm.create(sdff_pp0, naja.SNLTerm.Direction.Input, "D")
119
+ naja.SNLScalarTerm.create(sdff_pp0, naja.SNLTerm.Direction.Output, "Q")
120
+ naja.SNLScalarTerm.create(sdff_pp0, naja.SNLTerm.Direction.Input, "R")
121
+
122
+
123
+ def constructSDFFE_PP0N(lib):
124
+ sdffe_pp0n = naja.SNLDesign.createPrimitive(lib, "$_SDFFE_PP0N_")
125
+ naja.SNLScalarTerm.create(sdffe_pp0n, naja.SNLTerm.Direction.Input, "C")
126
+ naja.SNLScalarTerm.create(sdffe_pp0n, naja.SNLTerm.Direction.Input, "D")
127
+ naja.SNLScalarTerm.create(sdffe_pp0n, naja.SNLTerm.Direction.Input, "E")
128
+ naja.SNLScalarTerm.create(sdffe_pp0n, naja.SNLTerm.Direction.Output, "Q")
129
+ naja.SNLScalarTerm.create(sdffe_pp0n, naja.SNLTerm.Direction.Input, "R")
130
+
131
+
132
+ def constructSDFFE_PN0P(lib):
133
+ sdffe_pn0p = naja.SNLDesign.createPrimitive(lib, "$_SDFFE_PN0P_")
134
+ naja.SNLScalarTerm.create(sdffe_pn0p, naja.SNLTerm.Direction.Input, "C")
135
+ naja.SNLScalarTerm.create(sdffe_pn0p, naja.SNLTerm.Direction.Input, "D")
136
+ naja.SNLScalarTerm.create(sdffe_pn0p, naja.SNLTerm.Direction.Input, "E")
137
+ naja.SNLScalarTerm.create(sdffe_pn0p, naja.SNLTerm.Direction.Output, "Q")
138
+ naja.SNLScalarTerm.create(sdffe_pn0p, naja.SNLTerm.Direction.Input, "R")
139
+
140
+
141
+ def constructSDFFE_PN0N(lib):
142
+ sdffe_pn0n = naja.SNLDesign.createPrimitive(lib, "$_SDFFE_PN0N_")
143
+ naja.SNLScalarTerm.create(sdffe_pn0n, naja.SNLTerm.Direction.Input, "C")
144
+ naja.SNLScalarTerm.create(sdffe_pn0n, naja.SNLTerm.Direction.Input, "D")
145
+ naja.SNLScalarTerm.create(sdffe_pn0n, naja.SNLTerm.Direction.Input, "E")
146
+ naja.SNLScalarTerm.create(sdffe_pn0n, naja.SNLTerm.Direction.Output, "Q")
147
+ naja.SNLScalarTerm.create(sdffe_pn0n, naja.SNLTerm.Direction.Input, "R")
148
+
149
+
150
+ def constructSDFFCE_PP0P(lib):
151
+ sdffce_pp0p = naja.SNLDesign.createPrimitive(lib, "$_SDFFCE_PP0P_")
152
+ naja.SNLScalarTerm.create(sdffce_pp0p, naja.SNLTerm.Direction.Input, "C")
153
+ naja.SNLScalarTerm.create(sdffce_pp0p, naja.SNLTerm.Direction.Input, "D")
154
+ naja.SNLScalarTerm.create(sdffce_pp0p, naja.SNLTerm.Direction.Input, "E")
155
+ naja.SNLScalarTerm.create(sdffce_pp0p, naja.SNLTerm.Direction.Output, "Q")
156
+ naja.SNLScalarTerm.create(sdffce_pp0p, naja.SNLTerm.Direction.Input, "R")
157
+
158
+
159
+ def constructSDFFCE_PN0N(lib):
160
+ sdffce_pn0n = naja.SNLDesign.createPrimitive(lib, "$_SDFFCE_PN0N_")
161
+ naja.SNLScalarTerm.create(sdffce_pn0n, naja.SNLTerm.Direction.Input, "C")
162
+ naja.SNLScalarTerm.create(sdffce_pn0n, naja.SNLTerm.Direction.Input, "D")
163
+ naja.SNLScalarTerm.create(sdffce_pn0n, naja.SNLTerm.Direction.Input, "E")
164
+ naja.SNLScalarTerm.create(sdffce_pn0n, naja.SNLTerm.Direction.Output, "Q")
165
+ naja.SNLScalarTerm.create(sdffce_pn0n, naja.SNLTerm.Direction.Input, "R")
166
+
167
+
168
+ def load(db):
169
+ logging.info("Loading Yosys primitives")
170
+ lib = naja.NLLibrary.createPrimitives(db, "yosys")
171
+ constructAND(lib)
172
+ constructOR(lib)
173
+ constructXOR(lib)
174
+ constructMUX(lib)
175
+ constructNOT(lib)
176
+ constructDFFP(lib)
177
+ constructDFFE_PP(lib)
178
+ constructDFFE_PN(lib)
179
+ constructDFF_PP0(lib)
180
+ constructDFF_PP1(lib)
181
+ constructDFFE_PP0P(lib)
182
+ constructDFFE_PP1P(lib)
183
+ constructDFFE_PP0N(lib)
184
+ constructSDFF_PP0(lib)
185
+ constructSDFFE_PP0N(lib)
186
+ constructSDFFE_PN0P(lib)
187
+ constructSDFFE_PN0N(lib)
188
+ constructSDFFCE_PP0P(lib)
189
+ constructSDFFCE_PN0N(lib)
najaeda/stats.py CHANGED
@@ -207,19 +207,19 @@ def compute_instance_stats(instance, instances_stats):
207
207
 
208
208
  def compute_instance_terms(instance, instance_stats):
209
209
  for term in instance.get_terms():
210
- if term.get_direction() == netlist.Term.INPUT:
210
+ if term.get_direction() == netlist.Term.Direction.INPUT:
211
211
  instance_stats.terms["inputs"] = instance_stats.terms.get("inputs", 0) + 1
212
212
  bit_terms = sum(1 for _ in term.get_bits())
213
213
  instance_stats.bit_terms["inputs"] = (
214
214
  instance_stats.bit_terms.get("inputs", 0) + bit_terms
215
215
  )
216
- elif term.get_direction() == netlist.Term.OUTPUT:
216
+ elif term.get_direction() == netlist.Term.Direction.OUTPUT:
217
217
  instance_stats.terms["outputs"] = instance_stats.terms.get("outputs", 0) + 1
218
218
  bit_terms = sum(1 for _ in term.get_bits())
219
219
  instance_stats.bit_terms["outputs"] = (
220
220
  instance_stats.bit_terms.get("outputs", 0) + bit_terms
221
221
  )
222
- elif term.get_direction() == netlist.Term.INOUT:
222
+ elif term.get_direction() == netlist.Term.Direction.INOUT:
223
223
  instance_stats.terms["inouts"] = instance_stats.terms.get("inouts", 0) + 1
224
224
  bit_terms = sum(1 for _ in term.get_bits())
225
225
  instance_stats.bit_terms["inouts"] = (
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: najaeda
3
- Version: 0.1.23
3
+ Version: 0.1.25
4
4
  Summary: Naja EDA Python package
5
5
  Author-Email: Naja Authors <contact@keplertech.io>
6
6
  License: Apache License 2.0
@@ -19,16 +19,16 @@ Project-URL: Homepage, https://github.com/najaeda/naja
19
19
  Requires-Python: >=3.8
20
20
  Description-Content-Type: text/x-rst
21
21
 
22
- Naja EDA Python Package
22
+ najaeda Python Package
23
23
  =======================
24
24
 
25
- Naja EDA is a Python package that provides data structures and APIs for developing post-synthesis Electronic Design Automation (EDA) algorithms.
25
+ najaeda is a Python package that provides data structures and APIs for developing post-synthesis Electronic Design Automation (EDA) algorithms.
26
26
 
27
- Naja EDA provides a powerful yet simple framework designed to help software
27
+ najaeda provides a powerful yet simple framework designed to help software
28
28
  and hardware developers efficiently navigate and manipulate electronic
29
29
  design automation (EDA) workflows.
30
30
 
31
- With Naja EDA, you can:
31
+ With najaeda, you can:
32
32
 
33
33
  * Explore Netlists with Ease:
34
34
 
@@ -51,10 +51,10 @@ With Naja EDA, you can:
51
51
 
52
52
  * Build fast, tailored tools for solving specific challenges without relying on costly, proprietary EDA software.
53
53
 
54
- Naja EDA empowers developers to innovate, adapt, and accelerate their EDA
54
+ najaeda empowers developers to innovate, adapt, and accelerate their EDA
55
55
  processes with minimal overhead.
56
56
 
57
- Naja EDA is the Python counterpart of the `Naja C++ project <https://github.com/najaeda/naja>`_.
57
+ najaeda is the Python counterpart of the `Naja C++ project <https://github.com/najaeda/naja>`_.
58
58
 
59
59
  If you’re interested in this project, please consider starring it on GitHub.
60
60
  Feel free to reach out to us anytime at `contact@keplertech.io <mailto:contact@keplertech.io>`_.
@@ -68,6 +68,15 @@ Install Naja EDA using pip:
68
68
 
69
69
  pip install najaeda
70
70
 
71
+ Quick Start
72
+ -----------
73
+
74
+ To quickly explore what **najaeda** can do, launch the interactive tutorial notebook on Google Colab:
75
+
76
+ .. image:: https://colab.research.google.com/assets/colab-badge.svg
77
+ :target: https://colab.research.google.com/github/najaeda/najaeda-tutorials/blob/main/notebooks/01_getting_started.ipynb
78
+ :alt: Open in Colab
79
+
71
80
  Documentation
72
81
  -------------
73
82
 
@@ -1,19 +1,19 @@
1
- najaeda-0.1.23.dist-info/RECORD,,
2
- najaeda-0.1.23.dist-info/WHEEL,sha256=K65AJzICMUVN6ED5A5fm1lV1nZZqwk4MGF2oXTxJaVw,115
3
- najaeda-0.1.23.dist-info/METADATA,sha256=fUZcD04Cf0r8tlSQgRGVIOQ9NeRfMJYPNLdAR5UcSZE,3046
4
- najaeda-0.1.23.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
5
- najaeda-0.1.23.dist-info/licenses/AUTHORS,sha256=7NYEGDAX_1QZvCCHfq8YVXC5ZbwH_pbNI8DcSmm70GU,377
6
- najaeda/netlist.py,sha256=RA8jMz9uwwlLSLVli5mzqI5Z3RS6mk9YuFol-7SeEIM,53647
7
- najaeda/libnaja_nl.dylib,sha256=O1pfUil1jLkWu89X3JGpKyTwuVqmpsnwZDOESYqjqeU,713152
1
+ najaeda-0.1.25.dist-info/RECORD,,
2
+ najaeda-0.1.25.dist-info/WHEEL,sha256=K65AJzICMUVN6ED5A5fm1lV1nZZqwk4MGF2oXTxJaVw,115
3
+ najaeda-0.1.25.dist-info/METADATA,sha256=gX37lYtMJ59BpS-CtFKG2bq5UCCubzjLNxC8-Xp6Ipk,3384
4
+ najaeda-0.1.25.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
5
+ najaeda-0.1.25.dist-info/licenses/AUTHORS,sha256=7NYEGDAX_1QZvCCHfq8YVXC5ZbwH_pbNI8DcSmm70GU,377
6
+ najaeda/netlist.py,sha256=2h7Tbl3IsCqGDdylWiVX5u-E3yoWAVi6kNb7sS7JqtA,55809
7
+ najaeda/libnaja_nl.dylib,sha256=5995NHdDOsc66W_7HN6dbyvBCqqY3l1u97f8CI4X7mo,738240
8
8
  najaeda/pandas_stats.py,sha256=yOb4ka965U7rN4D6AwvSGmRyeT_O7Ed-5cmT8BFbfeo,1070
9
9
  najaeda/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
- najaeda/naja.so,sha256=G3GyUg1q6mXnFryEyUYh1aPWzc0BoWUZRwc88-3hS9s,99440
10
+ najaeda/naja.so,sha256=DFFPgU5EOfyiK3j1azRi5l8M7GWtlEo09caPybr2zAM,99440
11
11
  najaeda/net_visitor.py,sha256=P_esjibYb-wBDuF-AyF7es9sJYw1Ha8RhTPu-qKe7G4,1940
12
- najaeda/libnaja_opt.dylib,sha256=91kz37-SLpztC7x1F_VYZlddwzCBoNVaD6NqL7OL2GQ,190816
13
- najaeda/libnaja_python.dylib,sha256=P3N0GrfhBgdO3bJ4mMln9TzsFAWDX4ZGa_DejTDRn6U,904352
14
- najaeda/stats.py,sha256=wackXsf0x24ic9v-UifECHj4t5yveUWssMDZp2B057A,16187
12
+ najaeda/libnaja_opt.dylib,sha256=DueaGAzPtgYg5Xn3eVl6cvCMpY2oj_SZqF3uV2iBHb8,212720
13
+ najaeda/libnaja_python.dylib,sha256=r3WP4xrPu_GtfYYhedey2M5S2hXQCGsW0VltuHUFQ58,942752
14
+ najaeda/stats.py,sha256=SJ9rca0Z6ldNAFOjU7DPO2hfx1zq-9Bec0Rx_oLasJo,16217
15
15
  najaeda/instance_visitor.py,sha256=JMsPSQaWNiDjxS05rxg83a0PIsrOIuTi9G35hkwdibs,1530
16
- najaeda/libnaja_bne.dylib,sha256=r9-g0qCILL6w_BgXYg62karCWloSPSpdNGEeS2Ey0Jk,134064
16
+ najaeda/libnaja_bne.dylib,sha256=pLbGUnDr5PSGXbA8wKD-pqEyQIWHbiCb1icPpxRYrWE,136416
17
17
  najaeda/libnaja_dnl.dylib,sha256=zWsiT-RPDJz9koiDDUHqGNFzSFz7x2SmlIo5PTLkTUs,145936
18
18
  najaeda/native/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
19
  najaeda/native/stats.py,sha256=t50hhE9pEFNtlssjES0A-K9TsO_2ZSUAb-e9L3Rt6yc,13063
@@ -30,11 +30,12 @@ najaeda/docs/source/examples.rst.in,sha256=4ZStOA3N5VHbKZgdn2kaEQZL7wPoJwODS2E1B
30
30
  najaeda/docs/source/common_classes.rst,sha256=o20u3mcpFYINwy0sVdye90ZPMQcPqoH3V4ERKcG7SZI,181
31
31
  najaeda/docs/source/equipotential.rst,sha256=0MDi-4fPEsX7K_ezWj5DB3mCalnhqN-sicYbQKYQfNc,335
32
32
  najaeda/docs/source/netlist_classes.rst,sha256=Zrha9MQVEdEwxmP2zhgC0K3iioZXXerzeFoOz5SrOXM,132
33
- najaeda/docs/source/introduction.rst,sha256=kE4qxEJCgcAswiT3rIJS21oBYIMg1cyT_rKmOzQgvsI,2095
33
+ najaeda/docs/source/introduction.rst,sha256=nvxL5OQ-SeVWuTF6CY93iPt7S5ReXvqk5D9bW36CUUs,2416
34
34
  najaeda/docs/source/api.rst,sha256=47VCPyF4Py_1cklZ3q9fmOMhqqI17rxwU_VUJETfCwY,151
35
35
  najaeda/.dylibs/libcapnp-1.1.0.dylib,sha256=l9SvRdxPrCI2mB_UitO7QjsaC7I5mq2R3rZjoIQKEYI,709328
36
36
  najaeda/.dylibs/libtbbmalloc.2.15.dylib,sha256=ORLa9YDlOcMwtcYPZoVnNTTbBpL4lHwYcfA3YCJm_xA,126688
37
37
  najaeda/.dylibs/libtbb.12.15.dylib,sha256=MGGmYnvwo6PQYq7aVv_m2gKHBbOkAdwjPLJtYZvtG7w,366192
38
38
  najaeda/.dylibs/libkj-1.1.0.dylib,sha256=pB7dMks8b8ybJ6xKWqFR_hHjKsmpf7wzbcunZaS7gO4,578320
39
39
  najaeda/primitives/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
40
+ najaeda/primitives/yosys.py,sha256=g1L70AUJoPCkd9B-b9aW4Pzc1AeR9KyIHoXvneW_UEU,8584
40
41
  najaeda/primitives/xilinx.py,sha256=Ka-jlu-OxixEZ_yR_niXLHtaUL8HxT1Bg9H9Kpnr4ns,26551