This TCL code I wrote to fetch pin details and compare with layer and rect
proc fileinput {filename} {
set filedata [open $filename r]
set file1 [ read $filedata ]
close $filedata
set pindata [dict create]
foreach line [split $file1 \n] {
if {[string match "*PIN*" $line]} {
set pin [lindex $line 1]
}
if {[string match "*LAYER*" $line]} {
set layer [lindex $line 1]
dict lappend pindata $pin layer $layer
}
if {[string match *RECT* $line]} {
set rect [lindex $line 1 4]
dict lappend pindata $pin rect $rect
}
}
return $pindata
}
set pin_data1 [fileinput osi_hbmp_top_briscm_1.txt]
set pin_data2 [fileinput osi_hbmp_top_briscm_2.txt]
#last block
foreach pin_name [dict keys $pin_data1] {
set layer1 [dict get $pin_data1 $pin_name layer]
set layer2 [dict get $pin_data2 $pin_name layer]
if {$layer1 != $layer2} {
puts "pin not match"
} else {
puts $pin_name
}
}
In this code, I am getting an error at the last code block. The two files contain the same format of data and some pin names are different. When it compares with two files it will throw an error. i_hbmc_ieee1500_wsi_san this pin is present on only the first file there no such pin is on the second file. may I know what wrong I did in the code? please highlight my mistake:) The error that I got is:-
key "i_hbmc_ieee1500_wsi_san" not known in dictionary
while executing
"dict get $pin_data2 $pin_name layer"
("foreach" body line 3)
invoked from within
"foreach pin_name [dict keys $pin_data1] {
set layer1 [dict get $pin_data1 $pin_name layer]
set layer2 [dict get $pin_data2 $pin_name lay..."
(file "aa.tcl" line 26)
for reference, The format of the file (indentation is present in the file)
PIN i_hbmc_ieee1500_sel_wir
DIRECTION INPUT ;
USE SIGNAL ;
PORT
LAYER K3 ;
RECT 2090.163000 3265.856000 2090.476000 3265.920000 ;
END
END i_hbmc_ieee1500_sel_wir
PIN i_hbmc_ieee1500_cap_wr
DIRECTION INPUT ;
USE SIGNAL ;
PORT
LAYER K3 ;
RECT 2090.163000 3265.984000 2090.476000 3266.048000 ;
END
END i_hbmc_ieee1500_cap_wr
PIN i_hbmc_ieee1500_shft_wr
DIRECTION INPUT ;
USE SIGNAL ;
PORT
LAYER K3 ;
RECT 2090.163000 3265.728000 2090.476000 3265.792000 ;
END
END i_hbmc_ieee1500_shft_wr