2018-05-12 01:32:00 +02:00
|
|
|
#!/usr/bin/env python3
|
2017-05-30 21:50:07 +02:00
|
|
|
"""
|
|
|
|
|
Check the .lib file for an SRAM
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
import unittest
|
2018-01-31 20:48:41 +01:00
|
|
|
from testutils import header,openram_test
|
2018-02-10 00:33:03 +01:00
|
|
|
import sys,os,re
|
2017-05-30 21:50:07 +02:00
|
|
|
sys.path.append(os.path.join(sys.path[0],".."))
|
|
|
|
|
import globals
|
2017-11-16 22:52:58 +01:00
|
|
|
from globals import OPTS
|
2017-05-30 21:50:07 +02:00
|
|
|
import debug
|
|
|
|
|
|
2018-01-30 01:59:29 +01:00
|
|
|
class lib_test(openram_test):
|
2017-05-30 21:50:07 +02:00
|
|
|
|
|
|
|
|
def runTest(self):
|
|
|
|
|
globals.init_openram("config_20_{0}".format(OPTS.tech_name))
|
|
|
|
|
|
|
|
|
|
import sram
|
2017-11-16 22:52:58 +01:00
|
|
|
from characterizer import lib
|
2017-05-30 21:50:07 +02:00
|
|
|
|
|
|
|
|
debug.info(1, "Testing timing for sample 2 bit, 16 words SRAM with 1 bank")
|
2017-05-31 23:59:22 +02:00
|
|
|
s = sram.sram(word_size=2,
|
2018-02-12 01:35:10 +01:00
|
|
|
num_words=16,
|
|
|
|
|
num_banks=1,
|
2017-05-31 23:59:22 +02:00
|
|
|
name="sram_2_16_1_{0}".format(OPTS.tech_name))
|
2018-07-11 01:39:32 +02:00
|
|
|
|
2017-05-30 21:50:07 +02:00
|
|
|
tempspice = OPTS.openram_temp + "temp.sp"
|
|
|
|
|
s.sp_write(tempspice)
|
|
|
|
|
|
2018-07-18 20:51:42 +02:00
|
|
|
lib(out_dir=OPTS.openram_temp, sram=s.s, sp_file=tempspice, use_model=True)
|
2017-05-30 21:50:07 +02:00
|
|
|
|
2018-02-10 00:33:03 +01:00
|
|
|
# get all of the .lib files generated
|
|
|
|
|
files = os.listdir(OPTS.openram_temp)
|
|
|
|
|
nametest = re.compile("\.lib$", re.IGNORECASE)
|
|
|
|
|
lib_files = filter(nametest.search, files)
|
2017-05-30 21:50:07 +02:00
|
|
|
|
2018-02-10 00:33:03 +01:00
|
|
|
# and compare them with the golden model
|
|
|
|
|
for filename in lib_files:
|
|
|
|
|
newname = filename.replace(".lib","_analytical.lib")
|
|
|
|
|
libname = "{0}/{1}".format(OPTS.openram_temp,filename)
|
|
|
|
|
golden = "{0}/golden/{1}".format(os.path.dirname(os.path.realpath(__file__)),newname)
|
2018-07-27 18:34:44 +02:00
|
|
|
self.assertTrue(self.isapproxdiff(libname,golden,0.15))
|
2018-02-10 00:33:03 +01:00
|
|
|
|
2017-05-30 21:50:07 +02:00
|
|
|
globals.end_openram()
|
|
|
|
|
|
|
|
|
|
# instantiate a copdsay of the class to actually run the test
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
(OPTS, args) = globals.parse_args()
|
|
|
|
|
del sys.argv[1:]
|
|
|
|
|
header(__file__, OPTS.tech_name)
|
|
|
|
|
unittest.main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|