From cead264e70662a952d76699fe1203c829b637aaf Mon Sep 17 00:00:00 2001 From: Ali Hammoud <70279295+alibillalhammoud@users.noreply.github.com> Date: Thu, 6 Jun 2024 01:12:21 +0000 Subject: [PATCH 01/11] fix imports --- .../glayout/glayout/flow/blocks/__init__.py | 0 .../flow/blocks/current_mirror/__init__.py | 2 +- .../blocks/current_mirror/current_mirror.py | 4 +- .../glayout/flow/blocks/diff_pair/__init__.py | 2 +- .../diff_to_single_converter/__init__.py | 1 - .../blocks/diffpair_cmirror_bias/__init__.py | 2 +- .../diff_pair_cmirrorbias.py | 4 +- .../diffpair_stacked_cmirror/__init__.py | 1 - .../glayout/flow/blocks/opamp/__init__.py | 3 +- .../diff_pair_stackedcmirror.py | 4 +- .../differential_to_single_ended_converter.py | 0 .../glayout/flow/blocks/opamp/opamp.py | 4 +- .../flow/blocks/opamp/opamp_twostage.py | 10 +-- ...mplifier_diff_to_single_ended_converter.py | 0 .../glayout/flow/blocks/row_csamp/__init__.py | 1 - .../blocks/stacked_current_mirror/__init__.py | 2 +- .../glayout/glayout/llm/train_and_run.py | 34 ++++++++- openfasoc/generators/glayout/requirements.txt | 1 + openfasoc/generators/glayout/setup.py | 72 ++++++++++--------- 19 files changed, 88 insertions(+), 59 deletions(-) create mode 100644 openfasoc/generators/glayout/glayout/flow/blocks/__init__.py delete mode 100644 openfasoc/generators/glayout/glayout/flow/blocks/diff_to_single_converter/__init__.py delete mode 100644 openfasoc/generators/glayout/glayout/flow/blocks/diffpair_stacked_cmirror/__init__.py rename openfasoc/generators/glayout/glayout/flow/blocks/{diffpair_stacked_cmirror => opamp}/diff_pair_stackedcmirror.py (97%) rename openfasoc/generators/glayout/glayout/flow/blocks/{diff_to_single_converter => opamp}/differential_to_single_ended_converter.py (100%) rename openfasoc/generators/glayout/glayout/flow/blocks/{row_csamp => opamp}/row_csamplifier_diff_to_single_ended_converter.py (100%) delete mode 100644 openfasoc/generators/glayout/glayout/flow/blocks/row_csamp/__init__.py diff --git a/openfasoc/generators/glayout/glayout/flow/blocks/__init__.py b/openfasoc/generators/glayout/glayout/flow/blocks/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/openfasoc/generators/glayout/glayout/flow/blocks/current_mirror/__init__.py b/openfasoc/generators/glayout/glayout/flow/blocks/current_mirror/__init__.py index f54277642..3e000b7f7 100644 --- a/openfasoc/generators/glayout/glayout/flow/blocks/current_mirror/__init__.py +++ b/openfasoc/generators/glayout/glayout/flow/blocks/current_mirror/__init__.py @@ -1 +1 @@ -from .current_mirror import * \ No newline at end of file +from glayout.flow.blocks.current_mirror.current_mirror import current_mirror, current_mirror_netlist \ No newline at end of file diff --git a/openfasoc/generators/glayout/glayout/flow/blocks/current_mirror/current_mirror.py b/openfasoc/generators/glayout/glayout/flow/blocks/current_mirror/current_mirror.py index f29334fb2..e7cdb39e8 100644 --- a/openfasoc/generators/glayout/glayout/flow/blocks/current_mirror/current_mirror.py +++ b/openfasoc/generators/glayout/glayout/flow/blocks/current_mirror/current_mirror.py @@ -12,7 +12,7 @@ from typing import Optional, Union -def cmirror_netlist( +def current_mirror_netlist( pdk: MappedPDK, width: float, length: float, @@ -144,7 +144,7 @@ def current_mirror( top_level.add_ports(source_short.get_ports_list(), prefix='purposegndports') - top_level.info['netlist'] = cmirror_netlist( + top_level.info['netlist'] = current_mirror_netlist( pdk, width=kwargs.get('width', 3), length=kwargs.get('length', 1), multipliers=numcols, n_or_p_fet=device, diff --git a/openfasoc/generators/glayout/glayout/flow/blocks/diff_pair/__init__.py b/openfasoc/generators/glayout/glayout/flow/blocks/diff_pair/__init__.py index 558bc061e..946c0a569 100644 --- a/openfasoc/generators/glayout/glayout/flow/blocks/diff_pair/__init__.py +++ b/openfasoc/generators/glayout/glayout/flow/blocks/diff_pair/__init__.py @@ -1 +1 @@ -from .diff_pair import * \ No newline at end of file +from glayout.flow.blocks.diff_pair.diff_pair import diff_pair, diff_pair_generic, diff_pair_netlist \ No newline at end of file diff --git a/openfasoc/generators/glayout/glayout/flow/blocks/diff_to_single_converter/__init__.py b/openfasoc/generators/glayout/glayout/flow/blocks/diff_to_single_converter/__init__.py deleted file mode 100644 index 498da8f85..000000000 --- a/openfasoc/generators/glayout/glayout/flow/blocks/diff_to_single_converter/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from .differential_to_single_ended_converter import * \ No newline at end of file diff --git a/openfasoc/generators/glayout/glayout/flow/blocks/diffpair_cmirror_bias/__init__.py b/openfasoc/generators/glayout/glayout/flow/blocks/diffpair_cmirror_bias/__init__.py index df721390d..0324167f1 100644 --- a/openfasoc/generators/glayout/glayout/flow/blocks/diffpair_cmirror_bias/__init__.py +++ b/openfasoc/generators/glayout/glayout/flow/blocks/diffpair_cmirror_bias/__init__.py @@ -1 +1 @@ -from .diff_pair_cmirrorbias import * \ No newline at end of file +from glayout.flow.blocks.diffpair_cmirror_bias.diff_pair_cmirrorbias import diff_pair_ibias, diff_pair_ibias_netlist \ No newline at end of file diff --git a/openfasoc/generators/glayout/glayout/flow/blocks/diffpair_cmirror_bias/diff_pair_cmirrorbias.py b/openfasoc/generators/glayout/glayout/flow/blocks/diffpair_cmirror_bias/diff_pair_cmirrorbias.py index 0f3300faf..341f7efed 100644 --- a/openfasoc/generators/glayout/glayout/flow/blocks/diffpair_cmirror_bias/diff_pair_cmirrorbias.py +++ b/openfasoc/generators/glayout/glayout/flow/blocks/diffpair_cmirror_bias/diff_pair_cmirrorbias.py @@ -36,7 +36,7 @@ from pydantic import validate_arguments from glayout.flow.placement.two_transistor_interdigitized import two_nfet_interdigitized from glayout.flow.spice import Netlist -from glayout.flow.blocks.current_mirror import cmirror_netlist +from glayout.flow.blocks.current_mirror import current_mirror_netlist def diff_pair_ibias_netlist(center_diffpair: Component, current_mirror: Component, antenna_diode: Optional[Component] = None) -> Netlist: netlist = Netlist( @@ -183,7 +183,7 @@ def diff_pair_ibias( ) cmirror.add_ports(srcshort.get_ports_list(), prefix="purposegndports") # current mirror netlist - cmirror.info['netlist'] = cmirror_netlist( + cmirror.info['netlist'] = current_mirror_netlist( pdk, width=diffpair_bias[0], length=diffpair_bias[1], diff --git a/openfasoc/generators/glayout/glayout/flow/blocks/diffpair_stacked_cmirror/__init__.py b/openfasoc/generators/glayout/glayout/flow/blocks/diffpair_stacked_cmirror/__init__.py deleted file mode 100644 index 3aba630e8..000000000 --- a/openfasoc/generators/glayout/glayout/flow/blocks/diffpair_stacked_cmirror/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from .diff_pair_stackedcmirror import * \ No newline at end of file diff --git a/openfasoc/generators/glayout/glayout/flow/blocks/opamp/__init__.py b/openfasoc/generators/glayout/glayout/flow/blocks/opamp/__init__.py index 5b94626fb..2894569f9 100644 --- a/openfasoc/generators/glayout/glayout/flow/blocks/opamp/__init__.py +++ b/openfasoc/generators/glayout/glayout/flow/blocks/opamp/__init__.py @@ -1,2 +1 @@ -from .opamp_twostage import * -from .opamp import * \ No newline at end of file +from glayout.flow.blocks.opamp.opamp import opamp, opamp_netlist \ No newline at end of file diff --git a/openfasoc/generators/glayout/glayout/flow/blocks/diffpair_stacked_cmirror/diff_pair_stackedcmirror.py b/openfasoc/generators/glayout/glayout/flow/blocks/opamp/diff_pair_stackedcmirror.py similarity index 97% rename from openfasoc/generators/glayout/glayout/flow/blocks/diffpair_stacked_cmirror/diff_pair_stackedcmirror.py rename to openfasoc/generators/glayout/glayout/flow/blocks/opamp/diff_pair_stackedcmirror.py index c6536c5d5..718562973 100644 --- a/openfasoc/generators/glayout/glayout/flow/blocks/diffpair_stacked_cmirror/diff_pair_stackedcmirror.py +++ b/openfasoc/generators/glayout/glayout/flow/blocks/opamp/diff_pair_stackedcmirror.py @@ -21,8 +21,8 @@ from glayout.flow.blocks.diffpair_cmirror_bias import diff_pair_ibias from glayout.flow.blocks.stacked_current_mirror import stacked_nfet_current_mirror -from glayout.flow.blocks.diff_to_single_converter import differential_to_single_ended_converter -from glayout.flow.blocks.row_csamp import row_csamplifier_diff_to_single_ended_converter +from glayout.flow.blocks.opamp.differential_to_single_ended_converter import differential_to_single_ended_converter +from glayout.flow.blocks.opamp.row_csamplifier_diff_to_single_ended_converter import row_csamplifier_diff_to_single_ended_converter @validate_arguments diff --git a/openfasoc/generators/glayout/glayout/flow/blocks/diff_to_single_converter/differential_to_single_ended_converter.py b/openfasoc/generators/glayout/glayout/flow/blocks/opamp/differential_to_single_ended_converter.py similarity index 100% rename from openfasoc/generators/glayout/glayout/flow/blocks/diff_to_single_converter/differential_to_single_ended_converter.py rename to openfasoc/generators/glayout/glayout/flow/blocks/opamp/differential_to_single_ended_converter.py diff --git a/openfasoc/generators/glayout/glayout/flow/blocks/opamp/opamp.py b/openfasoc/generators/glayout/glayout/flow/blocks/opamp/opamp.py index dec871ffb..7550e80a1 100644 --- a/openfasoc/generators/glayout/glayout/flow/blocks/opamp/opamp.py +++ b/openfasoc/generators/glayout/glayout/flow/blocks/opamp/opamp.py @@ -21,10 +21,10 @@ from glayout.flow.spice import Netlist from glayout.flow.blocks.opamp import opamp_twostage -from glayout.flow.blocks.current_mirror import cmirror_netlist +from glayout.flow.blocks.current_mirror import current_mirror_netlist def opamp_output_stage_netlist(pdk: MappedPDK, output_amp_fet_ref: ComponentReference, biasParams: list) -> Netlist: - bias_netlist = cmirror_netlist(pdk, biasParams[0], biasParams[1], biasParams[2]) + bias_netlist = current_mirror_netlist(pdk, biasParams[0], biasParams[1], biasParams[2]) output_stage_netlist = Netlist( circuit_name="OUTPUT_STAGE", diff --git a/openfasoc/generators/glayout/glayout/flow/blocks/opamp/opamp_twostage.py b/openfasoc/generators/glayout/glayout/flow/blocks/opamp/opamp_twostage.py index 3dc31bbd6..dd3a1a05d 100644 --- a/openfasoc/generators/glayout/glayout/flow/blocks/opamp/opamp_twostage.py +++ b/openfasoc/generators/glayout/glayout/flow/blocks/opamp/opamp_twostage.py @@ -21,11 +21,11 @@ from glayout.flow.blocks.diffpair_cmirror_bias import diff_pair_ibias from glayout.flow.blocks.stacked_current_mirror import stacked_nfet_current_mirror -from glayout.flow.blocks.diff_to_single_converter import differential_to_single_ended_converter -from glayout.flow.blocks.row_csamp import row_csamplifier_diff_to_single_ended_converter -from glayout.flow.blocks.diffpair_stacked_cmirror import diff_pair_stackedcmirror +from glayout.flow.blocks.opamp.differential_to_single_ended_converter import differential_to_single_ended_converter +from glayout.flow.blocks.opamp.row_csamplifier_diff_to_single_ended_converter import row_csamplifier_diff_to_single_ended_converter +from glayout.flow.blocks.opamp.diff_pair_stackedcmirror import diff_pair_stackedcmirror from glayout.flow.spice import Netlist -from glayout.flow.blocks.current_mirror import cmirror_netlist +from glayout.flow.blocks.current_mirror import current_mirror_netlist @validate_arguments def __create_and_route_pins( @@ -219,7 +219,7 @@ def opamp_twostage( pmos_comps = row_csamplifier_diff_to_single_ended_converter(pdk, pmos_comps, half_common_source_params, rmult) - cs_bias_netlist = cmirror_netlist( + cs_bias_netlist = current_mirror_netlist( pdk, width=diffpair_bias[0], length=diffpair_bias[1], diff --git a/openfasoc/generators/glayout/glayout/flow/blocks/row_csamp/row_csamplifier_diff_to_single_ended_converter.py b/openfasoc/generators/glayout/glayout/flow/blocks/opamp/row_csamplifier_diff_to_single_ended_converter.py similarity index 100% rename from openfasoc/generators/glayout/glayout/flow/blocks/row_csamp/row_csamplifier_diff_to_single_ended_converter.py rename to openfasoc/generators/glayout/glayout/flow/blocks/opamp/row_csamplifier_diff_to_single_ended_converter.py diff --git a/openfasoc/generators/glayout/glayout/flow/blocks/row_csamp/__init__.py b/openfasoc/generators/glayout/glayout/flow/blocks/row_csamp/__init__.py deleted file mode 100644 index 7ab024a7a..000000000 --- a/openfasoc/generators/glayout/glayout/flow/blocks/row_csamp/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from .row_csamplifier_diff_to_single_ended_converter import * \ No newline at end of file diff --git a/openfasoc/generators/glayout/glayout/flow/blocks/stacked_current_mirror/__init__.py b/openfasoc/generators/glayout/glayout/flow/blocks/stacked_current_mirror/__init__.py index 5f4254391..0fbb1952e 100644 --- a/openfasoc/generators/glayout/glayout/flow/blocks/stacked_current_mirror/__init__.py +++ b/openfasoc/generators/glayout/glayout/flow/blocks/stacked_current_mirror/__init__.py @@ -1 +1 @@ -from .stacked_current_mirror import * \ No newline at end of file +from glayout.flow.blocks.stacked_current_mirror.stacked_current_mirror import stacked_nfet_current_mirror \ No newline at end of file diff --git a/openfasoc/generators/glayout/glayout/llm/train_and_run.py b/openfasoc/generators/glayout/glayout/llm/train_and_run.py index 4ddc3d2a9..afda17b47 100644 --- a/openfasoc/generators/glayout/glayout/llm/train_and_run.py +++ b/openfasoc/generators/glayout/glayout/llm/train_and_run.py @@ -2,7 +2,7 @@ import json from typing import Union import time -import requests +import argparse from glayout.llm.manage_data import ( load_preprocessed_pretokenized_data, @@ -34,7 +34,35 @@ import transformers from trl import DataCollatorForCompletionOnlyLM, SFTTrainer -accesstoken = "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" + +def get_huggingface_token(): + """Parse the command-line arguments to retrieve the Hugging Face access token. + This function uses argparse to handle command-line arguments and specifically looks for an + access token required to download models and tokenizers from Hugging Face. If the token is + not provided, it raises an EnvironmentError with instructions on how to obtain one. + Returns: + str: The Hugging Face access token. + Raises: + EnvironmentError: If the access token is not provided in the command-line arguments. + """ + parser = argparse.ArgumentParser(description="Manage, interact, and run the Glayout LLM") + parser.add_argument( + "-t", + "--token", + type=str, + help="Specify the access token you are using to download the model and tokenizer from huggingface", + ) + args = parser.parse_args() + if args.token is None: + errstring = "To download models from huggingface you need a hugging face account and an access token" + errstring += "\nYou can create a hugging face account here: https://huggingface.co/join\n" + errstring += "Once you have an account and sign in, you can create an access token (need read access) here:\n" + errstring += "https://huggingface.co/settings/tokens\n" + errstring += "pass the access token in the command line with the option --token=[insert token here]" + raise EnvironmentError(errstring) + return args.token +#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 +accesstoken = get_huggingface_token() # returns model, tokenizer @@ -305,7 +333,7 @@ def generate(self, user_input: str, clear: bool = False) -> str: return_tensors="pt", ) inputs = inputs.to(self.device) - outputs = self.model.generate(input_ids=inputs, max_new_tokens=512) + outputs = self.model.generate(input_ids=inputs, max_new_tokens=4096) response = self.tokenizer.decode( outputs[0][len(inputs[0]) : -1], skip_special_tokens=False ) diff --git a/openfasoc/generators/glayout/requirements.txt b/openfasoc/generators/glayout/requirements.txt index d0fdd02d7..02a3f6895 100644 --- a/openfasoc/generators/glayout/requirements.txt +++ b/openfasoc/generators/glayout/requirements.txt @@ -21,3 +21,4 @@ auto-gptq optimum trl langchain_huggingface +tensorboard diff --git a/openfasoc/generators/glayout/setup.py b/openfasoc/generators/glayout/setup.py index d0b290c4c..f859bc0f0 100644 --- a/openfasoc/generators/glayout/setup.py +++ b/openfasoc/generators/glayout/setup.py @@ -2,49 +2,53 @@ setup( - name='glayout', - version='0.0.5', - author='Ali Hammoud, Harsh Khandeparkar, Vijay Shankar, Chetanya Goyal, Sakib Pathen, Arlene Dai, Ryan Wans, Mehdi Saligane', - author_email='alibilal@umich.edu, Harsh, vijayshankar.renganathan@analog.com, Chetanya, spathen@umich.edu, arlendai@umich.edu, Ryan, mehdi@umich.edu', - description='A human language to analog layout API with support for different technologies.', - long_description=open('README.md').read(), - long_description_content_type='text/markdown', - url='https://github.com/idea-fasoc/OpenFASOC/tree/main/openfasoc/generators/glayout', + name="glayout", + version="0.0.6", + author="Ali Hammoud, Harsh Khandeparkar, Vijay Shankar, Chetanya Goyal, Sakib Pathen, Arlene Dai, Ryan Wans, Mehdi Saligane", + author_email="alibilal@umich.edu, Harsh, vijayshankar.renganathan@analog.com, Chetanya, spathen@umich.edu, arlendai@umich.edu, Ryan, mehdi@umich.edu", + description="A human language to analog layout API with support for different technologies.", + long_description=open("README.md").read(), + long_description_content_type="text/markdown", + url="https://github.com/idea-fasoc/OpenFASOC/tree/main/openfasoc/generators/glayout", packages=find_packages(), classifiers=[ - 'Programming Language :: Python :: 3.10', - 'License :: OSI Approved :: MIT License', - 'Operating System :: OS Independent', + "Programming Language :: Python :: 3.10", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", ], - python_requires='>=3.10', + python_requires=">=3.10", install_requires=[ "gdsfactory==7.7.0", "prettyprint", "prettyprinttree", - "nltk", - "torch", - "transformers", - "langchain", - "langchain_community", - "chromadb", - "ollama", - "unstructured", - "unstructured[md]", - "sentence-transformers", - "peft", - "accelerate", - "bitsandbytes", - "safetensors", - "requests", - "datasets", - "auto-gptq", - "optimum", - "trl", - "langchain_huggingface" + "nltk" ], + extras_require={ + "llm": [ + "torch", + "transformers", + "langchain", + "langchain_community", + "chromadb", + "ollama", + "unstructured", + "unstructured[md]", + "sentence-transformers", + "peft", + "accelerate", + "bitsandbytes", + "safetensors", + "datasets", + "auto-gptq", + "optimum", + "trl", + "langchain_huggingface", + "tensorboard" + ] + }, entry_points={ - 'console_scripts': [ - #"glayout = something:run"# Define any command line scripts here + "console_scripts": [ + # "glayout = something:run"# Define any command line scripts here ], }, ) From f8625cb88288f25fa25a18d1e409b2d0a1690679 Mon Sep 17 00:00:00 2001 From: Ali Hammoud <70279295+alibillalhammoud@users.noreply.github.com> Date: Wed, 5 Jun 2024 21:22:53 -0400 Subject: [PATCH 02/11] Glayout cmirror notebook --- docs/source/notebooks/glayout/GLayout_Cmirror.ipynb | 1 + 1 file changed, 1 insertion(+) create mode 100644 docs/source/notebooks/glayout/GLayout_Cmirror.ipynb diff --git a/docs/source/notebooks/glayout/GLayout_Cmirror.ipynb b/docs/source/notebooks/glayout/GLayout_Cmirror.ipynb new file mode 100644 index 000000000..bdae62890 --- /dev/null +++ b/docs/source/notebooks/glayout/GLayout_Cmirror.ipynb @@ -0,0 +1 @@ +{"cells":[{"cell_type":"markdown","metadata":{"id":"aK2t7aSWNojQ"},"source":["# GLayout Current Mirror Tutorial\n"]},{"cell_type":"markdown","metadata":{"id":"view-in-github"},"source":["\"Open\n"]},{"cell_type":"markdown","metadata":{"id":"xjDewsT5Y4lP"},"source":["```\n","OpenFASOC Team, Feb 2024\n","SPDX-License-Identifier: Apache-2.0\n","```"]},{"cell_type":"markdown","metadata":{"id":"-Xp4cEjkeHIx"},"source":["## Introduction\n","Welcome!\n","This notebook serves as an introduction to the GDSFactory-based layout automation tool **GLayout** and an example producing a VIA to explain grules and glayers, as a part of [OpenFASoC](https://github.com/idea-fasoc/OpenFASOC).\n","\n","Below we have the installation steps needed for the google collab envirment used in the tutorial, and for a local ubuntu installation (if you want to follow along locally).\n"]},{"cell_type":"markdown","metadata":{"id":"j4dNshkgMM4I"},"source":["## Installation On Google Collab\n","### 1. Clone the repository and install dependencies\n","**Python Dependencies**\n","* [`gdsfactory`](https://github.com/gdsfactory/gdsfactory): Provides the backend for GDS manipulation.\n","* [`sky130`](https://github.com/gdsfactory/skywater130): The Skywater 130nm PDK Python package for GDSFactory to use in this demo.\n","* [`gf180`](https://github.com/gdsfactory/gf180): The GF 180nm PDK Python package for GDSFactory to use in this demo.\n","* [`gdstk`](https://heitzmann.github.io/gdstk/): (installed as a part of gdsfactory) Used for converting GDS files into SVG images for viewing.\n","* [`svgutils`](https://svgutils.readthedocs.io/en/latest/): To scale the SVG image.\n","\n","**System Dependencies**\n","* [`klayout`](https://klayout.de/): For DRC (Design Rule Checking).\n"]},{"cell_type":"markdown","metadata":{"id":"bANz_LDB8TQW"},"source":["#### 1.1. Installing the binary dependency `klayout` using micromamba\n","**You only need to run this once**"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"JzDjayJIMSHe","scrolled":true},"outputs":[],"source":["# Setup the environment for the OpenFASOC GDSFactory generator\n","# You only need to run this block once!\n","\n","# Clone OpenFASoC\n","!git clone https://github.com/idea-fasoc/OpenFASOC\n","# Install python dependencies\n","!pip install sky130\n","!pip install gf180 prettyprinttree svgutils\n","!pip install gdsfactory==7.7.0\n","\n","import pathlib\n","import os\n","# Install KLayout (via conda)\n","!curl -Ls https://micro.mamba.pm/api/micromamba/linux-64/latest | tar -xvj bin/micromamba\n","conda_prefix_path = pathlib.Path('conda-env')\n","CONDA_PREFIX = str(conda_prefix_path.resolve())\n","%env CONDA_PREFIX={CONDA_PREFIX}\n","\n","!bin/micromamba create --yes --prefix $CONDA_PREFIX\n","# Install from the litex-hub channel\n","!bin/micromamba install --yes --prefix $CONDA_PREFIX \\\n"," --channel litex-hub \\\n"," --channel main \\\n"," klayout\n"]},{"cell_type":"markdown","metadata":{"id":"B6dO3W3m8TQZ"},"source":["#### 1.2. Adding the `klayout` binary to the system path, then goto the GLayout directory\n","**You need to run this each time you restart the kernel**"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"Izl4QURo8TQa"},"outputs":[],"source":["# Setup the environment for the OpenFASOC GDSFactory generator\n","\n","# Adding micro-mamba binary directory to the PATH\n","# This directory contains Klayout\n","import pathlib\n","import os\n","conda_prefix_path = pathlib.Path('conda-env')\n","CONDA_PREFIX = str(conda_prefix_path.resolve())\n","%env CONDA_PREFIX={CONDA_PREFIX}\n","# Add conda packages to the PATH\n","PATH = os.environ['PATH']\n","%env PATH={PATH}:{CONDA_PREFIX}/bin\n","\n","%cd /content/OpenFASOC/openfasoc/generators/glayout"]},{"cell_type":"markdown","metadata":{"id":"e-sbwZb_8TQb"},"source":["#### 1.3. Importing Libraries and Utility Functions"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"Nc7wGAz68TQb"},"outputs":[],"source":["from glayout.flow.pdk.sky130_mapped import sky130_mapped_pdk as sky130\n","from glayout.flow.pdk.gf180_mapped import gf180_mapped_pdk as gf180\n","import gdstk\n","import svgutils.transform as sg\n","import IPython.display\n","from IPython.display import clear_output\n","import ipywidgets as widgets\n","\n","# Redirect all outputs here\n","hide = widgets.Output()\n","\n","def display_gds(gds_file, scale = 3):\n"," # Generate an SVG image\n"," top_level_cell = gdstk.read_gds(gds_file).top_level()[0]\n"," top_level_cell.write_svg('out.svg')\n"," # Scale the image for displaying\n"," fig = sg.fromfile('out.svg')\n"," fig.set_size((str(float(fig.width) * scale), str(float(fig.height) * scale)))\n"," fig.save('out.svg')\n","\n"," # Display the image\n"," IPython.display.display(IPython.display.SVG('out.svg'))\n","\n","def display_component(component, scale = 3):\n"," # Save to a GDS file\n"," with hide:\n"," component.write_gds(\"out.gds\")\n"," display_gds('out.gds', scale)\n"]},{"cell_type":"markdown","metadata":{"id":"ywJ1Xc5K395z"},"source":["# Current Mirror Layout Design using GLayout API\n","\n","## Overview\n","\n","This document provides a detailed tutorial on using the GLayout API to design and generate a layout for a PMOS current mirror circuit. It outlines the steps to initialize the layout components, place the devices, make necessary adjustments, route the connections, and generate the final layout for visualization.\n","\n","## Prerequisites\n","\n","Ensure that you have the following installed:\n","- Python environment with access to GLayout API.\n","- GDSFactory package for handling generic layout components.\n","- A PDK (Process Design Kit) appropriate for the technology node you're working on (e.g., `gf180` in this example).\n","\n","## Step-by-Step Guide\n","\n","### Step 1: Setting up the Environment\n","\n","**1.1 Import Required Modules**\n","Begin by importing the necessary classes and functions from the GLayout and GDSFactory packages:\n","\n"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"idb2xYtJqwna"},"outputs":[],"source":["from glayout.flow.primitives.guardring import tapring\n","from glayout.flow.primitives.fet import pmos\n","from glayout.flow.pdk.util.comp_utils import evaluate_bbox, prec_center\n","from glayout.flow.pdk.mappedpdk import MappedPDK\n","from glayout.flow.routing.straight_route import straight_route\n","from glayout.flow.routing.c_route import c_route\n","from gdsfactory import Component\n","from glayout.pdk.gf180_mapped import gf180_mapped_pdk"]},{"cell_type":"markdown","metadata":{"id":"fy1-h5NTq0US"},"source":["### Step 2: Define the Current Mirror Function\n","\n","**2.1 Initialize the Current Mirror Component**\n","Within your Python script, start by defining the `currentMirror` function that takes in a `MappedPDK` object:\n","```python\n","def currentMirror(pdk: MappedPDK):\n"," currMirrComp = Component()\n","```\n","\n","**2.2 Create the Transistor Instances**\n","Use the PDK to instantiate two PMOS transistors, a reference and a mirror, with specified modifications:\n","```python\n"," pfet_ref = pmos(with_substrate_tap=False, with_dummy=(False, True))\n"," pfet_mir = pmos(with_substrate_tap=False, with_dummy=(True, False))\n","```\n","\n","**2.3 Add Transistors to the Component**\n","Insert the transistors into the current mirror component and position them:\n","```python\n"," cref_ref = currMirrComp << pfet_ref\n"," cmir_ref = currMirrComp << pfet_mir\n"," cref_ref.movex(evaluate_bbox(pfet_mir)[0] + max_metal_separation(pdk))\n","```\n","\n","**2.4 Add and Position the Tap Ring**\n","Incorporate a tap ring and ensure it encloses the transistors with additional padding to satisfy design rules:\n","```python\n"," tap_ring = tapring(pdk, enclosed_rectangle=evaluate_bbox(currMirrComp.flatten(), padding=pdk.get_grule(\"nwell\", \"active_diff\")[\"min_enclosure\"]))\n"," shift_amount = -prec_center(currMirrComp.flatten())[0]\n"," tring_ref = currMirrComp << tap_ring\n"," tring_ref.movex(destination=shift_amount)\n","```\n","\n","**2.5 Route the Connections**\n","Create routes between the ports:\n","```python\n"," currMirrComp << straight_route(pdk, cref_ref.ports[\"multiplier_0_source_E\"], cmir_ref.ports[\"multiplier_0_source_E\"])\n"," currMirrComp << straight_route(pdk, cref_ref.ports[\"multiplier_0_gate_E\"], cmir_ref.ports[\"multiplier_0_gate_E\"])\n"," currMirrComp << c_route(pdk, cref_ref.ports[\"multiplier_0_gate_E\"], cref_ref.ports[\"multiplier_0_drain_E\"])\n","\n"," return currMirrComp\n","```\n","\n","### Step 3: Visualizing the Layout\n","\n","**3.1 Generate and View the Layout**\n","Finally, visualize the generated layout by calling the `currentMirror` function and using the `.show()` method:\n","```python\n","# To visualize the layout\n","currentMirror(gf180).show()\n","```"]},{"cell_type":"markdown","metadata":{"id":"EFtjsVAixzzr"},"source":["Create the final design cell with the following code block:"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"DGCUq98Qx58n"},"outputs":[],"source":["def currentMirror(pdk: MappedPDK):\n"," currMirrComp = Component()\n"," pfet_ref = pmos(pdk, with_substrate_tap=False, with_dummy=(False, True))\n"," pfet_mir = pmos(pdk, with_substrate_tap=False, with_dummy=(True, False))\n"," cref_ref = currMirrComp << pfet_ref\n"," cmir_ref = currMirrComp << pfet_mir\n"," pdk.util_max_metal_seperation()\n"," cref_ref.movex(evaluate_bbox(pfet_mir)[0] + pdk.util_max_metal_seperation())\n"," tap_ring = tapring(pdk, enclosed_rectangle=evaluate_bbox(currMirrComp.flatten(), padding=pdk.get_grule(\"nwell\", \"active_diff\")[\"min_enclosure\"]))\n"," shift_amount = -prec_center(currMirrComp.flatten())[0]\n"," tring_ref = currMirrComp << tap_ring\n"," tring_ref.movex(destination=shift_amount)\n"," currMirrComp << straight_route(pdk, cref_ref.ports[\"multiplier_0_source_E\"], cmir_ref.ports[\"multiplier_0_source_E\"])\n"," currMirrComp << straight_route(pdk, cref_ref.ports[\"multiplier_0_gate_E\"], cmir_ref.ports[\"multiplier_0_gate_E\"])\n"," currMirrComp << c_route(pdk, cref_ref.ports[\"multiplier_0_gate_E\"], cref_ref.ports[\"multiplier_0_drain_E\"])\n"," return currMirrComp\n","\n","currentMirror(gf180_mapped_pdk).write_gds(\"cmirror_example.gds\")\n","display_gds(\"cmirror_example.gds\")"]},{"cell_type":"markdown","metadata":{"id":"gLC6QYRbxk-v"},"source":["## Conclusion\n","\n","Following these steps results in a PMOS current mirror layout being composed and visualized. The tap ring encloses the transistors and the routing utilities are used to create the required connections respecting the design rules specified by the PDK.\n","\n","Each function call and module used here directly corresponds to a specific structure or operation within the context of the PDK and the layout process. This example provides a foundation upon which more complex circuits can be designed using the powerful features of the GLayout API."]}],"metadata":{"colab":{"provenance":[]},"kernelspec":{"display_name":"Python 3 (ipykernel)","language":"python","name":"python3"},"language_info":{"codemirror_mode":{"name":"ipython","version":3},"file_extension":".py","mimetype":"text/x-python","name":"python","nbconvert_exporter":"python","pygments_lexer":"ipython3","version":"3.11.7"},"vscode":{"interpreter":{"hash":"397704579725e15f5c7cb49fe5f0341eb7531c82d19f2c29d197e8b64ab5776b"}}},"nbformat":4,"nbformat_minor":0} From 97e98d99dcbd99bbcdf26b38f17ec3b00021e031 Mon Sep 17 00:00:00 2001 From: Ali Hammoud <70279295+alibillalhammoud@users.noreply.github.com> Date: Thu, 6 Jun 2024 01:50:09 +0000 Subject: [PATCH 03/11] more import fixes --- .../blocks/differential_to_single_ended_converter/__init__.py | 1 + .../differential_to_single_ended_converter.py | 2 +- .../glayout/flow/blocks/opamp/diff_pair_stackedcmirror.py | 2 +- .../glayout/glayout/flow/blocks/opamp/opamp_twostage.py | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 openfasoc/generators/glayout/glayout/flow/blocks/differential_to_single_ended_converter/__init__.py rename openfasoc/generators/glayout/glayout/flow/blocks/{opamp => differential_to_single_ended_converter}/differential_to_single_ended_converter.py (99%) diff --git a/openfasoc/generators/glayout/glayout/flow/blocks/differential_to_single_ended_converter/__init__.py b/openfasoc/generators/glayout/glayout/flow/blocks/differential_to_single_ended_converter/__init__.py new file mode 100644 index 000000000..096d2617c --- /dev/null +++ b/openfasoc/generators/glayout/glayout/flow/blocks/differential_to_single_ended_converter/__init__.py @@ -0,0 +1 @@ +from glayout.flow.blocks.differential_to_single_ended_converter.differential_to_single_ended_converter import differential_to_single_ended_converter, differential_to_single_ended_converter_netlist \ No newline at end of file diff --git a/openfasoc/generators/glayout/glayout/flow/blocks/opamp/differential_to_single_ended_converter.py b/openfasoc/generators/glayout/glayout/flow/blocks/differential_to_single_ended_converter/differential_to_single_ended_converter.py similarity index 99% rename from openfasoc/generators/glayout/glayout/flow/blocks/opamp/differential_to_single_ended_converter.py rename to openfasoc/generators/glayout/glayout/flow/blocks/differential_to_single_ended_converter/differential_to_single_ended_converter.py index 927d16390..ecce9b3a5 100644 --- a/openfasoc/generators/glayout/glayout/flow/blocks/opamp/differential_to_single_ended_converter.py +++ b/openfasoc/generators/glayout/glayout/flow/blocks/differential_to_single_ended_converter/differential_to_single_ended_converter.py @@ -166,7 +166,7 @@ def differential_to_single_ended_converter_netlist(pdk: MappedPDK, half_pload: t } ) -def differential_to_single_ended_converter(pdk: MappedPDK, rmult: int, half_pload: tuple[float,float,int], via_xlocation) -> tuple: +def differential_to_single_ended_converter(pdk: MappedPDK, rmult: int, half_pload: tuple[float,float,int], via_xlocation) -> Component: clear_cache() pmos_comps, ptop_AB, pbottom_AB, LRplusdopedPorts, LRgatePorts, LRdrainsPorts, LRsourcesPorts, LRdummyports = __create_sharedgatecomps(pdk, rmult,half_pload) clear_cache() diff --git a/openfasoc/generators/glayout/glayout/flow/blocks/opamp/diff_pair_stackedcmirror.py b/openfasoc/generators/glayout/glayout/flow/blocks/opamp/diff_pair_stackedcmirror.py index 718562973..d841db16c 100644 --- a/openfasoc/generators/glayout/glayout/flow/blocks/opamp/diff_pair_stackedcmirror.py +++ b/openfasoc/generators/glayout/glayout/flow/blocks/opamp/diff_pair_stackedcmirror.py @@ -21,7 +21,7 @@ from glayout.flow.blocks.diffpair_cmirror_bias import diff_pair_ibias from glayout.flow.blocks.stacked_current_mirror import stacked_nfet_current_mirror -from glayout.flow.blocks.opamp.differential_to_single_ended_converter import differential_to_single_ended_converter +from glayout.flow.blocks.differential_to_single_ended_converter import differential_to_single_ended_converter from glayout.flow.blocks.opamp.row_csamplifier_diff_to_single_ended_converter import row_csamplifier_diff_to_single_ended_converter diff --git a/openfasoc/generators/glayout/glayout/flow/blocks/opamp/opamp_twostage.py b/openfasoc/generators/glayout/glayout/flow/blocks/opamp/opamp_twostage.py index dd3a1a05d..992bfc0c8 100644 --- a/openfasoc/generators/glayout/glayout/flow/blocks/opamp/opamp_twostage.py +++ b/openfasoc/generators/glayout/glayout/flow/blocks/opamp/opamp_twostage.py @@ -21,7 +21,7 @@ from glayout.flow.blocks.diffpair_cmirror_bias import diff_pair_ibias from glayout.flow.blocks.stacked_current_mirror import stacked_nfet_current_mirror -from glayout.flow.blocks.opamp.differential_to_single_ended_converter import differential_to_single_ended_converter +from glayout.flow.blocks.differential_to_single_ended_converter import differential_to_single_ended_converter from glayout.flow.blocks.opamp.row_csamplifier_diff_to_single_ended_converter import row_csamplifier_diff_to_single_ended_converter from glayout.flow.blocks.opamp.diff_pair_stackedcmirror import diff_pair_stackedcmirror from glayout.flow.spice import Netlist From 6e75ea518f63d261d706df11c90c4400022f8907 Mon Sep 17 00:00:00 2001 From: Ali Hammoud <70279295+alibillalhammoud@users.noreply.github.com> Date: Wed, 5 Jun 2024 21:52:32 -0400 Subject: [PATCH 04/11] Update GLayout_Cells.ipynb --- docs/source/notebooks/glayout/GLayout_Cells.ipynb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/source/notebooks/glayout/GLayout_Cells.ipynb b/docs/source/notebooks/glayout/GLayout_Cells.ipynb index 2c9c1ce04..116545eb6 100644 --- a/docs/source/notebooks/glayout/GLayout_Cells.ipynb +++ b/docs/source/notebooks/glayout/GLayout_Cells.ipynb @@ -407,7 +407,7 @@ }, "outputs": [], "source": [ - "from glayout.flow.components.diff_pair import diff_pair\n", + "from glayout.flow.blocks.diff_pair import diff_pair\n", "# Used to display the results in a grid (notebook only)\n", "left = widgets.Output()\n", "leftSPICE = widgets.Output()\n", @@ -453,7 +453,7 @@ }, "outputs": [], "source": [ - "from glayout.flow.components.differential_to_single_ended_converter import differential_to_single_ended_converter\n", + "from glayout.flow.blocks.differential_to_single_ended_converter import differential_to_single_ended_converter\n", "# Used to display the results in a grid (notebook only)\n", "left = widgets.Output()\n", "leftSPICE = widgets.Output()\n", @@ -530,7 +530,7 @@ }, "outputs": [], "source": [ - "from glayout.flow.components.opamp import opamp\n", + "from glayout.flow.blocks.opamp import opamp\n", "\n", "# Select which PDK to use\n", "pdk = sky130\n", @@ -590,4 +590,4 @@ }, "nbformat": 4, "nbformat_minor": 0 -} \ No newline at end of file +} From 69609e7a419d8d089457e35d3018602e4a6783e3 Mon Sep 17 00:00:00 2001 From: Ali Hammoud <70279295+alibillalhammoud@users.noreply.github.com> Date: Wed, 5 Jun 2024 21:55:07 -0400 Subject: [PATCH 05/11] Update glayout_opamp.ipynb --- docs/source/notebooks/glayout/glayout_opamp.ipynb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/source/notebooks/glayout/glayout_opamp.ipynb b/docs/source/notebooks/glayout/glayout_opamp.ipynb index 8e81f9679..0c67b5223 100644 --- a/docs/source/notebooks/glayout/glayout_opamp.ipynb +++ b/docs/source/notebooks/glayout/glayout_opamp.ipynb @@ -280,7 +280,7 @@ "outputs": [], "source": [ "from glayout.flow.primitives import fet, mimcap, guardring\n", - "from glayout.flow.components import diff_pair\n", + "from glayout.flow.blocks import diff_pair\n", "import ipywidgets as widgets\n", "\n", "selection_button = widgets.RadioButtons(\n", @@ -485,7 +485,7 @@ }, "outputs": [], "source": [ - "from glayout.flow.components.opamp import opamp\n", + "from glayout.flow.blocks.opamp import opamp\n", "\n", "# Select which PDK to use\n", "pdk = sky130\n", @@ -800,4 +800,4 @@ }, "nbformat": 4, "nbformat_minor": 0 -} \ No newline at end of file +} From 5d245be5dbd16c79b1c46a49b627445526c64605 Mon Sep 17 00:00:00 2001 From: Ali Hammoud <70279295+alibillalhammoud@users.noreply.github.com> Date: Wed, 5 Jun 2024 21:56:59 -0400 Subject: [PATCH 06/11] Update GLayout_Via.ipynb --- docs/source/notebooks/glayout/GLayout_Via.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/notebooks/glayout/GLayout_Via.ipynb b/docs/source/notebooks/glayout/GLayout_Via.ipynb index fbea30147..a2f899708 100644 --- a/docs/source/notebooks/glayout/GLayout_Via.ipynb +++ b/docs/source/notebooks/glayout/GLayout_Via.ipynb @@ -1 +1 @@ -{"cells":[{"cell_type":"markdown","metadata":{"id":"aK2t7aSWNojQ"},"source":["# GLayout Installation & Simple Via Creation Tutorial\n"]},{"cell_type":"markdown","metadata":{"id":"view-in-github"},"source":["\"Open\n"]},{"cell_type":"markdown","metadata":{"id":"xjDewsT5Y4lP"},"source":["```\n","OpenFASOC Team, Feb 2024\n","SPDX-License-Identifier: Apache-2.0\n","```"]},{"cell_type":"markdown","metadata":{"id":"-Xp4cEjkeHIx"},"source":["## Introduction\n","Welcome!\n","This notebook serves as an introduction to the GDSFactory-based layout automation tool **GLayout** and an example producing a VIA to explain grules and glayers, as a part of [OpenFASoC](https://github.com/idea-fasoc/OpenFASOC).\n","\n","Below we have the installation steps needed for the google collab envirment used in the tutorial, and for a local ubuntu installation (if you want to follow along locally).\n"]},{"cell_type":"markdown","metadata":{"id":"j4dNshkgMM4I"},"source":["## Installation On Google Collab\n","### 1. Clone the repository and install dependencies\n","**Python Dependencies**\n","* [`gdsfactory`](https://github.com/gdsfactory/gdsfactory): Provides the backend for GDS manipulation.\n","* [`sky130`](https://github.com/gdsfactory/skywater130): The Skywater 130nm PDK Python package for GDSFactory to use in this demo.\n","* [`gf180`](https://github.com/gdsfactory/gf180): The GF 180nm PDK Python package for GDSFactory to use in this demo.\n","* [`gdstk`](https://heitzmann.github.io/gdstk/): (installed as a part of gdsfactory) Used for converting GDS files into SVG images for viewing.\n","* [`svgutils`](https://svgutils.readthedocs.io/en/latest/): To scale the SVG image.\n","\n","**System Dependencies**\n","* [`klayout`](https://klayout.de/): For DRC (Design Rule Checking).\n"]},{"cell_type":"markdown","metadata":{"id":"bANz_LDB8TQW"},"source":["#### 1.1. Installing the binary dependency `klayout` using micromamba\n","**You only need to run this once**"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"JzDjayJIMSHe","scrolled":true},"outputs":[],"source":["# Setup the environment for the OpenFASOC GDSFactory generator\n","# You only need to run this block once!\n","\n","# Clone OpenFASoC\n","!git clone https://github.com/idea-fasoc/OpenFASOC\n","# Install python dependencies\n","!pip install sky130\n","!pip install gf180 prettyprinttree svgutils\n","!pip install gdsfactory==7.7.0\n","\n","import pathlib\n","import os\n","# Install KLayout (via conda)\n","!curl -Ls https://micro.mamba.pm/api/micromamba/linux-64/latest | tar -xvj bin/micromamba\n","conda_prefix_path = pathlib.Path('conda-env')\n","CONDA_PREFIX = str(conda_prefix_path.resolve())\n","%env CONDA_PREFIX={CONDA_PREFIX}\n","\n","!bin/micromamba create --yes --prefix $CONDA_PREFIX\n","# Install from the litex-hub channel\n","!bin/micromamba install --yes --prefix $CONDA_PREFIX \\\n"," --channel litex-hub \\\n"," --channel main \\\n"," klayout\n"]},{"cell_type":"markdown","metadata":{"id":"B6dO3W3m8TQZ"},"source":["#### 1.2. Adding the `klayout` binary to the system path, then goto the GLayout directory\n","**You need to run this each time you restart the kernel**"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"Izl4QURo8TQa"},"outputs":[],"source":["# Setup the environment for the OpenFASOC GDSFactory generator\n","\n","# Adding micro-mamba binary directory to the PATH\n","# This directory contains Klayout\n","import pathlib\n","import os\n","conda_prefix_path = pathlib.Path('conda-env')\n","CONDA_PREFIX = str(conda_prefix_path.resolve())\n","%env CONDA_PREFIX={CONDA_PREFIX}\n","# Add conda packages to the PATH\n","PATH = os.environ['PATH']\n","%env PATH={PATH}:{CONDA_PREFIX}/bin\n","\n","%cd /content/OpenFASOC/openfasoc/generators/glayout"]},{"cell_type":"markdown","metadata":{"id":"e-sbwZb_8TQb"},"source":["#### 1.3. Importing Libraries and Utility Functions"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"Nc7wGAz68TQb"},"outputs":[],"source":["from glayout.flow.pdk.sky130_mapped import sky130_mapped_pdk as sky130\n","from glayout.flow.pdk.gf180_mapped import gf180_mapped_pdk as gf180\n","import gdstk\n","import svgutils.transform as sg\n","import IPython.display\n","from IPython.display import clear_output\n","import ipywidgets as widgets\n","\n","# Redirect all outputs here\n","hide = widgets.Output()\n","\n","def display_gds(gds_file, scale = 3):\n"," # Generate an SVG image\n"," top_level_cell = gdstk.read_gds(gds_file).top_level()[0]\n"," top_level_cell.write_svg('out.svg')\n"," # Scale the image for displaying\n"," fig = sg.fromfile('out.svg')\n"," fig.set_size((str(float(fig.width) * scale), str(float(fig.height) * scale)))\n"," fig.save('out.svg')\n","\n"," # Display the image\n"," IPython.display.display(IPython.display.SVG('out.svg'))\n","\n","def display_component(component, scale = 3):\n"," # Save to a GDS file\n"," with hide:\n"," component.write_gds(\"out.gds\")\n"," display_gds('out.gds', scale)\n"]},{"cell_type":"markdown","source":["\n","## Installation Steps For Ubuntu:\n","\n","**1. Install System Dependencies**\n","- Ensure you have Python 3 installed; version 3.10 or greater is required.\n","- If you're on Ubuntu, use the package manager to install Python with the following command:\n"," ```\n"," sudo apt-get install python3\n"," ```\n","- You may also need to install the following dependency for klayout\n"," ```\n"," sudo apt-get install ruby-dev\n"," ```\n","\n","**2. Install KLayout**\n","- KLayout needs to be installed for layout viewing and generation. Install it using:\n"," ```\n"," sudo apt-get install klayout\n"," ```\n","\n","**3. Verify Python Version and install pip**\n","- Run:\n"," ```\n"," python3 --version\n"," ```\n","- Verify installed version is >3.10\n","- You need to install pip if it is not installed:\n"," ```\n"," sudo apt-get install python3-pip\n"," ```\n","\n","**4. Install Open-Source PDK (e.g., GF180)**\n","- Install an open-source PDK using pip:\n"," ```\n"," python3 -m pip install gf180\n"," ```\n","\n","**5. Install GLayout API**\n","- Install Glayout using pip with:\n"," ```\n"," python3 -m pip install glayout\n"," ```\n"],"metadata":{"id":"_90PvHDShVp3"}},{"cell_type":"markdown","source":["\n","## Building a Simple Via\n","\n","**1. Open Your Favorite IDE, Create a File**\n","- Open your preferred code editor.\n","- Create a new Python file: `example.py`.\n","- In this collab env, we will edit in code blocks below\n","\n","**2. Import Required Modules**"],"metadata":{"id":"Pi7u2ZgVjosO"}},{"cell_type":"markdown","source":["The via function will use several imports:\n","\n","* gf180_mapped_pdk from the glayout.pdk.gf180_mapped module: PDK for GF180 (180-nanometer technology node) provided by the glayout package. The PDK contains technology-specific information including rules and layers.\n","\n","* MappedPDK from the glayout.pdk.mappedpdk module: This is a class for mapping generic layers and design rules to the specific layers and design rules present in the chosen PDK.\n","\n","* Component from gdsfactory: This is a class representing a layout component, which includes polygons, paths, etc.\n","\n","* rectangle from gdsfactory.components: This function creates a rectangle polygon."],"metadata":{"id":"hyYzrMWLlDoi"}},{"cell_type":"code","source":["from glayout.flow.pdk.gf180_mapped import gf180_mapped_pdk\n","from glayout.flow.pdk.mappedpdk import MappedPDK\n","from gdsfactory import Component\n","from gdsfactory.components import rectangle"],"metadata":{"id":"zT4AQDr8j6mg"},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":["\n","**3. Define the Via Function**"],"metadata":{"id":"K0gKdrEAj9VE"}},{"cell_type":"markdown","source":["The function create_via which takes a single argument which is the PDK. Inside the function, the following steps are executed:\n","\n","* Via Dimensions: Using the get_grule method of the PDK object, the width of the via is retrieved from the technology's design rules. This rule specifies the minimum size that the via can be. This dimension is set as both the length and width for a via.\n","\n","* Metal Dimensions: The dimensions of the metal layers above and below the via are determined. These dimensions must accommodate the via and any required enclosure space as mandated by the PDK. Enclosure space refers to the required minimum spacing between the edge of the via and the edge of the surrounding metal layer.\n","\n","* Layer Retrieval: The get_glayer method retrieves the specific layer numbers or names from the PDK. These are then used to assign the correct graphical layers to the shapes that will be generated.\n","\n","* Shape Creation and Placement: An empty Component instance named top_level is created, representing the top component in which all shapes will be placed. Using the insertion operator (<<), rectangles representing the metal layers and via are added to the top_level component with their specified sizes and layers.\n","\n","* Return Value: The top_level component, now containing the layout shapes for the metals and via, is the return value of the function. This component can be written out as a GDSII file."],"metadata":{"id":"rlGg2kObltMW"}},{"cell_type":"code","source":["def create_via(PDK: MappedPDK):\n"," # Define the via dimensions and rules\n"," via_dimension = PDK.get_grule('via1')['width']\n"," metal1_dimension = via_dimension + 2 * PDK.get_grule('via1','met1')['min_enclosure']\n"," metal2_dimension = via_dimension + 2 * PDK.get_grule('via1','met2')['min_enclosure']\n","\n"," # Get the layers for via and metals\n"," via_layer = PDK.get_glayer('via1')\n"," metal1_layer = PDK.get_glayer('met1')\n"," metal2_layer = PDK.get_glayer('met2')\n","\n"," # Create the component and add the layers\n"," top_level = Component(name='via_example')\n"," top_level << rectangle(size=(via_dimension, via_dimension), layer=via_layer)\n"," top_level << rectangle(size=(metal1_dimension, metal1_dimension), layer=metal1_layer)\n"," top_level << rectangle(size=(metal2_dimension, metal2_dimension), layer=metal2_layer)\n","\n"," return top_level"],"metadata":{"id":"MgKks3kuj_Ow"},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":["**4. Run the Via Function and Generate Layout**"],"metadata":{"id":"gPBHRStqkCCW"}},{"cell_type":"code","source":["via_component = create_via(PDK=gf180_mapped_pdk)\n","via_component.write_gds('via_example.gds')"],"metadata":{"id":"ox35X1mAkPFC"},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":["**5. View the Generated Layout**\n","- Open KLayout and load the generated GDS file to view your layout.\n","- Or view in notebook with the following code block."],"metadata":{"id":"fgNPjeuckUk_"}},{"cell_type":"code","source":["display_gds('via_example.gds',scale=20)"],"metadata":{"id":"JqzYORoZwQ-q"},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":["By concluding these steps, you will have downloaded Glayout, installed the necessary dependencies, and completed the construction of a simple via using Glayout."],"metadata":{"id":"lau7cFu9wYxI"}}],"metadata":{"colab":{"provenance":[]},"kernelspec":{"display_name":"Python 3 (ipykernel)","language":"python","name":"python3"},"language_info":{"codemirror_mode":{"name":"ipython","version":3},"file_extension":".py","mimetype":"text/x-python","name":"python","nbconvert_exporter":"python","pygments_lexer":"ipython3","version":"3.11.7"},"vscode":{"interpreter":{"hash":"397704579725e15f5c7cb49fe5f0341eb7531c82d19f2c29d197e8b64ab5776b"}}},"nbformat":4,"nbformat_minor":0} \ No newline at end of file +{"cells":[{"cell_type":"markdown","metadata":{"id":"aK2t7aSWNojQ"},"source":["# GLayout Installation & Simple Via Creation Tutorial\n"]},{"cell_type":"markdown","metadata":{"id":"view-in-github"},"source":["\"Open\n"]},{"cell_type":"markdown","metadata":{"id":"xjDewsT5Y4lP"},"source":["```\n","OpenFASOC Team, Feb 2024\n","SPDX-License-Identifier: Apache-2.0\n","```"]},{"cell_type":"markdown","metadata":{"id":"-Xp4cEjkeHIx"},"source":["## Introduction\n","Welcome!\n","This notebook serves as an introduction to the GDSFactory-based layout automation tool **GLayout** and an example producing a VIA to explain grules and glayers, as a part of [OpenFASoC](https://github.com/idea-fasoc/OpenFASOC).\n","\n","Below we have the installation steps needed for the google collab envirment used in the tutorial, and for a local ubuntu installation (if you want to follow along locally).\n"]},{"cell_type":"markdown","metadata":{"id":"j4dNshkgMM4I"},"source":["## Installation On Google Collab\n","### 1. Clone the repository and install dependencies\n","**Python Dependencies**\n","* [`gdsfactory`](https://github.com/gdsfactory/gdsfactory): Provides the backend for GDS manipulation.\n","* [`sky130`](https://github.com/gdsfactory/skywater130): The Skywater 130nm PDK Python package for GDSFactory to use in this demo.\n","* [`gf180`](https://github.com/gdsfactory/gf180): The GF 180nm PDK Python package for GDSFactory to use in this demo.\n","* [`gdstk`](https://heitzmann.github.io/gdstk/): (installed as a part of gdsfactory) Used for converting GDS files into SVG images for viewing.\n","* [`svgutils`](https://svgutils.readthedocs.io/en/latest/): To scale the SVG image.\n","\n","**System Dependencies**\n","* [`klayout`](https://klayout.de/): For DRC (Design Rule Checking).\n"]},{"cell_type":"markdown","metadata":{"id":"bANz_LDB8TQW"},"source":["#### 1.1. Installing the binary dependency `klayout` using micromamba\n","**You only need to run this once**"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"JzDjayJIMSHe","scrolled":true},"outputs":[],"source":["# Setup the environment for the OpenFASOC GDSFactory generator\n","# You only need to run this block once!\n","\n","# Clone OpenFASoC\n","!git clone https://github.com/idea-fasoc/OpenFASOC\n","# Install python dependencies\n","!pip install sky130\n","!pip install gf180 prettyprinttree svgutils\n","!pip install gdsfactory==7.7.0\n","\n","import pathlib\n","import os\n","# Install KLayout (via conda)\n","!curl -Ls https://micro.mamba.pm/api/micromamba/linux-64/latest | tar -xvj bin/micromamba\n","conda_prefix_path = pathlib.Path('conda-env')\n","CONDA_PREFIX = str(conda_prefix_path.resolve())\n","%env CONDA_PREFIX={CONDA_PREFIX}\n","\n","!bin/micromamba create --yes --prefix $CONDA_PREFIX\n","# Install from the litex-hub channel\n","!bin/micromamba install --yes --prefix $CONDA_PREFIX \\\n"," --channel litex-hub \\\n"," --channel main \\\n"," klayout\n"]},{"cell_type":"markdown","metadata":{"id":"B6dO3W3m8TQZ"},"source":["#### 1.2. Adding the `klayout` binary to the system path, then goto the GLayout directory\n","**You need to run this each time you restart the kernel**"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"Izl4QURo8TQa"},"outputs":[],"source":["# Setup the environment for the OpenFASOC GDSFactory generator\n","\n","# Adding micro-mamba binary directory to the PATH\n","# This directory contains Klayout\n","import pathlib\n","import os\n","conda_prefix_path = pathlib.Path('conda-env')\n","CONDA_PREFIX = str(conda_prefix_path.resolve())\n","%env CONDA_PREFIX={CONDA_PREFIX}\n","# Add conda packages to the PATH\n","PATH = os.environ['PATH']\n","%env PATH={PATH}:{CONDA_PREFIX}/bin\n","\n","%cd /content/OpenFASOC/openfasoc/generators/glayout"]},{"cell_type":"markdown","metadata":{"id":"e-sbwZb_8TQb"},"source":["#### 1.3. Importing Libraries and Utility Functions"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"Nc7wGAz68TQb"},"outputs":[],"source":["from glayout.flow.pdk.sky130_mapped import sky130_mapped_pdk as sky130\n","from glayout.flow.pdk.gf180_mapped import gf180_mapped_pdk as gf180\n","import gdstk\n","import svgutils.transform as sg\n","import IPython.display\n","from IPython.display import clear_output\n","import ipywidgets as widgets\n","\n","# Redirect all outputs here\n","hide = widgets.Output()\n","\n","def display_gds(gds_file, scale = 3):\n"," # Generate an SVG image\n"," top_level_cell = gdstk.read_gds(gds_file).top_level()[0]\n"," top_level_cell.write_svg('out.svg')\n"," # Scale the image for displaying\n"," fig = sg.fromfile('out.svg')\n"," fig.set_size((str(float(fig.width) * scale), str(float(fig.height) * scale)))\n"," fig.save('out.svg')\n","\n"," # Display the image\n"," IPython.display.display(IPython.display.SVG('out.svg'))\n","\n","def display_component(component, scale = 3):\n"," # Save to a GDS file\n"," with hide:\n"," component.write_gds(\"out.gds\")\n"," display_gds('out.gds', scale)\n"]},{"cell_type":"markdown","source":["\n","## Installation Steps For Ubuntu:\n","\n","**1. Install System Dependencies**\n","- Ensure you have Python 3 installed; version 3.10 or greater is required.\n","- If you're on Ubuntu, use the package manager to install Python with the following command:\n"," ```\n"," sudo apt-get install python3\n"," ```\n","- You may also need to install the following dependency for klayout\n"," ```\n"," sudo apt-get install ruby-dev\n"," ```\n","\n","**2. Install KLayout**\n","- KLayout needs to be installed for layout viewing and generation. Install it using:\n"," ```\n"," sudo apt-get install klayout\n"," ```\n","\n","**3. Verify Python Version and install pip**\n","- Run:\n"," ```\n"," python3 --version\n"," ```\n","- Verify installed version is >3.10\n","- You need to install pip if it is not installed:\n"," ```\n"," sudo apt-get install python3-pip\n"," ```\n","\n","**4. Install Open-Source PDK (e.g., GF180)**\n","- Install an open-source PDK using pip:\n"," ```\n"," python3 -m pip install gf180\n"," ```\n","\n","**5. Install GLayout API**\n","- Install Glayout using pip with:\n"," ```\n"," python3 -m pip install glayout\n"," ```\n"],"metadata":{"id":"_90PvHDShVp3"}},{"cell_type":"markdown","source":["\n","## Building a Simple Via\n","\n","**1. Open Your Favorite IDE, Create a File**\n","- Open your preferred code editor.\n","- Create a new Python file: `example.py`.\n","- In this collab env, we will edit in code blocks below\n","\n","**2. Import Required Modules**"],"metadata":{"id":"Pi7u2ZgVjosO"}},{"cell_type":"markdown","source":["The via function will use several imports:\n","\n","* gf180_mapped_pdk from the glayout.pdk.gf180_mapped module: PDK for GF180 (180-nanometer technology node) provided by the glayout package. The PDK contains technology-specific information including rules and layers.\n","\n","* MappedPDK from the glayout.pdk.mappedpdk module: This is a class for mapping generic layers and design rules to the specific layers and design rules present in the chosen PDK.\n","\n","* Component from gdsfactory: This is a class representing a layout component, which includes polygons, paths, etc.\n","\n","* rectangle from gdsfactory.components: This function creates a rectangle polygon."],"metadata":{"id":"hyYzrMWLlDoi"}},{"cell_type":"code","source":["from glayout.flow.pdk.gf180_mapped import gf180_mapped_pdk\n","from glayout.flow.pdk.mappedpdk import MappedPDK\n","from gdsfactory import Component\n","from gdsfactory.components import rectangle"],"metadata":{"id":"zT4AQDr8j6mg"},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":["\n","**3. Define the Via Function**"],"metadata":{"id":"K0gKdrEAj9VE"}},{"cell_type":"markdown","source":["The function create_via which takes a single argument which is the PDK. Inside the function, the following steps are executed:\n","\n","* Via Dimensions: Using the get_grule method of the PDK object, the width of the via is retrieved from the technology's design rules. This rule specifies the minimum size that the via can be. This dimension is set as both the length and width for a via.\n","\n","* Metal Dimensions: The dimensions of the metal layers above and below the via are determined. These dimensions must accommodate the via and any required enclosure space as mandated by the PDK. Enclosure space refers to the required minimum spacing between the edge of the via and the edge of the surrounding metal layer.\n","\n","* Layer Retrieval: The get_glayer method retrieves the specific layer numbers or names from the PDK. These are then used to assign the correct graphical layers to the shapes that will be generated.\n","\n","* Shape Creation and Placement: An empty Component instance named top_level is created, representing the top component in which all shapes will be placed. Using the insertion operator (<<), rectangles representing the metal layers and via are added to the top_level component with their specified sizes and layers.\n","\n","* Return Value: The top_level component, now containing the layout shapes for the metals and via, is the return value of the function. This component can be written out as a GDSII file."],"metadata":{"id":"rlGg2kObltMW"}},{"cell_type":"code","source":["def create_via(PDK: MappedPDK):\n"," # Define the via dimensions and rules\n"," via_dimension = PDK.get_grule('via1')['width']\n"," metal1_dimension = via_dimension + 2 * PDK.get_grule('via1','met1')['min_enclosure']\n"," metal2_dimension = via_dimension + 2 * PDK.get_grule('via1','met2')['min_enclosure']\n","\n"," # Get the layers for via and metals\n"," via_layer = PDK.get_glayer('via1')\n"," metal1_layer = PDK.get_glayer('met1')\n"," metal2_layer = PDK.get_glayer('met2')\n","\n"," # Create the component and add the layers\n"," top_level = Component(name='via_example')\n"," top_level << rectangle(size=(via_dimension, via_dimension), layer=via_layer)\n"," top_level << rectangle(size=(metal1_dimension, metal1_dimension), layer=metal1_layer)\n"," top_level << rectangle(size=(metal2_dimension, metal2_dimension), layer=metal2_layer)\n","\n"," return top_level"],"metadata":{"id":"MgKks3kuj_Ow"},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":["**4. Run the Via Function and Generate Layout**"],"metadata":{"id":"gPBHRStqkCCW"}},{"cell_type":"code","source":["via_component = create_via(PDK=gf180_mapped_pdk)\n","via_component.write_gds('via_example.gds')"],"metadata":{"id":"ox35X1mAkPFC"},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":["**5. View the Generated Layout**\n","- Open KLayout and load the generated GDS file to view your layout.\n","- Or view in notebook with the following code block."],"metadata":{"id":"fgNPjeuckUk_"}},{"cell_type":"code","source":["display_gds('via_example.gds',scale=20)"],"metadata":{"id":"JqzYORoZwQ-q"},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":["By concluding these steps, you will have downloaded Glayout, installed the necessary dependencies, and completed the construction of a simple via using Glayout."],"metadata":{"id":"lau7cFu9wYxI"}}],"metadata":{"colab":{"provenance":[]},"kernelspec":{"display_name":"Python 3 (ipykernel)","language":"python","name":"python3"},"language_info":{"codemirror_mode":{"name":"ipython","version":3},"file_extension":".py","mimetype":"text/x-python","name":"python","nbconvert_exporter":"python","pygments_lexer":"ipython3","version":"3.11.7"},"vscode":{"interpreter":{"hash":"397704579725e15f5c7cb49fe5f0341eb7531c82d19f2c29d197e8b64ab5776b"}}},"nbformat":4,"nbformat_minor":0} From 7701e265d6c4a06d4960170674aa72bf6245ca88 Mon Sep 17 00:00:00 2001 From: labtob <70279295+alibillalhammoud@users.noreply.github.com> Date: Wed, 5 Jun 2024 22:10:21 -0400 Subject: [PATCH 07/11] notebook install is less confusing --- docs/source/notebooks/glayout/GLayout_Cells.ipynb | 4 +++- docs/source/notebooks/glayout/GLayout_Cmirror.ipynb | 2 +- docs/source/notebooks/glayout/GLayout_Via.ipynb | 2 +- docs/source/notebooks/glayout/glayout_opamp.ipynb | 4 +++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/docs/source/notebooks/glayout/GLayout_Cells.ipynb b/docs/source/notebooks/glayout/GLayout_Cells.ipynb index 116545eb6..f3d2c1b04 100644 --- a/docs/source/notebooks/glayout/GLayout_Cells.ipynb +++ b/docs/source/notebooks/glayout/GLayout_Cells.ipynb @@ -38,7 +38,9 @@ "source": [ "## Introduction\n", "Welcome!\n", - "This notebook serves as an introduction to the GDSFactory-based layout automation tool **GLayout** and an example two-stage Operational Amplifier (Op-Amp) generator, as a part of [OpenFASoC](https://github.com/idea-fasoc/OpenFASOC).\n", + "This notebook serves as an introduction to the GDSFactory-based layout automation tool **GLayout** and an example two-stage Operational Amplifier (Op-Amp) generator, as a part of [OpenFASoC](https://github.com/idea-fasoc/OpenFASOC). \n", + "\n", + "This Notebook will run as-is on Google Collab, or you can run locally by using the install steps in [this document](https://docs.google.com/document/d/e/2PACX-1vRL8ksIvB-fHaqWgkgBPDUznOcDmmFhNrvzPNx9GSSkZyfhJYexEI9gBZCJ0SNNnHdUrAf1EBOeU182/pub). If you choose a local install, skip part 1 of this notebook.\n", "\n", "### List of Generators\n", "\n", diff --git a/docs/source/notebooks/glayout/GLayout_Cmirror.ipynb b/docs/source/notebooks/glayout/GLayout_Cmirror.ipynb index bdae62890..7d67820d2 100644 --- a/docs/source/notebooks/glayout/GLayout_Cmirror.ipynb +++ b/docs/source/notebooks/glayout/GLayout_Cmirror.ipynb @@ -1 +1 @@ -{"cells":[{"cell_type":"markdown","metadata":{"id":"aK2t7aSWNojQ"},"source":["# GLayout Current Mirror Tutorial\n"]},{"cell_type":"markdown","metadata":{"id":"view-in-github"},"source":["\"Open\n"]},{"cell_type":"markdown","metadata":{"id":"xjDewsT5Y4lP"},"source":["```\n","OpenFASOC Team, Feb 2024\n","SPDX-License-Identifier: Apache-2.0\n","```"]},{"cell_type":"markdown","metadata":{"id":"-Xp4cEjkeHIx"},"source":["## Introduction\n","Welcome!\n","This notebook serves as an introduction to the GDSFactory-based layout automation tool **GLayout** and an example producing a VIA to explain grules and glayers, as a part of [OpenFASoC](https://github.com/idea-fasoc/OpenFASOC).\n","\n","Below we have the installation steps needed for the google collab envirment used in the tutorial, and for a local ubuntu installation (if you want to follow along locally).\n"]},{"cell_type":"markdown","metadata":{"id":"j4dNshkgMM4I"},"source":["## Installation On Google Collab\n","### 1. Clone the repository and install dependencies\n","**Python Dependencies**\n","* [`gdsfactory`](https://github.com/gdsfactory/gdsfactory): Provides the backend for GDS manipulation.\n","* [`sky130`](https://github.com/gdsfactory/skywater130): The Skywater 130nm PDK Python package for GDSFactory to use in this demo.\n","* [`gf180`](https://github.com/gdsfactory/gf180): The GF 180nm PDK Python package for GDSFactory to use in this demo.\n","* [`gdstk`](https://heitzmann.github.io/gdstk/): (installed as a part of gdsfactory) Used for converting GDS files into SVG images for viewing.\n","* [`svgutils`](https://svgutils.readthedocs.io/en/latest/): To scale the SVG image.\n","\n","**System Dependencies**\n","* [`klayout`](https://klayout.de/): For DRC (Design Rule Checking).\n"]},{"cell_type":"markdown","metadata":{"id":"bANz_LDB8TQW"},"source":["#### 1.1. Installing the binary dependency `klayout` using micromamba\n","**You only need to run this once**"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"JzDjayJIMSHe","scrolled":true},"outputs":[],"source":["# Setup the environment for the OpenFASOC GDSFactory generator\n","# You only need to run this block once!\n","\n","# Clone OpenFASoC\n","!git clone https://github.com/idea-fasoc/OpenFASOC\n","# Install python dependencies\n","!pip install sky130\n","!pip install gf180 prettyprinttree svgutils\n","!pip install gdsfactory==7.7.0\n","\n","import pathlib\n","import os\n","# Install KLayout (via conda)\n","!curl -Ls https://micro.mamba.pm/api/micromamba/linux-64/latest | tar -xvj bin/micromamba\n","conda_prefix_path = pathlib.Path('conda-env')\n","CONDA_PREFIX = str(conda_prefix_path.resolve())\n","%env CONDA_PREFIX={CONDA_PREFIX}\n","\n","!bin/micromamba create --yes --prefix $CONDA_PREFIX\n","# Install from the litex-hub channel\n","!bin/micromamba install --yes --prefix $CONDA_PREFIX \\\n"," --channel litex-hub \\\n"," --channel main \\\n"," klayout\n"]},{"cell_type":"markdown","metadata":{"id":"B6dO3W3m8TQZ"},"source":["#### 1.2. Adding the `klayout` binary to the system path, then goto the GLayout directory\n","**You need to run this each time you restart the kernel**"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"Izl4QURo8TQa"},"outputs":[],"source":["# Setup the environment for the OpenFASOC GDSFactory generator\n","\n","# Adding micro-mamba binary directory to the PATH\n","# This directory contains Klayout\n","import pathlib\n","import os\n","conda_prefix_path = pathlib.Path('conda-env')\n","CONDA_PREFIX = str(conda_prefix_path.resolve())\n","%env CONDA_PREFIX={CONDA_PREFIX}\n","# Add conda packages to the PATH\n","PATH = os.environ['PATH']\n","%env PATH={PATH}:{CONDA_PREFIX}/bin\n","\n","%cd /content/OpenFASOC/openfasoc/generators/glayout"]},{"cell_type":"markdown","metadata":{"id":"e-sbwZb_8TQb"},"source":["#### 1.3. Importing Libraries and Utility Functions"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"Nc7wGAz68TQb"},"outputs":[],"source":["from glayout.flow.pdk.sky130_mapped import sky130_mapped_pdk as sky130\n","from glayout.flow.pdk.gf180_mapped import gf180_mapped_pdk as gf180\n","import gdstk\n","import svgutils.transform as sg\n","import IPython.display\n","from IPython.display import clear_output\n","import ipywidgets as widgets\n","\n","# Redirect all outputs here\n","hide = widgets.Output()\n","\n","def display_gds(gds_file, scale = 3):\n"," # Generate an SVG image\n"," top_level_cell = gdstk.read_gds(gds_file).top_level()[0]\n"," top_level_cell.write_svg('out.svg')\n"," # Scale the image for displaying\n"," fig = sg.fromfile('out.svg')\n"," fig.set_size((str(float(fig.width) * scale), str(float(fig.height) * scale)))\n"," fig.save('out.svg')\n","\n"," # Display the image\n"," IPython.display.display(IPython.display.SVG('out.svg'))\n","\n","def display_component(component, scale = 3):\n"," # Save to a GDS file\n"," with hide:\n"," component.write_gds(\"out.gds\")\n"," display_gds('out.gds', scale)\n"]},{"cell_type":"markdown","metadata":{"id":"ywJ1Xc5K395z"},"source":["# Current Mirror Layout Design using GLayout API\n","\n","## Overview\n","\n","This document provides a detailed tutorial on using the GLayout API to design and generate a layout for a PMOS current mirror circuit. It outlines the steps to initialize the layout components, place the devices, make necessary adjustments, route the connections, and generate the final layout for visualization.\n","\n","## Prerequisites\n","\n","Ensure that you have the following installed:\n","- Python environment with access to GLayout API.\n","- GDSFactory package for handling generic layout components.\n","- A PDK (Process Design Kit) appropriate for the technology node you're working on (e.g., `gf180` in this example).\n","\n","## Step-by-Step Guide\n","\n","### Step 1: Setting up the Environment\n","\n","**1.1 Import Required Modules**\n","Begin by importing the necessary classes and functions from the GLayout and GDSFactory packages:\n","\n"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"idb2xYtJqwna"},"outputs":[],"source":["from glayout.flow.primitives.guardring import tapring\n","from glayout.flow.primitives.fet import pmos\n","from glayout.flow.pdk.util.comp_utils import evaluate_bbox, prec_center\n","from glayout.flow.pdk.mappedpdk import MappedPDK\n","from glayout.flow.routing.straight_route import straight_route\n","from glayout.flow.routing.c_route import c_route\n","from gdsfactory import Component\n","from glayout.pdk.gf180_mapped import gf180_mapped_pdk"]},{"cell_type":"markdown","metadata":{"id":"fy1-h5NTq0US"},"source":["### Step 2: Define the Current Mirror Function\n","\n","**2.1 Initialize the Current Mirror Component**\n","Within your Python script, start by defining the `currentMirror` function that takes in a `MappedPDK` object:\n","```python\n","def currentMirror(pdk: MappedPDK):\n"," currMirrComp = Component()\n","```\n","\n","**2.2 Create the Transistor Instances**\n","Use the PDK to instantiate two PMOS transistors, a reference and a mirror, with specified modifications:\n","```python\n"," pfet_ref = pmos(with_substrate_tap=False, with_dummy=(False, True))\n"," pfet_mir = pmos(with_substrate_tap=False, with_dummy=(True, False))\n","```\n","\n","**2.3 Add Transistors to the Component**\n","Insert the transistors into the current mirror component and position them:\n","```python\n"," cref_ref = currMirrComp << pfet_ref\n"," cmir_ref = currMirrComp << pfet_mir\n"," cref_ref.movex(evaluate_bbox(pfet_mir)[0] + max_metal_separation(pdk))\n","```\n","\n","**2.4 Add and Position the Tap Ring**\n","Incorporate a tap ring and ensure it encloses the transistors with additional padding to satisfy design rules:\n","```python\n"," tap_ring = tapring(pdk, enclosed_rectangle=evaluate_bbox(currMirrComp.flatten(), padding=pdk.get_grule(\"nwell\", \"active_diff\")[\"min_enclosure\"]))\n"," shift_amount = -prec_center(currMirrComp.flatten())[0]\n"," tring_ref = currMirrComp << tap_ring\n"," tring_ref.movex(destination=shift_amount)\n","```\n","\n","**2.5 Route the Connections**\n","Create routes between the ports:\n","```python\n"," currMirrComp << straight_route(pdk, cref_ref.ports[\"multiplier_0_source_E\"], cmir_ref.ports[\"multiplier_0_source_E\"])\n"," currMirrComp << straight_route(pdk, cref_ref.ports[\"multiplier_0_gate_E\"], cmir_ref.ports[\"multiplier_0_gate_E\"])\n"," currMirrComp << c_route(pdk, cref_ref.ports[\"multiplier_0_gate_E\"], cref_ref.ports[\"multiplier_0_drain_E\"])\n","\n"," return currMirrComp\n","```\n","\n","### Step 3: Visualizing the Layout\n","\n","**3.1 Generate and View the Layout**\n","Finally, visualize the generated layout by calling the `currentMirror` function and using the `.show()` method:\n","```python\n","# To visualize the layout\n","currentMirror(gf180).show()\n","```"]},{"cell_type":"markdown","metadata":{"id":"EFtjsVAixzzr"},"source":["Create the final design cell with the following code block:"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"DGCUq98Qx58n"},"outputs":[],"source":["def currentMirror(pdk: MappedPDK):\n"," currMirrComp = Component()\n"," pfet_ref = pmos(pdk, with_substrate_tap=False, with_dummy=(False, True))\n"," pfet_mir = pmos(pdk, with_substrate_tap=False, with_dummy=(True, False))\n"," cref_ref = currMirrComp << pfet_ref\n"," cmir_ref = currMirrComp << pfet_mir\n"," pdk.util_max_metal_seperation()\n"," cref_ref.movex(evaluate_bbox(pfet_mir)[0] + pdk.util_max_metal_seperation())\n"," tap_ring = tapring(pdk, enclosed_rectangle=evaluate_bbox(currMirrComp.flatten(), padding=pdk.get_grule(\"nwell\", \"active_diff\")[\"min_enclosure\"]))\n"," shift_amount = -prec_center(currMirrComp.flatten())[0]\n"," tring_ref = currMirrComp << tap_ring\n"," tring_ref.movex(destination=shift_amount)\n"," currMirrComp << straight_route(pdk, cref_ref.ports[\"multiplier_0_source_E\"], cmir_ref.ports[\"multiplier_0_source_E\"])\n"," currMirrComp << straight_route(pdk, cref_ref.ports[\"multiplier_0_gate_E\"], cmir_ref.ports[\"multiplier_0_gate_E\"])\n"," currMirrComp << c_route(pdk, cref_ref.ports[\"multiplier_0_gate_E\"], cref_ref.ports[\"multiplier_0_drain_E\"])\n"," return currMirrComp\n","\n","currentMirror(gf180_mapped_pdk).write_gds(\"cmirror_example.gds\")\n","display_gds(\"cmirror_example.gds\")"]},{"cell_type":"markdown","metadata":{"id":"gLC6QYRbxk-v"},"source":["## Conclusion\n","\n","Following these steps results in a PMOS current mirror layout being composed and visualized. The tap ring encloses the transistors and the routing utilities are used to create the required connections respecting the design rules specified by the PDK.\n","\n","Each function call and module used here directly corresponds to a specific structure or operation within the context of the PDK and the layout process. This example provides a foundation upon which more complex circuits can be designed using the powerful features of the GLayout API."]}],"metadata":{"colab":{"provenance":[]},"kernelspec":{"display_name":"Python 3 (ipykernel)","language":"python","name":"python3"},"language_info":{"codemirror_mode":{"name":"ipython","version":3},"file_extension":".py","mimetype":"text/x-python","name":"python","nbconvert_exporter":"python","pygments_lexer":"ipython3","version":"3.11.7"},"vscode":{"interpreter":{"hash":"397704579725e15f5c7cb49fe5f0341eb7531c82d19f2c29d197e8b64ab5776b"}}},"nbformat":4,"nbformat_minor":0} +{"cells":[{"cell_type":"markdown","metadata":{"id":"aK2t7aSWNojQ"},"source":["# GLayout Current Mirror Tutorial\n"]},{"cell_type":"markdown","metadata":{"id":"view-in-github"},"source":["\"Open\n"]},{"cell_type":"markdown","metadata":{"id":"xjDewsT5Y4lP"},"source":["```\n","OpenFASOC Team, Feb 2024\n","SPDX-License-Identifier: Apache-2.0\n","```"]},{"cell_type":"markdown","metadata":{"id":"-Xp4cEjkeHIx"},"source":["## Introduction\n","Welcome!\n","This notebook serves as an introduction to the GDSFactory-based layout automation tool **GLayout** and an example producing a VIA to explain grules and glayers, as a part of [OpenFASoC](https://github.com/idea-fasoc/OpenFASOC). \n","\n","This Notebook will run as-is on Google Collab, or you can run locally by using the install steps in [this document](https://docs.google.com/document/d/e/2PACX-1vRL8ksIvB-fHaqWgkgBPDUznOcDmmFhNrvzPNx9GSSkZyfhJYexEI9gBZCJ0SNNnHdUrAf1EBOeU182/pub). If you choose a local install, skip part 1 of this notebook.\n"]},{"cell_type":"markdown","metadata":{"id":"j4dNshkgMM4I"},"source":["## Installation On Google Collab\n","### 1. Clone the repository and install dependencies\n","**Python Dependencies**\n","* [`gdsfactory`](https://github.com/gdsfactory/gdsfactory): Provides the backend for GDS manipulation.\n","* [`sky130`](https://github.com/gdsfactory/skywater130): The Skywater 130nm PDK Python package for GDSFactory to use in this demo.\n","* [`gf180`](https://github.com/gdsfactory/gf180): The GF 180nm PDK Python package for GDSFactory to use in this demo.\n","* [`gdstk`](https://heitzmann.github.io/gdstk/): (installed as a part of gdsfactory) Used for converting GDS files into SVG images for viewing.\n","* [`svgutils`](https://svgutils.readthedocs.io/en/latest/): To scale the SVG image.\n","\n","**System Dependencies**\n","* [`klayout`](https://klayout.de/): For DRC (Design Rule Checking).\n"]},{"cell_type":"markdown","metadata":{"id":"bANz_LDB8TQW"},"source":["#### 1.1. Installing the binary dependency `klayout` using micromamba\n","**You only need to run this once**"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"JzDjayJIMSHe","scrolled":true},"outputs":[],"source":["# Setup the environment for the OpenFASOC GDSFactory generator\n","# You only need to run this block once!\n","\n","# Clone OpenFASoC\n","!git clone https://github.com/idea-fasoc/OpenFASOC\n","# Install python dependencies\n","!pip install sky130\n","!pip install gf180 prettyprinttree svgutils\n","!pip install gdsfactory==7.7.0\n","\n","import pathlib\n","import os\n","# Install KLayout (via conda)\n","!curl -Ls https://micro.mamba.pm/api/micromamba/linux-64/latest | tar -xvj bin/micromamba\n","conda_prefix_path = pathlib.Path('conda-env')\n","CONDA_PREFIX = str(conda_prefix_path.resolve())\n","%env CONDA_PREFIX={CONDA_PREFIX}\n","\n","!bin/micromamba create --yes --prefix $CONDA_PREFIX\n","# Install from the litex-hub channel\n","!bin/micromamba install --yes --prefix $CONDA_PREFIX \\\n"," --channel litex-hub \\\n"," --channel main \\\n"," klayout\n"]},{"cell_type":"markdown","metadata":{"id":"B6dO3W3m8TQZ"},"source":["#### 1.2. Adding the `klayout` binary to the system path, then goto the GLayout directory\n","**You need to run this each time you restart the kernel**"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"Izl4QURo8TQa"},"outputs":[],"source":["# Setup the environment for the OpenFASOC GDSFactory generator\n","\n","# Adding micro-mamba binary directory to the PATH\n","# This directory contains Klayout\n","import pathlib\n","import os\n","conda_prefix_path = pathlib.Path('conda-env')\n","CONDA_PREFIX = str(conda_prefix_path.resolve())\n","%env CONDA_PREFIX={CONDA_PREFIX}\n","# Add conda packages to the PATH\n","PATH = os.environ['PATH']\n","%env PATH={PATH}:{CONDA_PREFIX}/bin\n","\n","%cd /content/OpenFASOC/openfasoc/generators/glayout"]},{"cell_type":"markdown","metadata":{"id":"e-sbwZb_8TQb"},"source":["#### 1.3. Importing Libraries and Utility Functions"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"Nc7wGAz68TQb"},"outputs":[],"source":["from glayout.flow.pdk.sky130_mapped import sky130_mapped_pdk as sky130\n","from glayout.flow.pdk.gf180_mapped import gf180_mapped_pdk as gf180\n","import gdstk\n","import svgutils.transform as sg\n","import IPython.display\n","from IPython.display import clear_output\n","import ipywidgets as widgets\n","\n","# Redirect all outputs here\n","hide = widgets.Output()\n","\n","def display_gds(gds_file, scale = 3):\n"," # Generate an SVG image\n"," top_level_cell = gdstk.read_gds(gds_file).top_level()[0]\n"," top_level_cell.write_svg('out.svg')\n"," # Scale the image for displaying\n"," fig = sg.fromfile('out.svg')\n"," fig.set_size((str(float(fig.width) * scale), str(float(fig.height) * scale)))\n"," fig.save('out.svg')\n","\n"," # Display the image\n"," IPython.display.display(IPython.display.SVG('out.svg'))\n","\n","def display_component(component, scale = 3):\n"," # Save to a GDS file\n"," with hide:\n"," component.write_gds(\"out.gds\")\n"," display_gds('out.gds', scale)\n"]},{"cell_type":"markdown","metadata":{"id":"ywJ1Xc5K395z"},"source":["# Current Mirror Layout Design using GLayout API\n","\n","## Overview\n","\n","This document provides a detailed tutorial on using the GLayout API to design and generate a layout for a PMOS current mirror circuit. It outlines the steps to initialize the layout components, place the devices, make necessary adjustments, route the connections, and generate the final layout for visualization.\n","\n","## Prerequisites\n","\n","Ensure that you have the following installed:\n","- Python environment with access to GLayout API.\n","- GDSFactory package for handling generic layout components.\n","- A PDK (Process Design Kit) appropriate for the technology node you're working on (e.g., `gf180` in this example).\n","\n","## Step-by-Step Guide\n","\n","### Step 1: Setting up the Environment\n","\n","**1.1 Import Required Modules**\n","Begin by importing the necessary classes and functions from the GLayout and GDSFactory packages:\n","\n"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"idb2xYtJqwna"},"outputs":[],"source":["from glayout.flow.primitives.guardring import tapring\n","from glayout.flow.primitives.fet import pmos\n","from glayout.flow.pdk.util.comp_utils import evaluate_bbox, prec_center\n","from glayout.flow.pdk.mappedpdk import MappedPDK\n","from glayout.flow.routing.straight_route import straight_route\n","from glayout.flow.routing.c_route import c_route\n","from gdsfactory import Component\n","from glayout.pdk.gf180_mapped import gf180_mapped_pdk"]},{"cell_type":"markdown","metadata":{"id":"fy1-h5NTq0US"},"source":["### Step 2: Define the Current Mirror Function\n","\n","**2.1 Initialize the Current Mirror Component**\n","Within your Python script, start by defining the `currentMirror` function that takes in a `MappedPDK` object:\n","```python\n","def currentMirror(pdk: MappedPDK):\n"," currMirrComp = Component()\n","```\n","\n","**2.2 Create the Transistor Instances**\n","Use the PDK to instantiate two PMOS transistors, a reference and a mirror, with specified modifications:\n","```python\n"," pfet_ref = pmos(with_substrate_tap=False, with_dummy=(False, True))\n"," pfet_mir = pmos(with_substrate_tap=False, with_dummy=(True, False))\n","```\n","\n","**2.3 Add Transistors to the Component**\n","Insert the transistors into the current mirror component and position them:\n","```python\n"," cref_ref = currMirrComp << pfet_ref\n"," cmir_ref = currMirrComp << pfet_mir\n"," cref_ref.movex(evaluate_bbox(pfet_mir)[0] + max_metal_separation(pdk))\n","```\n","\n","**2.4 Add and Position the Tap Ring**\n","Incorporate a tap ring and ensure it encloses the transistors with additional padding to satisfy design rules:\n","```python\n"," tap_ring = tapring(pdk, enclosed_rectangle=evaluate_bbox(currMirrComp.flatten(), padding=pdk.get_grule(\"nwell\", \"active_diff\")[\"min_enclosure\"]))\n"," shift_amount = -prec_center(currMirrComp.flatten())[0]\n"," tring_ref = currMirrComp << tap_ring\n"," tring_ref.movex(destination=shift_amount)\n","```\n","\n","**2.5 Route the Connections**\n","Create routes between the ports:\n","```python\n"," currMirrComp << straight_route(pdk, cref_ref.ports[\"multiplier_0_source_E\"], cmir_ref.ports[\"multiplier_0_source_E\"])\n"," currMirrComp << straight_route(pdk, cref_ref.ports[\"multiplier_0_gate_E\"], cmir_ref.ports[\"multiplier_0_gate_E\"])\n"," currMirrComp << c_route(pdk, cref_ref.ports[\"multiplier_0_gate_E\"], cref_ref.ports[\"multiplier_0_drain_E\"])\n","\n"," return currMirrComp\n","```\n","\n","### Step 3: Visualizing the Layout\n","\n","**3.1 Generate and View the Layout**\n","Finally, visualize the generated layout by calling the `currentMirror` function and using the `.show()` method:\n","```python\n","# To visualize the layout\n","currentMirror(gf180).show()\n","```"]},{"cell_type":"markdown","metadata":{"id":"EFtjsVAixzzr"},"source":["Create the final design cell with the following code block:"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"DGCUq98Qx58n"},"outputs":[],"source":["def currentMirror(pdk: MappedPDK):\n"," currMirrComp = Component()\n"," pfet_ref = pmos(pdk, with_substrate_tap=False, with_dummy=(False, True))\n"," pfet_mir = pmos(pdk, with_substrate_tap=False, with_dummy=(True, False))\n"," cref_ref = currMirrComp << pfet_ref\n"," cmir_ref = currMirrComp << pfet_mir\n"," pdk.util_max_metal_seperation()\n"," cref_ref.movex(evaluate_bbox(pfet_mir)[0] + pdk.util_max_metal_seperation())\n"," tap_ring = tapring(pdk, enclosed_rectangle=evaluate_bbox(currMirrComp.flatten(), padding=pdk.get_grule(\"nwell\", \"active_diff\")[\"min_enclosure\"]))\n"," shift_amount = -prec_center(currMirrComp.flatten())[0]\n"," tring_ref = currMirrComp << tap_ring\n"," tring_ref.movex(destination=shift_amount)\n"," currMirrComp << straight_route(pdk, cref_ref.ports[\"multiplier_0_source_E\"], cmir_ref.ports[\"multiplier_0_source_E\"])\n"," currMirrComp << straight_route(pdk, cref_ref.ports[\"multiplier_0_gate_E\"], cmir_ref.ports[\"multiplier_0_gate_E\"])\n"," currMirrComp << c_route(pdk, cref_ref.ports[\"multiplier_0_gate_E\"], cref_ref.ports[\"multiplier_0_drain_E\"])\n"," return currMirrComp\n","\n","currentMirror(gf180_mapped_pdk).write_gds(\"cmirror_example.gds\")\n","display_gds(\"cmirror_example.gds\")"]},{"cell_type":"markdown","metadata":{"id":"gLC6QYRbxk-v"},"source":["## Conclusion\n","\n","Following these steps results in a PMOS current mirror layout being composed and visualized. The tap ring encloses the transistors and the routing utilities are used to create the required connections respecting the design rules specified by the PDK.\n","\n","Each function call and module used here directly corresponds to a specific structure or operation within the context of the PDK and the layout process. This example provides a foundation upon which more complex circuits can be designed using the powerful features of the GLayout API."]}],"metadata":{"colab":{"provenance":[]},"kernelspec":{"display_name":"Python 3 (ipykernel)","language":"python","name":"python3"},"language_info":{"codemirror_mode":{"name":"ipython","version":3},"file_extension":".py","mimetype":"text/x-python","name":"python","nbconvert_exporter":"python","pygments_lexer":"ipython3","version":"3.11.7"},"vscode":{"interpreter":{"hash":"397704579725e15f5c7cb49fe5f0341eb7531c82d19f2c29d197e8b64ab5776b"}}},"nbformat":4,"nbformat_minor":0} diff --git a/docs/source/notebooks/glayout/GLayout_Via.ipynb b/docs/source/notebooks/glayout/GLayout_Via.ipynb index a2f899708..9c28601b4 100644 --- a/docs/source/notebooks/glayout/GLayout_Via.ipynb +++ b/docs/source/notebooks/glayout/GLayout_Via.ipynb @@ -1 +1 @@ -{"cells":[{"cell_type":"markdown","metadata":{"id":"aK2t7aSWNojQ"},"source":["# GLayout Installation & Simple Via Creation Tutorial\n"]},{"cell_type":"markdown","metadata":{"id":"view-in-github"},"source":["\"Open\n"]},{"cell_type":"markdown","metadata":{"id":"xjDewsT5Y4lP"},"source":["```\n","OpenFASOC Team, Feb 2024\n","SPDX-License-Identifier: Apache-2.0\n","```"]},{"cell_type":"markdown","metadata":{"id":"-Xp4cEjkeHIx"},"source":["## Introduction\n","Welcome!\n","This notebook serves as an introduction to the GDSFactory-based layout automation tool **GLayout** and an example producing a VIA to explain grules and glayers, as a part of [OpenFASoC](https://github.com/idea-fasoc/OpenFASOC).\n","\n","Below we have the installation steps needed for the google collab envirment used in the tutorial, and for a local ubuntu installation (if you want to follow along locally).\n"]},{"cell_type":"markdown","metadata":{"id":"j4dNshkgMM4I"},"source":["## Installation On Google Collab\n","### 1. Clone the repository and install dependencies\n","**Python Dependencies**\n","* [`gdsfactory`](https://github.com/gdsfactory/gdsfactory): Provides the backend for GDS manipulation.\n","* [`sky130`](https://github.com/gdsfactory/skywater130): The Skywater 130nm PDK Python package for GDSFactory to use in this demo.\n","* [`gf180`](https://github.com/gdsfactory/gf180): The GF 180nm PDK Python package for GDSFactory to use in this demo.\n","* [`gdstk`](https://heitzmann.github.io/gdstk/): (installed as a part of gdsfactory) Used for converting GDS files into SVG images for viewing.\n","* [`svgutils`](https://svgutils.readthedocs.io/en/latest/): To scale the SVG image.\n","\n","**System Dependencies**\n","* [`klayout`](https://klayout.de/): For DRC (Design Rule Checking).\n"]},{"cell_type":"markdown","metadata":{"id":"bANz_LDB8TQW"},"source":["#### 1.1. Installing the binary dependency `klayout` using micromamba\n","**You only need to run this once**"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"JzDjayJIMSHe","scrolled":true},"outputs":[],"source":["# Setup the environment for the OpenFASOC GDSFactory generator\n","# You only need to run this block once!\n","\n","# Clone OpenFASoC\n","!git clone https://github.com/idea-fasoc/OpenFASOC\n","# Install python dependencies\n","!pip install sky130\n","!pip install gf180 prettyprinttree svgutils\n","!pip install gdsfactory==7.7.0\n","\n","import pathlib\n","import os\n","# Install KLayout (via conda)\n","!curl -Ls https://micro.mamba.pm/api/micromamba/linux-64/latest | tar -xvj bin/micromamba\n","conda_prefix_path = pathlib.Path('conda-env')\n","CONDA_PREFIX = str(conda_prefix_path.resolve())\n","%env CONDA_PREFIX={CONDA_PREFIX}\n","\n","!bin/micromamba create --yes --prefix $CONDA_PREFIX\n","# Install from the litex-hub channel\n","!bin/micromamba install --yes --prefix $CONDA_PREFIX \\\n"," --channel litex-hub \\\n"," --channel main \\\n"," klayout\n"]},{"cell_type":"markdown","metadata":{"id":"B6dO3W3m8TQZ"},"source":["#### 1.2. Adding the `klayout` binary to the system path, then goto the GLayout directory\n","**You need to run this each time you restart the kernel**"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"Izl4QURo8TQa"},"outputs":[],"source":["# Setup the environment for the OpenFASOC GDSFactory generator\n","\n","# Adding micro-mamba binary directory to the PATH\n","# This directory contains Klayout\n","import pathlib\n","import os\n","conda_prefix_path = pathlib.Path('conda-env')\n","CONDA_PREFIX = str(conda_prefix_path.resolve())\n","%env CONDA_PREFIX={CONDA_PREFIX}\n","# Add conda packages to the PATH\n","PATH = os.environ['PATH']\n","%env PATH={PATH}:{CONDA_PREFIX}/bin\n","\n","%cd /content/OpenFASOC/openfasoc/generators/glayout"]},{"cell_type":"markdown","metadata":{"id":"e-sbwZb_8TQb"},"source":["#### 1.3. Importing Libraries and Utility Functions"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"Nc7wGAz68TQb"},"outputs":[],"source":["from glayout.flow.pdk.sky130_mapped import sky130_mapped_pdk as sky130\n","from glayout.flow.pdk.gf180_mapped import gf180_mapped_pdk as gf180\n","import gdstk\n","import svgutils.transform as sg\n","import IPython.display\n","from IPython.display import clear_output\n","import ipywidgets as widgets\n","\n","# Redirect all outputs here\n","hide = widgets.Output()\n","\n","def display_gds(gds_file, scale = 3):\n"," # Generate an SVG image\n"," top_level_cell = gdstk.read_gds(gds_file).top_level()[0]\n"," top_level_cell.write_svg('out.svg')\n"," # Scale the image for displaying\n"," fig = sg.fromfile('out.svg')\n"," fig.set_size((str(float(fig.width) * scale), str(float(fig.height) * scale)))\n"," fig.save('out.svg')\n","\n"," # Display the image\n"," IPython.display.display(IPython.display.SVG('out.svg'))\n","\n","def display_component(component, scale = 3):\n"," # Save to a GDS file\n"," with hide:\n"," component.write_gds(\"out.gds\")\n"," display_gds('out.gds', scale)\n"]},{"cell_type":"markdown","source":["\n","## Installation Steps For Ubuntu:\n","\n","**1. Install System Dependencies**\n","- Ensure you have Python 3 installed; version 3.10 or greater is required.\n","- If you're on Ubuntu, use the package manager to install Python with the following command:\n"," ```\n"," sudo apt-get install python3\n"," ```\n","- You may also need to install the following dependency for klayout\n"," ```\n"," sudo apt-get install ruby-dev\n"," ```\n","\n","**2. Install KLayout**\n","- KLayout needs to be installed for layout viewing and generation. Install it using:\n"," ```\n"," sudo apt-get install klayout\n"," ```\n","\n","**3. Verify Python Version and install pip**\n","- Run:\n"," ```\n"," python3 --version\n"," ```\n","- Verify installed version is >3.10\n","- You need to install pip if it is not installed:\n"," ```\n"," sudo apt-get install python3-pip\n"," ```\n","\n","**4. Install Open-Source PDK (e.g., GF180)**\n","- Install an open-source PDK using pip:\n"," ```\n"," python3 -m pip install gf180\n"," ```\n","\n","**5. Install GLayout API**\n","- Install Glayout using pip with:\n"," ```\n"," python3 -m pip install glayout\n"," ```\n"],"metadata":{"id":"_90PvHDShVp3"}},{"cell_type":"markdown","source":["\n","## Building a Simple Via\n","\n","**1. Open Your Favorite IDE, Create a File**\n","- Open your preferred code editor.\n","- Create a new Python file: `example.py`.\n","- In this collab env, we will edit in code blocks below\n","\n","**2. Import Required Modules**"],"metadata":{"id":"Pi7u2ZgVjosO"}},{"cell_type":"markdown","source":["The via function will use several imports:\n","\n","* gf180_mapped_pdk from the glayout.pdk.gf180_mapped module: PDK for GF180 (180-nanometer technology node) provided by the glayout package. The PDK contains technology-specific information including rules and layers.\n","\n","* MappedPDK from the glayout.pdk.mappedpdk module: This is a class for mapping generic layers and design rules to the specific layers and design rules present in the chosen PDK.\n","\n","* Component from gdsfactory: This is a class representing a layout component, which includes polygons, paths, etc.\n","\n","* rectangle from gdsfactory.components: This function creates a rectangle polygon."],"metadata":{"id":"hyYzrMWLlDoi"}},{"cell_type":"code","source":["from glayout.flow.pdk.gf180_mapped import gf180_mapped_pdk\n","from glayout.flow.pdk.mappedpdk import MappedPDK\n","from gdsfactory import Component\n","from gdsfactory.components import rectangle"],"metadata":{"id":"zT4AQDr8j6mg"},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":["\n","**3. Define the Via Function**"],"metadata":{"id":"K0gKdrEAj9VE"}},{"cell_type":"markdown","source":["The function create_via which takes a single argument which is the PDK. Inside the function, the following steps are executed:\n","\n","* Via Dimensions: Using the get_grule method of the PDK object, the width of the via is retrieved from the technology's design rules. This rule specifies the minimum size that the via can be. This dimension is set as both the length and width for a via.\n","\n","* Metal Dimensions: The dimensions of the metal layers above and below the via are determined. These dimensions must accommodate the via and any required enclosure space as mandated by the PDK. Enclosure space refers to the required minimum spacing between the edge of the via and the edge of the surrounding metal layer.\n","\n","* Layer Retrieval: The get_glayer method retrieves the specific layer numbers or names from the PDK. These are then used to assign the correct graphical layers to the shapes that will be generated.\n","\n","* Shape Creation and Placement: An empty Component instance named top_level is created, representing the top component in which all shapes will be placed. Using the insertion operator (<<), rectangles representing the metal layers and via are added to the top_level component with their specified sizes and layers.\n","\n","* Return Value: The top_level component, now containing the layout shapes for the metals and via, is the return value of the function. This component can be written out as a GDSII file."],"metadata":{"id":"rlGg2kObltMW"}},{"cell_type":"code","source":["def create_via(PDK: MappedPDK):\n"," # Define the via dimensions and rules\n"," via_dimension = PDK.get_grule('via1')['width']\n"," metal1_dimension = via_dimension + 2 * PDK.get_grule('via1','met1')['min_enclosure']\n"," metal2_dimension = via_dimension + 2 * PDK.get_grule('via1','met2')['min_enclosure']\n","\n"," # Get the layers for via and metals\n"," via_layer = PDK.get_glayer('via1')\n"," metal1_layer = PDK.get_glayer('met1')\n"," metal2_layer = PDK.get_glayer('met2')\n","\n"," # Create the component and add the layers\n"," top_level = Component(name='via_example')\n"," top_level << rectangle(size=(via_dimension, via_dimension), layer=via_layer)\n"," top_level << rectangle(size=(metal1_dimension, metal1_dimension), layer=metal1_layer)\n"," top_level << rectangle(size=(metal2_dimension, metal2_dimension), layer=metal2_layer)\n","\n"," return top_level"],"metadata":{"id":"MgKks3kuj_Ow"},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":["**4. Run the Via Function and Generate Layout**"],"metadata":{"id":"gPBHRStqkCCW"}},{"cell_type":"code","source":["via_component = create_via(PDK=gf180_mapped_pdk)\n","via_component.write_gds('via_example.gds')"],"metadata":{"id":"ox35X1mAkPFC"},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":["**5. View the Generated Layout**\n","- Open KLayout and load the generated GDS file to view your layout.\n","- Or view in notebook with the following code block."],"metadata":{"id":"fgNPjeuckUk_"}},{"cell_type":"code","source":["display_gds('via_example.gds',scale=20)"],"metadata":{"id":"JqzYORoZwQ-q"},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":["By concluding these steps, you will have downloaded Glayout, installed the necessary dependencies, and completed the construction of a simple via using Glayout."],"metadata":{"id":"lau7cFu9wYxI"}}],"metadata":{"colab":{"provenance":[]},"kernelspec":{"display_name":"Python 3 (ipykernel)","language":"python","name":"python3"},"language_info":{"codemirror_mode":{"name":"ipython","version":3},"file_extension":".py","mimetype":"text/x-python","name":"python","nbconvert_exporter":"python","pygments_lexer":"ipython3","version":"3.11.7"},"vscode":{"interpreter":{"hash":"397704579725e15f5c7cb49fe5f0341eb7531c82d19f2c29d197e8b64ab5776b"}}},"nbformat":4,"nbformat_minor":0} +{"cells":[{"cell_type":"markdown","metadata":{"id":"aK2t7aSWNojQ"},"source":["# GLayout Installation & Simple Via Creation Tutorial\n"]},{"cell_type":"markdown","metadata":{"id":"view-in-github"},"source":["\"Open\n"]},{"cell_type":"markdown","metadata":{"id":"xjDewsT5Y4lP"},"source":["```\n","OpenFASOC Team, Feb 2024\n","SPDX-License-Identifier: Apache-2.0\n","```"]},{"cell_type":"markdown","metadata":{"id":"-Xp4cEjkeHIx"},"source":["## Introduction\n","Welcome!\n","This notebook serves as an introduction to the GDSFactory-based layout automation tool **GLayout** and an example producing a VIA to explain grules and glayers, as a part of [OpenFASoC](https://github.com/idea-fasoc/OpenFASOC). \n","\n","This Notebook will run as-is on Google Collab, or you can run locally by using the install steps in [this document](https://docs.google.com/document/d/e/2PACX-1vRL8ksIvB-fHaqWgkgBPDUznOcDmmFhNrvzPNx9GSSkZyfhJYexEI9gBZCJ0SNNnHdUrAf1EBOeU182/pub). If you choose a local install, skip part 1 of this notebook.\n"]},{"cell_type":"markdown","metadata":{"id":"j4dNshkgMM4I"},"source":["## Installation On Google Collab\n","### 1. Clone the repository and install dependencies\n","**Python Dependencies**\n","* [`gdsfactory`](https://github.com/gdsfactory/gdsfactory): Provides the backend for GDS manipulation.\n","* [`sky130`](https://github.com/gdsfactory/skywater130): The Skywater 130nm PDK Python package for GDSFactory to use in this demo.\n","* [`gf180`](https://github.com/gdsfactory/gf180): The GF 180nm PDK Python package for GDSFactory to use in this demo.\n","* [`gdstk`](https://heitzmann.github.io/gdstk/): (installed as a part of gdsfactory) Used for converting GDS files into SVG images for viewing.\n","* [`svgutils`](https://svgutils.readthedocs.io/en/latest/): To scale the SVG image.\n","\n","**System Dependencies**\n","* [`klayout`](https://klayout.de/): For DRC (Design Rule Checking).\n"]},{"cell_type":"markdown","metadata":{"id":"bANz_LDB8TQW"},"source":["#### 1.1. Installing the binary dependency `klayout` using micromamba\n","**You only need to run this once**"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"JzDjayJIMSHe","scrolled":true},"outputs":[],"source":["# Setup the environment for the OpenFASOC GDSFactory generator\n","# You only need to run this block once!\n","\n","# Clone OpenFASoC\n","!git clone https://github.com/idea-fasoc/OpenFASOC\n","# Install python dependencies\n","!pip install sky130\n","!pip install gf180 prettyprinttree svgutils\n","!pip install gdsfactory==7.7.0\n","\n","import pathlib\n","import os\n","# Install KLayout (via conda)\n","!curl -Ls https://micro.mamba.pm/api/micromamba/linux-64/latest | tar -xvj bin/micromamba\n","conda_prefix_path = pathlib.Path('conda-env')\n","CONDA_PREFIX = str(conda_prefix_path.resolve())\n","%env CONDA_PREFIX={CONDA_PREFIX}\n","\n","!bin/micromamba create --yes --prefix $CONDA_PREFIX\n","# Install from the litex-hub channel\n","!bin/micromamba install --yes --prefix $CONDA_PREFIX \\\n"," --channel litex-hub \\\n"," --channel main \\\n"," klayout\n"]},{"cell_type":"markdown","metadata":{"id":"B6dO3W3m8TQZ"},"source":["#### 1.2. Adding the `klayout` binary to the system path, then goto the GLayout directory\n","**You need to run this each time you restart the kernel**"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"Izl4QURo8TQa"},"outputs":[],"source":["# Setup the environment for the OpenFASOC GDSFactory generator\n","\n","# Adding micro-mamba binary directory to the PATH\n","# This directory contains Klayout\n","import pathlib\n","import os\n","conda_prefix_path = pathlib.Path('conda-env')\n","CONDA_PREFIX = str(conda_prefix_path.resolve())\n","%env CONDA_PREFIX={CONDA_PREFIX}\n","# Add conda packages to the PATH\n","PATH = os.environ['PATH']\n","%env PATH={PATH}:{CONDA_PREFIX}/bin\n","\n","%cd /content/OpenFASOC/openfasoc/generators/glayout"]},{"cell_type":"markdown","metadata":{"id":"e-sbwZb_8TQb"},"source":["#### 1.3. Importing Libraries and Utility Functions"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"Nc7wGAz68TQb"},"outputs":[],"source":["from glayout.flow.pdk.sky130_mapped import sky130_mapped_pdk as sky130\n","from glayout.flow.pdk.gf180_mapped import gf180_mapped_pdk as gf180\n","import gdstk\n","import svgutils.transform as sg\n","import IPython.display\n","from IPython.display import clear_output\n","import ipywidgets as widgets\n","\n","# Redirect all outputs here\n","hide = widgets.Output()\n","\n","def display_gds(gds_file, scale = 3):\n"," # Generate an SVG image\n"," top_level_cell = gdstk.read_gds(gds_file).top_level()[0]\n"," top_level_cell.write_svg('out.svg')\n"," # Scale the image for displaying\n"," fig = sg.fromfile('out.svg')\n"," fig.set_size((str(float(fig.width) * scale), str(float(fig.height) * scale)))\n"," fig.save('out.svg')\n","\n"," # Display the image\n"," IPython.display.display(IPython.display.SVG('out.svg'))\n","\n","def display_component(component, scale = 3):\n"," # Save to a GDS file\n"," with hide:\n"," component.write_gds(\"out.gds\")\n"," display_gds('out.gds', scale)\n"]},{"cell_type":"markdown","metadata":{"id":"Pi7u2ZgVjosO"},"source":["\n","## Building a Simple Via\n","\n","**1. Open Your Favorite IDE, Create a File**\n","- Open your preferred code editor.\n","- Create a new Python file: `example.py`.\n","- In this collab env, we will edit in code blocks below\n","\n","**2. Import Required Modules**"]},{"cell_type":"markdown","metadata":{"id":"hyYzrMWLlDoi"},"source":["The via function will use several imports:\n","\n","* gf180_mapped_pdk from the glayout.pdk.gf180_mapped module: PDK for GF180 (180-nanometer technology node) provided by the glayout package. The PDK contains technology-specific information including rules and layers.\n","\n","* MappedPDK from the glayout.pdk.mappedpdk module: This is a class for mapping generic layers and design rules to the specific layers and design rules present in the chosen PDK.\n","\n","* Component from gdsfactory: This is a class representing a layout component, which includes polygons, paths, etc.\n","\n","* rectangle from gdsfactory.components: This function creates a rectangle polygon."]},{"cell_type":"code","execution_count":null,"metadata":{"id":"zT4AQDr8j6mg"},"outputs":[],"source":["from glayout.flow.pdk.gf180_mapped import gf180_mapped_pdk\n","from glayout.flow.pdk.mappedpdk import MappedPDK\n","from gdsfactory import Component\n","from gdsfactory.components import rectangle"]},{"cell_type":"markdown","metadata":{"id":"K0gKdrEAj9VE"},"source":["\n","**3. Define the Via Function**"]},{"cell_type":"markdown","metadata":{"id":"rlGg2kObltMW"},"source":["The function create_via which takes a single argument which is the PDK. Inside the function, the following steps are executed:\n","\n","* Via Dimensions: Using the get_grule method of the PDK object, the width of the via is retrieved from the technology's design rules. This rule specifies the minimum size that the via can be. This dimension is set as both the length and width for a via.\n","\n","* Metal Dimensions: The dimensions of the metal layers above and below the via are determined. These dimensions must accommodate the via and any required enclosure space as mandated by the PDK. Enclosure space refers to the required minimum spacing between the edge of the via and the edge of the surrounding metal layer.\n","\n","* Layer Retrieval: The get_glayer method retrieves the specific layer numbers or names from the PDK. These are then used to assign the correct graphical layers to the shapes that will be generated.\n","\n","* Shape Creation and Placement: An empty Component instance named top_level is created, representing the top component in which all shapes will be placed. Using the insertion operator (<<), rectangles representing the metal layers and via are added to the top_level component with their specified sizes and layers.\n","\n","* Return Value: The top_level component, now containing the layout shapes for the metals and via, is the return value of the function. This component can be written out as a GDSII file."]},{"cell_type":"code","execution_count":null,"metadata":{"id":"MgKks3kuj_Ow"},"outputs":[],"source":["def create_via(PDK: MappedPDK):\n"," # Define the via dimensions and rules\n"," via_dimension = PDK.get_grule('via1')['width']\n"," metal1_dimension = via_dimension + 2 * PDK.get_grule('via1','met1')['min_enclosure']\n"," metal2_dimension = via_dimension + 2 * PDK.get_grule('via1','met2')['min_enclosure']\n","\n"," # Get the layers for via and metals\n"," via_layer = PDK.get_glayer('via1')\n"," metal1_layer = PDK.get_glayer('met1')\n"," metal2_layer = PDK.get_glayer('met2')\n","\n"," # Create the component and add the layers\n"," top_level = Component(name='via_example')\n"," top_level << rectangle(size=(via_dimension, via_dimension), layer=via_layer)\n"," top_level << rectangle(size=(metal1_dimension, metal1_dimension), layer=metal1_layer)\n"," top_level << rectangle(size=(metal2_dimension, metal2_dimension), layer=metal2_layer)\n","\n"," return top_level"]},{"cell_type":"markdown","metadata":{"id":"gPBHRStqkCCW"},"source":["**4. Run the Via Function and Generate Layout**"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"ox35X1mAkPFC"},"outputs":[],"source":["via_component = create_via(PDK=gf180_mapped_pdk)\n","via_component.write_gds('via_example.gds')"]},{"cell_type":"markdown","metadata":{"id":"fgNPjeuckUk_"},"source":["**5. View the Generated Layout**\n","- Open KLayout and load the generated GDS file to view your layout.\n","- Or view in notebook with the following code block."]},{"cell_type":"code","execution_count":null,"metadata":{"id":"JqzYORoZwQ-q"},"outputs":[],"source":["display_gds('via_example.gds',scale=20)"]},{"cell_type":"markdown","metadata":{"id":"lau7cFu9wYxI"},"source":["By concluding these steps, you will have downloaded Glayout, installed the necessary dependencies, and completed the construction of a simple via using Glayout."]}],"metadata":{"colab":{"provenance":[]},"kernelspec":{"display_name":"Python 3 (ipykernel)","language":"python","name":"python3"},"language_info":{"codemirror_mode":{"name":"ipython","version":3},"file_extension":".py","mimetype":"text/x-python","name":"python","nbconvert_exporter":"python","pygments_lexer":"ipython3","version":"3.11.7"},"vscode":{"interpreter":{"hash":"397704579725e15f5c7cb49fe5f0341eb7531c82d19f2c29d197e8b64ab5776b"}}},"nbformat":4,"nbformat_minor":0} diff --git a/docs/source/notebooks/glayout/glayout_opamp.ipynb b/docs/source/notebooks/glayout/glayout_opamp.ipynb index 0c67b5223..4858898c3 100644 --- a/docs/source/notebooks/glayout/glayout_opamp.ipynb +++ b/docs/source/notebooks/glayout/glayout_opamp.ipynb @@ -55,7 +55,9 @@ "source": [ "# Introduction\n", "Welcome!\n", - "This notebook serves as an introduction to the GDSFactory-based layout automation tool **GLayout** and an example two-stage Operational Amplifier (Op-Amp) generator, as a part of [OpenFASoC](https://github.com/idea-fasoc/OpenFASOC).\n", + "This notebook serves as an introduction to the GDSFactory-based layout automation tool **GLayout** and an example two-stage Operational Amplifier (Op-Amp) generator, as a part of [OpenFASoC](https://github.com/idea-fasoc/OpenFASOC). \n", + "\n", + "This Notebook will run as-is on Google Collab, or you can run locally by using the install steps in [this document](https://docs.google.com/document/d/e/2PACX-1vRL8ksIvB-fHaqWgkgBPDUznOcDmmFhNrvzPNx9GSSkZyfhJYexEI9gBZCJ0SNNnHdUrAf1EBOeU182/pub). If you choose a local install, skip part 1 of this notebook.\n", "\n", "## GDSFactory\n", "[GDSFactory](https://gdsfactory.github.io/gdsfactory/index.html) is a Python library for designing integrated circuit layouts in Python and save it directly in the [GDSII](https://en.wikipedia.org/wiki/GDSII) format, and run DRC (Design Rule Checking) and LVS (Layout v/s Schematic) verification, or simulation.\n", From 30afeafec0b34399fbc4628b1ed9b8fbcc210048 Mon Sep 17 00:00:00 2001 From: labtob <70279295+alibillalhammoud@users.noreply.github.com> Date: Wed, 5 Jun 2024 22:11:37 -0400 Subject: [PATCH 08/11] update dockerfile and packages --- docker/conda/Dockerfile | 27 ++++++++++++++------------- docker/conda/packages.txt | 2 ++ 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/docker/conda/Dockerfile b/docker/conda/Dockerfile index e381168e4..0ee98e006 100755 --- a/docker/conda/Dockerfile +++ b/docker/conda/Dockerfile @@ -12,21 +12,22 @@ RUN wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh \ ENV PATH=/usr/bin/miniconda3/bin:${PATH} RUN conda update conda --all -y RUN conda install python=3.10 \ - yosys \ - open_pdks.sky130a \ - open_pdks.gf180mcuC \ - magic \ - netgen \ - openroad \ - -c litex-hub \ - -c conda-forge \ - -c anaconda \ - -y + yosys \ + open_pdks.sky130a \ + open_pdks.gf180mcuC \ + magic \ + netgen \ + openroad \ + -c litex-hub \ + -c conda-forge \ + -c anaconda \ + -y ENV PDK_ROOT=/usr/bin/miniconda3/share/pdk/ -RUN wget https://www.klayout.org/downloads/Ubuntu-22/klayout_0.28.12-1_amd64.deb -RUN dpkg -i klayout_0.28.12-1_amd64.deb -RUN strip --remove-section=.note.ABI-tag /usr/lib/x86_64-linux-gnu/libQt5Core.so.5 +RUN wget https://www.klayout.org/downloads/Ubuntu-22/klayout_0.28.17-1_amd64.deb +RUN dpkg -i klayout_0.28.17-1_amd64.deb +RUN pip install glayout +#RUN strip --remove-section=.note.ABI-tag /usr/lib/x86_64-linux-gnu/libQt5Core.so.5 COPY ./scripts /scripts diff --git a/docker/conda/packages.txt b/docker/conda/packages.txt index bfe190315..7fcf688df 100644 --- a/docker/conda/packages.txt +++ b/docker/conda/packages.txt @@ -23,3 +23,5 @@ libx11-dev libx11-6 libxaw7-dev libreadline6-dev +libz-dev +libgit2-dev From 00f8e4ca7ecd45171a05af3a45f08b4e1431b39d Mon Sep 17 00:00:00 2001 From: Ali Hammoud <70279295+alibillalhammoud@users.noreply.github.com> Date: Thu, 6 Jun 2024 02:24:45 +0000 Subject: [PATCH 09/11] update glayout test script --- openfasoc/generators/glayout/test_glayout.py | 21 +++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/openfasoc/generators/glayout/test_glayout.py b/openfasoc/generators/glayout/test_glayout.py index 351821d6a..877378eb5 100644 --- a/openfasoc/generators/glayout/test_glayout.py +++ b/openfasoc/generators/glayout/test_glayout.py @@ -60,8 +60,10 @@ def check_python_requirements(requirements_file): """Check if all Python requirements are installed using the requirements file provided in the top level directory of OpenFASOC. Checks the package versions as well""" print_heading("Checking Python requirements") - with open(requirements_file, 'r') as f: - requirements = f.read().splitlines() + # do not directly check reqs files because it has llm only packages + #with open(requirements_file, 'r') as f: + # requirements = f.read().splitlines() + requirements = ['gdsfactory==7.7.0', 'prettyprint', 'prettyprinttree', 'nltk'] for requirement in requirements: # Split the requirement safely parts = requirement.split('==') @@ -134,18 +136,22 @@ def check_miniconda3_and_pdk(): required_pdk_dirs = ["sky130A", "gf180mcuC"] missing_dirs = [pdk_dir for pdk_dir in required_pdk_dirs if not (pdk_root / pdk_dir).exists()] - if missing_dirs: + if len(missing_dirs)==len(required_pdk_dirs): + raise EnvironmentError(f"no installed PDK was found from {required_pdk_dirs}") + elif missing_dirs: warnings.warn(f"\nMissing required PDK directories: {', '.join(missing_dirs)}") - - print("\nAll required PDK directories are present!") + else: + print("\nAll required PDK directories are present!") return miniconda3_path, pdk_root def place_nfet_run_lvs(): """places a default nmos components using the sky130 pdk, and runs netgen lvs on it. This utilises the spice generation of the component, magic, and netgen, so it makes up a good test for the installation""" - + print_heading("NMOS and LVS") print("\n...Creating nmos component...") nmos_component = nmos(sky130) + print("\n...Showing nmos component...") + nmos_component.show() print("Created nmos component!") print("\n...Running LVS...") nmos_component.name = 'nmos_test' @@ -159,7 +165,8 @@ def place_nfet_run_lvs(): print_dynamic_separator() check_python_version() print_dynamic_separator() - check_python_requirements("../../../requirements.txt") + #check_python_requirements("../../../requirements.txt") + check_python_requirements() print_dynamic_separator() miniconda3_path, pdk_root = check_miniconda3_and_pdk() print_dynamic_separator() From d6a34519db74d3650203c00206da276d298d5fbb Mon Sep 17 00:00:00 2001 From: Ali Hammoud <70279295+alibillalhammoud@users.noreply.github.com> Date: Thu, 6 Jun 2024 02:35:46 +0000 Subject: [PATCH 10/11] bug fix --- openfasoc/generators/glayout/glayout/flow/blocks/opamp/opamp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openfasoc/generators/glayout/glayout/flow/blocks/opamp/opamp.py b/openfasoc/generators/glayout/glayout/flow/blocks/opamp/opamp.py index 7550e80a1..f3e462bbb 100644 --- a/openfasoc/generators/glayout/glayout/flow/blocks/opamp/opamp.py +++ b/openfasoc/generators/glayout/glayout/flow/blocks/opamp/opamp.py @@ -20,7 +20,7 @@ from glayout.flow.placement.two_transistor_interdigitized import two_nfet_interdigitized from glayout.flow.spice import Netlist -from glayout.flow.blocks.opamp import opamp_twostage +from glayout.flow.blocks.opamp.opamp_twostage import opamp_twostage from glayout.flow.blocks.current_mirror import current_mirror_netlist def opamp_output_stage_netlist(pdk: MappedPDK, output_amp_fet_ref: ComponentReference, biasParams: list) -> Netlist: From 264b15c7b07e885d705e5a749dc5779a6cc7d703 Mon Sep 17 00:00:00 2001 From: Ali Hammoud <70279295+alibillalhammoud@users.noreply.github.com> Date: Thu, 6 Jun 2024 03:07:44 +0000 Subject: [PATCH 11/11] v0.0.7 --- openfasoc/generators/glayout/setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openfasoc/generators/glayout/setup.py b/openfasoc/generators/glayout/setup.py index f859bc0f0..e557a3b31 100644 --- a/openfasoc/generators/glayout/setup.py +++ b/openfasoc/generators/glayout/setup.py @@ -3,7 +3,7 @@ setup( name="glayout", - version="0.0.6", + version="0.0.7", author="Ali Hammoud, Harsh Khandeparkar, Vijay Shankar, Chetanya Goyal, Sakib Pathen, Arlene Dai, Ryan Wans, Mehdi Saligane", author_email="alibilal@umich.edu, Harsh, vijayshankar.renganathan@analog.com, Chetanya, spathen@umich.edu, arlendai@umich.edu, Ryan, mehdi@umich.edu", description="A human language to analog layout API with support for different technologies.",