我想用tcl脚本获取HDL设计器中包含文件的列表。我得到的例子是打印文件列表到日志中并进行更改。我添加全局变量ExpandoObject
并将所有文件名附加到它,但是当执行proc时我的变量是空的。
filenames
如果取消注释行proc walkDependencies {decl} {
global alreadyDone filenames
# Only look at each declaration once.
if {[info exists alreadyDone($decl)]} {
return
}
set alreadyDone($decl) 1
# Only report each file once.
set declFile [$decl file]
if {[info exists alreadyDone($declFile)]} {
set reportFile 0
} else {
set reportFile 1
set alreadyDone($declFile) 1
}
foreach pkg [$decl packages] {
walkDependencies $pkg
}
if {[$decl configure class] eq "architecture"} {
walkDependencies [$decl entity]
foreach inst [$decl instances] {
if {![catch {$inst child} child]} {
walkDependencies $child
}
}
}
set file [$decl file]
set fileType [$file configure type]
if {![regexp {Text$} $fileType]} {
if {[lsearch {symbol blockInterface} $fileType] != -1} {
# This assumes ent+arch are generated to a single file.
set reportFile 0
} else {
set file [$file generated]
}
}
if {$reportFile} {
set lib [$file library]
# Exclude standard and downstreamOnly libraries.
if {[$lib configure type] eq "regular"} {
# puts "[$lib configure hardHdlDir]/[$file configure relativePathname]"
set tmp "[$lib configure hardHdlDir]/[$file configure relativePathname]"
lappend $filenames $tmp
}
}
if {[$decl configure class] eq "packageHeader"} {
walkDependencies [$decl body]
}
}
set filenames
catch {unset alreadyDone}
set lib [library open Travers_lib]
walkDependencies [$lib declaration Travers_top struct]
foreach i $filenames {
puts $i
}
,所有包含的文件将被打印到日志中。
答案 0 :(得分:2)
您的问题很可能是您正在使用
lappend $filenames $tmp
表示您将tmp
的值附加到名称等于filenames
值的局部变量。尝试
lappend filenames $tmp
代替。
文档: lappend