OpenRAM/compiler/tests/01_library_test.py

85 lines
2.7 KiB
Python
Raw Normal View History

#!/usr/bin/env python3
# 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.
#
2016-11-08 18:57:35 +01:00
import unittest
from testutils import *
import sys, os,re
2016-11-08 18:57:35 +01:00
import globals
from globals import OPTS
2016-11-08 18:57:35 +01:00
import debug
class library_lvs_test(openram_test):
2016-11-08 18:57:35 +01:00
def runTest(self):
config_file = "{}/tests/configs/config".format(os.getenv("OPENRAM_HOME"))
globals.init_openram(config_file)
import verify
2016-11-08 18:57:35 +01:00
(gds_dir, sp_dir, allnames) = setup_files()
drc_errors = 0
2016-11-08 18:57:35 +01:00
lvs_errors = 0
debug.info(1, "Performing LVS on: " + ", ".join(allnames))
for f in allnames:
gds_name = "{0}/{1}.gds".format(gds_dir, f)
sp_name = "{0}/{1}.sp".format(sp_dir, f)
name = re.sub('\.gds$', '', f)
2016-11-08 18:57:35 +01:00
if not os.path.isfile(gds_name):
lvs_errors += 1
debug.error("Missing GDS file {}".format(gds_name))
if not os.path.isfile(sp_name):
lvs_errors += 1
debug.error("Missing SPICE file {}".format(sp_name))
drc_errors += verify.run_drc(name, gds_name, sp_name)
lvs_errors += verify.run_lvs(f, gds_name, sp_name)
2016-11-08 18:57:35 +01:00
# fail if the error count is not zero
self.assertEqual(drc_errors + lvs_errors, 0)
globals.end_openram()
2016-11-08 18:57:35 +01:00
2016-11-08 18:57:35 +01:00
def setup_files():
gds_dir = OPTS.openram_tech + "/gds_lib"
sp_dir = OPTS.openram_tech + "/lvs_lib"
if not os.path.exists(sp_dir):
sp_dir = OPTS.openram_tech + "/sp_lib"
2016-11-08 18:57:35 +01:00
files = os.listdir(gds_dir)
nametest = re.compile("\.gds$", re.IGNORECASE)
gds_files = list(filter(nametest.search, files))
2016-11-08 18:57:35 +01:00
files = os.listdir(sp_dir)
nametest = re.compile("\.sp$", re.IGNORECASE)
sp_files = filter(nametest.search, files)
# make a list of all the gds and spice files
tempnames = gds_files
tempnames.extend(sp_files)
# remove the .gds and .sp suffixes
for i in range(len(tempnames)):
tempnames[i] = re.sub('\.gds$', '', tempnames[i])
tempnames[i] = re.sub('\.sp$', '', tempnames[i])
try:
from tech import blackbox_cells
nameset = list(set(tempnames) - set(blackbox_cells))
except ImportError:
# remove duplicate base names
nameset = set(tempnames)
2016-11-08 18:57:35 +01:00
allnames = list(nameset)
return (gds_dir, sp_dir, allnames)
# run the test from the command line
2016-11-08 18:57:35 +01:00
if __name__ == "__main__":
(OPTS, args) = globals.parse_args()
del sys.argv[1:]
header(__file__, OPTS.tech_name)
unittest.main(testRunner=debugTestRunner())