如何在 Vivado GUI tcl 控制台中将参数传递给 tcl 脚本

How to pass arguments to tcl script in Vivado GUI tcl console

我正在尝试在 Vivado GUI Tcl 控制台中执行一个 tcl 脚本,我的脚本采用一个参数来决定必须配置哪种类型的 运行(synth、impl、bitgen 等)。 我知道,如果脚本在 Vivado 命令行模式下执行,则使用 -tclargs 可以传递参数。类似于:

vivado -mode batch -source <filename> -tclargs <arguments>

我在 Vivado gui 模式下尝试了同样的操作,但出现错误。

ERROR: [Common 17-170] Unknown option '-tclargs', please type 'source -help' for usage info.

运行 'source -help':

Syntax: 
source  [-encoding <arg>] [-notrace] [-quiet] [-verbose] <file>

Usage: 
  Name         Description
  ------------------------
  [-encoding]  specify the encoding of the data stored in filename
  [-notrace]   disable tracing of sourced commands
  [-quiet]     Ignore command errors
  [-verbose]   Suspend message limits during command execution
  <file>       script to source

通过查看 -help,我感觉这是不可能的。另外,我找不到这样做的任何文件。我想知道有没有办法实现这个。

source命令没有设置参数;它更像是 C 的 #include 而不是其他任何东西。因此,如果您正在 sourceing 的脚本期望设置 argvargc — 就好像脚本是 运行 作为程序一样 — 那么您应该只set 他们在 source 之前。就 Tcl 而言,它们是普通变量;它们只是碰巧是默认设置的。

您可能还需要为脚本设置 argv0。某些程序期望在非交互模式下 运行ning。

set argv [list "a b c" foo bar 123]
set argc [llength $argv]
set argv0 theScript.tcl
source $argv0