doom13 0 February 20, 2020 Posted February 20, 2020 · Report post Приветствую. Возможно ли при открытии проекта в Vivado запустить TCL скрипт. Хочу, чтоб при при открытии проекта переменная PWD указывала на директорию проекта (без привязки к конкретной директории и ПК). Quote Share this post Link to post Share on other sites More sharing options...
Nick_K 0 February 20, 2020 Posted February 20, 2020 · Report post Очень сомневаюсь, хотя хуками может и можно где-то вклинится. Вопрос зачем? Если Вы работаете в IDEшной консоли - то можно единожды перейти куда нужно и никаких проблем. Если же вопрос в запускаемых скриптах, тогда можно вместо абсолютного пути делать что-то подобное: [get_property directory [current_project]]/переходить_куда_нужно/и_дальше Quote Share this post Link to post Share on other sites More sharing options...
doom13 0 February 20, 2020 Posted February 20, 2020 · Report post Вопрос в скриптах. Нужно опцию tcl.pre с относительным путём прописать. Quote Share this post Link to post Share on other sites More sharing options...
RobFPGA 10 February 20, 2020 Posted February 20, 2020 · Report post Приветствую! 13 minutes ago, doom13 said: Возможно ли при открытии проекта в Vivado запустить TCL скрипт. Когда именно вы хотите запускать скрипт? При выполнении какого действия? Вы можете добавить любые свои процедуры и хуки в Vivado_init.tcl и соответственно менять поведение стандартных команд Vivado добавляя блек-джек и шлю...развлечения - например: ### proc hook_proc {name hook_name} { if {[llength [namespace which {${name}_}]]==0} { rename ::${name} ::${name}_ rename ${hook_name} ::${name} } } ### proc hook_open_project args { puts "Hook of open_project" # processing input options for {set i 0} {$i < [llength $args]} {incr i} { set option [string trim [lindex $args $i]] switch -regexp -- $option { "-part" { incr i } "-read_only" { } "-quiet" { } "-verbose" { } default { # is incorrect switch specified? if { [regexp {^-} $option] } { send_msg_id Vivado-projutils-001 ERROR "Unknown option '$option', please type 'open_project -help' for usage info.\n" return } set prj_file [file normalize $option] } } } set prj_dir [file dirname $prj_file] set ::env(PWD) $prj_dir ... uplevel 1 ::open_project_ $args } ... hook_proc "open_project" "hook_open_project" ... Успехов! Rob. Quote Share this post Link to post Share on other sites More sharing options...
doom13 0 February 20, 2020 Posted February 20, 2020 · Report post 4 minutes ago, RobFPGA said: Когда именно вы хотите запускать скрипт? При выполнении какого действия? Перед стартом синтеза, скрипт должен сгенерить константы для контроля версии. 4 minutes ago, RobFPGA said: Вы можете добавить любые свои процедуры и хуки в Vivado_init.tcl Я попробовал добавить, но всё не так просто) cd [get_property directory [current_project]] Quote Share this post Link to post Share on other sites More sharing options...
RobFPGA 10 February 20, 2020 Posted February 20, 2020 · Report post Приветствую! 6 minutes ago, doom13 said: Перед стартом синтеза, скрипт должен сгенерить константы для контроля версии. Если скрипт часть проекта то лучше привязываться к положению файла скрипта # .../PRJ_ROOT/some_soure_dir/tcl/script.tcl ... set SCRIPT_DIR [file dirname [info script]] set PRJ_DIR [file normalize "${SCRIPT_DIR}/../../.."] ... Удачи! Rob. Quote Share this post Link to post Share on other sites More sharing options...
doom13 0 February 20, 2020 Posted February 20, 2020 · Report post 56 minutes ago, RobFPGA said: например Оно должно работать? Выдаёт ошибки. Quote Share this post Link to post Share on other sites More sharing options...
RobFPGA 10 February 20, 2020 Posted February 20, 2020 · Report post Приветствую! Just now, doom13 said: Оно должно работать? Выдаёт ошибки. Конечно должно! - я целых пять минут придумывал это Что за ошибки? Может что забыл "придумать". Удачи! Rob. Quote Share this post Link to post Share on other sites More sharing options...
doom13 0 February 20, 2020 Posted February 20, 2020 · Report post Форматирование какое-то видно было неправильное, ещё раз скопировал - не ругается. Но значение pwd не изменилось, на дефолтную директорию ссылается. Quote Share this post Link to post Share on other sites More sharing options...
RobFPGA 10 February 20, 2020 Posted February 20, 2020 · Report post Приветствую! 11 minutes ago, doom13 said: Но значение pwd не изменилось, на дефолтную директорию ссылается. Вы наверное в другом окне cmd проверяете? А там другой enviroment чем тот в котором Vivado запустилась В контексте Vivado переменная PWD есть так как она добавлена после копирования enviroment из запускающего процесса. посмотрите в TCL консоле - parray ::env Удачи! Rob. Quote Share this post Link to post Share on other sites More sharing options...
Nick_K 0 February 20, 2020 Posted February 20, 2020 · Report post 8 minutes ago, doom13 said: Форматирование какое-то видно было неправильное, ещё раз скопировал - не ругается. Там есть непечатный символ - я уже попадался на этом скрипте от уважаемого Роба 9 minutes ago, doom13 said: Но значение pwd не изменилось, на дефолтную директорию ссылается. Оно и не должно ругаться. Вы просто указываете относительный путь для скрипта, а дальше он сам разгребает Quote Share this post Link to post Share on other sites More sharing options...
doom13 0 February 20, 2020 Posted February 20, 2020 · Report post 7 minutes ago, Nick_K said: Там есть непечатный символ - я уже попадался на этом скрипте от уважаемого Роба Так он же целых пять минут сочинялся) set_param xicom.use_bitstream_version_check false puts "Script is processing" ### proc hook_proc {name hook_name} { if {[llength [namespace which {${name}_}]]==0} { rename ::${name} ::${name}_ rename ${hook_name} ::${name} } } ### proc hook_open_project args { puts "Hook of open_project" # processing input options for {set i 0} {$i < [llength $args]} {incr i} { set option [string trim [lindex $args $i]] switch -regexp -- $option { "-part" { incr i } "-read_only" { } "-quiet" { } "-verbose" { } default { # is incorrect switch specified? if { [regexp {^-} $option] } { send_msg_id Vivado-projutils-001 ERROR "Unknown option '$option', please type 'open_project -help' for usage info.\n" return } set prj_file [file normalize $option] } } } set prj_dir [file dirname $prj_file] set ::env(PWD) $prj_dir uplevel 1 ::open_project_ $args puts "Script is done!!!" } hook_proc "open_project" "hook_open_project" Пытаюсь разобраться, как оно работает, получаю лог *** Running vivado with args -log xczu9eg.vds -m64 -product Vivado -mode batch -messageDb vivado.pb -notrace -source xczu9eg.tcl ****** Vivado v2018.2 (64-bit) **** SW Build 2258646 on Thu Jun 14 20:02:38 MDT 2018 **** IP Build 2256618 on Thu Jun 14 22:10:49 MDT 2018 ** Copyright 1986-2018 Xilinx, Inc. All Rights Reserved. Sourcing tcl script '/home/andrei/Programs/Xilinx/Vivado/2018.2/scripts/Vivado_init.tcl' Script is processing source xczu9eg.tcl -notrace WARNING: [Common 17-1361] You have specified a new message control rule that is equivalent to an existing rule with attributes ' -ruleid {11} -id {[BD 41-1271]} -suppress '. The existing rule will be replaced. WARNING: [Common 17-1361] You have specified a new message control rule that is equivalent to an existing rule with attributes ' -ruleid {10} -id {[BD 41-1306]} -suppress '. The existing rule will be replaced. WARNING: [Common 17-1361] You have specified a new message control rule that is equivalent to an existing rule with attributes ' -ruleid {3} -id {[BD 41-1271]} -suppress '. The existing rule will be replaced. WARNING: [Common 17-1361] You have specified a new message control rule that is equivalent to an existing rule with attributes ' -ruleid {4} -id {[BD 41-1306]} -suppress '. The existing rule will be replaced. WARNING: [Common 17-1361] You have specified a new message control rule that is equivalent to an existing rule with attributes ' -ruleid {5} -id {[BD 41-1271]} -suppress '. The existing rule will be replaced. WARNING: [Common 17-1361] You have specified a new message control rule that is equivalent to an existing rule with attributes ' -ruleid {7} -id {[BD 41-1271]} -suppress '. The existing rule will be replaced. WARNING: [Common 17-1361] You have specified a new message control rule that is equivalent to an existing rule with attributes ' -ruleid {6} -id {[BD 41-1306]} -suppress '. The existing rule will be replaced. add_files: Time (s): cpu = 00:00:07 ; elapsed = 00:00:07 . Memory (MB): peak = 2551.223 ; gain = 920.449 ; free physical = 1915 ; free virtual = 11697 Command: synth_design -top xczu9eg -part xczu9eg-ffvb1156-2-i Starting synth_design Attempting to get a license for feature 'Synthesis' and/or device 'xczu9eg' INFO: [Common 17-349] Got license for feature 'Synthesis' and/or device 'xczu9eg' INFO: Launching helper process for spawning children vivado processes INFO: Helper process launched with PID 1454 Что-то не так? hook_proc не вызывался 15 minutes ago, RobFPGA said: В контексте Vivado переменная PWD есть так как она добавлена после копирования enviroment из запускающего процесса. посмотрите в TCL консоле - parray ::env Да, есть такое, спасибо. Quote Share this post Link to post Share on other sites More sharing options...
RobFPGA 10 February 20, 2020 Posted February 20, 2020 · Report post Приветствую! 9 minutes ago, Nick_K said: Там есть непечатный символ Символ это упакованный архив непечатных слов которые распаковываются пользователем скрипта Коэффициент сжатия оху... Удачи! Rob. Quote Share this post Link to post Share on other sites More sharing options...
doom13 0 February 20, 2020 Posted February 20, 2020 · Report post Как из настроек проекта теперь достучаться к ::env(PWD), чтоб стартануть свой скрипт из папки проекта? Quote Share this post Link to post Share on other sites More sharing options...
RobFPGA 10 February 20, 2020 Posted February 20, 2020 · Report post Приветствую! 15 minutes ago, doom13 said: Starting synth_desig Ну так вы писали про добавление PWD при open_project а тут выполняется synth_design. Это как бы разные команды и разные процессы! Чем Vivado и сбивает с толку. Попробуйте добавить в hook_synth_design ... set top_run [current_run -synthesis] set top_fset [get_property SRCSET $top_run ] set top_name [get_property TOP $top_fset] puts ">> synth_design: current_project property ..." puts "[report_property -return_string [current_project]]\n" puts ">> synth_design: current_run property ..." puts "[report_property -return_string $top_run]\n" puts ">> synth_design: current_fileset property ..." puts "[report_property -return_string $top_fset]\n" ... 2 minutes ago, doom13 said: Как из настроек проекта теперь достучаться к ::env(PWD), чтоб стартануть свой скрипт из папки проекта? Проще всего указать скрипт в STEPS.SYNTH_DESIGN.TCL.PRE, а в самом скрипте привязываться к его же расположению в дереве проекта как я приводил выше. Удачи! Rob. Quote Share this post Link to post Share on other sites More sharing options...