How to call Tcl command with conditional option

拥有回忆 提交于 2019-12-11 21:02:30

问题


I want to conditionally append options when calling a Tcl command. I'm using a Xilinx Tcl command synth_design as indicated in UG835 p.1042 using Tcl version 8.5.

For instance, I want to:

  1. build a data structure that will append 0 or more of -verilog_define MACRO where -verilog_define is not a string but an option, and
  2. pass that structure to the command in its expanded form.

Where this:

synth_design -top ${top}_top -part ${part} -verilog_define MACRO1 -verilog_define MACRO2
                                           ^-------------------------------------------^

Becomes this:

synth_design -top ${top}_top -part ${part} ???
                                           ^-^

回答1:


With {*}$makro (expansion)

E.g.:

set makro {-verilog_define MACRO1 -verilog_define MACRO2}
synth_design -top ${top}_top -part ${part} {*}$makro


来源:https://stackoverflow.com/questions/26169533/how-to-call-tcl-command-with-conditional-option

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!