proc relative_to_absolute {relative_path} { #replace all "../" and count how many "../" occured in the original string set parent_dir_count [regsub -all {\.\.\/} $relative_path "" sufix_path] set redir_path [pwd]; #cut the current path by N-times to get the common parent path for both "abs" and "rela" for {set i 0 } {$i < $parent_dir_count} {incr i} { set last_dir [file tail redir_path]; regsub /$last_dir $redir_path "" redir_path; } set prefix_path $redir_path; set absolute_path $prefix_path/$sufix_path; return $absolute_path; } proc find_files {root_path } { list results; #store the current path set current_path [pwd]; cd $root_path; set root_path [pwd]; puts "entering $root_path" # get all files recusively foreach element [glob -nocomplain *] { # entering sub dirs if { [file isdirectory $element]} { set subList [find_files $element]; set results [concat $results $subList]; } else { # only valid source files are filtered if {[string match "*.v" $element] || [string match "*.sv" $element] || [string match "*.vhd" $element] || [string match "*.vhdl" $element]} { lappend results "$root_path/$element"; } } } cd $current_path; return $results; } puts "---------------------------------ATTENTION----------------------------------------" puts "----------- this file should be sourced after the vsim load sucessfully-----------" puts "----------- this file should be sourced from the funcXXX director-----------------" puts "" #write report -l info.txt puts ":::::::::get referced dut files:::::::::" set f_report [open info.txt r]; #read the report,get all referenced files while {![eof $f_report]} { gets $f_report line if { [string match "*Source File*" $line] } { lappend referenced_files $line } } close $f_report #remove those source file,point to precompiled vendor library #convert the relative path to absolute path list referenced_dut_files; foreach element $referenced_files { if { [string match "*Source File: \.\./\.\./*" $element] } { regsub {^.*Source File:} $element "" path set relative_path [string trim $path ] set abs_path [relative_to_absolute $relative_path] lappend referenced_dut_files $abs_path # puts $abs_path } } puts ":::::::::get all compiled source files:::::::::" #get all source files in the source file directory ,recursively set root_path ../../../01_source/01_func; set all_sources [find_files $root_path ]; puts ":::::::::try to match:::::::::" #try to match the two lists,and filter the mis-matched ones set f_referenced_dut_files [open "referenced.txt" w+]; foreach sim_file $referenced_dut_files { puts $f_referenced_dut_files $sim_file; } close $f_referenced_dut_files set f_dir_files [open "dir.txt" w+]; foreach dir_file $all_sources { puts $f_dir_files $dir_file; } close $f_dir_files lappend mis_matched_dir_files; foreach dir_file $all_sources { puts $dir_file set index [lsearch $referenced_dut_files $dir_file] if {$index == -1} { lappend mis_matched_dir_files $dir_file puts dir=$dir_file } }