2019-04-26 21:21:50 +02:00
|
|
|
# See LICENSE for licensing information.
|
|
|
|
|
#
|
2019-06-14 17:43:41 +02:00
|
|
|
# Copyright (c) 2016-2019 Regents of the University of California and The Board
|
|
|
|
|
# of Regents for the Oklahoma Agricultural and Mechanical College
|
|
|
|
|
# (acting for and on behalf of Oklahoma State University)
|
|
|
|
|
# All rights reserved.
|
2019-04-26 21:21:50 +02:00
|
|
|
#
|
2016-11-08 18:57:35 +01:00
|
|
|
import design
|
|
|
|
|
import debug
|
2019-11-26 22:34:39 +01:00
|
|
|
from tech import layer, drc, spice
|
2016-11-08 18:57:35 +01:00
|
|
|
from vector import vector
|
2019-01-17 01:56:06 +01:00
|
|
|
from sram_factory import factory
|
2016-11-08 18:57:35 +01:00
|
|
|
|
2019-10-06 19:30:16 +02:00
|
|
|
|
2016-11-08 18:57:35 +01:00
|
|
|
class ptx(design.design):
|
|
|
|
|
"""
|
2017-11-29 03:13:32 +01:00
|
|
|
This module generates gds and spice of a parametrically NMOS or
|
|
|
|
|
PMOS sized transistor. Pins are accessed as D, G, S, B. Width is
|
|
|
|
|
the transistor width. Mults is the number of transistors of the
|
|
|
|
|
given width. Total width is therefore mults*width. Options allow
|
|
|
|
|
you to connect the fingered gates and active for parallel devices.
|
|
|
|
|
|
2016-11-08 18:57:35 +01:00
|
|
|
"""
|
2019-10-06 19:30:16 +02:00
|
|
|
def __init__(self,
|
|
|
|
|
name="",
|
|
|
|
|
width=drc("minwidth_tx"),
|
|
|
|
|
mults=1,
|
|
|
|
|
tx_type="nmos",
|
|
|
|
|
connect_active=False,
|
|
|
|
|
connect_poly=False,
|
|
|
|
|
num_contacts=None):
|
2017-11-29 03:13:32 +01:00
|
|
|
# We need to keep unique names because outputting to GDSII
|
|
|
|
|
# will use the last record with a given name. I.e., you will
|
|
|
|
|
# over-write a design in GDS if one has and the other doesn't
|
|
|
|
|
# have poly connected, for example.
|
2019-07-03 22:17:12 +02:00
|
|
|
name = "{0}_m{1}_w{2:.3f}".format(tx_type, mults, width)
|
2017-09-30 01:22:13 +02:00
|
|
|
if connect_active:
|
|
|
|
|
name += "_a"
|
|
|
|
|
if connect_poly:
|
|
|
|
|
name += "_p"
|
|
|
|
|
if num_contacts:
|
|
|
|
|
name += "_c{}".format(num_contacts)
|
2017-11-29 03:13:32 +01:00
|
|
|
# replace periods with underscore for newer spice compatibility
|
2019-10-06 19:30:16 +02:00
|
|
|
name = name.replace('.', '_')
|
2019-04-26 20:57:29 +02:00
|
|
|
debug.info(3, "creating ptx {0}".format(name))
|
2019-04-26 21:15:05 +02:00
|
|
|
design.design.__init__(self, name)
|
2016-11-08 18:57:35 +01:00
|
|
|
|
|
|
|
|
self.tx_type = tx_type
|
|
|
|
|
self.mults = mults
|
2017-11-29 03:13:32 +01:00
|
|
|
self.tx_width = width
|
2017-09-30 01:22:13 +02:00
|
|
|
self.connect_active = connect_active
|
|
|
|
|
self.connect_poly = connect_poly
|
|
|
|
|
self.num_contacts = num_contacts
|
2016-11-08 18:57:35 +01:00
|
|
|
|
2019-04-26 20:57:29 +02:00
|
|
|
# Do NOT create the netlist and layout (not a pgate)
|
2019-04-26 21:15:05 +02:00
|
|
|
# Since it has variable height, it is not a pgate.
|
2018-08-27 23:18:32 +02:00
|
|
|
self.create_netlist()
|
2018-09-12 10:53:41 +02:00
|
|
|
# We must always create ptx layout for pbitcell
|
|
|
|
|
# some transistor sizes in other netlist depend on pbitcell
|
|
|
|
|
self.create_layout()
|
2019-12-06 00:14:25 +01:00
|
|
|
|
|
|
|
|
ll = self.find_lowest_coords()
|
|
|
|
|
ur = self.find_highest_coords()
|
|
|
|
|
self.add_boundary(ll, ur)
|
|
|
|
|
|
|
|
|
|
# (0,0) will be the corner ofthe active area (not the larger well)
|
|
|
|
|
self.translate_all(self.active_offset)
|
|
|
|
|
|
2016-11-08 18:57:35 +01:00
|
|
|
def create_layout(self):
|
2017-11-29 21:31:00 +01:00
|
|
|
"""Calls all functions related to the generation of the layout"""
|
2016-11-08 18:57:35 +01:00
|
|
|
self.setup_layout_constants()
|
|
|
|
|
self.add_active()
|
2019-10-06 19:30:16 +02:00
|
|
|
self.add_well_implant()
|
2016-11-08 18:57:35 +01:00
|
|
|
self.add_poly()
|
|
|
|
|
self.add_active_contacts()
|
2018-08-28 01:42:48 +02:00
|
|
|
|
|
|
|
|
# for run-time, we won't check every transitor DRC independently
|
|
|
|
|
# but this may be uncommented for debug purposes
|
2019-10-06 19:30:16 +02:00
|
|
|
# self.DRC()
|
2017-09-30 01:22:13 +02:00
|
|
|
|
2018-08-27 23:18:32 +02:00
|
|
|
def create_netlist(self):
|
2019-05-07 09:52:27 +02:00
|
|
|
pin_list = ["D", "G", "S", "B"]
|
2019-10-06 19:30:16 +02:00
|
|
|
if self.tx_type == "nmos":
|
2019-05-07 09:52:27 +02:00
|
|
|
body_dir = 'GROUND'
|
2019-10-06 19:30:16 +02:00
|
|
|
else:
|
|
|
|
|
# Assumed that the check for either pmos or nmos is done elsewhere.
|
2019-05-07 09:52:27 +02:00
|
|
|
body_dir = 'POWER'
|
|
|
|
|
dir_list = ['INOUT', 'INPUT', 'INOUT', body_dir]
|
|
|
|
|
self.add_pin_list(pin_list, dir_list)
|
2017-11-29 21:31:00 +01:00
|
|
|
|
2018-01-30 00:25:00 +01:00
|
|
|
# self.spice.append("\n.SUBCKT {0} {1}".format(self.name,
|
|
|
|
|
# " ".join(self.pins)))
|
2019-10-06 19:30:16 +02:00
|
|
|
# Just make a guess since these will actually
|
|
|
|
|
# be decided in the layout later.
|
|
|
|
|
area_sd = 2.5 * drc("minwidth_poly") * self.tx_width
|
|
|
|
|
perimeter_sd = 2 * drc("minwidth_poly") + 2 * self.tx_width
|
|
|
|
|
main_str = "M{{0}} {{1}} {0} m={1} w={2}u l={3}u ".format(spice[self.tx_type],
|
|
|
|
|
self.mults,
|
|
|
|
|
self.tx_width,
|
|
|
|
|
drc("minwidth_poly"))
|
|
|
|
|
area_str = "pd={0:.2f}u ps={0:.2f}u as={1:.2f}p ad={1:.2f}p".format(perimeter_sd,
|
|
|
|
|
area_sd)
|
|
|
|
|
self.spice_device= main_str + area_str
|
2018-01-30 00:25:00 +01:00
|
|
|
self.spice.append("\n* ptx " + self.spice_device)
|
|
|
|
|
# self.spice.append(".ENDS {0}".format(self.name))
|
2016-11-08 18:57:35 +01:00
|
|
|
|
|
|
|
|
def setup_layout_constants(self):
|
2017-11-29 03:13:32 +01:00
|
|
|
"""
|
|
|
|
|
Pre-compute some handy layout parameters.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
if self.num_contacts==None:
|
|
|
|
|
self.num_contacts=self.calculate_num_contacts()
|
2017-11-29 21:31:00 +01:00
|
|
|
|
|
|
|
|
# Determine layer types needed
|
|
|
|
|
if self.tx_type == "nmos":
|
|
|
|
|
self.implant_type = "n"
|
|
|
|
|
self.well_type = "p"
|
|
|
|
|
elif self.tx_type == "pmos":
|
|
|
|
|
self.implant_type = "p"
|
|
|
|
|
self.well_type = "n"
|
|
|
|
|
else:
|
|
|
|
|
self.error("Invalid transitor type.",-1)
|
|
|
|
|
|
|
|
|
|
|
2017-11-29 03:13:32 +01:00
|
|
|
# This is not actually instantiated but used for calculations
|
2019-01-17 01:56:06 +01:00
|
|
|
self.active_contact = factory.create(module_type="contact",
|
|
|
|
|
layer_stack=("active", "contact", "metal1"),
|
|
|
|
|
dimensions=(1, self.num_contacts))
|
2017-11-29 03:13:32 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
# The contacted poly pitch (or uncontacted in an odd technology)
|
2019-12-05 01:12:53 +01:00
|
|
|
self.poly_pitch = max(2 * self.active_contact_to_gate + self.contact_width + self.poly_width,
|
2018-01-26 21:39:00 +01:00
|
|
|
self.poly_space)
|
2017-11-29 03:13:32 +01:00
|
|
|
|
|
|
|
|
# The contacted poly pitch (or uncontacted in an odd technology)
|
2019-12-05 01:12:53 +01:00
|
|
|
self.contact_pitch = 2 * self.active_contact_to_gate + self.contact_width + self.poly_width
|
2017-11-29 03:13:32 +01:00
|
|
|
|
|
|
|
|
# The enclosure of an active contact. Not sure about second term.
|
2019-12-05 01:12:53 +01:00
|
|
|
active_enclose_contact = max(drc("active_enclosure_active_contact"),
|
2019-10-06 19:30:16 +02:00
|
|
|
(self.active_width - self.contact_width) / 2)
|
|
|
|
|
|
2017-11-29 03:13:32 +01:00
|
|
|
# This is the distance from the edge of poly to the contacted end of active
|
2019-12-05 01:12:53 +01:00
|
|
|
self.end_to_poly = active_enclose_contact + self.contact_width + self.active_contact_to_gate
|
2017-11-29 03:13:32 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
# Active width is determined by enclosure on both ends and contacted pitch,
|
|
|
|
|
# at least one poly and n-1 poly pitches
|
2019-10-06 19:30:16 +02:00
|
|
|
self.active_width = 2 * self.end_to_poly + self.poly_width + (self.mults - 1) * self.poly_pitch
|
2017-11-29 03:13:32 +01:00
|
|
|
|
|
|
|
|
# Active height is just the transistor width
|
|
|
|
|
self.active_height = self.tx_width
|
|
|
|
|
|
|
|
|
|
# Poly height must include poly extension over active
|
2019-10-06 19:30:16 +02:00
|
|
|
self.poly_height = self.tx_width + 2 * self.poly_extend_active
|
2017-11-29 03:13:32 +01:00
|
|
|
|
2018-01-26 21:39:00 +01:00
|
|
|
# The active offset is due to the well extension
|
2019-10-06 19:30:16 +02:00
|
|
|
self.active_offset = vector([self.well_enclose_active] * 2)
|
2018-01-26 21:39:00 +01:00
|
|
|
|
2017-11-29 03:13:32 +01:00
|
|
|
# Well enclosure of active, ensure minwidth as well
|
2019-11-26 22:22:52 +01:00
|
|
|
well_name = "{}well".format(self.well_type)
|
2019-11-26 22:24:19 +01:00
|
|
|
if layer[well_name]:
|
2019-10-06 19:30:16 +02:00
|
|
|
self.cell_well_width = max(self.active_width + 2 * self.well_enclose_active,
|
|
|
|
|
self.well_width)
|
|
|
|
|
self.cell_well_height = max(self.tx_width + 2 * self.well_enclose_active,
|
|
|
|
|
self.well_width)
|
2018-01-26 21:39:00 +01:00
|
|
|
# We are going to shift the 0,0, so include that in the width and height
|
|
|
|
|
self.height = self.cell_well_height - self.active_offset.y
|
|
|
|
|
self.width = self.cell_well_width - self.active_offset.x
|
2017-11-29 21:31:00 +01:00
|
|
|
else:
|
|
|
|
|
# If no well, use the boundary of the active and poly
|
|
|
|
|
self.height = self.poly_height
|
|
|
|
|
self.width = self.active_width
|
|
|
|
|
|
2017-11-29 03:13:32 +01:00
|
|
|
# The active offset is due to the well extension
|
2019-10-06 19:30:16 +02:00
|
|
|
self.active_offset = vector([self.well_enclose_active] * 2)
|
2017-09-30 01:22:13 +02:00
|
|
|
|
2017-11-29 03:13:32 +01:00
|
|
|
# This is the center of the first active contact offset (centered vertically)
|
2019-10-06 19:30:16 +02:00
|
|
|
self.contact_offset = self.active_offset + vector(active_enclose_contact + 0.5 * self.contact_width,
|
|
|
|
|
0.5 * self.active_height)
|
2017-11-29 03:13:32 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
# Min area results are just flagged for now.
|
2019-10-06 19:30:16 +02:00
|
|
|
debug.check(self.active_width * self.active_height >= drc("minarea_active"),
|
|
|
|
|
"Minimum active area violated.")
|
|
|
|
|
# We do not want to increase the poly dimensions to fix
|
|
|
|
|
# an area problem as it would cause an LVS issue.
|
|
|
|
|
debug.check(self.poly_width * self.poly_height >= drc("minarea_poly"),
|
|
|
|
|
"Minimum poly area violated.")
|
2017-11-29 03:13:32 +01:00
|
|
|
|
|
|
|
|
def connect_fingered_poly(self, poly_positions):
|
|
|
|
|
"""
|
|
|
|
|
Connect together the poly gates and create the single gate pin.
|
|
|
|
|
The poly positions are the center of the poly gates
|
|
|
|
|
and we will add a single horizontal connection.
|
|
|
|
|
"""
|
|
|
|
|
# Nothing to do if there's one poly gate
|
2017-11-30 20:56:40 +01:00
|
|
|
if len(poly_positions)<2:
|
2017-11-29 03:13:32 +01:00
|
|
|
return
|
|
|
|
|
|
|
|
|
|
# The width of the poly is from the left-most to right-most poly gate
|
|
|
|
|
poly_width = poly_positions[-1].x - poly_positions[0].x + self.poly_width
|
2017-12-01 17:31:16 +01:00
|
|
|
if self.tx_type == "pmos":
|
2019-10-06 19:30:16 +02:00
|
|
|
# This can be limited by poly to active spacing
|
|
|
|
|
# or the poly extension
|
|
|
|
|
distance_below_active = self.poly_width + max(self.poly_to_active,
|
|
|
|
|
0.5 * self.poly_height)
|
|
|
|
|
poly_offset = poly_positions[0] - vector(0.5 * self.poly_width,
|
|
|
|
|
distance_below_active)
|
2017-12-01 17:31:16 +01:00
|
|
|
else:
|
2019-10-06 19:30:16 +02:00
|
|
|
# This can be limited by poly to active spacing
|
|
|
|
|
# or the poly extension
|
|
|
|
|
distance_above_active = max(self.poly_to_active,
|
|
|
|
|
0.5 * self.poly_height)
|
|
|
|
|
poly_offset = poly_positions[0] + vector(-0.5 * self.poly_width,
|
|
|
|
|
distance_above_active)
|
2017-11-29 03:13:32 +01:00
|
|
|
# Remove the old pin and add the new one
|
|
|
|
|
self.remove_layout_pin("G") # only keep the main pin
|
|
|
|
|
self.add_layout_pin(text="G",
|
|
|
|
|
layer="poly",
|
|
|
|
|
offset=poly_offset,
|
|
|
|
|
width=poly_width,
|
2018-10-12 23:37:51 +02:00
|
|
|
height=drc("minwidth_poly"))
|
2017-10-06 02:35:05 +02:00
|
|
|
|
2016-11-08 18:57:35 +01:00
|
|
|
|
2017-11-29 03:13:32 +01:00
|
|
|
def connect_fingered_active(self, drain_positions, source_positions):
|
|
|
|
|
"""
|
|
|
|
|
Connect each contact up/down to a source or drain pin
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
# This is the distance that we must route up or down from the center
|
|
|
|
|
# of the contacts to avoid DRC violations to the other contacts
|
2019-10-06 19:30:16 +02:00
|
|
|
pin_offset = vector(0, 0.5 * self.active_contact.second_layer_height \
|
|
|
|
|
+ self.m1_space + 0.5 * self.m1_width)
|
2018-01-26 21:39:00 +01:00
|
|
|
# This is the width of a m1 extend the ends of the pin
|
|
|
|
|
end_offset = vector(self.m1_width/2,0)
|
2017-11-30 20:56:40 +01:00
|
|
|
|
2019-10-06 19:30:16 +02:00
|
|
|
# drains always go to the MIDDLE of the cell,
|
|
|
|
|
# so top of NMOS, bottom of PMOS
|
2017-12-12 23:53:19 +01:00
|
|
|
# so reverse the directions for NMOS compared to PMOS.
|
2017-12-01 17:31:16 +01:00
|
|
|
if self.tx_type == "pmos":
|
|
|
|
|
drain_dir = -1
|
|
|
|
|
source_dir = 1
|
2017-12-12 23:53:19 +01:00
|
|
|
else:
|
|
|
|
|
drain_dir = 1
|
|
|
|
|
source_dir = -1
|
2017-12-01 17:31:16 +01:00
|
|
|
|
2019-10-06 19:30:16 +02:00
|
|
|
if len(source_positions) > 1:
|
2017-12-12 23:53:19 +01:00
|
|
|
source_offset = pin_offset.scale(source_dir,source_dir)
|
2017-10-06 02:35:05 +02:00
|
|
|
self.remove_layout_pin("S") # remove the individual connections
|
2017-11-29 03:13:32 +01:00
|
|
|
# Add each vertical segment
|
|
|
|
|
for a in source_positions:
|
2019-10-06 19:30:16 +02:00
|
|
|
self.add_path(("metal1"),
|
|
|
|
|
[a, a + pin_offset.scale(source_dir,
|
|
|
|
|
source_dir)])
|
2017-11-29 03:13:32 +01:00
|
|
|
# Add a single horizontal pin
|
2018-03-21 21:20:48 +01:00
|
|
|
self.add_layout_pin_segment_center(text="S",
|
2017-11-29 03:13:32 +01:00
|
|
|
layer="metal1",
|
2019-10-06 19:30:16 +02:00
|
|
|
start=source_positions[0] + source_offset - end_offset,
|
|
|
|
|
end=source_positions[-1] + source_offset + end_offset)
|
2017-11-29 03:13:32 +01:00
|
|
|
|
2017-12-12 23:53:19 +01:00
|
|
|
if len(drain_positions)>1:
|
|
|
|
|
drain_offset = pin_offset.scale(drain_dir,drain_dir)
|
2017-10-06 02:35:05 +02:00
|
|
|
self.remove_layout_pin("D") # remove the individual connections
|
2017-11-29 03:13:32 +01:00
|
|
|
# Add each vertical segment
|
|
|
|
|
for a in drain_positions:
|
2017-12-12 23:53:19 +01:00
|
|
|
self.add_path(("metal1"), [a,a+drain_offset])
|
2017-11-29 03:13:32 +01:00
|
|
|
# Add a single horizontal pin
|
2018-03-21 21:20:48 +01:00
|
|
|
self.add_layout_pin_segment_center(text="D",
|
2017-11-29 03:13:32 +01:00
|
|
|
layer="metal1",
|
2019-10-06 19:30:16 +02:00
|
|
|
start=drain_positions[0] + drain_offset - end_offset,
|
|
|
|
|
end=drain_positions[-1] + drain_offset + end_offset)
|
2017-09-30 01:22:13 +02:00
|
|
|
|
2016-11-08 18:57:35 +01:00
|
|
|
def add_poly(self):
|
2017-11-29 03:13:32 +01:00
|
|
|
"""
|
|
|
|
|
Add the poly gates(s) and (optionally) connect them.
|
|
|
|
|
"""
|
|
|
|
|
# poly is one contacted spacing from the end and down an extension
|
2019-10-06 19:30:16 +02:00
|
|
|
poly_offset = self.active_offset \
|
|
|
|
|
+ vector(self.poly_width, self.poly_height).scale(0.5, 0.5) \
|
2017-12-01 00:58:16 +01:00
|
|
|
+ vector(self.end_to_poly, -self.poly_extend_active)
|
2017-11-29 03:13:32 +01:00
|
|
|
|
|
|
|
|
# poly_positions are the bottom center of the poly gates
|
|
|
|
|
poly_positions = []
|
2017-12-12 23:53:19 +01:00
|
|
|
|
2019-10-06 19:30:16 +02:00
|
|
|
# It is important that these are from left to right,
|
|
|
|
|
# so that the pins are in the right
|
2017-12-12 23:53:19 +01:00
|
|
|
# order for the accessors
|
2016-11-08 18:57:35 +01:00
|
|
|
for i in range(0, self.mults):
|
2019-10-06 19:30:16 +02:00
|
|
|
# Add this duplicate rectangle in case we remove
|
|
|
|
|
# the pin when joining fingers
|
2017-11-30 21:01:04 +01:00
|
|
|
self.add_rect_center(layer="poly",
|
2017-11-30 20:56:40 +01:00
|
|
|
offset=poly_offset,
|
|
|
|
|
height=self.poly_height,
|
|
|
|
|
width=self.poly_width)
|
2018-03-21 21:20:48 +01:00
|
|
|
self.add_layout_pin_rect_center(text="G",
|
2017-11-30 20:56:40 +01:00
|
|
|
layer="poly",
|
|
|
|
|
offset=poly_offset,
|
|
|
|
|
height=self.poly_height,
|
|
|
|
|
width=self.poly_width)
|
2017-11-29 03:13:32 +01:00
|
|
|
poly_positions.append(poly_offset)
|
|
|
|
|
poly_offset = poly_offset + vector(self.poly_pitch,0)
|
2016-11-08 18:57:35 +01:00
|
|
|
|
2017-11-29 03:13:32 +01:00
|
|
|
if self.connect_poly:
|
|
|
|
|
self.connect_fingered_poly(poly_positions)
|
|
|
|
|
|
2016-11-08 18:57:35 +01:00
|
|
|
def add_active(self):
|
2019-10-06 19:30:16 +02:00
|
|
|
"""
|
|
|
|
|
Adding the diffusion (active region = diffusion region)
|
2017-11-29 03:13:32 +01:00
|
|
|
"""
|
2016-11-08 18:57:35 +01:00
|
|
|
self.add_rect(layer="active",
|
2017-11-29 03:13:32 +01:00
|
|
|
offset=self.active_offset,
|
2016-11-08 18:57:35 +01:00
|
|
|
width=self.active_width,
|
|
|
|
|
height=self.active_height)
|
2018-01-08 21:27:50 +01:00
|
|
|
# If the implant must enclose the active, shift offset
|
|
|
|
|
# and increase width/height
|
2018-10-12 23:37:51 +02:00
|
|
|
enclose_width = drc("implant_enclosure_active")
|
2019-10-06 19:30:16 +02:00
|
|
|
enclose_offset = [enclose_width] * 2
|
2018-01-08 21:27:50 +01:00
|
|
|
self.add_rect(layer="{}implant".format(self.implant_type),
|
|
|
|
|
offset=self.active_offset - enclose_offset,
|
2019-10-06 19:30:16 +02:00
|
|
|
width=self.active_width + 2 * enclose_width,
|
|
|
|
|
height=self.active_height + 2 * enclose_width)
|
2016-11-08 18:57:35 +01:00
|
|
|
|
2017-11-29 03:13:32 +01:00
|
|
|
def add_well_implant(self):
|
|
|
|
|
"""
|
|
|
|
|
Add an (optional) well and implant for the type of transistor.
|
|
|
|
|
"""
|
2019-11-26 22:34:39 +01:00
|
|
|
well_name = "{}well".format(self.well_type)
|
|
|
|
|
if layer[well_name]:
|
|
|
|
|
self.add_rect(layer=well_name,
|
2017-11-29 03:13:32 +01:00
|
|
|
offset=(0,0),
|
2018-01-26 21:39:00 +01:00
|
|
|
width=self.cell_well_width,
|
|
|
|
|
height=self.cell_well_height)
|
2019-11-26 22:34:39 +01:00
|
|
|
if layer["vtg"]:
|
2016-11-08 18:57:35 +01:00
|
|
|
self.add_rect(layer="vtg",
|
2017-11-29 03:13:32 +01:00
|
|
|
offset=(0,0),
|
2018-01-26 21:39:00 +01:00
|
|
|
width=self.cell_well_width,
|
|
|
|
|
height=self.cell_well_height)
|
2017-11-29 03:13:32 +01:00
|
|
|
|
2016-11-08 18:57:35 +01:00
|
|
|
|
2017-09-30 01:22:13 +02:00
|
|
|
def calculate_num_contacts(self):
|
2017-11-29 03:13:32 +01:00
|
|
|
"""
|
|
|
|
|
Calculates the possible number of source/drain contacts in a finger.
|
|
|
|
|
For now, it is hard set as 1.
|
|
|
|
|
"""
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_contact_positions(self):
|
|
|
|
|
"""
|
|
|
|
|
Create a list of the centers of drain and source contact positions.
|
|
|
|
|
"""
|
|
|
|
|
# The first one will always be a source
|
|
|
|
|
source_positions = [self.contact_offset]
|
|
|
|
|
drain_positions = []
|
2019-10-06 19:30:16 +02:00
|
|
|
# It is important that these are from left to right,
|
|
|
|
|
# so that the pins are in the right
|
2017-12-12 23:53:19 +01:00
|
|
|
# order for the accessors.
|
2017-11-29 18:44:40 +01:00
|
|
|
for i in range(self.mults):
|
2017-11-29 03:13:32 +01:00
|
|
|
if i%2:
|
|
|
|
|
# It's a source... so offset from previous drain.
|
2019-10-06 19:30:16 +02:00
|
|
|
source_positions.append(drain_positions[-1] + vector(self.contact_pitch, 0))
|
2017-11-29 03:13:32 +01:00
|
|
|
else:
|
|
|
|
|
# It's a drain... so offset from previous source.
|
2019-10-06 19:30:16 +02:00
|
|
|
drain_positions.append(source_positions[-1] + vector(self.contact_pitch, 0))
|
2016-11-08 18:57:35 +01:00
|
|
|
|
2017-11-29 03:13:32 +01:00
|
|
|
return [source_positions,drain_positions]
|
|
|
|
|
|
2016-11-08 18:57:35 +01:00
|
|
|
def add_active_contacts(self):
|
2017-11-29 03:13:32 +01:00
|
|
|
"""
|
|
|
|
|
Add the active contacts to the transistor.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
[source_positions,drain_positions] = self.get_contact_positions()
|
|
|
|
|
|
|
|
|
|
for pos in source_positions:
|
2019-04-01 23:23:47 +02:00
|
|
|
contact=self.add_via_center(layers=("active", "contact", "metal1"),
|
|
|
|
|
offset=pos,
|
|
|
|
|
size=(1, self.num_contacts),
|
|
|
|
|
directions=("H","V"),
|
|
|
|
|
implant_type=self.implant_type,
|
|
|
|
|
well_type=self.well_type)
|
2018-03-21 21:20:48 +01:00
|
|
|
self.add_layout_pin_rect_center(text="S",
|
2017-11-30 20:56:40 +01:00
|
|
|
layer="metal1",
|
|
|
|
|
offset=pos,
|
2018-01-26 21:39:00 +01:00
|
|
|
width=contact.mod.second_layer_width,
|
|
|
|
|
height=contact.mod.second_layer_height)
|
2017-11-29 03:13:32 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
for pos in drain_positions:
|
2019-04-01 23:23:47 +02:00
|
|
|
contact=self.add_via_center(layers=("active", "contact", "metal1"),
|
|
|
|
|
offset=pos,
|
|
|
|
|
size=(1, self.num_contacts),
|
|
|
|
|
directions=("H","V"),
|
|
|
|
|
implant_type=self.implant_type,
|
|
|
|
|
well_type=self.well_type)
|
2018-03-21 21:20:48 +01:00
|
|
|
self.add_layout_pin_rect_center(text="D",
|
2017-11-30 20:56:40 +01:00
|
|
|
layer="metal1",
|
|
|
|
|
offset=pos,
|
2018-01-26 21:39:00 +01:00
|
|
|
width=contact.mod.second_layer_width,
|
|
|
|
|
height=contact.mod.second_layer_height)
|
2017-11-29 03:13:32 +01:00
|
|
|
|
2017-10-07 00:30:15 +02:00
|
|
|
if self.connect_active:
|
2017-11-29 03:13:32 +01:00
|
|
|
self.connect_fingered_active(drain_positions, source_positions)
|
2016-11-08 18:57:35 +01:00
|
|
|
|
2018-11-09 05:47:34 +01:00
|
|
|
def get_cin(self):
|
|
|
|
|
"""Returns the relative gate cin of the tx"""
|
2019-10-06 19:30:16 +02:00
|
|
|
return self.tx_width / drc("minwidth_tx")
|
2019-04-19 10:27:06 +02:00
|
|
|
|
2019-10-06 19:30:16 +02:00
|
|
|
def build_graph(self, graph, inst_name, port_nets):
|
|
|
|
|
"""
|
|
|
|
|
Adds edges based on inputs/outputs.
|
|
|
|
|
Overrides base class function.
|
|
|
|
|
"""
|
|
|
|
|
self.add_graph_edges(graph, port_nets)
|
|
|
|
|
|