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 *
|
|
|
|
|
|
|
|
|
|
class design_rules():
|
|
|
|
|
"""
|
|
|
|
|
This is a class that implements the design rules structures.
|
|
|
|
|
"""
|
|
|
|
|
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):
|
|
|
|
|
return rule(args)
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
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)
|
2018-10-12 18:44:36 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|