cvw/synthDC/ppa/ppaSynth.py

56 lines
2.1 KiB
Python
Raw Normal View History

2022-05-17 18:29:38 +00:00
#!/usr/bin/python3
2022-06-17 19:34:58 +00:00
# Madeleine Masser-Frye mmasserfrye@hmc.edu 6/22
2022-05-17 18:29:38 +00:00
import subprocess
import re
2022-06-17 19:34:58 +00:00
from multiprocessing import Pool
2022-06-03 21:23:04 +00:00
from ppaAnalyze import synthsfromcsv
2022-05-17 18:29:38 +00:00
def runCommand(module, width, tech, freq):
2022-06-17 19:34:58 +00:00
command = "make synth DESIGN=ppa_{}_{} TECH={} DRIVE=INV FREQ={} MAXOPT=1 MAXCORES=1".format(module, width, tech, freq)
2022-05-17 18:29:38 +00:00
subprocess.Popen(command, shell=True)
def deleteRedundant(LoT):
'''removes any previous runs for the current synthesis specifications'''
synthStr = "rm -rf runs/ppa_{}_{}_rv32e_{}nm_{}_*"
for synth in LoT:
bashCommand = synthStr.format(*synth)
outputCPL = subprocess.check_output(['bash','-c', bashCommand])
2022-06-17 19:34:58 +00:00
if __name__ == '__main__':
LoT = []
synthsToRun = []
##### Run specific syntheses
# widths = [8]
# modules = ['mult', 'add', 'shiftleft', 'flop', 'comparator', 'priorityencoder', 'add', 'csa', 'mux2', 'mux4', 'mux8']
# techs = ['sky90']
# freqs = [5000]
# for w in widths:
# for module in modules:
# for tech in techs:
# for freq in freqs:
# LoT += [[module, str(w), tech, str(freq)]]
##### Run a sweep based on best delay found in existing syntheses
arr = [-8, -6, -4, -2, 0, 2, 4, 6, 8]
allSynths = synthsfromcsv('bestSynths.csv')
for synth in allSynths:
f = 1000/synth.delay
for freq in [round(f+f*x/100) for x in arr]:
LoT += [[synth.module, str(synth.width), synth.tech, str(freq)]]
##### Only do syntheses for which a run doesn't already exist
bashCommand = "find . -path '*runs/ppa*rv32e*' -prune"
output = subprocess.check_output(['bash','-c', bashCommand])
specReg = re.compile('[a-zA-Z0-9]+')
allSynths = output.decode("utf-8").split('\n')[:-1]
allSynths = [specReg.findall(oneSynth)[2:7] for oneSynth in allSynths]
allSynths = [oneSynth[0:2] + [oneSynth[3][:-2]] + [oneSynth[4]] for oneSynth in allSynths]
for synth in LoT:
if (synth not in allSynths):
synthsToRun += [synth]
pool = Pool(processes=25)
pool.starmap(runCommand, synthsToRun)