# Generate FPGA Array Data
#run_tool -name GENERATEPROGRAMMINGDATA
run_tool_wrapper "run_tool -name GENERATEPROGRAMMINGDATA"

                  
# Configure and generate Design Initialization Data and Memories
# The following can be configured:
#   - Design initialization source - sNVM/uPROM/SPI-Flash
#   - sNVM user clients
#   - uPROM user clients
#   - Fabric RAM initialization content
#   - SPI-Flash user clients
# Examples TBD
#
# Example for configuring user snvm clients 
# Note that if using relative path, the path to the mem file specified in the SNVM.cfg file is relative to the libero *.prjx file. So please adjust the path according to the project location and where the SNVM.cfg and mem files are located. 
#configure_snvm -cfg_file {../snvm/SNVM.cfg} 

configure_ram -cfg_file {./src/cfg/Ethernet_OAM_EC.cfg}

configure_design_initialization_data \
-second_stage_start_address {0x00000000} \
-third_stage_snvm_start_address {0x00000000} \
-third_stage_spi_start_address {0x00000400} \
-third_stage_spi_type {SPIFLASH_NO_BINDING_PLAINTEXT} \
-third_stage_spi_clock_divider {6} \
-init_timeout 128 \
-auto_calib_timeout {3000} \
-broadcast_RAMs {1}

generate_design_initialization_data

# Jason Weng Add it to distinguish 1G/10G/SFP , 1G=0x11 , 10G=0x22, SFP=0x33 
configure_tool -name {CONFIGURE_PROG_OPTIONS} \
-params {design_version:0} \
-params {back_level_version:0} \
-params {silicon_signature:22}

    
# Configure and generate programming file data
# Examples for configuring the programming files TBD
#run_tool -name GENERATEPROGRAMMINGFILE
run_tool_wrapper "run_tool -name GENERATEPROGRAMMINGFILE"

puts "Programmingfile generated successfully\n"
    

# Export Programming Job
# Programming job files can be imported in FlasPro Express standalone for programming the device
export_prog_job \
    -job_file_name {Ethernet_OAM_10G_v2024p2} \
    -export_dir ${PrjLocation}/designer/PF_EVALKIT_TOP/export \
    -bitstream_file_type {TRUSTED_FACILITY} \
    -bitstream_file_components {FABRIC SNVM} \
    -program_design 1 \
    -program_spi_flash 0 \
    -include_plaintext_passkey 0 
	
puts "Exported job file successfully\n"
puts "Full design flow passed execution\n"	
