2018-05-12 01:32:00 +02:00
|
|
|
#!/usr/bin/env python3
|
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
|
|
|
#
|
2022-11-27 22:01:20 +01:00
|
|
|
import sys, os, re
|
2017-05-30 21:50:07 +02:00
|
|
|
import unittest
|
2019-05-31 19:51:42 +02:00
|
|
|
from testutils import *
|
2022-07-13 19:57:56 +02:00
|
|
|
|
2022-11-27 22:01:20 +01:00
|
|
|
import openram
|
|
|
|
|
from openram import debug
|
|
|
|
|
from openram import OPTS
|
|
|
|
|
|
2017-05-30 21:50:07 +02:00
|
|
|
|
2019-08-09 03:26:12 +02:00
|
|
|
#@unittest.skip("SKIPPING 23_lib_sram_model_test")
|
2019-07-25 23:46:33 +02:00
|
|
|
class lib_sram_model_test(openram_test):
|
2017-05-30 21:50:07 +02:00
|
|
|
|
|
|
|
|
def runTest(self):
|
2019-11-17 01:44:31 +01:00
|
|
|
config_file = "{}/tests/configs/config".format(os.getenv("OPENRAM_HOME"))
|
2022-11-27 22:01:20 +01:00
|
|
|
openram.init_openram(config_file, is_unit_test=True)
|
2019-11-30 21:48:25 +01:00
|
|
|
OPTS.nominal_corner_only = False
|
2019-09-05 01:06:12 +02:00
|
|
|
OPTS.netlist_only = True
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2022-03-06 20:26:18 +01:00
|
|
|
if OPTS.tech_name == "sky130":
|
|
|
|
|
num_spare_rows = 1
|
|
|
|
|
num_spare_cols = 1
|
|
|
|
|
else:
|
|
|
|
|
num_spare_rows = 0
|
|
|
|
|
num_spare_cols = 0
|
|
|
|
|
|
2022-11-27 22:01:20 +01:00
|
|
|
from openram.characterizer import lib
|
|
|
|
|
from openram.modules import sram
|
|
|
|
|
from openram.modules import sram_config
|
2018-08-31 21:03:28 +02:00
|
|
|
c = sram_config(word_size=2,
|
|
|
|
|
num_words=16,
|
2022-03-06 20:26:18 +01:00
|
|
|
num_banks=1,
|
|
|
|
|
num_spare_cols=num_spare_cols,
|
|
|
|
|
num_spare_rows=num_spare_rows)
|
2018-09-04 19:47:24 +02:00
|
|
|
c.words_per_row=1
|
2018-12-06 22:11:47 +01:00
|
|
|
c.recompute_sizes()
|
2018-08-31 21:03:28 +02:00
|
|
|
debug.info(1, "Testing analytical timing for sample 2 bit, 16 words SRAM with 1 bank")
|
2019-03-06 23:12:24 +01:00
|
|
|
|
2019-03-08 17:31:26 +01:00
|
|
|
# This doesn't have to use the factory since worst case
|
|
|
|
|
# it will just replaece the top-level module of the same name
|
|
|
|
|
s = sram(c, "sram_2_16_1_{0}".format(OPTS.tech_name))
|
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))
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2022-11-27 22:01:20 +01:00
|
|
|
openram.end_openram()
|
|
|
|
|
|
2017-05-30 21:50:07 +02:00
|
|
|
|
2018-11-03 00:34:26 +01:00
|
|
|
# run the test from the command line
|
2017-05-30 21:50:07 +02:00
|
|
|
if __name__ == "__main__":
|
2022-11-27 22:01:20 +01:00
|
|
|
(OPTS, args) = openram.parse_args()
|
2017-05-30 21:50:07 +02:00
|
|
|
del sys.argv[1:]
|
|
|
|
|
header(__file__, OPTS.tech_name)
|
2019-05-31 19:51:42 +02:00
|
|
|
unittest.main(testRunner=debugTestRunner())
|