Reputation: 25
I have an input file fI as follows :-
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
I want to manipulate this input file and get the output file fO as follows:-
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]
How can i do this in TCL ? Please help .
Upvotes: 0
Views: 147
Reputation: 13282
Assuming that "fI" and "fO" are actual file names:
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
Documentation: append, foreach, if, proc, puts, set, split, string
Upvotes: 1