## ------------------------------------------------------------------------------------------- ## Functions ## ------------------------------------------------------------------------------------------- proc get_pathname { pathname defaultpath } { set x [ string trim $pathname ] set i [ string first / $x ] if {$i!=0} { #relative path set x $defaultpath$x } return $x } proc replace_prj { name } { ##global project_dir ##global iplib_dir set x [ string trim $name ] # set x [ string map [ list "\$PRJ" $project_dir ] $x ] # set x [ string map [ list "\$IPLIB" $iplib_dir ] $x ] #puts "$name->$x" return $x } #Add design files proc parse_file { name {path ""} } { global macros global rtl_file_num global rtl_paths global rtl_files puts "Parse File: $path$name" set fileid [open $path$name] while { ![ eof $fileid ] } { set x [ gets $fileid ] #trim comments start by # set i [ string first # $x ] if {$i!=-1} { incr i -1 set x [ string range $x 0 $i ] } #trim comments start by // set i [ string first // $x ] if {$i!=-1} { incr i -1 set x [ string range $x 0 $i ] } #trim leading and trailing space set x [ string trim $x ] #options start by - set i [ string first - $x ] if {$i==0} { #find -f set i [ string first -f $x ] if {$i==0} { set j [ string length $x ] incr j -1 incr i 2 set x [ string range $x $i $j] set x [ replace_prj $x ] #puts "Parse file: $path$x" parse_file $x $path continue } #find -F set i [ string first -F $x ] if {$i==0} { set j [ string length $x ] incr j -1 incr i 2 set x [ string range $x $i $j] set x [ replace_prj $x ] set i [ string last / $x ] set y [ string range $x 0 $i] incr i 1 set j [ string length $x ] incr j -1 set x [ string range $x $i $j ] #puts "Parse File: $y$x" parse_file $x $path$y continue } #skip options not start by -v set i [ string first -v $x ] if {$i!=0} { continue } set j [ string length $x ] incr j -1 incr i 2 set x [ string range $x $i $j] set x [ string trim $x ] } #options start by + set i [ string first + $x ] if {$i==0} { #find include dir set i [ string first +incdir+ $x ] if {$i==0} { set j [ string length $x ] incr j -1 incr i 8 set x [ string range $x $i $j] set x [ replace_prj $x ] set x [ get_pathname $x $path ] puts "set include path: $x" set rtl_paths "$rtl_paths $x" continue } #find define macro set i [ string first +define+ $x ] if {$i==0} { set j [ string length $x ] incr j -1 incr i 8 set x [ string range $x $i $j] puts "define macro $x" puts "Error: +define+ found in filelist, which is not supported by \"parse_file\" in read_filelist.tcl." lappend macros $x continue } #skip options start by + continue } if { $x!="" } { set x [ replace_prj $x ] set x [ get_pathname $x $path ] #puts "add_file $x" incr rtl_file_num 1 set rtl_files "$rtl_files $x" } } close $fileid } ## --------------------------------------------------------------------------------------------------------------- ## Design Setup ## --------------------------------------------------------------------------------------------------------------- set rtl_file_num 0 set rtl_paths "" set rtl_files "" parse_file "design.f" "./inputs/" set search_path "$search_path $rtl_paths" echo "RTL Search Paths are:" > $svars(dir,logs)/read_filelist.log echo [string map {" " "\n"} $rtl_paths] >> $svars(dir,logs)/read_filelist.log echo "\n\n\n" >> $svars(dir,logs)/read_filelist.log echo "RTL Files are: " >> $svars(dir,logs)/read_filelist.log echo [string map {" " "\n"} $rtl_files] >> $svars(dir,logs)/read_filelist.log echo "\n\n\n" >> $svars(dir,logs)/read_filelist.log echo "Total $rtl_file_num files have been read in" >> $svars(dir,logs)/read_filelist.log