Merge branch 'develop' into develop_openroadapp
diff --git a/docker_build/docker/openroad_flow/Dockerfile b/docker_build/docker/openroad_flow/Dockerfile
index 657cc2a..20d2917 100644
--- a/docker_build/docker/openroad_flow/Dockerfile
+++ b/docker_build/docker/openroad_flow/Dockerfile
@@ -44,11 +44,12 @@
 
 RUN yum install -y http://opensource.wandisco.com/centos/6/git/x86_64/wandisco-git-release-6-1.noarch.rpm
 RUN yum install -y git 
-#RUN git clone --recursive --branch  gf14_alpha2.1 https://github.com/kareefardi/OpenROAD-1
+RUN ls
+#RUN git clone --recursive --branch debug https://github.com/kareefardi/OpenROAD-1
 #WORKDIR /OpenROAD-1/
 RUN git clone --recursive https://github.com/The-OpenROAD-Project/OpenROAD
 WORKDIR /OpenROAD/
-RUN git checkout eec88b45b938e8cff79d7701311546d9f7a49523
+#RUN git checkout eec88b45b938e8cff79d7701311546d9f7a49523
 
 # Build
 RUN mkdir build && mkdir -p /build/version && mkdir install
diff --git a/docker_build/tar/openroad_flow.tar.gz b/docker_build/tar/openroad_flow.tar.gz
index 009ae8b..2ce5c5c 100644
--- a/docker_build/tar/openroad_flow.tar.gz
+++ b/docker_build/tar/openroad_flow.tar.gz
Binary files differ
diff --git a/scripts/openroad/or_fastroute.tcl b/scripts/openroad/or_fastroute.tcl
new file mode 100644
index 0000000..9616f95
--- /dev/null
+++ b/scripts/openroad/or_fastroute.tcl
@@ -0,0 +1,15 @@
+read_lef $::env(MERGED_LEF)
+read_def $::env(CURRENT_DEF)
+FastRoute::set_output_file "$::env(fastroute_tmp_file_tag).guide"
+FastRoute::set_capacity_adjustment $::env(GLB_RT_ADJUSTMENT)
+FastRoute::set_min_layer 1
+FastRoute::set_max_layer $::env(GLB_RT_MAXLAYER)
+#FastRoute::set_layer_adjustment 1 $::env(GLB_RT_LI1_ADJUSTMENT)
+#FastRoute::set_layer_adjustment 2 $::env(GLB_RT_MET1_ADJUSTMENT)
+#FastRoute::set_clock_net_routing true
+#FastRoute::set_pdrev true
+FastRoute::set_verbose 1
+FastRoute::start_fastroute
+FastRoute::run_fastroute
+FastRoute::write_guides
+
diff --git a/scripts/openroad/or_opendp.tcl b/scripts/openroad/or_opendp.tcl
new file mode 100644
index 0000000..ca5b329
--- /dev/null
+++ b/scripts/openroad/or_opendp.tcl
@@ -0,0 +1,6 @@
+read_lef $::env(MERGED_LEF)
+read_def $::env(CURRENT_DEF)
+
+legalize_placement
+
+write_def $::env(SAVE_DEF)
diff --git a/scripts/openroad/or_replace.tcl b/scripts/openroad/or_replace.tcl
new file mode 100644
index 0000000..8a8c925
--- /dev/null
+++ b/scripts/openroad/or_replace.tcl
@@ -0,0 +1,36 @@
+
+replace_external rep
+
+rep set_verbose_level 3
+# rep set_plot_enable true
+rep set_density $::env(PL_TARGET_DENSITY)
+
+read_lef $::env(MERGED_LEF)
+read_def $::env(CURRENT_DEF)
+
+if { $::env(PL_TIME_DRIVEN) } {
+	rep set_timing_driven true
+	rep import_lib $::env(PL_LIB)
+	rep import_sdc ./scripts/base.sdc
+	rep import_verilog $::env(yosys_result_file_tag).v
+}
+
+
+rep set_seed_init_enable true
+rep init_replace
+rep place_cell_nesterov_place
+# rep print_instances
+
+write_def $::env(SAVE_DEF)
+
+set hpwl [rep get_hpwl]
+exec echo $hpwl >> $::env(replaceio_report_file_tag)_hpwl.rpt
+
+if { $::env(PL_TIME_DRIVEN) } {
+	set wns [rep get_wns]
+	set tns [rep get_tns]
+	puts "TNS after placement $tns"
+	puts "WNS after placement $wns"
+	exec echo $wns >> $::env(replaceio_report_file_tag)_wns.rpt
+	exec echo $tns >> $::env(replaceio_report_file_tag)_tns.rpt
+}
diff --git a/scripts/openroad/or_tapcell.tcl b/scripts/openroad/or_tapcell.tcl
new file mode 100644
index 0000000..23b78cf
--- /dev/null
+++ b/scripts/openroad/or_tapcell.tcl
@@ -0,0 +1,7 @@
+read_lef $::env(MERGED_LEF)
+read_def $::env(CURRENT_DEF)
+
+tapcell -endcap_cpp "1" -distance [expr $::env(FP_TAPCELL_DIST) * 2] -tapcell_master "$::env(FP_WELLTAP_CELL)" -endcap_master "$::env(FP_ENDCAP_CELL)"
+
+write_def $::env(SAVE_DEF)
+
diff --git a/scripts/tcl_commands/floorplan.tcl b/scripts/tcl_commands/floorplan.tcl
index c9b62ec..ab6af1d 100644
--- a/scripts/tcl_commands/floorplan.tcl
+++ b/scripts/tcl_commands/floorplan.tcl
@@ -39,6 +39,8 @@
 	TIMER::timer_stop
 	exec echo "[TIMER::get_runtime]" >> $::env(verilog2def_log_file_tag)_runtime.txt
 	set_def $::env(verilog2def_tmp_file_tag).def
+	#try_catch openroad_debug -exit $::env(SCRIPTS_DIR)/or_init_fp.tcl |& tee $::env(TERMINAL_OUTPUT) $::env(verilog2def_tmp_file_tag)_openroad.log
+	#exit
 }
 
 proc place_io {args} {
@@ -60,16 +62,18 @@
 }
 
 proc tap_decap {args} {
-	try_catch cp $::env(CURRENT_DEF) $::env(tapcell_result_file_tag).def
+	#try_catch cp $::env(CURRENT_DEF) $::env(tapcell_result_file_tag).def
 	TIMER::timer_start
-	try_catch tapcell -lef $::env(MERGED_LEF) \
-		-def $::env(tapcell_result_file_tag).def \
-		-rule [expr $::env(FP_TAPCELL_DIST) * 2] \
-		-welltap $::env(FP_WELLTAP_CELL) \
-		-endcap $::env(FP_ENDCAP_CELL) \
-		-outdef $::env(tapcell_result_file_tag).def \
-		|& tee $::env(TERMINAL_OUTPUT) $::env(tapcell_log_file_tag).log
-	TIMER::timer_stop
+#	try_catch tapcell -lef $::env(MERGED_LEF) \
+#		-def $::env(tapcell_result_file_tag).def \
+#		-rule [expr $::env(FP_TAPCELL_DIST) * 2] \
+#		-welltap $::env(FP_WELLTAP_CELL) \
+#		-endcap $::env(FP_ENDCAP_CELL) \
+#		-outdef $::env(tapcell_result_file_tag).def \
+#		|& tee $::env(TERMINAL_OUTPUT) $::env(tapcell_log_file_tag).log
+#	TIMER::timer_stop
+	set ::env(SAVE_DEF) $::env(tapcell_result_file_tag).def
+	try_catch openroad -exit $::env(SCRIPTS_DIR)/openroad/or_tapcell.tcl |& tee $::env(TERMINAL_OUTPUT) $::env(tapcell_log_file_tag).log
 	exec echo "[TIMER::get_runtime]" >> $::env(tapcell_log_file_tag)_runtime.txt
 	set_def $::env(tapcell_result_file_tag).def
 }
diff --git a/scripts/tcl_commands/placement.tcl b/scripts/tcl_commands/placement.tcl
index 6dc513d..ba9f5b5 100644
--- a/scripts/tcl_commands/placement.tcl
+++ b/scripts/tcl_commands/placement.tcl
@@ -1,7 +1,7 @@
 proc global_placement {args} {
 	TIMER::timer_start
 	#for {set i 0} {$i < $::env(PL_IO_ITER)} {incr i} {
-	try_catch replace < $::env(SCRIPTS_DIR)/replace_gp.tcl |& tee $::env(TERMINAL_OUTPUT) $::env(replaceio_log_file_tag).log
+	#try_catch replace < $::env(SCRIPTS_DIR)/replace_gp.tcl |& tee $::env(TERMINAL_OUTPUT) $::env(replaceio_log_file_tag).log
 
 		#try_catch mv $::env(replaceio_tmp_file_tag)_io.def $::env(replaceio_tmp_file_tag)_io_$i.def
 
@@ -17,27 +17,35 @@
 
 		#try_catch cp $::env(replaceio_tmp_file_tag)_place.def $::env(replaceio_tmp_file_tag)_place_$i.def
 	#}
-	try_catch cp $::env(replaceio_tmp_file_tag)_place.def $::env(replaceio_tmp_file_tag).def
+	#try_catch cp $::env(replaceio_tmp_file_tag)_place.def $::env(replaceio_tmp_file_tag).def
+	set ::env(SAVE_DEF) $::env(replaceio_tmp_file_tag)_openroad.def
+	try_catch openroad -exit $::env(SCRIPTS_DIR)/openroad/or_replace.tcl |& tee $::env(TERMINAL_OUTPUT) $::env(replaceio_log_file_tag)_openroad.log
 	TIMER::timer_stop
 	exec echo "[TIMER::get_runtime]" >> $::env(replaceio_log_file_tag)_runtime.txt
-	set_def $::env(replaceio_tmp_file_tag).def
+	set_def $::env(SAVE_DEF)
+	
+	#try_catch openroad -exit $::env(SCRIPTS_DIR)/replace_gp.tcl |& tee $::env(TERMINAL_OUTPUT) $::env(replaceio_log_file_tag)_openroad.log
+	#set_def $::env(replaceio_tmp_file_tag).def
 
 }
 
 proc detailed_placement {args} {
 	TIMER::timer_start
-	try_catch opendp \
-		-lef $::env(MERGED_LEF) \
-		-def $::env(CURRENT_DEF) \
-		-output_def $::env(opendp_result_file_tag).def \
-		|& tee $::env(TERMINAL_OUTPUT) $::env(opendp_log_file_tag).log
+#	try_catch opendp \
+#		-lef $::env(MERGED_LEF) \
+#		-def $::env(CURRENT_DEF) \
+#		-output_def $::env(opendp_result_file_tag).def \
+#		|& tee $::env(TERMINAL_OUTPUT) $::env(opendp_log_file_tag).log
+	
+	set ::env(SAVE_DEF) $::env(opendp_result_file_tag)_openroad.def
+	try_catch openroad -exit $::env(SCRIPTS_DIR)/openroad/or_opendp.tcl |& tee $::env(TERMINAL_OUTPUT) $::env(opendp_log_file_tag)_openroad.log
 	TIMER::timer_stop
 	exec echo "[TIMER::get_runtime]" >> $::env(opendp_log_file_tag)_runtime.txt
 	if {![catch {eval exec grep -q "FAIL" $::env(opendp_log_file_tag).log}]}  {
 		puts "Error: Check $::env(opendp_log_file_tag).log"
 		exit 1
 	}
-	set_def $::env(opendp_result_file_tag).def 
+	set_def $::env(SAVE_DEF)
 }
 
 proc run_placement {args} {
diff --git a/scripts/tcl_commands/routing.tcl b/scripts/tcl_commands/routing.tcl
index 1adc238..d2701b5 100644
--- a/scripts/tcl_commands/routing.tcl
+++ b/scripts/tcl_commands/routing.tcl
@@ -1,17 +1,18 @@
 proc global_routing {args} {
 	TIMER::timer_start
-	if {$::env(GLB_RT_OLD_FR)} {
-		try_catch envsubst < $::env(SCRIPTS_DIR)/fastroute.rsyn > $::env(fastroute_tmp_file_tag).rsyn
-		try_catch FRlefdef_old \
-			--no-gui \
-			--script $::env(fastroute_tmp_file_tag).rsyn \
-			|& tee $::env(TERMINAL_OUTPUT) $::env(fastroute_log_file_tag).log
-	} else {
-		try_catch envsubst < $::env(SCRIPTS_DIR)/fastroute.tcl > $::env(fastroute_tmp_file_tag).tcl
-		cd $::env(OPENLANE_ROOT)/etc
-		try_catch FastRoute -c 1 < $::env(fastroute_tmp_file_tag).tcl \
-			|& tee $::env(TERMINAL_OUTPUT) $::env(fastroute_log_file_tag).log
-	}
+#	if {$::env(GLB_RT_OLD_FR)} {
+#		try_catch envsubst < $::env(SCRIPTS_DIR)/fastroute.rsyn > $::env(fastroute_tmp_file_tag).rsyn
+#		try_catch FRlefdef_old \
+#			--no-gui \
+#			--script $::env(fastroute_tmp_file_tag).rsyn \
+#			|& tee $::env(TERMINAL_OUTPUT) $::env(fastroute_log_file_tag).log
+#	} else {
+#		try_catch envsubst < $::env(SCRIPTS_DIR)/fastroute.tcl > $::env(fastroute_tmp_file_tag).tcl
+#		cd $::env(OPENLANE_ROOT)/etc
+#		try_catch FastRoute -c 1 < $::env(fastroute_tmp_file_tag).tcl \
+#			|& tee $::env(TERMINAL_OUTPUT) $::env(fastroute_log_file_tag).log
+#	}
+	try_catch openroad -exit $::env(SCRIPTS_DIR)/openroad/or_fastroute.tcl |& tee $::env(TERMINAL_OUTPUT) $::env(fastroute_log_file_tag)_openroad.log
 	TIMER::timer_stop
 	exec echo "[TIMER::get_runtime]" >> $::env(fastroute_log_file_tag)_runtime.txt
 }