【问题标题】:How to pass arguments to tcl script in Vivado GUI tcl console如何在 Vivado GUI tcl 控制台中将参数传递给 tcl 脚本
【发布时间】:2016-08-29 09:12:19
【问题描述】:

我正在尝试在 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 之前设置 argv 和 argc?
  • @haggai_e,谢谢。现在可以了。

标签: tcl vivado


【解决方案1】:

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

您可能还需要将argv0 设置为脚本。一些程序希望在非交互模式下运行时出现这种情况。

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-09
    • 1970-01-01
    • 2015-03-19
    相关资源
    最近更新 更多