diff --git a/scripts/write_project_tcl_git.tcl b/scripts/write_project_tcl_git.tcl index eb1f68f..708178e 100644 --- a/scripts/write_project_tcl_git.tcl +++ b/scripts/write_project_tcl_git.tcl @@ -62,6 +62,7 @@ proc write_project_tcl_git {args} { # [-dump_project_info]: Write object values # [-use_bd_files ]: Use BD sources directly instead of writing out procs to create them # [-internal]: Print basic header information in the generated tcl script + # [-quiet]: Execute the command quietly, returning no messages from the command. # file: Name of the tcl script file to generate # Return Value: @@ -114,15 +115,25 @@ proc write_project_tcl_git {args} { } } } + # suppress all messages if -quiet flag is provided + if { $a_global_vars(b_arg_quiet) } { + suppress_messages + } # script file is a must if { [string equal $a_global_vars(script_file) ""] } { + if { $a_global_vars(b_arg_quiet) } { + reset_msg_setting + } send_msg_id Vivado-projutils-002 ERROR "Missing value for option 'file', please type 'write_project_tcl -help' for usage info.\n" return } # should not be a directory if { [file isdirectory $a_global_vars(script_file)] } { + if { $a_global_vars(b_arg_quiet) } { + reset_msg_setting + } send_msg_id Vivado-projutils-003 ERROR "The specified filename is a directory ($a_global_vars(script_file)), please type 'write_project_tcl -help' for usage info.\n" return } @@ -137,12 +148,18 @@ proc write_project_tcl_git {args} { set file_path [file dirname $a_global_vars(script_file)] if { ! [file exists $file_path] } { set script_filename [file tail $a_global_vars(script_file)] + if { $a_global_vars(b_arg_quiet) } { + reset_msg_setting + } send_msg_id Vivado-projutils-013 ERROR "Directory in which file ${script_filename} is to be written does not exist \[$a_global_vars(script_file)\]\n" return } # recommend -force if file exists if { [file exists $a_global_vars(script_file)] && !$a_global_vars(b_arg_force) } { + if { $a_global_vars(b_arg_quiet) } { + reset_msg_setting + } send_msg_id Vivado-projutils-004 ERROR "Tcl Script '$a_global_vars(script_file)' already exist. Use -force option to overwrite.\n" return } @@ -151,6 +168,9 @@ proc write_project_tcl_git {args} { # -no_copy_sources cannot be used without -use_bd_files if { $a_global_vars(b_arg_no_copy_srcs) && !$a_global_vars(b_arg_use_bd_files) } { + if { $a_global_vars(b_arg_quiet) } { + reset_msg_setting + } send_msg_id Vivado-projutils-019 ERROR "This design contains BD sources. The option -no_copy_sources cannot be used without -use_bd_files.\ Please remove -no_copy_sources if you wish to write out BD's as procs in the project tcl, otherwise add the option -use_bd_files to directly\ include the *.bd files to the new project \n" @@ -162,6 +182,9 @@ proc write_project_tcl_git {args} { # now write if {[write_project_tcl_script]} { + if { $a_global_vars(b_arg_quiet) } { + reset_msg_setting + } return } } @@ -224,6 +247,7 @@ proc reset_global_vars {} { set a_global_vars(dp_fh) 0 set a_global_vars(def_val_fh) 0 set a_global_vars(script_file) "" + set a_global_vars(b_arg_quiet) 0 if { [get_param project.enableMergedProjTcl] } { set a_global_vars(b_arg_use_bd_files) 0 @@ -286,6 +310,9 @@ proc write_project_tcl_script {} { # output file script handle set file $a_global_vars(script_file) if {[catch {open $file w} a_global_vars(fh)]} { + if { $a_global_vars(b_arg_quiet) } { + reset_msg_setting + } send_msg_id Vivado-projutils-005 ERROR "failed to open file for write ($file)\n" return 1 } @@ -294,6 +321,9 @@ proc write_project_tcl_script {} { if { $a_global_vars(b_arg_dump_proj_info) } { set dump_file [file normalize [file join $a_global_vars(s_path_to_script_dir) ${proj_name}_dump.txt]] if {[catch {open $dump_file w} a_global_vars(dp_fh)]} { + if { $a_global_vars(b_arg_quiet) } { + reset_msg_setting + } send_msg_id Vivado-projutils-006 ERROR "failed to open file for write ($dump_file)\n" return 1 } @@ -301,6 +331,9 @@ proc write_project_tcl_script {} { # default value output file script handle set def_val_file [file normalize [file join $a_global_vars(s_path_to_script_dir) ${proj_name}_def_val.txt]] if {[catch {open $def_val_file w} a_global_vars(def_val_fh)]} { + if { $a_global_vars(b_arg_quiet) } { + reset_msg_setting + } send_msg_id Vivado-projutils-007 ERROR "failed to open file for write ($file)\n" return 1 } @@ -353,6 +386,7 @@ proc write_project_tcl_script {} { set script_filename [file tail $file] set out_dir [file dirname [file normalize $file]] + if { !$a_global_vars(b_arg_quiet) } { send_msg_id Vivado-projutils-008 INFO "Tcl script '$script_filename' generated in output directory '$out_dir'\n\n" if { $a_global_vars(b_absolute_path) } { @@ -371,7 +405,11 @@ proc write_project_tcl_script {} { send_msg_id Vivado-projutils-015 INFO "The file paths for the project source files were set relative to the location of the generated script.\n" } } - + } + + if { $a_global_vars(b_arg_quiet) } { + reset_msg_setting + } reset_global_vars return 0 @@ -409,7 +447,7 @@ proc wr_create_project { proj_dir name part_name } { lappend l_script_data "variable script_file" lappend l_script_data "set script_file \"[file tail $a_global_vars(script_file)]\"\n" lappend l_script_data "# Help information for this script" - lappend l_script_data "proc help \{\} \{" + lappend l_script_data "proc print_help \{\} \{" lappend l_script_data " variable script_file" lappend l_script_data " puts \"\\nDescription:\"" lappend l_script_data " puts \"Recreate a Vivado project from this script. The created project will be\"" @@ -448,7 +486,7 @@ proc wr_create_project { proj_dir name part_name } { lappend l_script_data " switch -regexp -- \$option \{" lappend l_script_data " \"--origin_dir\" \{ incr i; set origin_dir \[lindex \$::argv \$i\] \}" lappend l_script_data " \"--project_name\" \{ incr i; set _xil_proj_name_ \[lindex \$::argv \$i\] \}" - lappend l_script_data " \"--help\" \{ help \}" + lappend l_script_data " \"--help\" \{ print_help \}" lappend l_script_data " default \{" lappend l_script_data " if \{ \[regexp \{^-\} \$option\] \} \{" lappend l_script_data " puts \"ERROR: Unknown option '\$option' specified, please type '\$script_file -tclargs --help' for usage info.\\n\"" @@ -502,15 +540,6 @@ proc wr_create_project { proj_dir name part_name } { lappend l_script_data "set proj_dir \[get_property directory \[current_project\]\]" lappend l_script_data "" - lappend l_script_data "# Reconstruct message rules" - - set msg_control_rules [ debug::get_msg_control_rules -as_tcl ] - if { [string length $msg_control_rules] > 0 } { - lappend l_script_data "${msg_control_rules}" - } else { - lappend l_script_data "# None" - } - lappend l_script_data "" } proc wr_project_properties { proj_dir proj_name } { @@ -544,6 +573,7 @@ proc write_bd_as_proc { bd_file } { # Argument: BD file # Return Value: None + variable a_global_vars variable l_added_bds variable l_bd_proc_calls variable l_script_data @@ -575,7 +605,7 @@ proc write_bd_as_proc { bd_file } { incr temp_offset } set temp_bd_file [file join $temp_dir "temp_$temp_offset.tcl"] - write_bd_tcl -no_project_wrapper -make_local $temp_bd_file + write_bd_tcl -no_project_wrapper -make_local -include_layout $temp_bd_file # Set non default properties for the BD wr_bd_properties $bd_file @@ -587,6 +617,9 @@ proc write_bd_as_proc { bd_file } { # Get proc call if {[catch {open $temp_bd_file r} fp]} { + if { $a_global_vars(b_arg_quiet) } { + reset_msg_setting + } send_msg_id Vivado-projutils-020 ERROR "failed to write out proc for $bd_file \n" return 1 } @@ -703,6 +736,9 @@ proc wr_bd {} { set is_locked [get_property IS_LOCKED [get_files [list "$bd_file"] ] ] if { $is_locked == 1 } { file delete $a_global_vars(script_file) + if { $a_global_vars(b_arg_quiet) } { + reset_msg_setting + } send_msg_id Vivado-projutils-018 ERROR "Project tcl cannot be written as the design contains one or more \ locked/out-of-date design(s). Please run report_ip_status and update the design.\n" return 1 @@ -998,7 +1034,7 @@ proc filter { prop val { file {} } } { } # filter sim_types - if { [string equal -nocase $prop {sim_types}] } { + if { ([string equal -nocase $prop {allowed_sim_models}]) || ([string equal -nocase $prop {preferred_sim_model}]) } { return 1 } @@ -1077,7 +1113,7 @@ proc write_properties { prop_info_list get_what tcl_obj {delim "#"} } { } else { # comment "is_readonly" project property if { [string equal $get_what "get_projects"] && [string equal "$name" "is_readonly"] } { - if { ! $a_global_vars(b_arg_all_props) } { + if { ! $a_global_vars(b_arg_all_props) && !$a_global_vars(b_arg_quiet) } { send_msg_id Vivado-projutils-012 INFO "The current project is in 'read_only' state. The generated script will create a writable project." } continue @@ -1144,7 +1180,7 @@ proc write_props { proj_dir proj_name get_what tcl_obj type {delim "#"}} { set tcl_obj [ list "$tcl_obj"] } if { [string first " " $get_what 0] != -1 } { - # For cases where get_what is multiple workds like "get_gadgets -of_object..." + # For cases where get_what is multiple workds like "get_dashboard_gadgets -of_object..." set current_obj [ eval $get_what $tcl_obj] } else { set current_obj [$get_what $tcl_obj] @@ -2405,24 +2441,11 @@ proc wr_dashboards { proj_dir proj_name } { # get all dash boards # For each dash boards # create dash board - variable l_script_data - - set dashboardsExist 0 - set dashboards [get_dashboards] - foreach db $dashboards { - write_specified_dashboard $proj_dir $proj_name $db - set dashboardsExist 1 - } - if { $dashboardsExist == 0} { - return - } + write_specified_dashboard $proj_dir $proj_name - set currentDashboard [current_dashboard] - lappend l_script_data "# Set current dashboard to '$currentDashboard' " - lappend l_script_data "current_dashboard $currentDashboard " } -proc write_specified_gadget { proj_dir proj_name gadget dashboard} { +proc write_specified_gadget { proj_dir proj_name gadget } { # Summary: write the specified gadget # This helper command is used to script help. # Argument Usage: @@ -2430,26 +2453,24 @@ proc write_specified_gadget { proj_dir proj_name gadget dashboard} { # none variable l_script_data - set db_name [get_property name [get_dashboards $dashboard]] - - set gadgetName [get_property name [get_gadgets -of_objects [get_dashboards $db_name] $gadget]] - set gadgetType [get_property type [get_gadgets -of_objects [get_dashboards $db_name] $gadget]] + set gadgetName [get_property name [get_dashboard_gadgets [list "$gadget"]]] + set gadgetType [get_property type [get_dashboard_gadgets [list "$gadget"]]] - set cmd_str "create_gadget -name {$gadgetName} -type $gadgetType -dashboard $dashboard" + set cmd_str "create_dashboard_gadget -name {$gadgetName} -type $gadgetType" lappend l_script_data "# Create '$gadgetName' gadget (if not found)" - lappend l_script_data "if \{\[string equal \[get_gadgets -of_objects \[get_dashboards $db_name\] $gadget \] \"\"\]\} \{" + lappend l_script_data "if \{\[string equal \[get_dashboard_gadgets \[ list \"$gadget\" \] \] \"\"\]\} \{" lappend l_script_data "$cmd_str" lappend l_script_data "\}" - lappend l_script_data "set obj \[get_gadgets -of_objects \[get_dashboards $db_name\] $gadget \]" - set tcl_obj [get_gadgets -of_objects [get_dashboards $db_name] $gadget ] - set get_what "get_gadgets -of_objects \[get_dashboards $db_name\]" + lappend l_script_data "set obj \[get_dashboard_gadgets \[ list \"$gadget\" \] \]" + set tcl_obj [get_dashboard_gadgets [list "$gadget"] ] + set get_what "get_dashboard_gadgets " write_props $proj_dir $proj_name $get_what $tcl_obj "gadget" "$" } -proc write_specified_dashboard { proj_dir proj_name dashboard } { +proc write_specified_dashboard { proj_dir proj_name } { # Summary: write the specified dashboard # This helper command is used to script help. # Argument Usage: @@ -2457,33 +2478,43 @@ proc write_specified_dashboard { proj_dir proj_name dashboard } { # none variable l_script_data - set get_what "get_dashboards" - - set dashboardName [get_property name [$get_what $dashboard]] - - lappend l_script_data "set obj \[$get_what $dashboard\]" - write_props $proj_dir $proj_name $get_what $dashboard "dashboard" + #Create map of gadgets wrt to their position, so that gadget position can be restored. + set gadgetPositionMap [dict create] ##get gadgets of this dashboard - set gadgets [get_gadgets -of_objects [$get_what $dashboard]] + set gadgets [get_dashboard_gadgets ] foreach gd $gadgets { - write_specified_gadget $proj_dir $proj_name $gd $dashboard + write_specified_gadget $proj_dir $proj_name $gd + set gadgetCol [get_property COL [get_dashboard_gadgets [list "$gd"]]] + set gadgetRow [get_property ROW [get_dashboard_gadgets [list "$gd"]]] + dict set gadgetPositionMap $gadgetCol $gadgetRow $gd } #if current dashboard is "default_dashboard" #check if the above "gadgets" variable has all the default_gadgets, if any default gadget is not there in "gadgets" variable, it means user has deleted those gadgets but as part of create_project, all the default gadgets are created. So we have to delete the gadgets which user has deleted. - set def_db "default_dashboard" - if { [string equal $def_db $dashboard] } { + set default_gadgets {"drc_1" "methodology_1" "power_1" "timing_1" "utilization_1" "utilization_2"} foreach dgd $default_gadgets { #if dgd is not in gadgets, then delete dgd if {$dgd ni $gadgets } { - set cmd_str "delete_gadgets -gadgets $dgd" lappend l_script_data "# Delete the gadget '$dgd' " + lappend l_script_data "if \{\[string equal \[get_dashboard_gadgets \[ list \"$dgd\" \] \] \"$dgd\"\]\} \{" + set cmd_str "delete_dashboard_gadgets -gadgets $dgd" lappend l_script_data "$cmd_str" + lappend l_script_data "\}" } } + + + foreach col [lsort [dict keys $gadgetPositionMap]] { + set rowDict [dict get $gadgetPositionMap $col] + foreach row [lsort [dict keys $rowDict]] { + set gadgetName [dict get $rowDict $row] + set cmd_str "move_dashboard_gadget -name {$gadgetName} -row $row -col $col" + lappend l_script_data "$cmd_str" + } } + } proc wr_prflow { proj_dir proj_name } { @@ -2560,15 +2591,47 @@ proc wr_reconfigModules { proj_dir proj_name } { set reconfigModules [get_reconfig_modules] variable a_global_vars + # associate a bd with rm to be used with write_specified_reconfig_module + set bd_rm_map [dict create] foreach rm $reconfigModules { - if { !$a_global_vars(b_arg_use_bd_files) } { - set rm_bds [get_files -norecurse -quiet -of_objects [get_reconfig_modules $rm] *.bd] - foreach rm_bd $rm_bds { - write_bd_as_proc $rm_bd + set rm_bds [get_files -norecurse -quiet -of_objects [get_reconfig_modules $rm] *.bd] + foreach rm_bd1 $rm_bds { + dict set bd_rm_map $rm_bd1 $rm + } + } + + set done_bds [list] + foreach rm $reconfigModules { + set rm_bds [get_files -norecurse -quiet -of_objects [get_reconfig_modules $rm] *.bd] + # get the dependent bd for a rm and process it first, this is required for 2RP support + set rm_bd_dep [lindex [get_files -references -quiet -of_objects [get_reconfig_modules $rm] *.bd] 0] + if {[llength $rm_bd_dep] == 1} { + if {$rm_bd ni $done_bds} { + if { !$a_global_vars(b_arg_use_bd_files) } { + write_bd_as_proc $rm_bd_dep + } + set rm1 [dict get $bd_rm_map $rm_bd_dep] + write_specified_reconfig_module $proj_dir $proj_name $rm1 + lappend done_bds $rm_bd_dep } } - write_specified_reconfig_module $proj_dir $proj_name $rm + foreach rm_bd $rm_bds { + # process bd only if it has not already been processed + if {$rm_bd ni $done_bds} { + if { !$a_global_vars(b_arg_use_bd_files) } { + write_bd_as_proc $rm_bd + } + set rm1 [dict get $bd_rm_map $rm_bd] + write_specified_reconfig_module $proj_dir $proj_name $rm1 + lappend done_bds $rm_bd + } + } + + # when no RM BDs are present + if {[llength $rm_bds] == 0} { + write_specified_reconfig_module $proj_dir $proj_name $rm + } } } @@ -3019,4 +3082,32 @@ proc write_report_props { report } { write_properties $prop_info_list "get_report_configs" $report } + +proc suppress_messages {} { + variable levels_to_suppress + set levels_to_suppress { {STATUS} {INFO} {WARNING} {CRITICAL WARNING} } + set msg_rules [split [ debug::get_msg_control_rules -as_tcl ] \n] + foreach line $msg_rules { + set idx_suppress [lsearch $line "-suppress"] + if { $idx_suppress >= 0 } { + set idx_severity [lsearch $line "-severity"] + if { $idx_suppress == $idx_severity + 2 } { + set lvl_idx [ lsearch $levels_to_suppress [lindex $line $idx_suppress-1 ] ] + if { $lvl_idx >= 0 } { + set levels_to_suppress [ lreplace $levels_to_suppress $lvl_idx $lvl_idx] + } + } + } + } + foreach level $levels_to_suppress { + set_msg_config -quiet -suppress -severity $level + } +} + +proc reset_msg_setting {} { + variable levels_to_suppress + foreach level $levels_to_suppress { + reset_msg_config -quiet -suppress -severity $level + } +} }