#!/usr/bin/tclsh
#############################
## filter postsim log file ##
#############################
set log_dir "./log"
set file_list [ glob "$log_dir/*.log" ]
set msg_get ""
set reserve_lvl ""
set ignore_type ""
set violation_type ""
set ref_name ""
set ref_time ""
set dat_name ""
set dat_time ""
set su_limit ""
set hd_limit ""
set wd_limit ""
set timing_cell ""
set timing_msg ""
set temp_str ""
foreach file_name $file_list {
set dp [ open $file_name.fix w ]
set fp [ open $file_name r ]
while { [ gets $fp line ] >= 0 } {
if { $msg_get == "enable" } {
### timing messege line
# capture violation_type
regexp {^/s*/$(/w*)/(.*} $line temp_str violation_type
# capture timing messege
if { $violation_type == "setuphold" } {
regexp {^/s+/$/w+/(/s+(.*):(/d+)/s*,/s+(.*):(/d+),/s+limits:/s+/((.*),(.*)/)/s+/);} $line temp_str /
ref_name ref_time dat_name dat_time su_limit hd_limit
} elseif { $violation_type == "width" } {
regexp {^/s+/$/w+/(/s+(.*):(/d+),/s+:/s+(.*),/s+limit:/s+(.*)/s+/);.*} $line temp_str /
ref_name ref_time dat_time wd_limit
}
## filter timing messege, accroding timing_cell,vioaltion_type
if { $reserve_lvl == "all" } {
regexp {/s+(/$.*)} $line temp_str line_valid
puts $dp $timing_cell
puts $dp $line_valid
puts $dp "~~~~~~~~~~~~"
} elseif { $reserve_lvl == "type" } {
if { $violation_type != $ignore_type } {
regexp {/s+(/$.*)} $line temp_str line_valid
puts $dp $timing_cell
puts $dp $line_valid
puts $dp "~~~~~~~~~~~~"
}
} elseif { $reserve_lvl == "ignore" } {
# do nothing, ignore
}
## clear all flag
set msg_get ""
set reserve_lvl ""
set ignore_type ""
set timing_cell ""
set violation_type ""
set ref_name ""
set ref_time ""
set dat_name ""
set dat_time ""
set su_limit ""
set hd_limit ""
set wd_limit ""
} else {
if { [ regexp {.*Timing violation.*} $line ] != 1 } {
puts $dp $line
}
}
if { [ regexp {.*Timing violation.*} $line ] } {
regexp {.*Timing violation in (.*)} $line temp_str timing_cell
set reserve_lvl "all"
if { $timing_cell == "fm289_top_v02_tb.i_va.x_digit_top.x_clk_gen_dma_clk_en_reg" } {
set reserve_lvl "type"
set ignore_type "setuphold"
}
set msg_get "enable"
}
}
close $fp
close $dp
}
---------------
转载,原文链接:http://blog.csdn.net/vwzhd/article/details/6542407