
#########################################################
#                 2_synthesize_optimize.tcl
#
# Description:  Synthesize and optimize the 
#               DEMO CHIP and generate
#               the Oasys-RTL databases. 
#
# Usage:        source in Oasys-RTL Command prompt
#
# Dependencies: init_design.tcl
#               1_read_design.tcl
#               Launched from Oasys-RTL shell
#
#########################################################


#=======================================================#
#Check Status of Flow and load prior scripts if needed
#=======================================================#
set script_dir [file dirname [info script]]
set ekit_dir   [file dirname ${script_dir}]

#Check if dependent scripts have been loaded
if {![info exists top_module]} {
     source ${script_dir}/init_design.tcl
     source ${script_dir}/1_read_design.tcl
     source ${script_dir}/2_synthesize_optimize.tcl
}

#=======================================================#	
#Perform DFT
#=======================================================#
if {[info exists dft_flow] && [string match $dft_flow tessent]} {
  puts "INFO::Running oasys Tessent DFT flow"
  source scripts_risc_v/oasys_tessent_dft.tcl
  echo "\n-------------------------------------"
  echo "\n Tessent DFT complete"
  echo "\n-------------------------------------\n"
} elseif {[info exists dft_flow] && [string match $dft_flow oasys]} {
  puts "INFO::Running oasys native DFT flow"
  source scripts/oasys_dft.tcl
  report_scan_chains
  echo "\n-------------------------------------"
  echo "\n Oasys DFT complete"
  echo "\n-------------------------------------\n"
} else {
  puts "\nINFO:: 'dft_flow'  variable not set to 'tessent' or 'oasys'."
  puts "       skipping DFT flow. 'source' following script to run DFT"
  puts "       source ${ekit_dir}/scripts/oasys_dft.tcl"
  puts "       source ${ekit_dir}/scripts/oasys_tessent_dft.tcl"
}

#exit
