-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathengine.py
More file actions
134 lines (109 loc) · 6.4 KB
/
Copy pathengine.py
File metadata and controls
134 lines (109 loc) · 6.4 KB
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
import subprocess
import os
import util
import ops.cds.syn as syn
import ops.cds.floorplan as fp
import ops.cds.pdn as pdn
import ops.cds.place as place
import ops.cds.cts as cts
import ops.cds.route as route
import ops.cds.drc as drc
import time
def run(design, flow, flow_name):
begin_t = time.time()
design_name = design.top_name
run_path = util.getRunPath(design)
# print(run_path)
os.system("mkdir -p %s && rm -rf %s*" % (run_path, run_path))
make_file = open(os.path.join(run_path, "Makefile"), "w")
tcl_path = util.getScriptPath(design)
os.system("mkdir -p %s && rm -rf %s*" % (tcl_path, tcl_path))
overall_tcl = open(os.path.join(tcl_path, "flow.tcl"), 'w', encoding='utf-8')
obj_path = util.getObjPath(design)
os.system("mkdir -p %s && rm -rf %s*" % (obj_path, obj_path))
os.system(f"cp {design.rtl_input} {obj_path}")
rpt_path = util.getRptPath(design)
os.system("mkdir -p %s && rm -rf %s*" % (rpt_path, rpt_path))
for x in flow.ops:
if x[0] == "GenusSynth":
script_path = "../scripts/"
tmp_op_syn = syn.GenusSynth(design)
tmp_op_syn.config(design_name + "_" + x[1])
output = "\n" if flow.verbose else f" > {os.path.join(rpt_path, 'GenusSynth.log')}\n"
make_file.write("all:\n")
make_file.write("\tgenus -legacy_ui -batch -files " + script_path + design_name + "_" + x[1] + ".tcl" + output)
if x[0] == "yosys":
script_path = "../scripts/"
tmp_op_syn = syn.YosysSynth(design)
tmp_op_syn.config(design_name + "_" + x[1], flow)
make_file.write("all:\n")
yosys_path = os.path.join(flow.yosys_bin_path, "yosys")
save_log = f" | tee -a {os.path.join(rpt_path, 'yosys.log')}\n" if flow.verbose else f" > {os.path.join(rpt_path, 'YosysSynth.log')}\n"
make_file.write(f"\t{yosys_path} " + script_path + design_name + "_" + x[1] + ".ys" + save_log)
if x[0] == "InnovusFloorplan":
tmp_op_fp = fp.InnovusFloorplan(design)
for key, val in flow.params_fp.items():
tmp_op_fp.setParams(key, val)
tmp_op_fp.config(design, design_name + "_" + x[1])
overall_tcl.write('source %s%s_to_floorplan.tcl\n'%(tcl_path, design_name))
if x[0] == "InnovusPDN":
tmp_op_pdn = pdn.InnovusPDN(design)
tmp_op_pdn.config(design, design_name + "_" + x[1])
overall_tcl.write('source %s%s_to_pdn.tcl\n'%(tcl_path, design_name))
if x[0] == "InnovusPlace":
tmp_op_pdn = place.InnovusPlace(design)
tmp_op_pdn.params['cadence_version'] = flow.cadence_version
tmp_op_pdn.config(design, design_name + "_" + x[1])
overall_tcl.write('source %s%s_to_place.tcl\n'%(tcl_path, design_name))
if x[0] == "DREAMPlace":
tmp_op_place = place.DREAMPlace(design)
tmp_op_place.config(design, design_name + "_" + x[1])
if x[0] == "InnovusCTS":
tmp_op_cts = cts.InnovusCTS(design)
tmp_op_cts.config(design, design_name + "_" + x[1])
overall_tcl.write('source %s%s_to_cts.tcl\n'%(tcl_path, design_name))
if x[0] == "InnovusRoute":
tmp_op_route = route.InnovusRoute(design)
for key, val in flow.params_route.items():
tmp_op_route.setParams(key, val)
tmp_op_route.paramsExtern['cadence_version'] = flow.cadence_version
tmp_op_route.config(design, design_name + "_" + x[1])
overall_tcl.write('source %s%s_to_route.tcl\n'%(tcl_path, design_name))
# overall_tcl.write('set dbgLefDefOutVersion 5.8\ndefOut -floorplan -netlist -routing %s.def\n'%(design_name))
if x[0] == "InnovusDRC":
tmp_op_drc = drc.InnovusDRC(design)
tmp_op_drc.config(design, design_name + "_" + x[1])
overall_tcl.write('source %s%s_to_drc.tcl\n'%(tcl_path, design_name))
if flow.flow['placement'] == "innovus":
output = "\n" if flow.verbose else f" > {os.path.join(rpt_path, 'innovus.log')}\n"
make_file.write("\tinnovus -batch -files " + script_path + "flow.tcl" + output)
elif flow.flow['placement'] == "dreamplace":
output = "\n" if flow.verbose else f" > {os.path.join(rpt_path, 'innovus_fp.log')}\n"
make_file.write("\tinnovus -batch -files " + script_path + ("%s_to_floorplan.tcl" % design_name) + output)
save_log = f" | tee -a {os.path.join(rpt_path, 'dreamplace.log')}\n" if flow.verbose else f" > {os.path.join(rpt_path, 'dreamplace.log')}\n"
make_file.write("\tpython %s %s" % (flow.dreamplace_bin_path, script_path + "%s_to_place.json" % design_name) + save_log)
output = "\n" if flow.verbose else f" > {os.path.join(rpt_path, 'innovus_route.log')}\n"
make_file.write("\tinnovus -batch -files " + script_path + ("%s_to_route.tcl" % design_name) + output)
make_file.close()
overall_tcl.close()
run_path = util.getRunPath(design)
print("Current working directory: %s" % run_path)
proc_make = subprocess.Popen('make', cwd=run_path) # Start a child process
proc_make.wait() # Wait until the process finishes
assert proc_make.poll() == 0, "The flow [%s] failed and the process finished abnormally" % flow_name
print("The basic flow has finished successfully!")
print(f"Design is saved to {run_path}{design.top_name}\n\n")
# Iterative Feedback Tuning
if flow.n_iter_IFT > 0:
for i in range(flow.n_iter_IFT):
print("========== Start of the IFT iteration %d ==========\n" % (i+1))
rpt_path = tmp_op_syn.getRptTiming()
critical_path = util.parseTimingRpt(rpt_path)
tmp_op_syn = syn.GenusSynth(design, critical_path)
tmp_op_syn.config(design_name + "_" + "to_synth")
proc_make = subprocess.Popen('make', cwd=run_path) # Start a child process
proc_make.wait() # Wait until the process finishes
assert proc_make.poll() == 0, "The flow failed and the process finished abnormally"
print(f"========== Finish IFT round [{i+1}] ==========\n")
end_t = time.time()
print("*************** Flow [{}] finishes in {:.1f} seconds ***************\n".format(flow_name, end_t - begin_t))