-
Notifications
You must be signed in to change notification settings - Fork 5
/
util.py
111 lines (92 loc) · 3.63 KB
/
util.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
import os
home_path = os.getcwd()
#print(home_path)
def getHDL(design):
return design.rtl_file
def getLib(design):
return design.lib_file
def getLef(design):
return design.lef_file
def getMmmc(design):
return design.mmmc_file
def getHDLPath(design, baseflow):
if baseflow == "Cadence":
hdl_path = home_path + "/design/" + design.top_name + "/hdl"
elif baseflow == "Openroad":
hdl_path = "/OpenROAD-flow/flow/designs/design/" + design.top_name + "/hdl"
return hdl_path
def getLibPath(design, baseflow):
if baseflow == "Cadence":
lib_path = home_path + "/design/lib"
elif baseflow == "Openroad":
lib_path = "/OpenROAD-flow/flow/platforms/" + design.lib_name
return lib_path
def getLefPath(design, baseflow):
if baseflow == "Cadence":
lef_path = home_path + "/design/lib"
elif baseflow == "Openroad":
lef_path = ""
return lef_path
def getRptPath(design):
"""
get the reports directory
"""
return os.path.join(design.result_dir, design.top_name, design.lib_name, "reports/")
def getObjPath(design):
"""
get the objects directory
"""
return os.path.join(design.result_dir, design.top_name, design.lib_name, "objects/")
def getScriptPath(design):
"""
get the scripts directory
"""
return os.path.join(design.result_dir, design.top_name, design.lib_name, "scripts/")
def getRunPath(design):
"""
get the working directory
"""
return os.path.join(design.result_dir, design.top_name, design.lib_name, "run/")
def createMMMC(design, path):
"""
Create a mmmc file according to the design
"""
mmmc = open(path, mode='w')
mmmc.write("create_library_set -name %s -timing {%s}\n" % (design.lib_name, design.liberty_input))
mmmc.write("create_rc_corner -name default_rc_corner -preRoute_res {1.0} -preRoute_cap {1.0} -preRoute_clkres {0.0} -preRoute_clkcap {0.0} -postRoute_res {1.0} -postRoute_cap {1.0} -postRoute_xcap {1.0} -postRoute_clkres {0.0} -postRoute_clkcap {0.0}\n")
mmmc.write("create_delay_corner -name default_delay_corner -library_set {%s} -rc_corner {default_rc_corner}\n" % design.lib_name)
mmmc.write("create_constraint_mode -name common -sdc_files {%s}\n" % os.path.join(getObjPath(design), design.top_name + ".sdc"))
mmmc.write("create_analysis_view -name default_view_hold -constraint_mode {common} -delay_corner {default_delay_corner}\n")
mmmc.write("create_analysis_view -name default_view_setup -constraint_mode {common} -delay_corner {default_delay_corner}\n")
mmmc.write("set_analysis_view -setup {default_view_setup} -hold {default_view_hold}\n")
mmmc.close()
def parseTimingRpt(timing_rpt_path):
"""
Args:
timing_rpt_path: path/to/timing_synth.rpt
Return:
critical path in form (start-point, end-point)
"""
timing_rpt = open(timing_rpt_path, mode='r')
lines = timing_rpt.readlines()
lines.reverse()
start, end = None, None
for line in lines:
line = line.strip()
if "End-point" in line:
fields = line.split()
end = fields[-1]
elif "Start-point" in line:
fields = line.split()
start = fields[-1]
break
timing_rpt.close()
return (start, end)
def printWelcome():
content = """\
=======================================================
Cocoon
- An Infrastructure for Integrated EDA -
by PKU-DASYS
======================================================="""
print(content)