mirror of
https://github.com/openhwgroup/cvw
synced 2025-02-11 06:05:49 +00:00
Lots more python cleanup
This commit is contained in:
parent
0e3030dc23
commit
21e35c9068
@ -31,7 +31,7 @@ def tabulate_arch_sweep(directory):
|
|||||||
file_path = os.path.join(directory, file)
|
file_path = os.path.join(directory, file)
|
||||||
lines = []
|
lines = []
|
||||||
try:
|
try:
|
||||||
f = open(file_path, "r")
|
f = open(file_path)
|
||||||
lines = f.readlines()
|
lines = f.readlines()
|
||||||
except:
|
except:
|
||||||
f.close()
|
f.close()
|
||||||
|
@ -230,7 +230,7 @@ def main(args):
|
|||||||
atoms = 0
|
atoms = 0
|
||||||
totalops = 0
|
totalops = 0
|
||||||
|
|
||||||
with open(extfile, "r", encoding="utf-8") as f:
|
with open(extfile) as f:
|
||||||
for ln in f:
|
for ln in f:
|
||||||
ln = ln.strip()
|
ln = ln.strip()
|
||||||
lninfo = ln.split()
|
lninfo = ln.split()
|
||||||
|
@ -391,7 +391,7 @@ class TestRunner:
|
|||||||
# Implement cleaning and formatting logic here
|
# Implement cleaning and formatting logic here
|
||||||
|
|
||||||
# Open up the file with only read permissions
|
# Open up the file with only read permissions
|
||||||
with open(input_file, 'r') as input_file:
|
with open(input_file) as input_file:
|
||||||
uncleaned_output = input_file.read()
|
uncleaned_output = input_file.read()
|
||||||
|
|
||||||
# use something like this function to detect pass and fail
|
# use something like this function to detect pass and fail
|
||||||
@ -598,7 +598,7 @@ class TestRunner:
|
|||||||
# Implement markdown to HTML conversion logic here
|
# Implement markdown to HTML conversion logic here
|
||||||
os.chdir(self.results_dir)
|
os.chdir(self.results_dir)
|
||||||
|
|
||||||
with open(markdown_file, 'r') as md_file:
|
with open(markdown_file) as md_file:
|
||||||
md_content = md_file.read()
|
md_content = md_file.read()
|
||||||
html_content = markdown.markdown(md_content)
|
html_content = markdown.markdown(md_content)
|
||||||
|
|
||||||
@ -632,7 +632,7 @@ class TestRunner:
|
|||||||
os.chdir(self.results_dir)
|
os.chdir(self.results_dir)
|
||||||
html_file = "results.html"
|
html_file = "results.html"
|
||||||
|
|
||||||
with open(html_file, 'r') as html_file:
|
with open(html_file) as html_file:
|
||||||
body = html_file.read()
|
body = html_file.read()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -46,7 +46,7 @@ def ParseBranchListFile(path):
|
|||||||
is formated in row columns. Each row is a trace with the file, branch predictor type, and the parameters.
|
is formated in row columns. Each row is a trace with the file, branch predictor type, and the parameters.
|
||||||
parameters can be any number and depend on the predictor type. Returns a list of lists.'''
|
parameters can be any number and depend on the predictor type. Returns a list of lists.'''
|
||||||
lst = []
|
lst = []
|
||||||
BranchList = open(path, 'r')
|
BranchList = open(path)
|
||||||
for line in BranchList:
|
for line in BranchList:
|
||||||
tokens = line.split()
|
tokens = line.split()
|
||||||
predictorLog = os.path.dirname(path) + '/' + tokens[0]
|
predictorLog = os.path.dirname(path) + '/' + tokens[0]
|
||||||
@ -62,7 +62,7 @@ def ProcessFile(fileName):
|
|||||||
# 1 find lines with Read memfile and extract test name
|
# 1 find lines with Read memfile and extract test name
|
||||||
# 2 parse counters into a list of (name, value) tuples (dictionary maybe?)
|
# 2 parse counters into a list of (name, value) tuples (dictionary maybe?)
|
||||||
benchmarks = []
|
benchmarks = []
|
||||||
transcript = open(fileName, 'r')
|
transcript = open(fileName)
|
||||||
HPMClist = { }
|
HPMClist = { }
|
||||||
testName = ''
|
testName = ''
|
||||||
for line in transcript.readlines():
|
for line in transcript.readlines():
|
||||||
@ -227,13 +227,13 @@ def ReportAsTable(benchmarkDict):
|
|||||||
|
|
||||||
sys.stdout.write('benchmark\t\t')
|
sys.stdout.write('benchmark\t\t')
|
||||||
for name in FirstLine:
|
for name in FirstLine:
|
||||||
if(len(name) < 8): sys.stdout.write('%s\t\t' % name)
|
if(len(name) < 8): sys.stdout.write(f'{name}\t\t')
|
||||||
else: sys.stdout.write('%s\t' % name)
|
else: sys.stdout.write(f'{name}\t')
|
||||||
sys.stdout.write('\n')
|
sys.stdout.write('\n')
|
||||||
sys.stdout.write('size\t\t\t')
|
sys.stdout.write('size\t\t\t')
|
||||||
for size in SecondLine:
|
for size in SecondLine:
|
||||||
if(len(str(size)) < 8): sys.stdout.write('%d\t\t' % size)
|
if(len(str(size)) < 8): sys.stdout.write(f'{size}\t\t')
|
||||||
else: sys.stdout.write('%d\t' % size)
|
else: sys.stdout.write(f'{size}\t')
|
||||||
sys.stdout.write('\n')
|
sys.stdout.write('\n')
|
||||||
|
|
||||||
if(args.summary):
|
if(args.summary):
|
||||||
@ -245,9 +245,9 @@ def ReportAsTable(benchmarkDict):
|
|||||||
if(not args.summary):
|
if(not args.summary):
|
||||||
for benchmark in benchmarkDict:
|
for benchmark in benchmarkDict:
|
||||||
length = len(benchmark)
|
length = len(benchmark)
|
||||||
if(length < 8): sys.stdout.write('%s\t\t\t' % benchmark)
|
if(length < 8): sys.stdout.write(f'{benchmark}\t\t\t')
|
||||||
elif(length < 16): sys.stdout.write('%s\t\t' % benchmark)
|
elif(length < 16): sys.stdout.write(f'{benchmark}\t\t')
|
||||||
else: sys.stdout.write('%s\t' % benchmark)
|
else: sys.stdout.write(f'{benchmark}\t')
|
||||||
for (name, typ, entries, size, val) in benchmarkDict[benchmark]:
|
for (name, typ, entries, size, val) in benchmarkDict[benchmark]:
|
||||||
sys.stdout.write('%0.2f\t\t' % (val if not args.invert else 100 -val))
|
sys.stdout.write('%0.2f\t\t' % (val if not args.invert else 100 -val))
|
||||||
sys.stdout.write('\n')
|
sys.stdout.write('\n')
|
||||||
@ -257,13 +257,13 @@ def ReportAsText(benchmarkDict):
|
|||||||
mean = benchmarkDict['Mean']
|
mean = benchmarkDict['Mean']
|
||||||
print('Mean')
|
print('Mean')
|
||||||
for (name, typ, entries, size, val) in mean:
|
for (name, typ, entries, size, val) in mean:
|
||||||
sys.stdout.write('%s %s %0.2f\n' % (name, entries if not args.size else size, val if not args.invert else 100 - val))
|
sys.stdout.write(f'{name} {entries if not args.size else size} {val if not args.invert else 100 - val:0.2f}\n')
|
||||||
|
|
||||||
if(not args.summary):
|
if(not args.summary):
|
||||||
for benchmark in benchmarkDict:
|
for benchmark in benchmarkDict:
|
||||||
print(benchmark)
|
print(benchmark)
|
||||||
for (name, type, entries, size, val) in benchmarkDict[benchmark]:
|
for (name, type, entries, size, val) in benchmarkDict[benchmark]:
|
||||||
sys.stdout.write('%s %s %0.2f\n' % (name, entries if not args.size else size, val if not args.invert else 100 - val))
|
sys.stdout.write(f'{name} {entries if not args.size else size} {val if not args.invert else 100 - val:0.2f}\n')
|
||||||
|
|
||||||
def Inversion(lst):
|
def Inversion(lst):
|
||||||
return [x if not args.invert else 100 - x for x in lst]
|
return [x if not args.invert else 100 - x for x in lst]
|
||||||
@ -354,7 +354,7 @@ def ReportAsGraph(benchmarkDict, bar, FileName):
|
|||||||
axes.set_xticks(xdata)
|
axes.set_xticks(xdata)
|
||||||
axes.set_xticklabels(xdata)
|
axes.set_xticklabels(xdata)
|
||||||
axes.grid(color='b', alpha=0.5, linestyle='dashed', linewidth=0.5)
|
axes.grid(color='b', alpha=0.5, linestyle='dashed', linewidth=0.5)
|
||||||
if(FileName == None): plt.show()
|
if FileName is None: plt.show()
|
||||||
else: plt.savefig(FileName)
|
else: plt.savefig(FileName)
|
||||||
|
|
||||||
# if(not args.summary):
|
# if(not args.summary):
|
||||||
@ -414,7 +414,7 @@ def ReportAsGraph(benchmarkDict, bar, FileName):
|
|||||||
# on each piece.
|
# on each piece.
|
||||||
for row in range(0, math.ceil(NumBenchmarks / BenchPerRow)):
|
for row in range(0, math.ceil(NumBenchmarks / BenchPerRow)):
|
||||||
(xlabelListTrunk, seriesDictTrunk) = SelectPartition(xlabelListBig, seriesDictBig, row, BenchPerRow)
|
(xlabelListTrunk, seriesDictTrunk) = SelectPartition(xlabelListBig, seriesDictBig, row, BenchPerRow)
|
||||||
FileName = 'barSegment%d.svg' % row
|
FileName = f'barSegment{row}.svg'
|
||||||
groupLen = len(xlabelListTrunk)
|
groupLen = len(xlabelListTrunk)
|
||||||
BarGraph(seriesDictTrunk, xlabelListTrunk, groupLen, FileName, (row == 0))
|
BarGraph(seriesDictTrunk, xlabelListTrunk, groupLen, FileName, (row == 0))
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ def main(args):
|
|||||||
probenum = 0
|
probenum = 0
|
||||||
countLines = 1
|
countLines = 1
|
||||||
|
|
||||||
with open(args[0],'r') as xdcfile, open(args[1], 'w') as outfile:
|
with open(args[0]) as xdcfile, open(args[1], 'w') as outfile:
|
||||||
Lines = xdcfile.readlines()
|
Lines = xdcfile.readlines()
|
||||||
for line in Lines:
|
for line in Lines:
|
||||||
t = re.sub("probe[0-9]+", f"probe{probenum}",line)
|
t = re.sub("probe[0-9]+", f"probe{probenum}",line)
|
||||||
|
@ -13,7 +13,7 @@ if not os.path.isfile(sys.path[0]+'/slack-webhook-url.txt'):
|
|||||||
print('Tutorial for slack webhook urls: https://bit.ly/BenSlackNotifier')
|
print('Tutorial for slack webhook urls: https://bit.ly/BenSlackNotifier')
|
||||||
print('==============================================================')
|
print('==============================================================')
|
||||||
else:
|
else:
|
||||||
urlFile = open(sys.path[0]+'/slack-webhook-url.txt','r')
|
urlFile = open(sys.path[0]+'/slack-webhook-url.txt')
|
||||||
url = urlFile.readline().strip('\n')
|
url = urlFile.readline().strip('\n')
|
||||||
|
|
||||||
# Traverse 3 parents up the process tree
|
# Traverse 3 parents up the process tree
|
||||||
|
@ -129,7 +129,7 @@ def getVals(tech, module, var, freq=None, width=None):
|
|||||||
works at a specified target frequency or if none is given, uses the synthesis with the best achievable delay for each width
|
works at a specified target frequency or if none is given, uses the synthesis with the best achievable delay for each width
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if width != None:
|
if width is not None:
|
||||||
widthsToGet = width
|
widthsToGet = width
|
||||||
else:
|
else:
|
||||||
widthsToGet = widths
|
widthsToGet = widths
|
||||||
@ -137,7 +137,7 @@ def getVals(tech, module, var, freq=None, width=None):
|
|||||||
metric = []
|
metric = []
|
||||||
widthL = []
|
widthL = []
|
||||||
|
|
||||||
if freq != None:
|
if freq is not None:
|
||||||
for oneSynth in allSynths:
|
for oneSynth in allSynths:
|
||||||
if (
|
if (
|
||||||
(oneSynth.freq == freq)
|
(oneSynth.freq == freq)
|
||||||
@ -182,7 +182,7 @@ def csvOfBest(filename):
|
|||||||
m = oneSynth.delay
|
m = oneSynth.delay
|
||||||
best = oneSynth
|
best = oneSynth
|
||||||
|
|
||||||
if (best != None) & (best not in bestSynths):
|
if (best is not None) & (best not in bestSynths):
|
||||||
bestSynths += [best]
|
bestSynths += [best]
|
||||||
|
|
||||||
file = open(filename, "w")
|
file = open(filename, "w")
|
||||||
@ -237,7 +237,7 @@ def genLegend(fits, coefs, r2=None, spec=None, ale=False):
|
|||||||
|
|
||||||
eq = eq[3:] # chop off leading ' + '
|
eq = eq[3:] # chop off leading ' + '
|
||||||
|
|
||||||
if (r2 == None) or (spec == None):
|
if (r2 is None) or (spec is None):
|
||||||
return eq
|
return eq
|
||||||
else:
|
else:
|
||||||
legend_elements = [lines.Line2D([0], [0], color=spec.color, label=eq)]
|
legend_elements = [lines.Line2D([0], [0], color=spec.color, label=eq)]
|
||||||
@ -339,7 +339,7 @@ def oneMetricPlot(
|
|||||||
ax.add_artist(ax.legend(handles=fullLeg, loc=legLoc))
|
ax.add_artist(ax.legend(handles=fullLeg, loc=legLoc))
|
||||||
titleStr = (
|
titleStr = (
|
||||||
" (target " + str(freq) + "MHz)"
|
" (target " + str(freq) + "MHz)"
|
||||||
if freq != None
|
if freq is not None
|
||||||
else " (best achievable delay)"
|
else " (best achievable delay)"
|
||||||
)
|
)
|
||||||
ax.set_title(module + titleStr)
|
ax.set_title(module + titleStr)
|
||||||
@ -719,7 +719,7 @@ def plotPPA(mod, freq=None, norm=True, aleOpt=False):
|
|||||||
else:
|
else:
|
||||||
axs[i, j].legend(handles=leg, handlelength=1.5)
|
axs[i, j].legend(handles=leg, handlelength=1.5)
|
||||||
|
|
||||||
titleStr = " (target " + str(freq) + "MHz)" if freq != None else ""
|
titleStr = f" (target {freq} MHz)" if freq is not None else ""
|
||||||
plt.suptitle(mod + titleStr)
|
plt.suptitle(mod + titleStr)
|
||||||
plt.tight_layout(pad=0.05, w_pad=1, h_pad=0.5, rect=(0, 0, 1, 0.97))
|
plt.tight_layout(pad=0.05, w_pad=1, h_pad=0.5, rect=(0, 0, 1, 0.97))
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ from multiprocessing import Pool
|
|||||||
from ppaAnalyze import synthsfromcsv
|
from ppaAnalyze import synthsfromcsv
|
||||||
|
|
||||||
def runCommand(module, width, tech, freq):
|
def runCommand(module, width, tech, freq):
|
||||||
command = "make synth DESIGN={} WIDTH={} TECH={} DRIVE=INV FREQ={} MAXOPT=1 MAXCORES=1".format(module, width, tech, freq)
|
command = f"make synth DESIGN={module} WIDTH={width} TECH={tech} DRIVE=INV FREQ={freq} MAXOPT=1 MAXCORES=1"
|
||||||
subprocess.call(command, shell=True)
|
subprocess.call(command, shell=True)
|
||||||
|
|
||||||
def deleteRedundant(synthsToRun):
|
def deleteRedundant(synthsToRun):
|
||||||
|
@ -21,7 +21,7 @@ args=parser.parse_args()
|
|||||||
|
|
||||||
fin_path = glob.glob(f"{os.getenv('WALLY')}/src/**/{args.DESIGN}.sv",recursive=True)[0]
|
fin_path = glob.glob(f"{os.getenv('WALLY')}/src/**/{args.DESIGN}.sv",recursive=True)[0]
|
||||||
|
|
||||||
fin = open(fin_path, "r", encoding='utf-8')
|
fin = open(fin_path)
|
||||||
|
|
||||||
lines = fin.readlines()
|
lines = fin.readlines()
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ def runSynth(config, mod, tech, freq, maxopt, usesram):
|
|||||||
else:
|
else:
|
||||||
prefix = "syn_"
|
prefix = "syn_"
|
||||||
cfg = prefix + config
|
cfg = prefix + config
|
||||||
command = "make synth DESIGN=wallypipelinedcore CONFIG={} MOD={} TECH={} DRIVE=FLOP FREQ={} MAXOPT={} USESRAM={} MAXCORES=1".format(cfg, mod, tech, freq, maxopt, usesram)
|
command = f"make synth DESIGN=wallypipelinedcore CONFIG={cfg} MOD={mod} TECH={tech} DRIVE=FLOP FREQ={freq} MAXOPT={maxopt} USESRAM={usesram} MAXCORES=1"
|
||||||
pool.map(mask, [command])
|
pool.map(mask, [command])
|
||||||
|
|
||||||
def mask(command):
|
def mask(command):
|
||||||
|
@ -9,5 +9,5 @@ address = 0
|
|||||||
for line in fileinput.input('-'):
|
for line in fileinput.input('-'):
|
||||||
# the 14- is to reverse the byte order to little endian
|
# the 14- is to reverse the byte order to little endian
|
||||||
formatedLine = ' '.join(line[14-i:14-i+2] for i in range(0, len(line), 2))
|
formatedLine = ' '.join(line[14-i:14-i+2] for i in range(0, len(line), 2))
|
||||||
sys.stdout.write('@{:08x} {:s}\n'.format(address, formatedLine))
|
sys.stdout.write(f'@{address:08x} {formatedLine:s}\n')
|
||||||
address+=8
|
address+=8
|
||||||
|
@ -60,9 +60,9 @@ class Config:
|
|||||||
def create_vectors(my_config):
|
def create_vectors(my_config):
|
||||||
suite_folder_num = my_config.bits
|
suite_folder_num = my_config.bits
|
||||||
if my_config.bits == 64 and my_config.letter == "F": suite_folder_num = 32
|
if my_config.bits == 64 and my_config.letter == "F": suite_folder_num = 32
|
||||||
source_dir1 = "{}/addins/riscv-arch-test/riscv-test-suite/rv{}i_m/{}/src/".format(wally, suite_folder_num, my_config.letter)
|
source_dir1 = f"{wally}/addins/riscv-arch-test/riscv-test-suite/rv{suite_folder_num}i_m/{my_config.letter}/src/"
|
||||||
source_dir2 = "{}/tests/riscof/work/riscv-arch-test/rv{}i_m/{}/src/".format(wally, my_config.bits, my_config.letter)
|
source_dir2 = f"{wally}/tests/riscof/work/riscv-arch-test/rv{my_config.bits}i_m/{my_config.letter}/src/"
|
||||||
dest_dir = "{}/tests/fp/combined_IF_vectors/IF_vectors/".format(wally)
|
dest_dir = f"{wally}/tests/fp/combined_IF_vectors/IF_vectors/"
|
||||||
all_vectors1 = os.listdir(source_dir1)
|
all_vectors1 = os.listdir(source_dir1)
|
||||||
|
|
||||||
filt_vectors1 = [v for v in all_vectors1 if my_config.filt in v]
|
filt_vectors1 = [v for v in all_vectors1 if my_config.filt in v]
|
||||||
@ -77,10 +77,10 @@ def create_vectors(my_config):
|
|||||||
rounding_mode = "X"
|
rounding_mode = "X"
|
||||||
flags = "XX"
|
flags = "XX"
|
||||||
# use name to create our new tv
|
# use name to create our new tv
|
||||||
dest_file = open("{}cvw_{}_{}.tv".format(dest_dir, my_config.bits, vector1[:-2]), 'w')
|
dest_file = open(f"{dest_dir}cvw_{my_config.bits}_{vector1[:-2]}.tv", 'w')
|
||||||
# open vectors
|
# open vectors
|
||||||
src_file1 = open(source_dir1 + vector1,'r')
|
src_file1 = open(source_dir1 + vector1)
|
||||||
src_file2 = open(source_dir2 + vector2,'r')
|
src_file2 = open(source_dir2 + vector2)
|
||||||
# for each test in the vector
|
# for each test in the vector
|
||||||
reading = True
|
reading = True
|
||||||
src_file2.readline() #skip first bc junk
|
src_file2.readline() #skip first bc junk
|
||||||
@ -133,7 +133,7 @@ def create_vectors(my_config):
|
|||||||
done = True
|
done = True
|
||||||
# put it all together
|
# put it all together
|
||||||
if not done:
|
if not done:
|
||||||
translation = "{}_{}_{}_{}_{}_{}".format(operation, ext_bits(op1val), ext_bits(op2val), ext_bits(answer.strip()), flags, rounding_mode)
|
translation = f"{operation}_{ext_bits(op1val)}_{ext_bits(op2val)}_{ext_bits(answer.strip())}_{flags}_{rounding_mode}"
|
||||||
dest_file.write(translation + "\n")
|
dest_file.write(translation + "\n")
|
||||||
else:
|
else:
|
||||||
# print("read false")
|
# print("read false")
|
||||||
@ -182,7 +182,7 @@ def create_vectors(my_config):
|
|||||||
flags = "XX"
|
flags = "XX"
|
||||||
# put it all together
|
# put it all together
|
||||||
if not done:
|
if not done:
|
||||||
translation = "{}_{}_{}_{}_{}_{}".format(operation, ext_bits(op1val), ext_bits(op2val), ext_bits(answer.strip()), flags.strip(), rounding_mode)
|
translation = f"{operation}_{ext_bits(op1val)}_{ext_bits(op2val)}_{ext_bits(answer.strip())}_{flags.strip()}_{rounding_mode}"
|
||||||
dest_file.write(translation + "\n")
|
dest_file.write(translation + "\n")
|
||||||
else:
|
else:
|
||||||
# print("read false")
|
# print("read false")
|
||||||
@ -230,7 +230,7 @@ def create_vectors(my_config):
|
|||||||
flags = "XX"
|
flags = "XX"
|
||||||
# put it all together
|
# put it all together
|
||||||
if not done:
|
if not done:
|
||||||
translation = "{}_{}_{}_{}_{}_{}".format(operation, ext_bits(op1val), ext_bits(op2val), ext_bits(answer.strip()), flags.strip(), rounding_mode)
|
translation = f"{operation}_{ext_bits(op1val)}_{ext_bits(op2val)}_{ext_bits(answer.strip())}_{flags.strip()}_{rounding_mode}"
|
||||||
dest_file.write(translation + "\n")
|
dest_file.write(translation + "\n")
|
||||||
else:
|
else:
|
||||||
# print("read false")
|
# print("read false")
|
||||||
@ -279,7 +279,7 @@ def create_vectors(my_config):
|
|||||||
|
|
||||||
# put it all together
|
# put it all together
|
||||||
if not done:
|
if not done:
|
||||||
translation = "{}_{}_{}_{}_{}_{}".format(operation, ext_bits(op1val), ext_bits(op2val), ext_bits(answer.strip()), flags, rounding_mode)
|
translation = f"{operation}_{ext_bits(op1val)}_{ext_bits(op2val)}_{ext_bits(answer.strip())}_{flags}_{rounding_mode}"
|
||||||
dest_file.write(translation + "\n")
|
dest_file.write(translation + "\n")
|
||||||
else:
|
else:
|
||||||
# print("read false")
|
# print("read false")
|
||||||
|
@ -27,8 +27,8 @@ round_dict = {
|
|||||||
|
|
||||||
print("creating testfloat div test vectors")
|
print("creating testfloat div test vectors")
|
||||||
|
|
||||||
source_dir = "{}/tests/fp/vectors/".format(wally)
|
source_dir = f"{wally}/tests/fp/vectors/"
|
||||||
dest_dir = "{}/tests/fp/combined_IF_vectors/IF_vectors/".format(wally)
|
dest_dir = f"{wally}/tests/fp/combined_IF_vectors/IF_vectors/"
|
||||||
all_vectors = os.listdir(source_dir)
|
all_vectors = os.listdir(source_dir)
|
||||||
|
|
||||||
div_vectors = [v for v in all_vectors if "div" in v]
|
div_vectors = [v for v in all_vectors if "div" in v]
|
||||||
@ -42,13 +42,13 @@ for vector in div_vectors:
|
|||||||
# use name to create our new tv
|
# use name to create our new tv
|
||||||
dest_file = open(dest_dir + "cvw_" + vector, 'a')
|
dest_file = open(dest_dir + "cvw_" + vector, 'a')
|
||||||
# open vector
|
# open vector
|
||||||
src_file = open(source_dir + vector,'r')
|
src_file = open(source_dir + vector)
|
||||||
# for each test in the vector
|
# for each test in the vector
|
||||||
for i in src_file.readlines():
|
for i in src_file.readlines():
|
||||||
translation = "" # this stores the test that we are currently working on
|
translation = "" # this stores the test that we are currently working on
|
||||||
[input_1, input_2, answer, flags] = i.split("_") # separate inputs, answer, and flags
|
[input_1, input_2, answer, flags] = i.split("_") # separate inputs, answer, and flags
|
||||||
# put it all together, strip nec for removing \n on the end of the flags
|
# put it all together, strip nec for removing \n on the end of the flags
|
||||||
translation = "{}_{}_{}_{}_{}_{}".format(operation, ext_bits(input_1), ext_bits(input_2), ext_bits(answer), flags.strip(), rounding_mode)
|
translation = f"{operation}_{ext_bits(input_1)}_{ext_bits(input_2)}_{ext_bits(answer)}_{flags.strip()}_{rounding_mode}"
|
||||||
dest_file.write(translation + "\n")
|
dest_file.write(translation + "\n")
|
||||||
dest_file.close()
|
dest_file.close()
|
||||||
src_file.close()
|
src_file.close()
|
||||||
@ -67,7 +67,7 @@ for vector in sqrt_vectors:
|
|||||||
# use name to create our new tv
|
# use name to create our new tv
|
||||||
dest_file = open(dest_dir + "cvw_" + vector, 'a')
|
dest_file = open(dest_dir + "cvw_" + vector, 'a')
|
||||||
# open vector
|
# open vector
|
||||||
src_file = open(source_dir + vector,'r')
|
src_file = open(source_dir + vector)
|
||||||
# for each test in the vector
|
# for each test in the vector
|
||||||
for i in src_file.readlines():
|
for i in src_file.readlines():
|
||||||
translation = "" # this stores the test that we are currently working on
|
translation = "" # this stores the test that we are currently working on
|
||||||
|
@ -107,9 +107,9 @@ class sail_cSim(pluginTemplate):
|
|||||||
if ('NO_SAIL=True' in testentry['macros']):
|
if ('NO_SAIL=True' in testentry['macros']):
|
||||||
# if the tests can't run on SAIL we copy the reference output to the src directory
|
# if the tests can't run on SAIL we copy the reference output to the src directory
|
||||||
reference_output = re.sub("/src/","/references/", re.sub(".S",".reference_output", test))
|
reference_output = re.sub("/src/","/references/", re.sub(".S",".reference_output", test))
|
||||||
execute += 'cut -c-{0:g} {1} > {2}'.format(8, reference_output, sig_file) #use cut to remove comments when copying
|
execute += f'cut -c-{8:g} {reference_output} > {sig_file}' #use cut to remove comments when copying
|
||||||
else:
|
else:
|
||||||
execute += self.sail_exe[self.xlen] + ' -z268435455 -i --trace=step ' + self.sailargs + ' --test-signature={0} {1} > {2}.log 2>&1;'.format(sig_file, elf, test_name)
|
execute += self.sail_exe[self.xlen] + ' -z268435455 -i --trace=step ' + self.sailargs + f' --test-signature={sig_file} {elf} > {test_name}.log 2>&1;'
|
||||||
|
|
||||||
cov_str = ' '
|
cov_str = ' '
|
||||||
for label in testentry['coverage_labels']:
|
for label in testentry['coverage_labels']:
|
||||||
@ -117,10 +117,10 @@ class sail_cSim(pluginTemplate):
|
|||||||
|
|
||||||
if cgf_file is not None:
|
if cgf_file is not None:
|
||||||
coverage_cmd = 'riscv_isac --verbose info coverage -d \
|
coverage_cmd = 'riscv_isac --verbose info coverage -d \
|
||||||
-t {0}.log --parser-name c_sail -o coverage.rpt \
|
-t {}.log --parser-name c_sail -o coverage.rpt \
|
||||||
--sig-label begin_signature end_signature \
|
--sig-label begin_signature end_signature \
|
||||||
--test-label rvtest_code_begin rvtest_code_end \
|
--test-label rvtest_code_begin rvtest_code_end \
|
||||||
-e ref.elf -c {1} -x{2} {3};'.format(\
|
-e ref.elf -c {} -x{} {};'.format(\
|
||||||
test_name, ' -c '.join(cgf_file), self.xlen, cov_str)
|
test_name, ' -c '.join(cgf_file), self.xlen, cov_str)
|
||||||
else:
|
else:
|
||||||
coverage_cmd = ''
|
coverage_cmd = ''
|
||||||
|
@ -194,14 +194,14 @@ class spike(pluginTemplate):
|
|||||||
if ('NO_SAIL=True' in testentry['macros']):
|
if ('NO_SAIL=True' in testentry['macros']):
|
||||||
# if the tests can't run on SAIL we copy the reference output to the src directory
|
# if the tests can't run on SAIL we copy the reference output to the src directory
|
||||||
reference_output = re.sub("/src/","/references/", re.sub(".S",".reference_output", test))
|
reference_output = re.sub("/src/","/references/", re.sub(".S",".reference_output", test))
|
||||||
simcmd = 'cut -c-{0:g} {1} > {2}'.format(8, reference_output, sig_file) #use cut to remove comments when copying
|
simcmd = f'cut -c-{8:g} {reference_output} > {sig_file}' #use cut to remove comments when copying
|
||||||
else:
|
else:
|
||||||
simcmd = self.dut_exe + ' --isa={0} +signature={1} +signature-granularity=4 {2}'.format(self.isa, sig_file, elf)
|
simcmd = self.dut_exe + f' --isa={self.isa} +signature={sig_file} +signature-granularity=4 {elf}'
|
||||||
else:
|
else:
|
||||||
simcmd = 'echo "NO RUN"'
|
simcmd = 'echo "NO RUN"'
|
||||||
|
|
||||||
# concatenate all commands that need to be executed within a make-target.
|
# concatenate all commands that need to be executed within a make-target.
|
||||||
execute = '@cd {0}; {1}; {2};'.format(testentry['work_dir'], cmd, simcmd)
|
execute = '@cd {}; {}; {};'.format(testentry['work_dir'], cmd, simcmd)
|
||||||
|
|
||||||
# create a target. The makeutil will create a target with the name "TARGET<num>" where num
|
# create a target. The makeutil will create a target with the name "TARGET<num>" where num
|
||||||
# starts from 0 and increments automatically for each new target that is added
|
# starts from 0 and increments automatically for each new target that is added
|
||||||
|
@ -17,7 +17,7 @@ if __name__ == "__main__":
|
|||||||
line_num = int(sig_adr / 4) + 1
|
line_num = int(sig_adr / 4) + 1
|
||||||
offset = sig_adr & 0x3F
|
offset = sig_adr & 0x3F
|
||||||
test_num = int((sig_adr-offset)/int("40",16))
|
test_num = int((sig_adr-offset)/int("40",16))
|
||||||
print("IntrNum 0x{:02X}".format(test_num))
|
print(f"IntrNum 0x{test_num:02X}")
|
||||||
print("Offset 0x{:02X}".format(offset))
|
print(f"Offset 0x{offset:02X}")
|
||||||
print("LineNum "+str(line_num))
|
print("LineNum "+str(line_num))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user