-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcollect_area_delay_synthesis.py
69 lines (51 loc) · 2.28 KB
/
collect_area_delay_synthesis.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
import os.path as osp
import csv,re,sys,os
rootFolder = sys.argv[1] #Path /home/abc586/llm_ppa_predictor
dumpFolder = osp.join(rootFolder,"dump")
def extractArea(areaFile):
with open(areaFile,'r') as rf:
areaLine = rf.readlines()[-2]
area = re.findall('[0-9.]+',areaLine)[-1]
return area
def extractDelay(delayFile):
delay = 0.0
with open(delayFile,'r') as rf:
delayLines = rf.readlines()
for line in delayLines:
if line.__contains__("5K_hvratio_1_1"):
delay = re.findall('[0-9.]+',line)[-2]
break
return delay
def checkErrorInSynLog(synLogFile):
with open(synLogFile,'r') as rf:
logLine = rf.readlines()[-1]
if logLine.__contains__("ERROR:"):
return True
return False
with open(osp.join(dumpFolder,'synthesis_data_nangate45nm.csv'), 'w', newline='') as csvfile:
fileHeader = ['design','module','recipe_type','area','delay']
writer = csv.DictWriter(csvfile, fieldnames=fileHeader)
writer.writeheader()
moduleCount = 0
for design in os.listdir(dumpFolder):
if design == "synthesis_data_nangate45nm.csv":
continue
for module in os.listdir(osp.join(rootFolder,"dump",design)):
if module.endswith("_area"):
recipe_type = "area"
moduleName = module.split('_area')[0]
else:
recipe_type = "delay"
moduleName = module.split('_speed')[0]
log_file = osp.join(rootFolder,"dump",design,module,"yosys_synth.log")
isError = checkErrorInSynLog(log_file)
if isError:
area = "error"
delay = "error"
else:
area_file = osp.join(rootFolder,"dump",design,module,"synth_stat.txt") # Area delay information
area = extractArea(area_file)
delay = extractDelay(log_file)
writer.writerow({'design': design, 'module': moduleName,'recipe_type':recipe_type,'area':area,'delay':delay})
moduleCount+=1
print("Synthesis data of all Verilog files has been written to 'synthesis_data_nangate45nm.csv'.")