Skip to content

Commit 8d02a92

Browse files
authored
Merge pull request #1231 from Pinata-Consulting/makefile-do-copy-like-do-step
Makefile do copy like do step
2 parents d349afa + ae08103 commit 8d02a92

File tree

2 files changed

+63
-26
lines changed

2 files changed

+63
-26
lines changed

flow/Makefile

Lines changed: 62 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,18 @@ UNSET_AND_MAKE = @bash -c 'for var in $(UNSET_VARIABLES_NAMES); do unset $$var;
450450
#
451451
# A "do-synth" step would be welcomed, but it isn't strictly necessary
452452
# for the Bazel use-case.
453+
#
454+
# do-floorplan, do-place, do-cts, do-route, do-finish are the
455+
# supported interface to execute those stages without checking
456+
# for dependencies.
457+
#
458+
# The do- substeps of each of these stages are subject to change.
459+
#
460+
# $(1) stem, e.g. 2_1_floorplan
461+
# $(2) dependencies
462+
# $(3) tcl script step
463+
# $(4) extension of result, default .odb
464+
# $(5) folder of target, default $(RESULTS_DIR)
453465
define do-step
454466
$(if $(5),$(5),$(RESULTS_DIR))/$(1)$(if $(4),$(4),.odb): $(2)
455467
$$(UNSET_AND_MAKE) do-$(1)
@@ -459,6 +471,25 @@ do-$(1):
459471
($(TIME_CMD) $(OPENROAD_CMD) $(SCRIPTS_DIR)/$(3).tcl -metrics $(LOG_DIR)/$(1).json) 2>&1 | tee $(LOG_DIR)/$(1).log
460472
endef
461473

474+
# generate make rules to copy a file, if a dependency change and
475+
# a do- sibling rule that copies the file unconditionally.
476+
#
477+
# The file is copied within the $(RESULTS_DIR)
478+
#
479+
# $(1) stem of target, e.g. 2_2_floorplan_io
480+
# $(2) basename of file to be copied
481+
# $(3) further dependencies
482+
# $(4) target extension, default .odb
483+
define do-copy
484+
$(RESULTS_DIR)/$(1)$(if $(4),$(4),.odb): $(RESULTS_DIR)/$(2) $(3)
485+
$$(UNSET_AND_MAKE) do-$(1)$(if $(4),$(4),)
486+
487+
.PHONY: do-$(1)$(if $(4),$(4),)
488+
do-$(1)$(if $(4),$(4),):
489+
cp $(RESULTS_DIR)/$(2) $(RESULTS_DIR)/$(1)$(if $(4),$(4),.odb)
490+
endef
491+
492+
462493
# STEP 1: Translate verilog to odb
463494
#-------------------------------------------------------------------------------
464495
$(eval $(call do-step,2_1_floorplan,$(RESULTS_DIR)/1_synth.v $(RESULTS_DIR)/1_synth.sdc $(TECH_LEF) $(SC_LEF) $(ADDITIONAL_LEFS) $(FOOTPRINT) $(SIG_MAP_FILE) $(FOOTPRINT_TCL),floorplan))
@@ -468,18 +499,15 @@ $(eval $(call do-step,2_1_floorplan,$(RESULTS_DIR)/1_synth.v $(RESULTS_DIR)/1_sy
468499
ifndef IS_CHIP
469500
$(eval $(call do-step,2_2_floorplan_io,$(RESULTS_DIR)/2_1_floorplan.odb $(IO_CONSTRAINTS),io_placement_random))
470501
else
471-
$(RESULTS_DIR)/2_2_floorplan_io.odb: $(RESULTS_DIR)/2_1_floorplan.odb $(IO_CONSTRAINTS)
472-
cp $< $@
502+
$(eval $(call do-copy,2_2_floorplan_io,2_1_floorplan.odb,$(IO_CONSTRAINTS)))
473503
endif
474504

475505
# STEP 3: Timing Driven Mixed Sized Placement
476506
#-------------------------------------------------------------------------------
477507
ifeq ($(MACRO_PLACEMENT),)
478508
$(eval $(call do-step,2_3_floorplan_tdms,$(RESULTS_DIR)/2_2_floorplan_io.odb $(RESULTS_DIR)/1_synth.v $(RESULTS_DIR)/1_synth.sdc $(LIB_FILES),tdms_place))
479509
else
480-
$(RESULTS_DIR)/2_3_floorplan_tdms.odb: $(RESULTS_DIR)/2_2_floorplan_io.odb $(RESULTS_DIR)/1_synth.v $(RESULTS_DIR)/1_synth.sdc $(LIB_FILES)
481-
$(info [INFO][FLOW] Using manual macro placement file $(MACRO_PLACEMENT))
482-
cp $< $@
510+
$(eval $(call do-copy,2_3_floorplan_tdms,2_2_floorplan_io.odb,$(RESULTS_DIR)/1_synth.v $(RESULTS_DIR)/1_synth.sdc $(LIB_FILES)))
483511
endif
484512

485513
# STEP 4: Macro Placement
@@ -494,11 +522,13 @@ $(eval $(call do-step,2_5_floorplan_tapcell,$(RESULTS_DIR)/2_4_floorplan_macro.o
494522
#-------------------------------------------------------------------------------
495523
$(eval $(call do-step,2_6_floorplan_pdn,$(RESULTS_DIR)/2_5_floorplan_tapcell.odb $(PDN_TCL),pdn))
496524

497-
$(RESULTS_DIR)/2_floorplan.odb: $(RESULTS_DIR)/2_6_floorplan_pdn.odb
498-
cp $< $@
525+
$(eval $(call do-copy,2_floorplan,2_6_floorplan_pdn.odb,))
499526

500527
$(RESULTS_DIR)/2_floorplan.sdc: $(RESULTS_DIR)/2_1_floorplan.odb
501528

529+
.PHONY: do-floorplan
530+
do-floorplan:
531+
$(UNSET_AND_MAKE) do-2_1_floorplan do-2_2_floorplan_io do-2_3_floorplan_tdms do-2_4_floorplan_macro do-2_5_floorplan_tapcell do-2_6_floorplan_pdn do-2_floorplan
502532

503533
.PHONY: clean_floorplan
504534
clean_floorplan:
@@ -526,8 +556,7 @@ $(eval $(call do-step,3_1_place_gp_skip_io,$(RESULTS_DIR)/2_floorplan.odb $(RESU
526556
ifndef IS_CHIP
527557
$(eval $(call do-step,3_2_place_iop,$(RESULTS_DIR)/3_1_place_gp_skip_io.odb $(IO_CONSTRAINTS),io_placement))
528558
else
529-
$(RESULTS_DIR)/3_2_place_iop.odb: $(RESULTS_DIR)/3_1_place_gp_skip_io.odb $(IO_CONSTRAINTS)
530-
cp $< $@
559+
$(eval $(call do-copy,3_2_place_iop,3_1_place_gp_skip_io.odb,$(IO_CONSTRAINTS)))
531560
endif
532561

533562
# STEP 3: Global placement with placed IOs, timing-driven, and routability-driven.
@@ -546,11 +575,13 @@ clean_resize:
546575
#-------------------------------------------------------------------------------
547576
$(eval $(call do-step,3_5_place_dp,$(RESULTS_DIR)/3_4_place_resized.odb,detail_place))
548577

549-
$(RESULTS_DIR)/3_place.odb: $(RESULTS_DIR)/3_5_place_dp.odb
550-
cp $< $@
578+
$(eval $(call do-copy,3_place,3_5_place_dp.odb,))
551579

552-
$(RESULTS_DIR)/3_place.sdc: $(RESULTS_DIR)/2_floorplan.sdc
553-
cp $< $@
580+
$(eval $(call do-copy,3_place,2_floorplan.sdc,,.sdc))
581+
582+
.PHONY: do-place
583+
do-place:
584+
$(UNSET_AND_MAKE) do-3_1_place_gp_skip_io do-3_2_place_iop do-3_3_place_gp do-3_4_place_resized do-3_5_place_dp do-3_place do-3_place.sdc
554585

555586
# Clean Targets
556587
#-------------------------------------------------------------------------------
@@ -585,8 +616,11 @@ $(eval $(call do-step,4_2_cts_fillcell,$(RESULTS_DIR)/4_1_cts.odb,fillcell))
585616

586617
$(RESULTS_DIR)/4_cts.sdc: $(RESULTS_DIR)/4_cts.odb
587618

588-
$(RESULTS_DIR)/4_cts.odb: $(RESULTS_DIR)/4_2_cts_fillcell.odb
589-
cp $< $@
619+
$(eval $(call do-copy,4_cts,4_2_cts_fillcell.odb))
620+
621+
.PHONY: do-cts
622+
do-cts:
623+
$(UNSET_AND_MAKE) do-4_1_cts do-4_2_cts_fillcell do-4_cts
590624

591625
.PHONY: clean_cts
592626
clean_cts:
@@ -620,11 +654,13 @@ else
620654
$(eval $(call do-step,5_2_route,$(RESULTS_DIR)/4_cts.odb,detail_route))
621655
endif
622656

623-
$(RESULTS_DIR)/5_route.odb: $(RESULTS_DIR)/5_2_route.odb
624-
cp $< $@
657+
$(eval $(call do-copy,5_route,5_2_route.odb))
625658

626-
$(RESULTS_DIR)/5_route.sdc: $(RESULTS_DIR)/4_cts.sdc
627-
cp $< $@
659+
$(eval $(call do-copy,5_route,4_cts.sdc,,.sdc))
660+
661+
.PHONY: do-route
662+
do-route:
663+
$(UNSET_AND_MAKE) do-5_1_grt do-5_2_route do-5_route do-5_route.sdc
628664

629665
$(RESULTS_DIR)/5_route.v:
630666
@export OR_DB=5_route ;\
@@ -680,20 +716,21 @@ elapsed:
680716
ifneq ($(USE_FILL),)
681717
$(eval $(call do-step,6_1_fill,$(RESULTS_DIR)/5_route.odb $(FILL_CONFIG),density_fill))
682718
else
683-
$(RESULTS_DIR)/6_1_fill.odb: $(RESULTS_DIR)/5_route.odb
684-
cp $< $@
719+
$(eval $(call do-copy,6_1_fill,5_route.odb))
685720
endif
686721

687-
$(RESULTS_DIR)/6_1_fill.sdc: $(RESULTS_DIR)/5_route.sdc
688-
cp $< $@
722+
$(eval $(call do-copy,6_1_fill,5_route.sdc,,.sdc))
689723

690-
$(RESULTS_DIR)/6_final.sdc: $(RESULTS_DIR)/5_route.sdc
691-
cp $< $@
724+
$(eval $(call do-copy,6_final,5_route.sdc,,.sdc))
692725

693726
$(eval $(call do-step,6_report,$(RESULTS_DIR)/6_1_fill.odb $(RESULTS_DIR)/6_1_fill.sdc,final_report,.log,$(LOG_DIR)))
694727

695728
$(RESULTS_DIR)/6_final.def: $(LOG_DIR)/6_report.log
696729

730+
# NOTE! No GDS file for now
731+
.PHONY: do-finish
732+
do-finish:
733+
$(UNSET_AND_MAKE) do-6_1_fill do-6_1_fill.sdc do-6_final.sdc do-6_report elapsed
697734

698735
# Skipping resize can be useful for mock abstracts
699736
.PHONY: skip_resize

flow/util/generate-vars.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
55
# exclude system and CI variables
66
EXCLUDED_VARS="MAKE|PYTHONPATH|PKG_CONFIG_PATH|PERL5LIB|PCP_DIR|PATH|MANPATH"
77
EXCLUDED_VARS+="|LD_LIBRARY_PATH|INFOPATH|HOME|PWD|MAIL|TIME_CMD|QT_QPA_PLATFORM"
8-
EXCLUDED_VARS+="|do-step|get_variables"
8+
EXCLUDED_VARS+="|do-step|get_variables|do-copy"
99

1010
printf '%s\n' "$ISSUE_VARIABLES" | while read -r V;
1111
do

0 commit comments

Comments
 (0)