From 3af3eeffffce8fa4af94833e6e4cd18d2230421d Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Tue, 4 Feb 2020 12:16:29 +0100 Subject: [PATCH 01/11] Change the file used to store the LICENSE. --- COPYRIGHT => LICENSE | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename COPYRIGHT => LICENSE (100%) diff --git a/COPYRIGHT b/LICENSE similarity index 100% rename from COPYRIGHT rename to LICENSE From 6077907f77856f50684997da25499120b0f4a884 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Tue, 4 Feb 2020 14:47:07 +0100 Subject: [PATCH 02/11] Adding generated files to .gitignore. --- .gitignore | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.gitignore b/.gitignore index 04cd59d6..50ebaf94 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,18 @@ scripts/defs.mak scmos/cif_template/objs/* UPDATE_ME VERSION +database/database.h +install.log +magic/proto.magicrc +make.log +readline/readline +scmos/gdsquery.tech +scmos/minimum.tech +scmos/scmos-sub.tech +scmos/scmos-tm.tech +scmos/scmos.tech +scmos/scmosWR.tech +tcltk/magic.sh +tcltk/magic.tcl +tcltk/magicdnull +tcltk/magicexec From 4f30e766880a5032e6a5fdfb10eca02199b60837 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Fri, 7 Feb 2020 17:29:16 +0100 Subject: [PATCH 03/11] Make SVG output actually SVG again. Currently the SVG output is a SVG file with an embedded `image/png` file. Restricting to `CAIRO_SVG_VERSION_1_2` means the file goes back to being a vector. Signed-off-by: Tim 'mithro' Ansell --- graphics/grTCairo1.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/graphics/grTCairo1.c b/graphics/grTCairo1.c index 7e293d2f..27299739 100644 --- a/graphics/grTCairo1.c +++ b/graphics/grTCairo1.c @@ -370,6 +370,9 @@ GrTCairoPlotSVG (char *filename, MagWindow *mw) wind_context = tcairodata->context; tcairodata->surface = (cairo_surface_t *)cairo_svg_surface_create(filename, (double)screenw, (double)screenh); + cairo_svg_surface_restrict_to_version( + tcairodata->surface, CAIRO_SVG_VERSION_1_2); + tcairodata->context = cairo_create(tcairodata->surface); WindRedisplay(mw); WindUpdate(); From 2ca95111529ad06c0577d61928b337c530a0e892 Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Fri, 7 Feb 2020 11:38:00 -0500 Subject: [PATCH 04/11] Added fix for SVG output. This brings back the original behavior of generating scalable output. Some libcairo update had caused the output to use the wrong version of SVG by default, which generates an SVG-wrapped PNG data block, which is not scalable, and not what was intended with the "plot svg" command. --- graphics/grTCairo1.c | 5 ++--- tcltk/ext2sim.sh | 2 +- tcltk/ext2spice.sh | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/graphics/grTCairo1.c b/graphics/grTCairo1.c index 27299739..ed5c1a5b 100644 --- a/graphics/grTCairo1.c +++ b/graphics/grTCairo1.c @@ -370,9 +370,8 @@ GrTCairoPlotSVG (char *filename, MagWindow *mw) wind_context = tcairodata->context; tcairodata->surface = (cairo_surface_t *)cairo_svg_surface_create(filename, (double)screenw, (double)screenh); - cairo_svg_surface_restrict_to_version( - tcairodata->surface, CAIRO_SVG_VERSION_1_2); - + cairo_svg_surface_restrict_to_version(tcairodata->surface, + CAIRO_SVG_VERSION_1_2); tcairodata->context = cairo_create(tcairodata->surface); WindRedisplay(mw); WindUpdate(); diff --git a/tcltk/ext2sim.sh b/tcltk/ext2sim.sh index b1c98edd..8bd40c31 100644 --- a/tcltk/ext2sim.sh +++ b/tcltk/ext2sim.sh @@ -15,7 +15,7 @@ for i in $@; do esac done # -eval /home/tim/cad/lib/magic/tcl/magicdnull -dnull -noconsole -nowrapper $mgargs < Date: Tue, 11 Feb 2020 10:21:36 -0500 Subject: [PATCH 05/11] Corrected ext2sim.c calls to hierAP and others using "scale" and declaring it to be an integer when it is actually a float. This will cause magic to crash when using, e.g., "ext2sim -f su". --- ext2sim/ext2sim.c | 19 +++++++++++-------- graphics/grTCairo1.c | 1 + 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/ext2sim/ext2sim.c b/ext2sim/ext2sim.c index 897e4f31..4efe627e 100644 --- a/ext2sim/ext2sim.c +++ b/ext2sim/ext2sim.c @@ -1078,7 +1078,7 @@ simdevVisit(dev, hierName, scale, trans) { putc(' ', esSimF); simdevSubstrate(hierName, subnode->efnode_name->efnn_hier, - dev->dev_type, 0, FALSE, esSimF); + dev->dev_type, 0.0, FALSE, esSimF); } GeoTransRect(trans, &dev->dev_rect, &r); @@ -1196,7 +1196,8 @@ int simdevSubstrate( prefix, suffix, type, scale, doAP, outf) HierName *prefix; HierName *suffix; -int type, scale; +int type; +float scale; bool doAP; FILE *outf; { @@ -1264,7 +1265,8 @@ FILE *outf; bool simnAP(node, resClass, scale, outf) EFNode *node; -int resClass, scale; +int resClass; +float scale; FILE *outf; { int a, p; @@ -1277,8 +1279,8 @@ FILE *outf; return FALSE; } markVisited((nodeClient *)node->efnode_client, resClass); - a = node->efnode_pa[resClass].pa_area*scale*scale; - p = node->efnode_pa[resClass].pa_perim*scale; + a = (int)(node->efnode_pa[resClass].pa_area*scale*scale); + p = (int)(node->efnode_pa[resClass].pa_perim*scale); if ( a < 0 ) a = 0; if ( p < 0 ) p = 0; fprintf(outf,"A_%d,P_%d", a, p); @@ -1288,7 +1290,8 @@ FILE *outf; bool simnAPHier(dterm, hierName, resClass, scale, outf) DevTerm *dterm; HierName *hierName; - int resClass, scale; + int resClass; + float scale; FILE *outf; { EFNode *node = dterm->dterm_node; @@ -1308,8 +1311,8 @@ bool simnAPHier(dterm, hierName, resClass, scale, outf) return FALSE; } markVisited((nodeClientHier *)node->efnode_client, resClass); - a = node->efnode_pa[resClass].pa_area*scale*scale; - p = node->efnode_pa[resClass].pa_perim*scale; + a = (int)(node->efnode_pa[resClass].pa_area*scale*scale); + p = (int)(node->efnode_pa[resClass].pa_perim*scale); if ( a < 0 ) a = 0; if ( p < 0 ) p = 0; fprintf(outf,"A_%d,P_%d", a, p); diff --git a/graphics/grTCairo1.c b/graphics/grTCairo1.c index ed5c1a5b..e84789a0 100644 --- a/graphics/grTCairo1.c +++ b/graphics/grTCairo1.c @@ -372,6 +372,7 @@ GrTCairoPlotSVG (char *filename, MagWindow *mw) (double)screenw, (double)screenh); cairo_svg_surface_restrict_to_version(tcairodata->surface, CAIRO_SVG_VERSION_1_2); + tcairodata->context = cairo_create(tcairodata->surface); WindRedisplay(mw); WindUpdate(); From f2dc4b37f01f427a578679c99e2a9c062c082809 Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Thu, 13 Feb 2020 10:04:55 -0500 Subject: [PATCH 06/11] Corrected the connectivity search function so that it does not attempt to copy and search on a label that already exists in the flattened, copied database. Otherwise multiple labels on a single net can cause the search to go into an infinite loop, repeatedly copying and erasing the same label over and over again. --- database/DBconnect.c | 5 ++++ database/DBlabel.c | 55 +++++++++++++++++++++++++++++++++++++++----- 2 files changed, 54 insertions(+), 6 deletions(-) diff --git a/database/DBconnect.c b/database/DBconnect.c index f1f5a6ab..826c2f48 100644 --- a/database/DBconnect.c +++ b/database/DBconnect.c @@ -679,6 +679,11 @@ dbcConnectLabelFunc(scx, lab, tpath, csa2) if (scx->scx_use == csa2->csa2_topscx->scx_use) { + /* Do not repeat a label copy; check that the label doesn't */ + /* already exist in the destination def first. */ + if (DBCheckLabelsByContent(def, &r, lab->lab_type, lab->lab_text)) + return 0; + DBEraseLabelsByContent(def, &r, -1, lab->lab_text); DBPutFontLabel(def, &r, lab->lab_font, lab->lab_size, rotate, &offset, pos, lab->lab_text, lab->lab_type, lab->lab_flags); diff --git a/database/DBlabel.c b/database/DBlabel.c index 6fb058dd..9e95d2d5 100644 --- a/database/DBlabel.c +++ b/database/DBlabel.c @@ -313,7 +313,55 @@ DBEraseLabel(cellDef, area, mask, areaReturn) cellDef->cd_flags |= CDMODIFIED|CDGETNEWSTAMP; return (erasedAny); } - + +#define RECTEQUAL(r1, r2) ((r1)->r_xbot == (r2)->r_xbot \ + && (r1)->r_ybot == (r2)->r_ybot \ + && (r1)->r_xtop == (r2)->r_xtop \ + && (r1)->r_ytop == (r2)->r_ytop) + +/* + * ---------------------------------------------------------------------------- + * + * DBCheckLabelsByContent -- + * + * Return any label found on the label list for the given + * CellDef that matches the given specification. + * + * Results: + * Returns a label if a match is found, otherwise returns NULL. + * + * Side effects: + * None. + * + * ---------------------------------------------------------------------------- + */ + +Label * +DBCheckLabelsByContent(def, rect, type, text) + CellDef *def; /* Where to look for label to delete. */ + Rect *rect; /* Coordinates of label. If NULL, then + * labels are searched regardless of coords. + */ + TileType type; /* Layer label is attached to. If < 0, then + * labels are searched regardless of type. + */ + char *text; /* Text associated with label. If NULL, then + * labels are searched regardless of text. + */ +{ + Label *lab; + + for (lab = def->cd_labels; lab; lab = lab->lab_next) + { + if ((rect != NULL) && !(RECTEQUAL(&lab->lab_rect, rect))) continue; + if ((type >= 0) && (type != lab->lab_type)) continue; + if ((text != NULL) && (strcmp(text, lab->lab_text) != 0)) continue; + + return lab; + } + return NULL; +} + /* * ---------------------------------------------------------------------------- * @@ -348,11 +396,6 @@ DBEraseLabelsByContent(def, rect, type, text) { Label *lab, *labPrev; -#define RECTEQUAL(r1, r2) ((r1)->r_xbot == (r2)->r_xbot \ - && (r1)->r_ybot == (r2)->r_ybot \ - && (r1)->r_xtop == (r2)->r_xtop \ - && (r1)->r_ytop == (r2)->r_ytop) - for (labPrev = NULL, lab = def->cd_labels; lab != NULL; labPrev = lab, lab = lab->lab_next) From 897a8064bab96609729dc2b3d0a6d6a44b54adb7 Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Fri, 14 Feb 2020 08:48:47 -0500 Subject: [PATCH 07/11] Restored the behavior of selecting and displaying labels that are down in the hierarchy when selecting a region or net, but with a (hopefully very useful) twist: To avoid the problem of ambiguous labels in subcells, the subcell name hierarchy is generated in the same way as is done when flattening a cell, with the instance name prepended. For example, when selecting a net in a standard cell design, a terminal would highlight the name "OR2X1_1/B" instead of just "B". --- commands/CmdFI.c | 1 + database/DBconnect.c | 44 ++++++++++++++++++++++++++++++++++---------- utils/Depend | 4 +--- 3 files changed, 36 insertions(+), 13 deletions(-) diff --git a/commands/CmdFI.c b/commands/CmdFI.c index 178fe9ee..f50e600e 100644 --- a/commands/CmdFI.c +++ b/commands/CmdFI.c @@ -1792,6 +1792,7 @@ FlatCopyAllLabels(scx, mask, xMask, targetUse) char pathstring[FLATTERMSIZE]; TerminalPath tpath; + pathstring[0] = '\0'; tpath.tp_first = tpath.tp_next = pathstring; tpath.tp_last = pathstring + FLATTERMSIZE; diff --git a/database/DBconnect.c b/database/DBconnect.c index 826c2f48..f81446bd 100644 --- a/database/DBconnect.c +++ b/database/DBconnect.c @@ -656,6 +656,9 @@ dbcUnconnectFunc(tile, clientData) * ---------------------------------------------------------------------------- */ +/* To do: Make the tpath entries dynamically allocated */ +#define FLATTERMSIZE 1024 + int dbcConnectLabelFunc(scx, lab, tpath, csa2) SearchContext *scx; @@ -667,6 +670,8 @@ dbcConnectLabelFunc(scx, lab, tpath, csa2) Rect r; Point offset; int pos, rotate; + char newlabtext[FLATTERMSIZE]; + char *newlabptr; int dbcConnectFunc(); /* Forward declaration */ GeoTransRect(&scx->scx_trans, &lab->lab_rect, &r); @@ -677,17 +682,29 @@ dbcConnectLabelFunc(scx, lab, tpath, csa2) /* Only add labels if they are on the search top level */ /* (NOTE: Could add hierachical labels using tpath) */ - if (scx->scx_use == csa2->csa2_topscx->scx_use) + if (scx->scx_use != csa2->csa2_topscx->scx_use) { - /* Do not repeat a label copy; check that the label doesn't */ - /* already exist in the destination def first. */ - if (DBCheckLabelsByContent(def, &r, lab->lab_type, lab->lab_text)) - return 0; - - DBEraseLabelsByContent(def, &r, -1, lab->lab_text); - DBPutFontLabel(def, &r, lab->lab_font, lab->lab_size, rotate, &offset, - pos, lab->lab_text, lab->lab_type, lab->lab_flags); + int newllen = tpath->tp_next - tpath->tp_first; + newlabtext[0] = '\0'; + if (newllen > 0) + strncpy(newlabtext, tpath->tp_first, newllen); + sprintf(newlabtext + newllen, "%s", lab->lab_text); + newlabptr = newlabtext; } + else + newlabptr = lab->lab_text; + + /* Do not repeat a label copy; check that the label doesn't */ + /* already exist in the destination def first. */ + if (DBCheckLabelsByContent(def, &r, lab->lab_type, lab->lab_text)) + return 0; + + if (DBCheckLabelsByContent(def, &r, lab->lab_type, newlabptr)) + return 0; + + DBEraseLabelsByContent(def, &r, -1, lab->lab_text); + DBPutFontLabel(def, &r, lab->lab_font, lab->lab_size, rotate, &offset, + pos, newlabptr, lab->lab_type, lab->lab_flags); if (lab->lab_flags & PORT_DIR_MASK) { @@ -1024,6 +1041,13 @@ DBTreeCopyConnect(scx, mask, xMask, connect, area, destUse) DBTreeSrTiles(scx, mask, xMask, dbcConnectFunc, (ClientData) &csa2); while (csa2.csa2_top >= 0) { + char pathstring[FLATTERMSIZE]; + TerminalPath tpath; + + tpath.tp_first = tpath.tp_next = pathstring; + tpath.tp_last = pathstring + FLATTERMSIZE; + pathstring[0] = '\0'; + newmask = csa2.csa2_list[csa2.csa2_top].connectMask; scx->scx_area = csa2.csa2_list[csa2.csa2_top].area; newtype = csa2.csa2_list[csa2.csa2_top].dinfo; @@ -1064,7 +1088,7 @@ DBTreeCopyConnect(scx, mask, xMask, connect, area, destUse) searchtype |= TF_LABEL_ATTACH_NOT_SE; } } - DBTreeSrLabels(scx, newmask, xMask, NULL, searchtype, + DBTreeSrLabels(scx, newmask, xMask, &tpath, searchtype, dbcConnectLabelFunc, (ClientData) &csa2); } freeMagic((char *)csa2.csa2_list); diff --git a/utils/Depend b/utils/Depend index 4f469cb1..56e88bb4 100644 --- a/utils/Depend +++ b/utils/Depend @@ -2,9 +2,7 @@ args.o: args.c ../utils/magic.h ../utils/utils.h child.o: child.c ../utils/utils.h ../utils/magic.h ../utils/malloc.h dqueue.o: dqueue.c ../utils/magic.h ../utils/dqueue.h ../utils/malloc.h finddisp.o: finddisp.c ../utils/magic.h ../utils/utils.h -flock.o: flock.c ../utils/magic.h ../utils/hash.h ../utils/geometry.h \ - ../tiles/tile.h ../database/database.h ../windows/windows.h \ - ../utils/malloc.h +flock.o: flock.c flsbuf.o: flsbuf.c fraction.o: fraction.c ../utils/magic.h ../utils/geometry.h geometry.o: geometry.c ../utils/magic.h ../utils/geometry.h \ From ed8117784e2f11abe4acd73ae3deeae926b4f153 Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Fri, 14 Feb 2020 09:36:30 -0500 Subject: [PATCH 08/11] Corrected three annoying errors: (1) Select net method had been changed to ignore labels below the top level of hierarchy. This turned out to be a bad idea. However, the original behavior was problematic due to confusion over what part of the hierarchy the labels were in. The new behavior prefixes each label with the cell hierarchy, eliminating both problems. (2) Corrected the problem where the attachment box for rendered labels is not displayed if the label name is not in the viewing area. (3) Corrected the problem where redirection of input from the layout window to the console window with the ":" command gets inadvertently canceled; this turned out to be due to a missing "*bypass" in front of the command that finds the output scale to display the pointer coordinates, and this was happening whenever the mouse was moved while typing in a command. --- database/DBcellsrch.c | 5 ++++- dbwind/DBWdisplay.c | 2 +- tcltk/wrapper.tcl | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/database/DBcellsrch.c b/database/DBcellsrch.c index a960bf2e..d3eaa667 100644 --- a/database/DBcellsrch.c +++ b/database/DBcellsrch.c @@ -581,8 +581,11 @@ DBTreeSrLabels(scx, mask, xMask, tpath, flags, func, cdarg) else is_touching = GEO_TOUCH(&lab->lab_rect, r); } - if (!is_touching && (flags & TF_LABEL_DISPLAY) && (lab->lab_font >= 0)) + if (!is_touching && (flags & TF_LABEL_DISPLAY) && lab->lab_font >= 0) + { + /* Check against bounds of the rendered label text */ is_touching = GEO_TOUCH(&lab->lab_bbox, r); + } if (is_touching && TTMaskHasType(mask, lab->lab_type)) if ((*func)(scx, lab, tpath, cdarg)) diff --git a/dbwind/DBWdisplay.c b/dbwind/DBWdisplay.c index 8ea1b3bd..0ccb80ea 100644 --- a/dbwind/DBWdisplay.c +++ b/dbwind/DBWdisplay.c @@ -418,7 +418,7 @@ DBWredisplay(w, rootArea, clipArea) /* Set style information beforehand */ GrSetStuff(STYLE_LABEL); (void) DBTreeSrLabels(&scontext, &DBAllTypeBits, bitMask, - (TerminalPath *) NULL, TF_LABEL_DISPLAY, + (TerminalPath *) NULL, TF_LABEL_DISPLAY | TF_LABEL_ATTACH, dbwLabelFunc, (ClientData) NULL); GrClipTo(&rootClip); } diff --git a/tcltk/wrapper.tcl b/tcltk/wrapper.tcl index 563778d5..271d2cd6 100644 --- a/tcltk/wrapper.tcl +++ b/tcltk/wrapper.tcl @@ -629,7 +629,7 @@ proc magic::cursorview {win} { return } set framename [winfo parent $win] - if {[catch {set cr [cif scale out]}]} {return} + if {[catch {set cr [*bypass cif scale out]}]} {return} if {$cr == 0} {return} set olst [${win} cursor internal] From 715843ca2a037530ebb38e4bd1d2fc17a346d276 Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Mon, 17 Feb 2020 10:25:45 -0500 Subject: [PATCH 09/11] 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. From 25724211620cb026dd791eded428cad75c835488 Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Mon, 17 Feb 2020 15:13:54 -0500 Subject: [PATCH 10/11] Added new option setting Opts(toolsize) that makes the toolbar icons scale with the given size (default 16). This can be put in the site.def or .magicrc file as, e.g., "set Opts(toolsize) 32". This is the first part of an attempt to get everything to scale properly on ultra-high- resolution monitors. --- tcltk/wrapper.tcl | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tcltk/wrapper.tcl b/tcltk/wrapper.tcl index 49936c8c..3252fea0 100644 --- a/tcltk/wrapper.tcl +++ b/tcltk/wrapper.tcl @@ -537,6 +537,7 @@ set Opts(crosshair) 0 set Opts(hidelocked) 0 set Opts(hidespecial) 0 set Opts(toolbar) 0 +set Opts(toolsize) 16 set Opts(drc) 1 set Opts(autobuttontext) 1 @@ -720,18 +721,21 @@ proc magic::toolupdate {win {yesno "yes"} {layerlist "none"}} { # Generate the toolbar images for a technology proc magic::maketoolimages {} { + global Opts + + set tsize $Opts(toolsize) # Generate a layer image for "space" that will be used when layers are # invisible. - image create layer img_space -name none + image create layer img_space -name none -width $tsize -height $tsize set all_layers [concat {errors labels subcell} [magic::tech layer "*"]] foreach layername $all_layers { - image create layer img_$layername -name $layername + image create layer img_$layername -name $layername -width $tsize -height $tsize image create layer pale_$layername -name $layername \ - -disabled true -icon 23 + -disabled true -icon 23 -width $tsize -height $tsize } } From 6049b7e00e288d7bb57d962300610281b21756da Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Mon, 17 Feb 2020 16:51:30 -0500 Subject: [PATCH 11/11] Further dealing with retinal displays: The scrollbars and related glyphs now scale with Opts(scale), which is a zoom scalefactor (default 1), and Opts(toolscale) sets an independent sizing for the toolbar icons, which is multiplied by the Opts(scale) scalefactor. Also: Added GR_LIBS to the link options for magicexec and magicdnull, to avoid compile-time problems on some systems (thank you to Charlene of OpenBSD for the patch!). --- magic/Makefile | 2 +- magic/bitmaps/down.png | Bin 0 -> 290 bytes magic/bitmaps/left.png | Bin 0 -> 291 bytes magic/bitmaps/right.png | Bin 0 -> 289 bytes magic/bitmaps/up.png | Bin 0 -> 290 bytes magic/bitmaps/zoom.png | Bin 0 -> 276 bytes tcltk/Makefile | 6 ++- tcltk/wrapper.tcl | 95 ++++++++++++++++++++++++++-------------- 8 files changed, 67 insertions(+), 36 deletions(-) create mode 100644 magic/bitmaps/down.png create mode 100644 magic/bitmaps/left.png create mode 100644 magic/bitmaps/right.png create mode 100644 magic/bitmaps/up.png create mode 100644 magic/bitmaps/zoom.png diff --git a/magic/Makefile b/magic/Makefile index 2079bca5..4dc62515 100644 --- a/magic/Makefile +++ b/magic/Makefile @@ -19,7 +19,7 @@ EXTRA_LIBS = ${MAGICDIR}/cmwind/libcmwind.o ${MAGICDIR}/commands/libcommands.o \ ${MAGICDIR}/plow/libplow.o ${MAGICDIR}/utils/libutils.o \ ${MAIN_EXTRA_LIBS} -BITMAPS = up.xbm down.xbm left.xbm right.xbm zoom.xbm lock.xbm +BITMAPS = up.png down.png left.png right.png zoom.png lock.xbm DEST_XBM = $(BITMAPS:%=$(DESTDIR)${INSTALL_TCLDIR}/bitmaps/%) DFLAGS += -DMAGIC_DATE="\"`date`\"" -DCAD_DIR="${LIBDIR}" diff --git a/magic/bitmaps/down.png b/magic/bitmaps/down.png new file mode 100644 index 0000000000000000000000000000000000000000..78c995180b6f428b733ea99c8ed6cb8c0b2037de GIT binary patch literal 290 zcmeAS@N?(olHy`uVBq!ia0vp@Ak4%JB>7u;-UBI?bVpxD28NCO+&S3Dk zz__fXwULpbQiP>m$K%LXpeEH4*NBpo#FA92@!;O_l%v literal 0 HcmV?d00001 diff --git a/magic/bitmaps/left.png b/magic/bitmaps/left.png new file mode 100644 index 0000000000000000000000000000000000000000..dd63f521c244b352b45a1b720c8043480dd02e23 GIT binary patch literal 291 zcmeAS@N?(olHy`uVBq!ia0vp@Ak4%JB>7u;-UBI?bVpxD28NCO+1b=SGH7YyFz6Q5 z;|^oL$asaDVdFj4q7$B7^MJZkOI#yLQW8s2t&)pUffR$0fsui(fswAEd5EEzm5G^^ qfr+kxsg;4j^huHFC>nC}Q!>*kacg*X{^4z)1_n=8KbLh*2~7a=eorR= literal 0 HcmV?d00001 diff --git a/magic/bitmaps/right.png b/magic/bitmaps/right.png new file mode 100644 index 0000000000000000000000000000000000000000..4ae31e9c8a9e5fa3ed5a98ce2ba08c56beed6590 GIT binary patch literal 289 zcmeAS@N?(olHy`uVBq!ia0vp@Ak4%JB>7u;-UBI?bVpxD28NCO+N1$1#t{3&#{_4-=zBos7JNLHKHUXu_V85l%cME*q4kei>9nO2EggI4N8SD*$4Pgg&ebxsLQ0LG?G{Qv*} literal 0 HcmV?d00001 diff --git a/magic/bitmaps/up.png b/magic/bitmaps/up.png new file mode 100644 index 0000000000000000000000000000000000000000..cbe449739f642a032b31865f9d89db956199e578 GIT binary patch literal 290 zcmeAS@N?(olHy`uVBq!ia0vp@Ak4%JB>7u;-UBI?bVpxD28NCO+!C8<`)MX5lF!N|bKK-a)X*U&t~(9Fuvz{>aG}y12r&sy85}Sb4q9e0Mh_XK>z>% literal 0 HcmV?d00001 diff --git a/magic/bitmaps/zoom.png b/magic/bitmaps/zoom.png new file mode 100644 index 0000000000000000000000000000000000000000..7d0f4484bd9c2c09304652e061442d6f7638571c GIT binary patch literal 276 zcmeAS@N?(olHy`uVBq!ia0vp@Ak4%JB>7u;-UBI?bVpxD28NCO+?an+uemJjk_iV$dUGRaSY+Oo}AFYeC>jO#6bln aPsvQH#I2!Wf0hwY1B0ilpUXO@geCyo)k?Vl literal 0 HcmV?d00001 diff --git a/tcltk/Makefile b/tcltk/Makefile index 5ff09b05..efa12d00 100644 --- a/tcltk/Makefile +++ b/tcltk/Makefile @@ -49,11 +49,13 @@ install-tcl: magicexec magicdnull ${BIN_FILES} ${TCL_FILES} magicexec: magicexec.c ${MAGICDIR}/defs.mak ${CC} ${CFLAGS} ${CPPFLAGS} ${DFLAGS_NOSTUB} ${LDFLAGS} magicexec.c \ - -o magicexec ${LD_RUN_PATH} ${LIBS} ${LIB_SPECS_NOSTUB} + -o magicexec ${LD_RUN_PATH} ${LIB_SPECS_NOSTUB} ${LIBS} \ + ${GR_LIBS} magicdnull: magicdnull.c ${MAGICDIR}/defs.mak ${CC} ${CFLAGS} ${CPPFLAGS} ${DFLAGS_NOSTUB} ${LDFLAGS} magicdnull.c \ - -o magicdnull ${LD_RUN_PATH} ${LIBS} ${LIB_SPECS_NOSTUB} + -o magicdnull ${LD_RUN_PATH} ${LIB_SPECS_NOSTUB} ${LIBS} \ + ${GR_LIBS} magic.tcl: magic.tcl.in ${MAGICDIR}/defs.mak sed -e /TCL_DIR/s%TCL_DIR%${TCLDIR}%g \ diff --git a/tcltk/wrapper.tcl b/tcltk/wrapper.tcl index 3252fea0..2758cd96 100644 --- a/tcltk/wrapper.tcl +++ b/tcltk/wrapper.tcl @@ -22,26 +22,43 @@ if {[lsearch [namespace children] ::tkshell] < 0} { catch {source ${CAD_ROOT}/magic/tcl/tkshell.tcl} } -# Button images +proc magic::makeglyphimages {} { + global Opts + global Glyph + global CAD_ROOT -set Glyph(up) [image create bitmap \ - -file ${CAD_ROOT}/magic/tcl/bitmaps/up.xbm \ - -background gray -foreground steelblue] -set Glyph(down) [image create bitmap \ - -file ${CAD_ROOT}/magic/tcl/bitmaps/down.xbm \ - -background gray -foreground steelblue] -set Glyph(left) [image create bitmap \ - -file ${CAD_ROOT}/magic/tcl/bitmaps/left.xbm \ - -background gray -foreground steelblue] -set Glyph(right) [image create bitmap \ - -file ${CAD_ROOT}/magic/tcl/bitmaps/right.xbm \ - -background gray -foreground steelblue] -set Glyph(zoom) [image create bitmap \ - -file ${CAD_ROOT}/magic/tcl/bitmaps/zoom.xbm \ - -background gray -foreground steelblue] -set Glyph(lock) [image create bitmap \ + # Check if glyphs exist---don't need to make them more than once + if {![catch {set Glyph(up)}]} {return} + + # Glyph images + + set gsize [expr {int($Opts(scale) * 13)}] + set gscale [expr {int($Opts(scale))}] + + image create photo stdglyph -file ${CAD_ROOT}/magic/tcl/bitmaps/up.png + image create photo Glyph(up) -width $gsize -height $gsize + Glyph(up) copy stdglyph -zoom $gscale + + image create photo stdglyph -file ${CAD_ROOT}/magic/tcl/bitmaps/down.png + image create photo Glyph(down) -width $gsize -height $gsize + Glyph(down) copy stdglyph -zoom $gscale + + image create photo stdglyph -file ${CAD_ROOT}/magic/tcl/bitmaps/left.png + image create photo Glyph(left) -width $gsize -height $gsize + Glyph(left) copy stdglyph -zoom $gscale + + image create photo stdglyph -file ${CAD_ROOT}/magic/tcl/bitmaps/right.png + image create photo Glyph(right) -width $gsize -height $gsize + Glyph(right) copy stdglyph -zoom $gscale + + image create photo stdglyph -file ${CAD_ROOT}/magic/tcl/bitmaps/zoom.png + image create photo Glyph(zoom) -width $gsize -height $gsize + Glyph(zoom) copy stdglyph -zoom $gscale + + image create bitmap Glyph(lock) \ -file ${CAD_ROOT}/magic/tcl/bitmaps/lock.xbm \ -background gray80 -foreground steelblue4] +} # Menu button callback functions @@ -537,7 +554,8 @@ set Opts(crosshair) 0 set Opts(hidelocked) 0 set Opts(hidespecial) 0 set Opts(toolbar) 0 -set Opts(toolsize) 16 +set Opts(scale) 1.0 +set Opts(toolscale) 1.0 set Opts(drc) 1 set Opts(autobuttontext) 1 @@ -723,7 +741,8 @@ proc magic::toolupdate {win {yesno "yes"} {layerlist "none"}} { proc magic::maketoolimages {} { global Opts - set tsize $Opts(toolsize) + # Tool size expands with the GUI scale but can also be expanded independently. + set tsize [expr {int($Opts(scale) * $Opts(toolscale) * 16)}] # Generate a layer image for "space" that will be used when layers are # invisible. @@ -900,6 +919,8 @@ proc magic::techrebuild {winpath {cmdstr ""}} { # current view in magic (in pixels) proc magic::setscrollvalues {win} { + global Opts + set svalues [${win} view get] set bvalues [${win} view bbox] @@ -926,16 +947,19 @@ proc magic::setscrollvalues {win} { set ya [expr { $wheight - $ya }] set yb [expr { $wheight - $yb }] - ${framename}.xscroll.bar coords slider $xa 2 $xb 15 - ${framename}.yscroll.bar coords slider 2 $ya 15 $yb + set swidth [expr {int($Opts(scale) * 13)}] + set slength [expr {$swidth + 2}] + + ${framename}.xscroll.bar coords slider $xa 2 $xb $slength + ${framename}.yscroll.bar coords slider 2 $ya $slength $yb set xb [expr { 1 + ($xa + $xb) / 2 }] set xa [expr { $xb - 2 }] - ${framename}.xscroll.bar coords centre $xa 4 $xb 13 + ${framename}.xscroll.bar coords centre $xa 4 $xb $swidth set yb [expr { 1 + ($ya + $yb) / 2 }] set ya [expr { $yb - 2 }] - ${framename}.yscroll.bar coords centre 4 $ya 13 $yb + ${framename}.yscroll.bar coords centre 4 $ya $swidth $yb } # Procedure to update scrollbars in response to an internal command @@ -1019,6 +1043,9 @@ proc magic::dragscroll { w v orient } { proc magic::makescrollbar { fname orient win } { global scale global Glyph + global Opts + + set swidth [expr {int($Opts(scale) * 13)}] set scale($orient,update) 0 set scale($orient,origin) 0 @@ -1026,19 +1053,19 @@ proc magic::makescrollbar { fname orient win } { # To be done: add glyphs for the arrows if { "$orient" == "x" } { - canvas ${fname}.bar -height 13 -relief sunken -borderwidth 1 - button ${fname}.lb -image $Glyph(left) -borderwidth 1 \ + canvas ${fname}.bar -height $swidth -relief sunken -borderwidth 1 + button ${fname}.lb -image Glyph(left) -borderwidth 1 \ -command "${win} scroll left .1 w" - button ${fname}.ub -image $Glyph(right) -borderwidth 1 \ + button ${fname}.ub -image Glyph(right) -borderwidth 1 \ -command "${win} scroll right .1 w" pack ${fname}.lb -side left pack ${fname}.bar -fill $orient -expand true -side left pack ${fname}.ub -side right } else { - canvas ${fname}.bar -width 13 -relief sunken -borderwidth 1 - button ${fname}.lb -image $Glyph(down) -borderwidth 1 \ + canvas ${fname}.bar -width $swidth -relief sunken -borderwidth 1 + button ${fname}.lb -image Glyph(down) -borderwidth 1 \ -command "${win} scroll down .1 w" - button ${fname}.ub -image $Glyph(up) -borderwidth 1 \ + button ${fname}.ub -image Glyph(up) -borderwidth 1 \ -command "${win} scroll up .1 w" pack ${fname}.ub pack ${fname}.bar -fill $orient -expand true @@ -1054,7 +1081,7 @@ proc magic::makescrollbar { fname orient win } { # Create a small mark in the center of the scrolling rectangle which aids # in determining how much the window is being scrolled when the full # scrollbar extends past the window edges. - ${fname}.bar create rect 4 4 13 13 -fill black -width 0 -tag centre + ${fname}.bar create rect 4 4 $swidth $swidth -fill black -width 0 -tag centre ${fname}.bar bind centre "magic::setscroll %W %$orient $orient" ${fname}.bar bind centre "magic::scrollview %W $win $orient" ${fname}.bar bind centre "magic::dragscroll %W %$orient $orient" @@ -1127,12 +1154,14 @@ proc magic::openwrapper {{cell ""} {framename ""}} { pack ${framename}.pane -side top -fill both -expand true - frame ${layoutframe}.xscroll -height 13 - frame ${layoutframe}.yscroll -width 13 + set swidth [expr {int($Opts(scale) * 13)}] + frame ${layoutframe}.xscroll -height $swidth + frame ${layoutframe}.yscroll -width $swidth + magic::makeglyphimages magic::makescrollbar ${layoutframe}.xscroll x ${winname} magic::makescrollbar ${layoutframe}.yscroll y ${winname} - button ${layoutframe}.zb -image $Glyph(zoom) -borderwidth 1 -command "${winname} zoom 2" + button ${layoutframe}.zb -image Glyph(zoom) -borderwidth 1 -command "${winname} zoom 2" # Add bindings for mouse buttons 2 and 3 to the zoom button bind ${layoutframe}.zb "${winname} zoom 0.5"