From 715843ca2a037530ebb38e4bd1d2fc17a346d276 Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Mon, 17 Feb 2020 10:25:45 -0500 Subject: [PATCH] Changed the script drc.tcl into two routines for DRC load and save, and merged the contents into drcmgr.tcl, with a new button in the DRC manager for saving the DRC contents. Loading is somewhat less useful since the DRC error tiles are interactive. The DRC manager still has the issue that every checked edge becomes a separate entry; this is an artifact of the way the DRC checker works, but it creates large numbers of error areas, many of which are redundant. --- tcltk/Makefile | 1 - tcltk/drc.tcl | 46 -------------------- tcltk/drcmgr.tcl | 107 +++++++++++++++++++++++++++++++++++++++++++++- tcltk/wrapper.tcl | 2 +- 4 files changed, 107 insertions(+), 49 deletions(-) delete mode 100644 tcltk/drc.tcl diff --git a/tcltk/Makefile b/tcltk/Makefile index a6619678..5ff09b05 100644 --- a/tcltk/Makefile +++ b/tcltk/Makefile @@ -24,7 +24,6 @@ TCL_FILES = \ tools.tcl \ mazeroute.tcl \ strip_reflibs.tcl \ - drc.tcl \ toolkit.tcl \ toolkit_rev0.tcl \ bsitools.tcl \ diff --git a/tcltk/drc.tcl b/tcltk/drc.tcl deleted file mode 100644 index 3820b925..00000000 --- a/tcltk/drc.tcl +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/tclsh -#---------------------------------------------- -# Dump a file of DRC errors from magic -#---------------------------------------------- -namespace path {::tcl::mathop ::tcl::mathfunc} - -magic::suspendall -set fout [open "drc.out" w] -set oscale [cif scale out] - -select top cell -set origcell [cellname list self] -drc check -set celllist [drc list count] -puts stdout "celllist is $celllist" -puts stdout "" -flush stdout -foreach pair $celllist { - set cellname [lindex $pair 0] - set count [lindex $pair 1] - puts stdout "loading $cellname" - flush stdout - - load $cellname - select top cell - puts $fout "$cellname $count" - puts $fout "----------------------------------------" - set drcresult [drc listall why] - foreach {errtype coordlist} $drcresult { - puts $fout $errtype - puts $fout "----------------------------------------" - foreach coord $coordlist { - set bllx [* $oscale [lindex $coord 0]] - set blly [* $oscale [lindex $coord 1]] - set burx [* $oscale [lindex $coord 2]] - set bury [* $oscale [lindex $coord 3]] - set coords [format "%.3f %.3f %.3f %.3f" $bllx $blly $burx $bury] - puts $fout "$coords" - } - puts $fout "----------------------------------------" - } - puts $fout "" -} -close $fout -load $origcell -magic::resumeall diff --git a/tcltk/drcmgr.tcl b/tcltk/drcmgr.tcl index abf9277f..3f46203e 100644 --- a/tcltk/drcmgr.tcl +++ b/tcltk/drcmgr.tcl @@ -101,11 +101,13 @@ proc magic::makedrcmanager { mgrpath } { -command {magic::drccallback update} button ${mgrpath}.actionbar.last -text "Last" -command {magic::drccallback last} button ${mgrpath}.actionbar.next -text "Next" -command {magic::drccallback next} + button ${mgrpath}.actionbar.save -text "Save" -command {magic::drc_save_report} button ${mgrpath}.actionbar.zoom -text "Zoom" -command {magic::drccallback zoom} pack ${mgrpath}.actionbar.update -side left pack ${mgrpath}.actionbar.last -side left pack ${mgrpath}.actionbar.next -side left + pack ${mgrpath}.actionbar.save -side left pack ${mgrpath}.actionbar.zoom -side right label ${mgrpath}.target.name -text "Target window:" @@ -150,7 +152,6 @@ proc magic::adddrcentry {key valuelist} { } } - #-------------------------------------------------------------- # The cell manager window main callback function #-------------------------------------------------------------- @@ -193,3 +194,107 @@ proc magic::drcmanager {{option "update"}} { } ;# (if Tk version 8.5) +#--------------------------------------------------- +# Alternative way to view/save DRC errors in magic. +# Dump a text file of errors and positions. Note +# that the dump, using "drc listall why", enumerates +# every single edge check and is therefore more +# detailed than the areas declared by "drc count" +# or enumerated in "drc find". +#--------------------------------------------------- + +proc magic::drc_save_report {{cellname ""} {outfile ""}} { + + if {$outfile == ""} {set outfile "drc.out"} + + set fout [open $outfile w] + set oscale [cif scale out] + + # magic::suspendall + + if {$cellname == ""} { + select top cell + set cellname [cellname list self] + set origname "" + } else { + set origname [cellname list self] + puts stdout "loading $cellname\n" + flush stdout + + load $cellname + select top cell + } + + drc check + set count [drc list count] + + puts $fout "$cellname $count" + puts $fout "----------------------------------------" + set drcresult [drc listall why] + foreach {errtype coordlist} $drcresult { + puts $fout $errtype + puts $fout "----------------------------------------" + foreach coord $coordlist { + set bllx [expr {$oscale * [lindex $coord 0]}] + set blly [expr {$oscale * [lindex $coord 1]}] + set burx [expr {$oscale * [lindex $coord 2]}] + set bury [expr {$oscale * [lindex $coord 3]}] + set coords [format " %.3f %.3f %.3f %.3f" $bllx $blly $burx $bury] + puts $fout "$coords" + } + puts $fout "----------------------------------------" + } + puts $fout "" + + if {$origname != ""} { + load $origname + } + + # magic::resumeall + + close $fout + puts stdout "done with $outfile\n" + flush stdout +} + +#--------------------------------------------------- +# Read back a dumped file of DRC errors. This is of +# limited use, as any layout should have DRC errors +# already marked. This routine loads errors into +# "feedback" areas, which is redundant to the error +# tiles. However, feedback areas are more precise, +# as they mark the error area at each checked edge +#--------------------------------------------------- + +proc magic::drc_load_report {{drc_file ""}} { + + if {$drc_file == ""} { + set drc_file "drc.out" + } + set fin [open $drc_file r] + + puts stdout "Reading $drc_file\n" + flush stdout + + magic::suspendall + + set error_text "" + while {[gets $fin line] >= 0} { + if {[string first " " $line] == 0} { + if [regexp { ([^ ]+) ([^ ]+) ([^ ]+) ([^ ]+)} $line lmatch llx lly urx ury] { + feedback add "$error_text" vert_highlights ${llx}um ${lly}um \ + ${llx}um ${ury}um ${urx}um ${ury}um ${urx}um ${lly}um + } + } elseif {[string first "-" $line] != 0} { + set error_text $line + } + } + magic::resumeall + + close $fin + + puts stdout "Done.\n" + puts stdout "Use \"feedback find\" to enumerate errors.\n" + flush stdout +} + diff --git a/tcltk/wrapper.tcl b/tcltk/wrapper.tcl index 271d2cd6..49936c8c 100644 --- a/tcltk/wrapper.tcl +++ b/tcltk/wrapper.tcl @@ -1,5 +1,5 @@ # This is the "Magic wrapper". -# It's main purpose is to redefine the "openwindow" command in magic so that +# Its main purpose is to redefine the "openwindow" command in magic so that # opening a new window creates a window wrapped by a GUI interface. # # Written by Tim Edwards, August 23, 2002.