################################# Parameters ############################
#
set DESIGN         {.ReplaceProjectName}
set NETLIST_NAME   {.ReplaceProjectName.ReplaceInputExtension}
set FMT_OP         -format
set NETLIST_FORMAT "EDIF"
set FLAVOR_OP      -edif_flavor
set NETLIST_FLAVOR "GENERIC"
set GCF_FORMAT     "gcf"
set PDC_FORMAT     "pdc"
set SDC_FORMAT     "sdc"		
set MERGE_OP       -merge
set MERGE_PHYSICAL -merge_physical
set MERGE_TIMING   -merge_timing
set MERGE_FLAG_NO  "no"
set MERGE_FLAG_YES "yes"	
set DESIGNFILE     ".ReplaceProjectName.ReplaceACTELDesignerDBExt"
#
#########################################################################

#
# Open Existing Design
#
if { [catch { open_design $DESIGNFILE } ] } {
    error "Unable to open design : $DESIGNFILE"
}

#
# Import EDIF Netlist(s) And ACTEL .SDC / .GCF / .PDC Constraint File(s)
#
if [file exists .ReplaceProjectName_MacroFiles.tcl] {
    # Load all child EDIF files, the top level EDIF file & the .SDC / .GCF file(s) if exists
    source [file join ".ReplaceProjectName_MacroFiles.tcl"];
} else {
    # Load only one EDIF file and the .GCF file if exists
    if [file exists .ReplaceProjectName.gcf] && [file exists .ReplaceProjectName.sdc] {
        import_source $FMT_OP $NETLIST_FORMAT $FLAVOR_OP $NETLIST_FLAVOR "$NETLIST_NAME" \
                      $FMT_OP $SDC_FORMAT                           ".ReplaceProjectName.sdc"
                      $FMT_OP $GCF_FORMAT $MERGE_OP  $MERGE_FLAG_NO ".ReplaceProjectName.gcf"
    } else if [file exists .ReplaceProjectName.pdc] && [file exists .ReplaceProjectName.sdc] {
        import_source $FMT_OP $NETLIST_FORMAT $FLAVOR_OP $NETLIST_FLAVOR "$NETLIST_NAME" \
                      $FMT_OP $SDC_FORMAT                           ".ReplaceProjectName.sdc"
                      $FMT_OP $PDC_FORMAT $MERGE_OP  $MERGE_FLAG_NO ".ReplaceProjectName.pdc"
    } else if [file exists .ReplaceProjectName.gcf] && [!file exists .ReplaceProjectName.sdc] {
        import_source $FMT_OP $NETLIST_FORMAT $FLAVOR_OP $NETLIST_FLAVOR "$NETLIST_NAME" \
                      $FMT_OP $GCF_FORMAT $MERGE_OP  $MERGE_FLAG_NO ".ReplaceProjectName.gcf"
    } else if [file exists .ReplaceProjectName.pdc] && [!file exists .ReplaceProjectName.sdc] {
        import_source $FMT_OP $NETLIST_FORMAT $FLAVOR_OP $NETLIST_FLAVOR "$NETLIST_NAME" \
                      $FMT_OP $PDC_FORMAT $MERGE_OP  $MERGE_FLAG_NO ".ReplaceProjectName.pdc"
    } else if [!file exists .ReplaceProjectName.gcf] && [file exists .ReplaceProjectName.sdc] {
        import_source $FMT_OP $NETLIST_FORMAT $FLAVOR_OP $NETLIST_FLAVOR "$NETLIST_NAME" \
                      $FMT_OP $SDC_FORMAT                           ".ReplaceProjectName.sdc"
    } else {
        import_source $FMT_OP $NETLIST_FORMAT $FLAVOR_OP $NETLIST_FLAVOR "$NETLIST_NAME"
    }
}

set isNetImported [ is_design_state_complete .ReplaceNetImportedState]
if { $isNetImported == 0 } {
    error "Unable to load EDIF netlist $NETLIST_NAME"
}

#
# Compile Design
#
if { [catch { compile -pdc_abort_on_error ".ReplaceAbortOnConstraintError" } ] } {
    error "Unable to compile design : $DESIGNFILE"
}

set isCompiled [is_design_state_complete .ReplaceDesignCompiledState]
if { $isCompiled == 0 } {
    error "Unable to compile design : $DESIGNFILE"
} else {
    save_design $DESIGNFILE
    #
    # Save Design
    #
}

#
# Output status Report
#
report -type status "$DESIGN.map.rpt"
 
#
# Close Design
#
close_design

return 0
# end of file .ReplaceTCLScriptName
