#.........................................# Parameters #................#
#
set DESIGN     {.ReplaceProjectName}
set DESIGNFILE ".ReplaceProjectName.ReplaceACTELDesignerDBExt"
#
#.......................................................................#

#
# Open Existing Design
#
if { [catch { open_design $DESIGNFILE } ] } {
    error "Unable to open design: $DESIGNFILE"
}
 
#
# Run Place & Route Command
#
# -standard or -timing_driven
set placement_type -.ReplacePlacementType 
set place          -place
set placeon        "ON"
set route          -route
set routeon        "ON"

if [string equal -nocase PA .ReplaceFamilyName] {
	if [ catch {layout $placement_type $place $placeon $route $routeon } ] {
	  error "Unable to place & route design"
	}
} else {
	if [ catch {layout $placement_type $place $placeon $route $routeon -placer_high_effort ".ReplaceExtraEffort" } ] {
    error "Unable to place & route design"
  }
}

set isLayoutDone [is_design_state_complete .ReplaceLayoutDoneState]
if { $isLayoutDone == 0 } {
    error "Unable to place & route design"
}

set isBackannotateDone [is_design_state_complete .ReplaceBackannotateDoneState]
if { $isBackannotateDone == 0 } {
    # Backannotate if not done yet
    set SDFFILENAME "$DESIGN.ba"
    if { [ catch { backannotate -name $SDFFILENAME  -format "SDF" -language "VHDL93" -netlist } ] } {
        error "Unable to backannotate design : $DESIGNFILE"
    }
    puts "Backannotation successful for design : $DESIGNFILE"
}
 
report -type "status" "$DESIGN.fit.rpt"

#
# Save Design
#
save_design $DESIGNFILE

#
# Dump PIN Report
#
report -type "pin" -listby "name" $DESIGN.pin.rpt

#
# Close Design
#
close_design

return 0
# end of file .ReplaceTCLScriptName
