forked from The-OpenROAD-Project/OpenLane
-
Notifications
You must be signed in to change notification settings - Fork 0
/
report_generation_wrapper.py
218 lines (187 loc) · 7.71 KB
/
report_generation_wrapper.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
# Copyright 2020 Efabless Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# The only purpose of this file is to create a wrapper around report.py and config.py and make them usable by flow.tcl
import argparse
import os
import re
from scripts.report.report import Report
from scripts.config.config import ConfigHandler
import scripts.utils.utils as utils
from scripts.report.get_file_name import get_name
parser = argparse.ArgumentParser(
description='Creates a final summary csv report for a given design \
+ a manufacturability report + a runtime summary report.')
parser.add_argument('--design', '-d', required=True,
help='Design Path')
parser.add_argument('--design_name', '-dn', required=True,
help='Design Name')
parser.add_argument('--tag', '-t', required=True,
help='Run Tag')
parser.add_argument('--run_path', '-r', default=None,
help='Run Path')
parser.add_argument('--output_file', '-o', required=True,
help='Output Final Summary Report')
parser.add_argument('--man_report', '-m', required=True,
help='Output Manufacturability Reports')
parser.add_argument('--runtime_summary', '-rs', required=True,
help='Output Runtime Summary Reports')
args = parser.parse_args()
design = args.design
design_name = args.design_name
tag = args.tag
run_path=args.run_path
output_file = args.output_file
man_report = args.man_report
runtime_summary = args.runtime_summary
# Extracting Configurations
params = ConfigHandler.get_config(design, tag, run_path)
# Extracting Report
report = Report(design, tag, design_name,params,run_path).get_report()
# write into file
outputFileOpener = open(output_file,"w")
outputFileOpener.write(Report.get_header() + "," + ConfigHandler.get_header())
outputFileOpener.write("\n")
outputFileOpener.write(report)
outputFileOpener.close()
# Adding Extra Attributes computed from configs and reported statistics
utils.addComputedStatistics(output_file)
# Tracking Magic DRC, LVS, Antenna Logs:
if run_path is None:
run_path = utils.get_run_path(design, tag)
magic_drc_report=get_name(str(run_path)+"/reports/magic/", "magic.drc")
lvs_report=str(run_path)+"/results/lvs/"+design_name+".lvs_parsed.lef.log"
if not os.path.exists(lvs_report):
lvs_report=str(run_path)+"/results/lvs/"+design_name+".lvs_parsed.gds.log"
magic_antenna_report=get_name(str(run_path)+"/reports/magic/","magic.antenna_violators.rpt")
arc_antenna_report=get_name(str(run_path)+"/reports/routing/","antenna.rpt")
printArr = []
printArr.append("Design Name: " + design_name)
printArr.append("Run Directory: " + str(run_path))
splitLine = '----------------------------------------'
# Summarizing Magic DRC
drcVioDict = dict()
cnt = 0
if os.path.exists(magic_drc_report):
drcFileOpener = open(magic_drc_report)
if drcFileOpener.mode == 'r':
drcContent = drcFileOpener.read()
drcFileOpener.close()
# design name
# violation message
# list of violations
# Total Count:
printArr.append(splitLine)
printArr.append("\nMagic DRC Summary:")
printArr.append("Source: " + str(magic_drc_report))
if drcContent is not None:
drcSections = drcContent.split(splitLine)
if (len(drcSections) > 2):
for i in range(1, len(drcSections) - 1, 2):
drcVioDict[drcSections[i]] = len(drcSections[i + 1].split("\n")) - 2
for key in drcVioDict:
val = drcVioDict[key]
cnt += val
printArr.append("Violation Message \"" + str(key.strip()) + " \"found " + str(val) + " Times.")
printArr.append("Total Magic DRC violations is " + str(cnt))
else:
printArr.append("Source not found.")
# Summarizing LVS
printArr.append(splitLine)
printArr.append("\nLVS Summary:")
printArr.append("Source: "+str(lvs_report))
if os.path.exists(lvs_report):
lvsFileOpener = open(lvs_report)
if lvsFileOpener.mode == 'r':
lvsContent = lvsFileOpener.read()
lvsFileOpener.close()
flag = False
for line in lvsContent.split("\n"):
if line.find("Total errors =") != -1:
flag = True
printArr.append(line)
elif line.find("net") != -1:
printArr.append(line)
if not flag:
printArr.append("Design is LVS clean.")
else:
printArr.append("Source not found.")
# Summarizing Antennas
printArr.append(splitLine)
printArr.append("\nAntenna Summary:")
if os.path.exists(arc_antenna_report):
printArr.append("Source: " + str(arc_antenna_report))
antFileOpener = open(arc_antenna_report)
if antFileOpener.mode == 'r':
antContent = antFileOpener.read().split("\n")[-5:]
antFileOpener.close()
for line in antContent:
if line.find("violated:") != -1:
printArr.append(line)
elif os.path.exists(magic_antenna_report):
printArr.append("Source: " + str(magic_antenna_report))
antFileOpener = open(magic_antenna_report)
if antFileOpener.mode == 'r':
antContent = antFileOpener.read().split("\n")
antFileOpener.close()
tot_cnt = 0
for ant in antContent:
if len(str(ant).strip()):
tot_cnt+=1
printArr.append("Number of pins violated: " + str(tot_cnt))
else:
printArr.append("No antenna report found.")
# write into file
outputFileOpener = open(man_report,"w")
outputFileOpener.write("\n".join(printArr))
outputFileOpener.close()
def getListOfFiles(dirName):
# create a list of file and sub directories
# names in the given directory
allFiles = list()
listOfFile = os.listdir(dirName)
# Iterate over all the entries
for entry in listOfFile:
# Create full path
fullPath = os.path.join(dirName, entry)
# If entry is a directory then get the list of files in this directory
if os.path.isdir(fullPath):
allFiles = allFiles + getListOfFiles(fullPath)
else:
allFiles.append(fullPath)
return allFiles
def conver_to_seconds(runtime):
pattern = re.compile(r'\s*([\d+]+)h([\d+]+)m([\d+]+)s([\d+]+)+ms')
m = pattern.match(runtime)
time = int(m.group(1))*60*60 + int(m.group(2))*60 + int(m.group(3)) + int(m.group(4))/1000.0
return str(time)
# Creating a runtime summary report
logs_path=run_path+"/logs"
neededfiles = sorted([(int(os.path.basename(f).split("-",1)[0]),f) for f in getListOfFiles(logs_path) if os.path.isfile(os.path.join(logs_path, f)) and len(f.split('_')) > 1 and f.split('_')[-1] == "runtime.txt" and len(os.path.basename(f).split('-')) > 1 and os.path.basename(f).split('-')[0].isnumeric()])
runtimeArr = []
prasableRuntimeArr= []
for (idx,f) in neededfiles:
stagename = os.path.basename(f).split("_runtime.txt")[0]
runtimeFileOpener = open(f, "r")
if runtimeFileOpener.mode == 'r':
runtimeContent = runtimeFileOpener.read().strip()
runtimeFileOpener.close()
runtimeArr.append(str(stagename)+ " "+ str(runtimeContent))
prasableRuntimeArr.append(str(stagename)+ " "+ conver_to_seconds(runtimeContent))
# write into file
outputFileOpener = open(runtime_summary,"w")
outputFileOpener.write("\n".join(runtimeArr))
outputFileOpener.close()
outputFileOpener = open(runtime_summary+".parsable","w")
outputFileOpener.write("\n".join(prasableRuntimeArr))
outputFileOpener.close()