From c7ff58cef3c64d10f5686701e4a511f4590675d1 Mon Sep 17 00:00:00 2001 From: Matt Guthaus Date: Thu, 30 Nov 2017 12:15:20 -0800 Subject: [PATCH] Round finger widths to grid. --- compiler/pinv.py | 10 +++++++--- compiler/utils.py | 21 +++++++++++---------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/compiler/pinv.py b/compiler/pinv.py index d776d70b..c4104900 100644 --- a/compiler/pinv.py +++ b/compiler/pinv.py @@ -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): """ diff --git a/compiler/utils.py b/compiler/utils.py index 0a469a7f..9c40ddac 100644 --- a/compiler/utils.py +++ b/compiler/utils.py @@ -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): """