Skip to content

Commit 6b03a03

Browse files
committed
move lambdalib class to correct repo
1 parent b28a2cb commit 6b03a03

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

lambdalib/__init__.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from siliconcompiler import DesignSchema, ASICProject
2+
13
# individual modules
24
from lambdalib import auxlib
35
from lambdalib import fpgalib
@@ -9,6 +11,55 @@
911

1012
__version__ = "0.3.4"
1113

14+
15+
class LambalibTechLibrary(DesignSchema):
16+
"""A DesignSchema class to manage a lambda library and its associated technology libraries.
17+
18+
This class encapsulates a main lambda library cell and a list of technology
19+
libraries, providing a mechanism to alias them within an ASIC project.
20+
"""
21+
def __init__(self, lambdalib, techlibs):
22+
"""Initializes the LambalibTechLibrary instance.
23+
24+
Args:
25+
lambdalib: The main lambda library cell.
26+
techlibs (list): A list of technology library classes to be associated
27+
with the main lambda library.
28+
"""
29+
super().__init__()
30+
31+
self.__cell = lambdalib
32+
33+
if not techlibs:
34+
techlibs = []
35+
self.__techlibs = techlibs
36+
37+
@classmethod
38+
def alias(cls, project: ASICProject):
39+
"""Creates and registers aliases for the library and its techlibs in a project.
40+
41+
This method checks if the provided project is an ASICProject and if the
42+
lambda library cell exists within the project's libraries. If both
43+
conditions are met, it adds an alias for the main library and adds
44+
each associated technology library to the project's ASIC libraries.
45+
46+
Args:
47+
project (ASICProject): The ASIC project instance to which the aliases
48+
and libraries will be added.
49+
"""
50+
if not isinstance(project, ASICProject):
51+
return
52+
53+
tech = cls()
54+
if not project.has_library(tech.__cell):
55+
return
56+
57+
project.add_alias(tech.__cell, "rtl", tech, "rtl")
58+
59+
for lib in tech.__techlibs:
60+
project.add_asiclib(lib())
61+
62+
1263
__all__ = [
1364
"auxlib",
1465
"fpgalib",

0 commit comments

Comments
 (0)