Skip to content

Commit

Permalink
Merge pull request #317 from chetanya-goyal/main
Browse files Browse the repository at this point in the history
general fixes
  • Loading branch information
msaligane authored Jun 8, 2024
2 parents 4184a40 + 7ee5c1c commit 7dc5eb4
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 9 deletions.
1 change: 1 addition & 0 deletions .github/workflows/glayout_opamp_sim.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ jobs:
$IMAGE_NAME \
bash -c "\
cp ./.github/scripts/test_glayout_ci.py ./openfasoc/generators/glayout/tapeout/tapeout_and_RL/. &&\
pip uninstall glayout -y &&\
pip3 install -r requirements.txt &&\
cd ./openfasoc/generators/glayout/tapeout/tapeout_and_RL/ &&\
pip3 install prettyprint prettyprinttree gdstk &&\
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/glayout_sky130.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ jobs:
-w $PWD \
$IMAGE_NAME \
bash -c "\
pip uninstall glayout -y &&\
cp ./.github/scripts/test_glayout_ci.py ./openfasoc/generators/glayout/. &&\
cd ./openfasoc/generators/glayout &&\
pip3 install gdsfactory==7.7.0 prettyprint prettyprinttree gdstk &&\
Expand All @@ -57,6 +58,7 @@ jobs:
-w $PWD \
$IMAGE_NAME \
bash -c "\
pip uninstall glayout -y &&\
cp ./.github/scripts/test_glayout_ci.py ./openfasoc/generators/glayout/. &&\
cd ./openfasoc/generators/glayout &&\
pip3 install gdsfactory==7.7.0 prettyprint prettyprinttree gdstk &&\
Expand All @@ -76,6 +78,7 @@ jobs:
-w $PWD \
$IMAGE_NAME \
bash -c "\
pip uninstall glayout -y &&\
cp ./.github/scripts/test_glayout_ci.py ./openfasoc/generators/glayout/. &&\
cd ./openfasoc/generators/glayout &&\
pip3 install gdsfactory==7.7.0 prettyprint prettyprinttree gdstk &&\
Expand All @@ -95,6 +98,7 @@ jobs:
-w $PWD \
$IMAGE_NAME \
bash -c "\
pip uninstall glayout -y &&\
cp ./.github/scripts/test_glayout_ci.py ./openfasoc/generators/glayout/. &&\
cd ./openfasoc/generators/glayout &&\
pip3 install gdsfactory==7.7.0 prettyprint prettyprinttree gdstk &&\
Expand All @@ -114,6 +118,7 @@ jobs:
-w $PWD \
$IMAGE_NAME \
bash -c "\
pip uninstall glayout -y &&\
cp ./.github/scripts/test_glayout_ci.py ./openfasoc/generators/glayout/. &&\
cd ./openfasoc/generators/glayout &&\
pip3 install gdsfactory==7.7.0 prettyprint prettyprinttree gdstk &&\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from glayout.flow.placement.two_transistor_interdigitized import two_nfet_interdigitized
from glayout.flow.placement.four_transistor_interdigitized import generic_4T_interdigitzed
from glayout.flow.placement.two_transistor_interdigitized import two_pfet_interdigitized
from glayout.flow.components.diff_pair import diff_pair_generic
from glayout.flow.blocks.diff_pair import diff_pair_generic
from glayout.flow.routing.smart_route import smart_route
from glayout.flow.routing.L_route import L_route
from glayout.flow.routing.c_route import c_route
Expand Down
4 changes: 2 additions & 2 deletions openfasoc/generators/glayout/glayout/flow/pdk/mappedpdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ def create_magic_commands_file(temp_dir):
dir_name = design_name
path_to_dir = path_to_regression_drc / dir_name
if not path_to_dir.exists():
path_to_dir.mkdir()
path_to_dir.mkdir(parents=True, exist_ok=False)
new_output_file_path = path_to_dir / output_file
if not new_output_file_path.exists():
shutil.copy(report_path, path_to_dir / output_file)
Expand Down Expand Up @@ -769,7 +769,7 @@ def write_spice(input_cdl, output_spice, lvs_schematic_ref_file):
dir_name = design_name
path_to_dir = Path(__file__).resolve().parents[1] / "regression" / "lvs" / dir_name
if not path_to_dir.exists():
path_to_dir.mkdir()
path_to_dir.mkdir(parents=True, exist_ok=False)
new_output_file_path = path_to_dir / output_file_path
if not new_output_file_path.exists():
shutil.copy(report_path, path_to_dir / output_file_path)
Expand Down
Empty file.
Empty file.
Empty file.
Empty file.
25 changes: 19 additions & 6 deletions openfasoc/generators/glayout/glayout/syntaxer/relational.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,24 +300,26 @@ def __init__(self, component_identifiers: list[str], component_name: str, module
# try to find an os path to the desired module by looking in Glayout
if module_path is None:
# try to resolve path of glayout package
matching_files = list(Path("./").resolve().rglob("glayout"))
if len(matching_files)>0:
glayout_path = (matching_files[0].resolve() / "flow").resolve()
matching_files = Path(__file__).resolve().parents[1]
# matching_files = list(Path("./").resolve().rglob("glayout"))
if matching_files.is_dir():
glayout_path = (matching_files.resolve() / "flow").resolve()
else:
raise FileNotFoundError("Glayout.flow package not found in a sub folder of ../ directory")
# try to resolve path of user module in Glayout package
# this will look for the file which starts with "component_name" ANYWHERE in the glayout.flow package
matching_files = list(glayout_path.rglob(str(component_name)+".py"))
matching_files += list(glayout_path.rglob(str(component_name)+"_cell.py"))
matching_files += list(glayout_path.rglob(str(component_name)+".convo"))
# also check the test_cases directory for convo files
matching_files += list((glayout_path / "../llm/syntax_data/convos").rglob(str(component_name)+".convo"))
# matching_files += list((glayout_path / "../llm/syntax_data/convos").rglob(str(component_name)+".convo"))
if len(matching_files)>0:
module_path = matching_files[-1].resolve()
else:
raise FileNotFoundError("Could not find a module called "+str(component_name)+" in Glayout")
# copy convo file into glayout Components and then create a python file and copy it into glayout components
if str(module_path).endswith(".convo"):
components_directory = glayout_path / "components"
components_directory = glayout_path / "blocks"
if module_path.parent != components_directory:
shutil.copy(module_path, components_directory)
glayoutcode = glayout.syntaxer.dynamic_load.run_session(module_path,True)
Expand Down Expand Up @@ -360,7 +362,18 @@ def from_module_import(cls, module: str, nameofobjtoimport: str):
Returns: the object that was imported
"""
module_object = import_module(module)
return getattr(module_object, nameofobjtoimport)
if module_object is None:
raise ImportError("could not import module, maybe cell's __init__.py is missing?")
try:
return getattr(module_object, nameofobjtoimport)
except AttributeError:
# Try appending "_cell" if the direct attribute fetch failed
cell_attr_name = f"{nameofobjtoimport}_cell"
try:
return getattr(module_object, cell_attr_name)
except AttributeError:
error_msg = (f"Could not find '{nameofobjtoimport}' or '{cell_attr_name}' in module '{module_object}'.")
raise AttributeError(error_msg) from None

def get_code(self) -> str:
"""returns as str a whole import line of code"""
Expand Down

0 comments on commit 7dc5eb4

Please sign in to comment.