Round finger widths to grid.

This commit is contained in:
Matt Guthaus 2017-11-30 12:15:20 -08:00
parent 107cad15a1
commit c7ff58cef3
2 changed files with 18 additions and 13 deletions

View File

@ -6,6 +6,7 @@ from ptx import ptx
from vector import vector
from math import ceil
from globals import OPTS
from utils import round_to_grid
class pinv(design.design):
"""
@ -111,10 +112,13 @@ class pinv(design.design):
# Recompute each mult width and check it isn't too small
# This could happen if the height is narrow and the size is small
# User should pick a bigger size to fix it...
self.nmos_width = self.nmos_width / self.tx_mults
# We also need to round the width to the grid or we will end up with LVS property
# mismatch errors when fingers are not a grid length and get rounded in the offset geometry.
self.nmos_width = round_to_grid(self.nmos_width / self.tx_mults)
debug.check(self.nmos_width>=drc["minwidth_tx"],"Cannot finger NMOS transistors to fit cell height.")
self.pmos_width = self.pmos_width / self.tx_mults
debug.check(self.pmos_width>=drc["minwidth_tx"],"Cannot finger PMOS transistors to fit cell height.")
self.pmos_width = round_to_grid(self.pmos_width / self.tx_mults)
debug.check(self.pmos_width>=drc["minwidth_tx"],"Cannot finger PMOS transistors to fit cell height.")
def setup_layout_constants(self):
"""

View File

@ -7,20 +7,21 @@ from pin_layout import pin_layout
OPTS = globals.OPTS
def round_to_grid(number):
"""
Rounds an arbitrary number to the grid.
"""
grid = tech.drc["grid"]
# this gets the nearest integer value
number_grid = int(round(round((number / grid), 2), 0))
number_off = number_grid * grid
return number_off
def snap_to_grid(offset):
"""
Changes the coodrinate to match the grid settings
"""
grid = tech.drc["grid"]
x = offset[0]
y = offset[1]
# this gets the nearest integer value
xgrid = int(round(round((x / grid), 2), 0))
ygrid = int(round(round((y / grid), 2), 0))
xoff = xgrid * grid
yoff = ygrid * grid
out_offset = [xoff, yoff]
return out_offset
return [round_to_grid(offset[0]),round_to_grid(offset[1])]
def pin_center(boundary):
"""