OpenRAM/compiler/design.py

66 lines
2.2 KiB
Python

import hierarchy_layout
import hierarchy_spice
import globals
import calibre
import os
OPTS = globals.get_opts()
class design(hierarchy_spice.spice, hierarchy_layout.layout):
"""
Design Class for all modules to inherit the base features.
Class consisting of a set of modules and instances of these modules
"""
def __init__(self, name):
self.gds_file = OPTS.openram_tech + "gds_lib/" + name + ".gds"
self.sp_file = OPTS.openram_tech + "sp_lib/" + name + ".sp"
self.name = name
hierarchy_layout.layout.__init__(self, name)
hierarchy_spice.spice.__init__(self, name)
def DRC_LVS(self):
"""Checks both DRC and LVS for a module"""
if OPTS.check_lvsdrc:
tempspice = OPTS.openram_temp + "/temp.sp"
tempgds = OPTS.openram_temp + "/temp.gds"
self.sp_write(tempspice)
self.gds_write(tempgds)
assert calibre.run_drc(self.name, tempgds) == 0
assert calibre.run_lvs(self.name, tempgds, tempspice) == 0
os.remove(tempspice)
os.remove(tempgds)
def DRC(self):
"""Checks DRC for a module"""
if OPTS.check_lvsdrc:
tempgds = OPTS.openram_temp + "/temp.gds"
self.gds_write(tempgds)
assert calibre.run_drc(self.name, tempgds) == 0
os.remove(tempgds)
def LVS(self):
"""Checks LVS for a module"""
if OPTS.check_lvsdrc:
tempspice = OPTS.openram_temp + "/temp.sp"
tempgds = OPTS.openram_temp + "/temp.gds"
self.sp_write(tempspice)
self.gds_write(tempgds)
assert calibre.run_lvs(self.name, tempgds, tempspice) == 0
os.remove(tempspice)
os.remove(tempgds)
def __str__(self):
""" override print function output """
return "design: " + self.name
def __repr__(self):
""" override print function output """
text="( design: " + self.name + " pins=" + str(self.pins) + " " + str(self.width) + "x" + str(self.height) + " )\n"
for i in self.objs:
text+=str(i)+",\n"
for i in self.insts:
text+=str(i)+",\n"
return text