mirror of
https://github.com/openhwgroup/cvw
synced 2025-02-11 06:05:49 +00:00
added plotting
This commit is contained in:
parent
c8e43e9798
commit
de8f66a121
@ -1,28 +1,37 @@
|
|||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
# from msilib.schema import File
|
#from msilib.schema import File
|
||||||
import subprocess
|
import subprocess
|
||||||
from multiprocessing import Pool
|
from multiprocessing import Pool
|
||||||
import csv
|
import csv
|
||||||
import re
|
import re
|
||||||
# import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
# import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
print("hi")
|
|
||||||
|
|
||||||
def run_command(module, width, freq):
|
def run_command(module, width, tech, freq):
|
||||||
command = "make synth DESIGN=ppa_{}_{} TECH=sky90 DRIVE=INV FREQ={} MAXOPT=1".format(module, width, freq)
|
command = "make synth DESIGN=ppa_{}_{} TECH={} DRIVE=INV FREQ={} MAXOPT=1".format(module, width, tech, freq)
|
||||||
subprocess.Popen(command, shell=True)
|
subprocess.Popen(command, shell=True)
|
||||||
|
|
||||||
widths = ['16']
|
def deleteRedundant(LoT):
|
||||||
modules = ['shifter']
|
'''not working'''
|
||||||
freqs = ['10']
|
synthStr = "rm -rf runs/ppa_{}_{}_rv32e_{}_{}_*"
|
||||||
|
for synth in LoT:
|
||||||
|
print(synth)
|
||||||
|
bashCommand = synthStr.format(*synth)
|
||||||
|
outputCPL = subprocess.check_output(['bash','-c', bashCommand])
|
||||||
|
|
||||||
|
widths = ['8']
|
||||||
|
modules = ['add']
|
||||||
|
freqs = ['10']
|
||||||
|
tech = 'sky90'
|
||||||
|
|
||||||
LoT = []
|
LoT = []
|
||||||
for module in modules:
|
for module in modules:
|
||||||
for width in widths:
|
for width in widths:
|
||||||
for freq in freqs:
|
for freq in freqs:
|
||||||
LoT += [[module, width, freq]]
|
LoT += [[module, width, tech, freq]]
|
||||||
|
|
||||||
|
deleteRedundant(LoT)
|
||||||
|
|
||||||
pool = Pool()
|
pool = Pool()
|
||||||
pool.starmap(run_command, LoT)
|
pool.starmap(run_command, LoT)
|
||||||
@ -45,13 +54,11 @@ allSynths = []
|
|||||||
|
|
||||||
for i in range(len(linesCPL)):
|
for i in range(len(linesCPL)):
|
||||||
line = linesCPL[i]
|
line = linesCPL[i]
|
||||||
oneSynth = []
|
|
||||||
mwm = wm.findall(line)[0][4:-4].split('_')
|
mwm = wm.findall(line)[0][4:-4].split('_')
|
||||||
oneSynth += [mwm[0]]
|
oneSynth = [mwm[0], int(mwm[1])]
|
||||||
oneSynth += [mwm[1]]
|
oneSynth += [int(f.findall(line)[0][1:-4])]
|
||||||
oneSynth += [f.findall(line)[0][1:-4]]
|
oneSynth += [float(cpl.findall(line)[0])]
|
||||||
oneSynth += cpl.findall(line)
|
oneSynth += [float(da.findall(linesDA[i])[0])]
|
||||||
oneSynth += da.findall(linesDA[i])
|
|
||||||
allSynths += [oneSynth]
|
allSynths += [oneSynth]
|
||||||
|
|
||||||
file = open("ppaData.csv", "w")
|
file = open("ppaData.csv", "w")
|
||||||
@ -61,4 +68,43 @@ writer.writerow(['Module', 'Width', 'Target Freq', 'Delay', 'Area'])
|
|||||||
for one in allSynths:
|
for one in allSynths:
|
||||||
writer.writerow(one)
|
writer.writerow(one)
|
||||||
|
|
||||||
file.close()
|
file.close()
|
||||||
|
|
||||||
|
|
||||||
|
def plotPPA(module, freq, var):
|
||||||
|
'''
|
||||||
|
module: string module name
|
||||||
|
freq: int freq (GHz)
|
||||||
|
var: string 'delay' or 'area'
|
||||||
|
plots chosen variable vs width for all matching syntheses with regression
|
||||||
|
'''
|
||||||
|
global allSynths
|
||||||
|
ind = 3 if (var == 'delay') else 4
|
||||||
|
widths = []
|
||||||
|
ivar = []
|
||||||
|
for oneSynth in allSynths:
|
||||||
|
if (oneSynth[0] == module) & (oneSynth[2] == freq):
|
||||||
|
|
||||||
|
widths += [oneSynth[1]]
|
||||||
|
ivar += [oneSynth[ind]]
|
||||||
|
|
||||||
|
x = np.array(widths, dtype=np.int)
|
||||||
|
y = np.array(ivar, dtype=np.float)
|
||||||
|
|
||||||
|
A = np.vstack([x, np.ones(len(x))]).T
|
||||||
|
m, c = np.linalg.lstsq(A, y, rcond=None)[0]
|
||||||
|
z = np.polyfit(x, y, 2)
|
||||||
|
p = np.poly1d(z)
|
||||||
|
|
||||||
|
xp = np.linspace(0, 140, 200)
|
||||||
|
|
||||||
|
_ = plt.plot(x, y, 'o', label=module, markersize=10)
|
||||||
|
_ = plt.plot(x, m*x + c, 'r', label='Linear fit')
|
||||||
|
_ = plt.plot(xp, p(xp), label='Quadratic fit')
|
||||||
|
_ = plt.legend()
|
||||||
|
_ = plt.xlabel("Width (bits)")
|
||||||
|
_ = plt.ylabel(str.title(var))
|
||||||
|
plt.show()
|
||||||
|
|
||||||
|
|
||||||
|
plotPPA('add', 5000, 'delay')
|
Loading…
Reference in New Issue
Block a user