Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update skywater130 pcells implementation with the its latest version #67

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 3 additions & 0 deletions sky130/cells/klayout/pymacros/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Skywater130_PCells

Contains klayout pcells generator.
87 changes: 87 additions & 0 deletions sky130/cells/klayout/pymacros/cells/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# Copyright 2022 Skywater 130nm pdk development
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

# ============================================================================
# ---------------- Pcells Generators for Klayout of sky ----------------
# ============================================================================

import pya

from cells.vias import vias_gen

from .bjt import npn_bjt, pnp_bjt
from .cap import cap_var, mim_cap
from .diode import n_diode, p_diode, photo_diode
from .fet import nfet, pfet
from .gr import guard_ring_gen
from .res_diff_klayout_panel import res_diff
from .res_metal_klayout_panel import res_metal
from .res_poly_klayout_panel import res_poly
from .rf import rf_bjt, rf_coils, rf_mosfet
from .vpp import cap_vpp


# It's a Python class that inherits from the pya.Library class
class sky130(pya.Library):
"""
The library where we will put the PCell into
"""

def __init__(self):
# Set the description
self.description = "sky130 Pcells"

# Create the PCell declarations
# MOS DEVICES
self.layout().register_pcell("pfet", pfet())
self.layout().register_pcell("nfet", nfet())

# BJT
self.layout().register_pcell(
"npn_bjt", npn_bjt()
) # npn_05v5_1p00x1p00, npn_05v5_1p00x2p00 , npn_11v0_1p00x1p00
self.layout().register_pcell(
"pnp_bjt", pnp_bjt()
) # pnp_05v5_0p68x0p68 , pnp_05v5_3p40x3p40

# CAP Devices
self.layout().register_pcell("cap_vpp", cap_vpp()) # VPP devices
self.layout().register_pcell("cap_var", cap_var()) # varactor devices
self.layout().register_pcell("mim_cap", mim_cap()) # mim cap devices

# DIODE DEVICES

self.layout().register_pcell("photodiode", photo_diode())
self.layout().register_pcell("n_diode", n_diode())
self.layout().register_pcell("p_diode", p_diode())

# RF Devices
self.layout().register_pcell("rf_mosfet", rf_mosfet()) # rf mosfets
self.layout().register_pcell("rf_bjt", rf_bjt()) # rf bjt
self.layout().register_pcell("rf_coils", rf_coils()) # rf coils

# vias
self.layout().register_pcell("vias_gen", vias_gen()) # vias generator
self.layout().register_pcell(
"guard_ring_gen", guard_ring_gen()
) # vias generator

# Resistor
self.layout().register_pcell("res_diff", res_diff()) # Res diff generator
self.layout().register_pcell("res_poly", res_poly()) # Res poly generator
self.layout().register_pcell("res_metal", res_metal()) # Res metal generator

# Register us with the name "skywater130".
self.register("skywater130")
112 changes: 112 additions & 0 deletions sky130/cells/klayout/pymacros/cells/bjt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# Copyright 2022 Skywater 130nm pdk development
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

########################################################################################################################
# BJT Generator for skywater130
########################################################################################################################


import pya

from .draw_bjt import draw_npn, draw_pnp
from .globals import BJT_NPN_DEV, BJT_PNP_DEV


class npn_bjt(pya.PCellDeclarationHelper):
"""
NPN BJT Generator for Skywater130
"""

def __init__(self):
# Important: initialize the super class
super().__init__()
self.Type_handle = self.param("type", self.TypeList, "type")

for i in BJT_NPN_DEV:
self.Type_handle.add_choice(i, i)

self.param(
"Model",
self.TypeString,
"Model",
default="sky130_fd_pr__npn",
readonly=True,
)

def display_text_impl(self):
# Provide a descriptive text for the cell
return str(self.type)

def produce_impl(self):
# This is the main part of the implementation: create the layout

self.percision = 1 / self.layout.dbu
# self.cell.flatten(1)
npn_instance = draw_npn(layout=self.layout, device_name=self.type)
write_cells = pya.CellInstArray(
npn_instance.cell_index(),
pya.Trans(pya.Point(0, 0)),
pya.Vector(0, 0),
pya.Vector(0, 0),
1,
1,
)
self.cell.flatten(1)
self.cell.insert(write_cells)
self.layout.cleanup()


class pnp_bjt(pya.PCellDeclarationHelper):
"""
PNP BJT Generator for Skywater130
"""

def __init__(self):
# Important: initialize the super class
super().__init__()
self.Type_handle = self.param("Type", self.TypeList, "Type")

for i in BJT_PNP_DEV:
self.Type_handle.add_choice(i, i)

self.param(
"Model",
self.TypeString,
"Model",
default="sky130_fd_pr__pnp",
readonly=True,
)

def display_text_impl(self):
# Provide a descriptive text for the cell
return str(self.Type)

def produce_impl(self):
# This is the main part of the implementation: create the layout

self.percision = 1 / self.layout.dbu
pnp_instance = draw_pnp(layout=self.layout, device_name=self.Type)
write_cells = pya.CellInstArray(
pnp_instance.cell_index(),
pya.Trans(pya.Point(0, 0)),
pya.Vector(0, 0),
pya.Vector(0, 0),
1,
1,
)
self.cell.flatten(1)
self.cell.insert(write_cells)

self.layout.cleanup()
Loading
Loading