最近一直在调试TCL脚本,然后再eda软件自带的控制台上运行,请大家看看下面一些代码:
set re [split [read [open line.txt r]]]
set b [llength [split [read [open line.txt r]]]]
set a [expr $b-1]
set res [open scri.txt r]
while { [gets $res line] >= 0 } {
while { $a >= 0 } {
if [regexp [eval set pattern {.*\\[lindex $re $a]$}] $line] {
set s [open a.txt a]
puts $s "$line"
flush $s
incr a -1
}
}
}
close $a
这段代码很简单,但是在modelsim的控制台上意运行就死机,不清楚是为了什么?
set re [split [read [open line.txt r]]]
set b [llength [split [read [open line.txt r]]]]
set a [expr $b-1]
set res [open scri.txt r]
while { [gets $res line] >= 0 } {
while { $a >= 0 } {
if [regexp [eval set pattern {.*\\[lindex $re $a]$}] $line] {
set s [open a.txt a]
puts $s "$line"
flush $s
}
incr a -1
#这是控制循环的变量,放到IF中,有可能造成死循环
}
}
close $a