mirror of https://github.com/VLSIDA/OpenRAM.git
Fix functional script spice file name and unit test
This commit is contained in:
parent
dbb8bb85cb
commit
b9123571f4
|
|
@ -8,6 +8,8 @@
|
||||||
import math
|
import math
|
||||||
import random
|
import random
|
||||||
import collections
|
import collections
|
||||||
|
from os import path
|
||||||
|
import shutil
|
||||||
from numpy import binary_repr
|
from numpy import binary_repr
|
||||||
from openram import debug
|
from openram import debug
|
||||||
from openram import OPTS
|
from openram import OPTS
|
||||||
|
|
@ -33,6 +35,9 @@ class functional(simulation):
|
||||||
if not spfile:
|
if not spfile:
|
||||||
# self.sp_file is assigned in base class
|
# self.sp_file is assigned in base class
|
||||||
sram.sp_write(self.sp_file, trim=OPTS.trim_netlist)
|
sram.sp_write(self.sp_file, trim=OPTS.trim_netlist)
|
||||||
|
# Copy sp file to temp dir
|
||||||
|
self.temp_spice = path.join(OPTS.openram_temp, "sram.sp")
|
||||||
|
shutil.copy(self.sp_file, self.temp_spice)
|
||||||
|
|
||||||
if not corner:
|
if not corner:
|
||||||
corner = (OPTS.process_corners[0], OPTS.supply_voltages[0], OPTS.temperatures[0])
|
corner = (OPTS.process_corners[0], OPTS.supply_voltages[0], OPTS.temperatures[0])
|
||||||
|
|
@ -386,16 +391,16 @@ class functional(simulation):
|
||||||
def write_functional_stimulus(self):
|
def write_functional_stimulus(self):
|
||||||
""" Writes SPICE stimulus. """
|
""" Writes SPICE stimulus. """
|
||||||
self.stim_sp = "functional_stim.sp"
|
self.stim_sp = "functional_stim.sp"
|
||||||
temp_stim = "{0}/{1}".format(self.output_path, self.stim_sp)
|
temp_stim = path.join(self.output_path, self.stim_sp)
|
||||||
self.sf = open(temp_stim, "w")
|
self.sf = open(temp_stim, "w")
|
||||||
self.sf.write("* Functional test stimulus file for {0}ns period\n\n".format(self.period))
|
self.sf.write("* Functional test stimulus file for {0}ns period\n\n".format(self.period))
|
||||||
self.meas_sp = "functional_meas.sp"
|
self.meas_sp = "functional_meas.sp"
|
||||||
temp_meas = "{0}/{1}".format(self.output_path, self.meas_sp)
|
temp_meas = path.join(self.output_path, self.meas_sp)
|
||||||
self.mf = open(temp_meas, "w")
|
self.mf = open(temp_meas, "w")
|
||||||
self.stim = stimuli(self.sf, self.mf, self.corner)
|
self.stim = stimuli(self.sf, self.mf, self.corner)
|
||||||
|
|
||||||
# Write include statements
|
# Write include statements
|
||||||
self.stim.write_include(self.sp_file)
|
self.stim.write_include(self.temp_spice)
|
||||||
|
|
||||||
# Write Vdd/Gnd statements
|
# Write Vdd/Gnd statements
|
||||||
self.sf.write("\n* Global Power Supplies\n")
|
self.sf.write("\n* Global Power Supplies\n")
|
||||||
|
|
@ -502,9 +507,11 @@ class functional(simulation):
|
||||||
# dout=signal_name,
|
# dout=signal_name,
|
||||||
# t_initial=t_initial,
|
# t_initial=t_initial,
|
||||||
# t_final=t_final)
|
# t_final=t_final)
|
||||||
|
|
||||||
|
self.sf.write(".include {0}\n".format(temp_meas))
|
||||||
self.stim.write_control(self.cycle_times[-1] + self.period)
|
self.stim.write_control(self.cycle_times[-1] + self.period)
|
||||||
self.sf.close()
|
self.sf.close()
|
||||||
|
self.mf.close()
|
||||||
|
|
||||||
# FIXME: Similar function to delay.py, refactor this
|
# FIXME: Similar function to delay.py, refactor this
|
||||||
def get_bit_name(self):
|
def get_bit_name(self):
|
||||||
|
|
|
||||||
|
|
@ -6,27 +6,33 @@
|
||||||
# (acting for and on behalf of Oklahoma State University)
|
# (acting for and on behalf of Oklahoma State University)
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
from asyncio import subprocess
|
import sys, os, re
|
||||||
|
import shutil
|
||||||
|
import getpass
|
||||||
import unittest
|
import unittest
|
||||||
from testutils import *
|
from testutils import *
|
||||||
import sys, os, re, shutil
|
|
||||||
sys.path.append(os.getenv("OPENRAM_HOME"))
|
import openram
|
||||||
import globals
|
from openram import debug
|
||||||
from globals import OPTS
|
from openram import OPTS
|
||||||
import debug
|
|
||||||
import getpass
|
|
||||||
|
|
||||||
|
|
||||||
class openram_front_end_test(openram_test):
|
class sram_func_test(openram_test):
|
||||||
|
|
||||||
def runTest(self):
|
def runTest(self):
|
||||||
OPENRAM_HOME = os.path.abspath(os.environ.get("OPENRAM_HOME"))
|
global OPTS
|
||||||
config_file = "{}/tests/configs/config_mem_char_func".format(os.getenv("OPENRAM_HOME"))
|
out_file = "sram_2_16_1_{0}".format(OPTS.tech_name)
|
||||||
globals.init_openram(config_file)
|
out_path = "{0}/testsram_{1}_{2}_{3}".format(OPTS.openram_temp, OPTS.tech_name, getpass.getuser(), os.getpid())
|
||||||
|
OPTS.output_name = out_file
|
||||||
|
OPTS.output_path = out_path
|
||||||
|
|
||||||
debug.info(1, "Testing commandline functional simulator script memfunc.py with 2-bit, 16 word SRAM.")
|
OPENRAM_HOME = os.path.abspath(os.environ.get("OPENRAM_HOME"))
|
||||||
out_file = "testsram"
|
config_file = "{}/tests/configs/config_mem_char_func".format(OPENRAM_HOME)
|
||||||
out_path = "/tmp/testsram_{0}_{1}_{2}".format(OPTS.tech_name, getpass.getuser(), os.getpid())
|
|
||||||
|
openram.init_openram(config_file, is_unit_test=False)
|
||||||
|
sp_file = "{0}/tests/sp_files/{1}.sp".format(OPENRAM_HOME, OPTS.output_name)
|
||||||
|
|
||||||
|
debug.info(1, "Testing commandline functional simulator script sram_char.py with 2-bit, 16 word SRAM.")
|
||||||
|
|
||||||
# make sure we start without the files existing
|
# make sure we start without the files existing
|
||||||
if os.path.exists(out_path):
|
if os.path.exists(out_path):
|
||||||
|
|
@ -39,11 +45,6 @@ class openram_front_end_test(openram_test):
|
||||||
if e.errno == 17: # errno.EEXIST
|
if e.errno == 17: # errno.EEXIST
|
||||||
os.chmod(out_path, 0o0750)
|
os.chmod(out_path, 0o0750)
|
||||||
|
|
||||||
# copy the 2x16 sram spice file into out_path because memfunc.py expects it there
|
|
||||||
sp_src_file = "{0}/tests/golden/sram_2_16_1_{1}.sp".format(OPENRAM_HOME, OPTS.tech_name)
|
|
||||||
sp_dst_file = out_path + "/" + OPTS.output_name + ".sp"
|
|
||||||
shutil.copy(sp_src_file, sp_dst_file)
|
|
||||||
|
|
||||||
# specify the same verbosity for the system call
|
# specify the same verbosity for the system call
|
||||||
options = ""
|
options = ""
|
||||||
for i in range(OPTS.verbose_level):
|
for i in range(OPTS.verbose_level):
|
||||||
|
|
@ -54,22 +55,23 @@ class openram_front_end_test(openram_test):
|
||||||
|
|
||||||
if OPTS.tech_name:
|
if OPTS.tech_name:
|
||||||
options += " -t {}".format(OPTS.tech_name)
|
options += " -t {}".format(OPTS.tech_name)
|
||||||
|
|
||||||
options += " -j 2"
|
options += " -j 2"
|
||||||
|
|
||||||
# Always perform code coverage
|
# Always perform code coverage
|
||||||
if OPTS.coverage == 0:
|
if OPTS.coverage == 0:
|
||||||
debug.warning("Failed to find coverage installation. This can be installed with pip3 install coverage")
|
debug.warning("Failed to find coverage installation. This can be installed with pip3 install coverage")
|
||||||
exe_name = "{0}/memfunc.py ".format(OPENRAM_HOME)
|
exe_name = "{0}/../sram_func.py ".format(OPENRAM_HOME)
|
||||||
else:
|
else:
|
||||||
exe_name = "{0}{1}/memfunc.py ".format(OPTS.coverage_exe, OPENRAM_HOME)
|
exe_name = "{0}{1}/../sram_func.py ".format(OPTS.coverage_exe, OPENRAM_HOME)
|
||||||
config_name = "{0}/tests/configs/config_mem_char_func.py".format(OPENRAM_HOME)
|
config_name = "{0}/tests/configs/config_mem_char_func.py".format(OPENRAM_HOME)
|
||||||
period_and_cycles = 10
|
period_and_cycles = 10
|
||||||
cmd = "{0} -n -o {1} -p {2} {3} {4} {5} {5} 2>&1 > {6}/output.log".format(exe_name,
|
cmd = "{0} -n -o {1} -p {2} {3} {4} {5} {6} {6} 2>&1 > {7}/output.log".format(exe_name,
|
||||||
out_file,
|
out_file,
|
||||||
out_path,
|
out_path,
|
||||||
options,
|
options,
|
||||||
config_name,
|
config_name,
|
||||||
|
sp_file,
|
||||||
period_and_cycles,
|
period_and_cycles,
|
||||||
out_path)
|
out_path)
|
||||||
debug.info(1, cmd)
|
debug.info(1, cmd)
|
||||||
|
|
@ -88,11 +90,11 @@ class openram_front_end_test(openram_test):
|
||||||
shutil.rmtree(out_path, ignore_errors=True)
|
shutil.rmtree(out_path, ignore_errors=True)
|
||||||
self.assertEqual(os.path.exists(out_path), False)
|
self.assertEqual(os.path.exists(out_path), False)
|
||||||
|
|
||||||
globals.end_openram()
|
openram.end_openram()
|
||||||
|
|
||||||
# run the test from the command line
|
# run the test from the command line
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
(OPTS, args) = globals.parse_args()
|
(OPTS, args) = openram.parse_args()
|
||||||
del sys.argv[1:]
|
del sys.argv[1:]
|
||||||
header(__file__, OPTS.tech_name)
|
header(__file__, OPTS.tech_name)
|
||||||
unittest.main(testRunner=debugTestRunner())
|
unittest.main(testRunner=debugTestRunner())
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue