From 1f229c53875704125f896b539fc4fa7bc70a4b5d Mon Sep 17 00:00:00 2001 From: Shreya Sanghai Date: Mon, 18 Apr 2022 04:18:50 +0000 Subject: [PATCH] automate synth --- synthDC/runSynth.sh | 4 +++ synthDC/scripts/extractSummary.py | 50 +++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 synthDC/runSynth.sh create mode 100755 synthDC/scripts/extractSummary.py diff --git a/synthDC/runSynth.sh b/synthDC/runSynth.sh new file mode 100644 index 00000000..8c4451b0 --- /dev/null +++ b/synthDC/runSynth.sh @@ -0,0 +1,4 @@ +rm -r runs/* +make clean +make freqs TECH=sky130 +python3 scripts/extractSummary.py \ No newline at end of file diff --git a/synthDC/scripts/extractSummary.py b/synthDC/scripts/extractSummary.py new file mode 100755 index 00000000..b7a2cc76 --- /dev/null +++ b/synthDC/scripts/extractSummary.py @@ -0,0 +1,50 @@ +#!/usr/bin/python3 +# Shreya Sanghai (ssanghai@hmc.edu) 2/28/2022 +import glob +import re +import csv +import linecache +import os + + +def main(): + data = [] + curr_dir = os.path.dirname(os.path.abspath(__file__)) + output_file = os.path.join(curr_dir,"..","Summary.csv") + runs_dir = os.path.join(curr_dir,"..","runs/*/reports/wallypipelinedcore_qor.rep") + search_strings = [ + "Critical Path Length:", "Cell Area:", "Overall Compile Time:", + "Critical Path Clk Period:", "Critical Path Slack:" + ] + + for name in glob.glob(runs_dir): + f = open(name, 'r') + trimName = re.search("wallypipelinedcore_(.*?)_2022",name).group(1) + + output = {'Name':trimName} + num_lines = len(f.readlines()) + curr_line_index = 0 + + while curr_line_index < num_lines: + line = linecache.getline(name, curr_line_index) + for search_string in search_strings: + if search_string in line: + val = getVal(name,search_string,line,curr_line_index) + output[search_string] = val + curr_line_index +=1 + data += [output] + + with open(output_file, 'w') as csvfile: + writer = csv.DictWriter(csvfile, fieldnames=['Name'] + search_strings) + writer.writeheader() + writer.writerows(data) + +def getVal(filename, search_string, line, line_index): + data = re.search(f"{search_string} *(.*?)\\n", line).group(1) + if data == '': #sometimes data is stored in two line + data = linecache.getline(filename, line_index+1).strip() + return data + +if __name__=="__main__": + main() + \ No newline at end of file