Commit Graph

693 Commits

Author SHA1 Message Date
R. Timothy Edwards 957d7edd64 A number of things in one commit:
1) Added a "*showmem" "wizard" command to get a dump of all memory
   being used by tiles in the database.
2) Made a slight correction to the way magic detects exact overlap
   of instances of the same cell.  This probably does not make any
   actual difference in practice.
3) Corrected an uninitialized variable in dbReComputeBboxFunc().
4) Changes DBSrCellPlaneArea() to use a static BPEnum variable, so
   that it does not waste time allocating and freeing memory for
   the same thing over and over again.
5) Corrected a memory leak in the tech file "extract" section that
   loses memory every time the extraction style is changed.
6) Corrected the tile join routines to fix a bad memory leak in the
   tile allocation and recovery---a fix which was mentioned in issue
   #414 but which had not yet been implemented.  This has now been
   tested and confirmed to work.
2025-11-07 11:00:22 -05:00
R. Timothy Edwards 969137d1e2 Corrected an unfortunate error from the previous commit due to
missing copying one line with a conditional.  The error results
in "bloat-all" DRC checks reporting false positive errors.  This
commit fixes that error.
2025-11-03 15:06:54 -05:00
R. Timothy Edwards f3adea8c65 Made a few corrections to recent code additions. Also added
more points to accept interrupts during DRC checks, and
modified the tech file parser to allow the full syntax for
magic layers that is allowed elsewhere (e.g., "(*ndiff,poly)/a")
(this applies to magic layers, not GDS layers).  Fixed a
clipping error in the bloat-all function which was causing
non-manhattan geometry to produce bad results, which would
cause false-positive DRC errors when used in a CIF-DRC rule.
2025-10-31 17:37:02 -04:00
R. Timothy Edwards 51b9846120 Made a correction to the DRC error checking on a non-Manhattan
edge.  This was catching geometry unrelated to the error when doing
a spacing check between geometry on different planes.  In the
reverse-edge case, magic needed to run an additional search over
the area on the other side of the original edge that triggered
the rule to effectively clip that corner of the triangle from the
search area.
2025-10-30 12:07:29 -04:00
R. Timothy Edwards 1afd48e840 Corrected an error in which an invalid client name passed to the
"macro" command will crash magic.  This will happen if, for
example, magic is compiled without OpenGL support, in which case
the "wind3d" client does not exist, and parsing the default
macros from the system .magicrc file will cause an immediate
crash.
2025-10-29 09:32:03 -04:00
R. Timothy Edwards 99a5a28a3e Added a drc check to the gencell change procedure, as it appears
that otherwise DRC is not re-checked after a gencell update.  It
is not clear to me why checks are not done otherwise.
2025-10-28 15:10:03 -04:00
R. Timothy Edwards 0ac4d3a465 Found a way to work around the problem of having subcell DRC
errors show up as "See error definition in subcell", which has
been the case since I modified the code to prevent showing DRC
errors in subcells that have been resolved by the hierarchy
above them.  DRC errors are now intelligently searched
downward in the heirarchy when enumerated for "drc why".
Also changed the DRC check tile definition to offset such that
there is a tile centered on the origin, instead of the origin
being between four tiles.  Since most layouts are subcells and
most subcells are small relative to the DRC check tile area,
and most subcells are placed near the origin, then most subcells
will appear in only one tile, which speeds up the DRC process
somewhat.
2025-10-23 17:11:44 -04:00
R. Timothy Edwards 42aa06f8f5 Corrected what seems to be a long-standing error in which
DRCCheckThis() is called in order of top to bottom of the hierarchy
when called from drcCheckFunc() although it was changed to order
DRCPendingRoot from bottom to top.  drcCheckFunc() then does it
backwards.  Fixing this appears to have resolved some weird errors
with DRC errors not showing up when doing "drc check" (initially)
and DRC errors disappearing when making changes to a generated
cell.  Appears to be okay now.
2025-10-22 17:27:00 -04:00
R. Timothy Edwards 4d2912a406 Corrected the return value of spcWriteValue() (recently added)
from "bool" to "void" (does not return a value).
2025-10-21 09:15:05 -04:00
R. Timothy Edwards b668b02a1f Corrected a problem in which "cellname delete" never cleared the
cell name from the cell name hash table.  So when "cellname rename"
was changed recently to prevent changing the name of a cell that
already exists, the suggested recipe for R-C extraction no longer
works:  "load x; flatten y; load y; cellname delete x; cellname
rename y x".  Solved by adding a HashRemove() function to the
cell deletion routine.  Thanks to Egor Lukyachenko for reporting
the issue (Github issue tracker #467).
2025-10-20 11:03:03 -04:00
R. Timothy Edwards 6b8f5d1d67 Modified the toolkit behavior so that a default callback to update
the dialog (and run limit checks) is installed by default on
checkboxes and selection menus, as it is already done for entry
boxes.  Otherwise it is possible to make a selection (like changing
a device type) that invalidates the existing values, but if Apply
is hit immediately afterward, then no checks will be run and the
values may be used as-is even if invalid.  This does not prohibit
the use of "add_dependency" to change the callback behavior.
2025-10-16 17:08:15 -04:00
R. Timothy Edwards 9327e319da Corrected ext2sim to handle the new "dsubcircuit" device type,
added in a recent commit.  The extension was handled by
"ext2spice" but "ext2sim" was missed.  Without it, "extresist"
will fail for any circuit containing a device defined in the
tech file extract section with "dsubcircuit".
2025-10-15 08:31:58 -04:00
R. Timothy Edwards 0e84616af8 Corrected an error that allows a cell to be renamed with the name
of an existing cell, which does not appear to be a fatal problem,
but must be causing a memory leak.  Also:  Corrected an error in
extresist when reading .sim files, in code that is slated to be
overhauled, so this is just a patch to avoid a crash condition.
2025-10-14 10:36:07 -04:00
R. Timothy Edwards c42db8e71b Modified the key input redirection so that it captures and
handles Control-u in the same way that tkcon does, so that when
typing via redirection into the console, Control-u will delete
the entire command back to the prompt. (See github issue #456.)
2025-10-10 10:39:40 -04:00
R. Timothy Edwards 27c423c2ed Substantially revised the "macro" command callback functions and
the "tool" implementation.  Previously, the "tool" implementation
would overwrite the button bindings for the mouse.  The problem
with that is that if the user customizes one or more of the
bindings, such as using the mouse wheel for zooming instead of
panning, then the custom macro gets obliterated when the tool
changes.  The reimplementation creates multiple macro sets which
are unique to each tool.  The "enable_tools" function sets up
the initial unique default bindings for each tool.  The user
can then customize the bindings for any tool, and the
implementation no longer requires the constant changing of key
bindings.  Note that the new implementation is slightly less
efficient because the macro tables are found by string hash
based on the name of the tool or client type, not the integer
client ID.  The reduction in efficiency is balanced by the
increased flexibility of the macros.
2025-10-09 15:43:54 -04:00
R. Timothy Edwards 4951f013d5 Corrected the output of the new "dsubcircuit" device which was
generating output for one of the device nodes twice in the
netlist.
2025-10-08 10:04:38 -04:00
R. Timothy Edwards 656d27b17a Added a new "devresist" type "terminal" to account for resistor
terminal resistance, for cases where the resistor value is
estimated and output along with (or instead of) the physical
length and width or area and perimeter.  Corrected the "area"
and "perimeter" type handling so that they combine in parallel,
not in series (note that "perimeter" resistance is just an area
resistance with the depth of the material factored in).
2025-10-07 12:12:33 -04:00
R. Timothy Edwards d6d8620a7c Added new statements "connect" and "disconnect" to the extract
section of the tech file, which can be used to alter the layer
connectivity tables from the default.  This can be used, for
example, to disconnect substrate and well from taps, to
generate a netlist that checks for soft-connect errors.
2025-10-06 11:50:38 -04:00
R. Timothy Edwards a2390167e6 Updated the version to go along with the merge of pull request #455
from Darryl Miles.
2025-10-04 20:50:51 -04:00
R. Timothy Edwards 78f7d22796 A number of changes:
1) Corrected spurious error messages about cells already existing
   in GDS when using "flatten" or "flatglob".
2) Fixed handling of resistance as a subcircuit parameter
3) Added area and perimeter resistance for a device;  this is done
   through the "devresist" statement in the tech file, which is an
   extension of the original "fetresist" statement.  Where "fetresist"
   only supported type "linear", "devresist" supports types "area"
   and "perimeter".
4) Support for CDL syntax, including generating subcircuit-like
   parameters for components starting with SPICE-standard prefixes
   like M, R, C, etc., adding "/" between pins and subcircuit name,
   and saving the file as ".cdl" instead of ".spice".
5) Estimated L and W for devices whose geometry is complex and do not
   reduce to a simple rectangle.  L and W are estimated as the square
   root of the area.
6) Changed the method of extracting L and W for diodes to use the same
   method as capacitors.  Note that diodes are not usually specified
   by L and W, but if they are, this will produce the right result.
7) Corrected the reported filename and line number when printing error
   messages related to errors inside a technology file, when the
   technology file uses "include" to combine multiple files.
2025-10-01 15:17:49 -04:00
R. Timothy Edwards b1c7b52ed2 Modified "gds flatglob" to have the value "*_CDNS_*" by default,
since this is a common artifact of foundry cells and almost
always incompatible with magic.  Modified the "port" command to
allow "port make <index>" on a label where other labels of the
same text already have the same index.  Removed deprecated
documentation and added some missing documentation, such as an
explanation of the "ext2spice subcircuit auto" option.
2025-09-26 09:18:43 -04:00
R. Timothy Edwards 5de118b762 Corrected the greatest common factor routine that is run when
doing "save", which was missing checks on properties representing
coordinates (e.g., FIXED_BBOX) resulting in those values
potentially getting truncated by scaling the output to an
incompatible common factor.  Thanks to Sylvain Munaut for finding
the issue!
2025-09-17 12:20:13 -04:00
R. Timothy Edwards 00e3bbd12a Corrected the tech loader, which was failing to set the file
prefix when doing a reentrant load, causing include files to not
be found.  Fixed a divide-by-zero issue that occurs when some
tech file sections are not loaded to the abovementioned error.
2025-09-11 10:51:14 -04:00
R. Timothy Edwards 741216d6f3 Added a new command "archive" that works roughly like the "crash"
command, but with some critical differences, since the "crash"
command is designed for crash backups.  "crash" will save in a
temp file and removes the file after a successful recovery.
"archive" can be used at any time to make a complete snapshot of
a layout in a single file, or to read back that snapshot.
There is a "writeall" option that will make a snapshot including
layout of all read-only (PDK) cells.
2025-09-10 12:40:40 -04:00
R. Timothy Edwards 6195c20d3d Fixed an egregious error introduced by the "save <file>.tcl"
command handling in the previous commit, that can cause a crash
whenever "writeall" is called while a cell's filename is still
NULL.  Thanks to Daniel Estevez for reporting the error.
2025-09-08 09:22:14 -04:00
R. Timothy Edwards 59a1953f3c Modified the GDS read routine to give location information when
a self-intersecting or reversing path is seen in the input.
Added a new feature in which "save <cell>.tcl" will create a
file of magic commands that will re-create the cell when sourced
as a command file.
2025-09-05 17:51:46 -04:00
R. Timothy Edwards b1095b323c Added a command option for "select move" without specifying the
X and Y values, in which case the selection is moved to the
current pointer position.  This allows a different implementation
of the "copy" command as "select move; select keep", which avoids
the problem that "copy" has of modifying the selection with layer
interactions with the existing layout.
2025-08-27 09:57:22 -04:00
R. Timothy Edwards e04307c085 Corrected an issue in computing the extended (includes area of
label text) vs. non-extended bounding box of a cell when doing
"getcell" (and probably a number of other commands/functions, as
well).  A function was always computing the extended bounding box
and then setting both the normal and extended bounding boxes of
the cell to this value, resulting in incorrect cell selections.
2025-08-26 11:00:20 -04:00
R. Timothy Edwards d2acdac901 Corrected an error accidentally introduced a few commits ago in
(commit 4084a6a246) in which a
misplaced close-brace altered the way that "getcell" handles
some orientation cases.  Thanks to Sylvain Munaut for discovering
the error.
2025-08-21 10:44:24 -04:00
R. Timothy Edwards 8d762b4f59 Corrected an error that accidentally misses an input line from a
LEF macro if the FOREIGN statement ends without the optional
coordinates.
2025-08-20 15:01:57 -04:00
R. Timothy Edwards 0301bdec9e Made a simple change to "extresist" to set the REDUNDANT flag on
nodes which are created due to having multiple ports with different
names on the same wire (electrically connected pins).  This prevents
"extresist" from double-counting the wire.
2025-08-19 10:00:05 -04:00
R. Timothy Edwards 4084a6a246 Modified the syntax of the "getcell" command to make the
arguments unambiguous, and to allow coordinates to be given in
any units.  To do this, the (seldom if ever used) passing of a
label as a reference point was changed to require the "label"
keyword before the label name, avoiding the code having to
disambiguate arguments from label text.  This now makes it
possible to specify the coordinates in microns, lambda, etc.,
units.
2025-08-15 10:24:31 -04:00
R. Timothy Edwards 117ca41b8a Corrected an error in the substrate generation for extraction, where
non-manhattan geometry was not being transformed into the parent
orientation.  This went unnoticed for some time due to testing on
PDKs where substrate and well were not allowed to have non-orthogonal
edges.
2025-08-14 08:51:36 -04:00
R. Timothy Edwards 0fb19e568c Extended the "spacing" and "edge"/"edge4way" rules to take an
option "manhattan_dist" that causes corner checks to assume a
manhattan distance measure.  This is useful for checking
distances involving generated edges that are created by a CIF
"grow" operator.  For "spacing", "manhattan_dist" is equivalent
to "touching_illegal", as a use-case for forcing manhattan
distance measurements in corners has not been found for other
"spacing" options.
2025-08-13 11:34:29 -04:00
R. Timothy Edwards 5791ae3701 Made a small change to the "cifmaxwidth" rule check implementation
to ignore non-Manhattan (split) tiles.  This avoids creating false-
positive DRC results on split tiles which are larger in X and Y
than the max-width distance.  False negatives are possible but
correctly implementing a "maxwidth" rule for non-orthogonal areas
requires a completely different algorithm.
2025-08-11 12:10:09 -04:00
R. Timothy Edwards b4912fd550 Updated the version to go along with the merge of pull request
version 8.3.521 that, due to an argument size mismatch, causes
device parameters in netlist output to be printed as zero.
Also added a small extension to the list of extraction types
to include "device veriloga", which has the same syntax as
"device subcircuit" but generates a component type "N"
(Verilog-A component) in the netlist output.
2025-08-07 11:54:49 -04:00
R. Timothy Edwards 3472474617 Re-implemented parts of the DRC angle check to make it consider
that all layer types passed to a single "angles" statement in the
tech file are mutually non-interacting.  That is, "angles allm1 45"
will check angles on edges between metal1 and space, but not edges
between metal1 and via (which makes sense, given that a via is an
area into which to place contact cuts, and its edge is not a
physical boundary).
2025-08-06 09:22:12 -04:00
R. Timothy Edwards 2630ebcde1 Reverted a change made to "select area" earlier in the year, which
changed the behavior from selecting subcells if they are unexpanded
to selecting subcells regardless of the expansion state.  The
change was short-sighted and the implementation hard to use.  There
is a need, I think, for a selection method that effectively
unexpands instances, selects everything, and re-expands afterward.
But it's not clear if it is better to select all touching instances
or instances inside the box area;  maybe only interacting
instances (instances with non-space content inside the box).
Regardless, it needs more thought, and meanwhile, the original
behavior works better.
2025-08-04 14:39:10 -04:00
R. Timothy Edwards 8ed7394431 Corrected some basic paint code related to drawing over top non-
Manhattan tiles.  After splitting a non-Manhattan tile crossing
a search area to paint, the routine was automatically merging
tiles to the right.  This is incorrect for tiles inside the search
area, as it can cause the search algorithm to miss unvisited tiles
whose origins are to the left of the split tile, resulting in part
of the area not getting painted.
2025-08-01 10:47:01 -04:00
R. Timothy Edwards f52d90346e Updated the version to go along with the merge of pull request #428
from Darryl Miles, which overhauled the Makefile and cleaned up a
lot of long-standing minor issues.
2025-07-29 10:56:54 -04:00
R. Timothy Edwards 1cc4d83425 Corrected an issue with "bloat-all ... [dist]" in which an attempt
not to re-process processed tiles made an incorrect assumption,
causing tiles not to be re-processed when the clip area changed,
such that areas would be missed.  It is not clear that in its
corrected version, "bloat-all ... [dist]" is any more efficient
than the original implementation of an incremental series of bloat
+ AND.  At least the syntax in the tech file is much simplified.
2025-07-28 11:53:44 -04:00
R. Timothy Edwards 9fe7bf4ab7 Fixed an issue with a non-boolean variable in DBtiles.c being
cast as "bool", causing issues with the proper/strict use of
the "bool" type.  Changed the version back so that it will
update the github mirror tonight, since the current version
appears to be working.
2025-07-27 21:02:40 -04:00
R. Timothy Edwards 43bc006338 Reducing VERSION back to the previous value so that a mirror copy of the
bad code won't be made to github in case the issue with stdbool isn't
resolved by tonight.
2025-07-27 16:52:57 -04:00
R. Timothy Edwards 669604ace3 Updated the version number to go along with merges of pull requests
from Darryl Miles and Torleif Skoar.
2025-07-27 12:54:25 -04:00
R. Timothy Edwards d4f487266f Updating the version number to go along with the merge of a bunch
of pull requests (about half of those pending) from Darryl Miles.
2025-07-26 20:54:46 -04:00
R. Timothy Edwards eb81da6c56 Updated the version to go along with pull request #406 from Darryl
Miles (updates for github actions).
2025-06-19 09:55:57 -04:00
R. Timothy Edwards 490fc6f9d7 Added a quick hack solution from Darryl Miles to prevent the
database corruption discovered recently that was uncovered by a
commit on Jan. 31 and is caused by DBMergeNMTiles0() using a
freed tile (reported in github issue #404).
2025-06-12 19:54:33 -04:00
R. Timothy Edwards 5ecc55b37d Added some alternative key bindings to the keypad for "stretch"
commands, because the keypad numerical values no longer work
regardless of the setting of Num Lock.  The keypad arrow keys
alone implement "move", while Shift + keypad arrow keys
implement "stretch".
2025-05-22 08:47:03 -04:00
R. Timothy Edwards f1f4b82a30 Corrected an error caused by extending the parsing of the FOREIGN
keyword in LEF.  FOREIGN may take an origin offset, but it is
optional.  The routine to check that there were no offset values
in the statement incorrectly checked for a NULL token instead of
a value ";" which would indicate an end-of-statement.
2025-05-16 19:36:16 -04:00
R. Timothy Edwards 02669de267 Updated the version number to go along with a bunch of pull request
merges for PRs by Darryl Miles.
2025-04-09 15:27:18 -04:00