我有一个输入文件fI如下: -
accent {a1} {Z} ;# net:n1551 , little:big
accent {a2} {C} ;# net:n1536 , little:big
accent {a3} {Z} ;# net:n1552 , little:big
accent {a4} {C} ;# net:n1537 , little:big
我想操作此输入文件并按如下方式获取输出文件: -
accord [get_pins c1/a1/Z] [get_nets c1/n1551]
accord [get_pins c1/a2/C] [get_nets c1/n1536]
accord [get_pins c2/a3/Z] [get_nets c2/n1552]
accord [get_pins c2/a4/C] [get_nets c2/n1537]
我怎样才能在TCL中这样做?请帮忙 。
答案 0 :(得分:1)
假设" fI"和" fO"是实际的文件名:
set fi [open fI]
set fo [open fO w]
set module {}
while {[chan gets $fi line] >= 0} {
if {[string is space $line]} continue
switch -- [lindex $line 0] {
module {set module [lindex $line 1]}
accent {
if {[regexp {{(\w+)}.+{(\w+)}.+:(\w+) ,} $line -> a b c]} {
chan puts $fo "accord \[get_pins $module/$a/$b] \[get_nets $module/$c]"
}
}
}
}
chan close $fi
chan close $fo