2019-04-26 21:21:50 +02:00
|
|
|
# See LICENSE for licensing information.
|
|
|
|
|
#
|
2021-01-22 20:23:28 +01:00
|
|
|
# Copyright (c) 2016-2021 Regents of the University of California and The Board
|
2019-06-14 17:43:41 +02:00
|
|
|
# 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
|
|
|
#
|
2018-10-12 23:37:51 +02:00
|
|
|
import debug
|
2018-10-12 18:44:36 +02:00
|
|
|
from drc_value import *
|
|
|
|
|
from drc_lut import *
|
|
|
|
|
|
2020-04-15 20:24:28 +02:00
|
|
|
|
2019-12-17 20:03:36 +01:00
|
|
|
class design_rules(dict):
|
2020-04-15 20:24:28 +02:00
|
|
|
"""
|
|
|
|
|
This is a class that implements the design rules structures.
|
2018-10-12 18:44:36 +02:00
|
|
|
"""
|
|
|
|
|
def __init__(self, name):
|
|
|
|
|
self.tech_name = name
|
|
|
|
|
self.rules = {}
|
|
|
|
|
|
|
|
|
|
def add(self, name, value):
|
|
|
|
|
self.rules[name] = value
|
|
|
|
|
|
|
|
|
|
def __call__(self, name, *args):
|
2018-10-12 23:37:51 +02:00
|
|
|
rule = self.rules[name]
|
|
|
|
|
if callable(rule):
|
2018-10-15 18:59:16 +02:00
|
|
|
return rule(*args)
|
2018-10-12 23:37:51 +02:00
|
|
|
else:
|
|
|
|
|
return rule
|
2018-10-12 18:44:36 +02:00
|
|
|
|
|
|
|
|
def __setitem__(self, b, c):
|
|
|
|
|
"""
|
|
|
|
|
For backward compatibility with existing rules.
|
|
|
|
|
"""
|
|
|
|
|
self.rules[b] = c
|
|
|
|
|
|
2021-07-27 23:31:22 +02:00
|
|
|
def __contains__(self, b):
|
|
|
|
|
"""
|
|
|
|
|
Allows checking existence of rules
|
|
|
|
|
"""
|
|
|
|
|
return b in self.rules
|
|
|
|
|
|
2018-10-12 18:44:36 +02:00
|
|
|
def __getitem__(self, b):
|
|
|
|
|
"""
|
|
|
|
|
For backward compatibility with existing rules.
|
|
|
|
|
"""
|
|
|
|
|
rule = self.rules[b]
|
2018-10-12 23:37:51 +02:00
|
|
|
if not callable(rule):
|
2018-10-12 18:44:36 +02:00
|
|
|
return rule
|
2018-10-12 23:37:51 +02:00
|
|
|
else:
|
|
|
|
|
debug.error("Must call complex DRC rule {} with arguments.".format(b),-1)
|
2019-05-28 02:38:59 +02:00
|
|
|
|
2019-12-17 20:03:36 +01:00
|
|
|
def keys(self):
|
|
|
|
|
return self.rules.keys()
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2019-12-12 02:56:55 +01:00
|
|
|
def add_layer(self, name, width, spacing, area=0):
|
|
|
|
|
# Minimum width
|
|
|
|
|
self.add("minwidth_{}".format(name), width)
|
|
|
|
|
# Minimum spacing (could be a table too)
|
|
|
|
|
self.add("{0}_to_{0}".format(name), spacing)
|
|
|
|
|
# Minimum area
|
|
|
|
|
self.add("minarea_{}".format(name), area)
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2019-12-12 02:56:55 +01:00
|
|
|
def add_enclosure(self, name, layer, enclosure, extension=None):
|
2019-12-17 20:03:36 +01:00
|
|
|
self.add("{0}_enclose_{1}".format(name, layer), enclosure)
|
2019-12-12 02:56:55 +01:00
|
|
|
# Reserved for asymmetric enclosures
|
|
|
|
|
if extension:
|
|
|
|
|
self.add("{0}_extend_{1}".format(name, layer), extension)
|
|
|
|
|
else:
|
|
|
|
|
self.add("{0}_extend_{1}".format(name, layer), enclosure)
|
2020-11-03 15:29:17 +01:00
|
|
|
|