set top [lindex $argv 0]
set part [lindex $argv 1]
set generics [lindex $argv 2]

set_part $part

set_msg_config -id {[Synth 8-7080]} -new_severity "INFO"
set_msg_config -id {[Synth 8-3917]} -new_severity "INFO"
set_msg_config -id {[Netlist 29-101]} -new_severity "INFO"
set_msg_config -id {[Vivado 12-13650]} -new_severity "INFO"
set_msg_config -id {[Coretcl 2-176]} -new_severity "INFO"
set_msg_config -id {[Coretcl 2-1042]} -new_severity "INFO"

read_vhdl -vhdl2008 [glob vhdl/*.vhd]
read_vhdl -vhdl2008 [glob vhdl/support/*.vhd]
# -library Moku
set mems [glob -nocomplain vhdl/*.mem]
foreach mem $mems {
    read_mem $mem
}

set ip_xcis [glob -nocomplain ip/*/*.xci*]
foreach xci $ip_xcis {
    read_ip $xci
}

set_property top $top [current_fileset]
set_property top_lib xil_defaultlib [current_fileset]
set_property top_file $top.vhd [current_fileset]
set_property generic $generics [current_fileset]

read_xdc [glob constraints/*.xdc]

reorder_files -auto

# save_project -force project

if {[llength [get_ips]]} {
    upgrade_ip [get_ips]
    synth_ip [get_ips]
}

synth_design -mode out_of_context \
             -assert \
             -bufg 0 \
             -flatten_hierarchy rebuilt

write_checkpoint -force synth.dcp
