Commit Graph

775 Commits

Author SHA1 Message Date
R. Timothy Edwards 1a1cee058e Fixed an issue with the connectivity stack which does not change
"lasttop" after a new heap has been allocated and "top" is reset.
This is a minor issue, as even random data at the top of the
newly allocated heap is vanishingly unlikely to make a match,
but valgrind caught it as a use of unallocated memory, and it
should be fixed.
2026-06-03 11:34:41 -04:00
R. Timothy Edwards 03610f6d40 Additional tweaks to the handling of the three new options for
determining what does and doesn't get into the R-C extraction
output.  Added option "debug" and moved all excess diagnostic
information to be gated by this flag.  Corrected an issue in
the standard extraction in which the substrate is always output
with zero lumped resistance, preventing it from being checked
by "extresist" for inclusion or exclusion in the .res.ext output.
Reinstated the computation of minimum resistance transistor but
excluded other devices.  Added more sane handling of exceptional
conditions like loops.  The result is a more consistent check of
nets in the design.  However, I still need to recheck the
"rg_maxres" calculation because it appears to be too low.
2026-06-01 17:21:02 -04:00
R. Timothy Edwards 4393d9310a More work on the "extresist" code, this time to revise the way
that "extresist" selects or rejects networks for resistance
extraction.  The "tolerance" value, which nobody (including
myself) seems to understand, is now deprecated, replaced by
a handful of more meaningful options:  "threshold" to set a
lumped resistance estimate threshold to determined whether or
not to extract a network;  "minres" to specify when to prune
small resistors from the resulting tree network, and "mindelay"
to gate the selection and output on the estimated signal
propagation delay.  With these settings, I am much better able
to control the size and complexity of the resulting output.
2026-05-29 11:47:01 -04:00
R. Timothy Edwards 1bcad6a25c Significant overhaul of the extresist code. The purpose of this
overhaul was to introduce the concept of a "connection point"
between two cells to the ".ext" file format so that it becomes
possible to do proper hierarchical R-C extraction.  Previously
this information was not kept in the .ext file, making it
impossible for "extresist" to know what sub-net of a net connects
up or down the hierarchy.  However, additional changes were made
to the extresist code (in the resis/ directory) to add the
handling of connections up and down the hierarchy, and to make
the code a lot clearer and fix ambiguous variable and subroutine
names.
2026-05-28 13:12:13 -04:00
R. Timothy Edwards d9e6c78adb Corrected an issue that was caused by early work on extresist:
The original version of extresist only worked with 4-terminal FET
devices, and handling of devices with fewer terminals was ignored,
and never properly dealt with.  This commit fixes the issues with
devices such as diodes that have fewer terminals.
2026-05-27 10:52:44 -04:00
R. Timothy Edwards d8580be739 Corrected a problem caused by fixing the "select visible" command
with respect to visible/invisible labels and cells.  The change
inadvertently made the "select area" command option stop selecting
labels on the same type as the layers being selected.  This has
been fixed.
2026-05-26 17:01:45 -04:00
R. Timothy Edwards 5ecf10c022 Updated the version to go along with the merge of pull request #521
from Sylvain Munaut, which fixes an issue with the "property" command
when using the recently-added plane properties.
2026-05-25 12:07:33 -04:00
R. Timothy Edwards 099d513011 Corrected the "Pick" button action in the "Library Manager" window;
this had two issues:  (1) "getcell" was not being called with
"child 0 0", leading to child cells that are not placed where
expected in relation to a grid snap setting;  and (2) "cursor"
was assuming internal units and needed that to be explicitly
stated using "cursor internal".
2026-05-24 16:23:18 -04:00
R. Timothy Edwards e45399d347 Yet another optimization on "extresist", to remove the calls to
DBPaint() and DBErase(), which are meant as high-level calls from
the "paint" and "erase" commands and are not appropriate for low-
level tasks like erasing all contacts out of a database.  This
cut maybe 40 to 50% time off of the resistance extraction.
2026-05-22 12:02:03 -04:00
R. Timothy Edwards 7a3717b02a Another performance optimization to "extresist", this one to
avoid re-parsing a linked list from the current breakpoint
to the end to find all entries pointing to the same node.
Instead, the change to be made is saved in a hash table and
applied at the following link, so only one pass through the
linked list is required.
2026-05-21 19:55:50 -04:00
R. Timothy Edwards a062fdcfe0 Continued optimizing poorly written routines in "extresist".
Changed the "ResDissolveContacts()" routine to avoid running both
redundant and useless code.  Changed the breakpoint sorting
routine from a bubble sort to a merge sort for linked lists
longer than 16, as merge sort is more efficient for long lists.
2026-05-20 19:02:22 -04:00
R. Timothy Edwards 9626b5e8c9 Changed two sprintf() to snprint() on recommendation from an AI. 2026-05-19 12:21:54 -04:00
R. Timothy Edwards b983e33be7 Corrected an error with the recently-added "exception" DRC rule.
The logical expression for determining an excepted area was wrong
for one direction, resulting in false positive DRC violations.
2026-05-15 11:04:23 -04:00
R. Timothy Edwards 0013dda92d Response to issue #513 in the github issue tracker: The command-
line parser does not recognize arguments that are both in the
same word and also space separated;  this is easy to do from, e.g.,
a python interpreter by setting an option as a single string as
in "-d null";  it is harder to do from the command line, but can
be done with quotes, as in 'magic "-d null"'.

The utils/args.c routine parses this with ArgStr(), which recognizes
two cases, one in which the option is split across two arguments,
and one in which the option is one word without space separation.

I modified ArgStr() to accept a third syntax in which the option
is in a single argument but is also space-separated.  This simply
detects a space in the third character position and moves forward
to the next non-space character and returns that position.
2026-05-13 08:30:32 -04:00
R. Timothy Edwards 8fea20425e Merged PR #512 from Intubun, reworking the wasm workflow. Updated
the version to force a test of the workflow.
2026-05-12 08:57:42 -04:00
R. Timothy Edwards fb01f77755 Updated the version to go along with the merge of pull request
the repo parsing on opencircuitdesign.com, since yesterday I found
out that the tags were not updating, caused by a documentation
change in a copy of the repository that created a merge conflict
when seen by the script.  Will check tomorrow that everything ran
smoothly overnight.
2026-05-11 14:23:04 -04:00
R. Timothy Edwards bdc0325901 Extended the use of "ext2spice resistor tee on" to include
DEV_RSUBCKT as well as (previously implemented) DEV_RES.  The
handling of DEV_RSUBCKT includes checking if the subcircuit has
a substrate pin, and zeroing the capacitance to substrate for the
resistor node, under the assumption that the parasitics are part of
the resistor subcircuit model.
2026-05-09 20:05:52 -04:00
R. Timothy Edwards df4ec3ab32 Corrects an error that can cause "extresist" to segfault. This is
due to moving away from using the node "location" in favor of a
drivepoint specified by a port or other connection point.  The
"location" record can end up at the default value of "infinity",
and should not be used to set the area for searches.  This fix
is in response to issue #502 on the github issue tracker, submitted
by Julian Schwarz.
2026-05-06 10:21:35 -04:00
R. Timothy Edwards d0e38df6bf Fixed an error introduced in the last commit (which has been in the
code now for 10 days).  The last commit fixed an error when using
drcCanonicalMaxwidth() multiple times in DRC rule checks on a single
edge.  At the time, I also added a method to save some
drcCanonicalMaxwidth() results to prevent needlessly re-doing the
same (potentially expensive) computation over and over.  However,
where I reused the cached result, I did not check if the number of
entries is zero.  Other code does not check the number of entries
and depends on the prior behavior that drcCanonicalMaxwidth()
returns NULL when there are no entries.  So the code needed to check
if the number of entries is zero before re-using the cached result.
Without the fix, any time the caching is used, the last computed
maximum area rectangle will be made active even when the current
check area does not meet the area requirement, resulting in many
false positive errors.
2026-04-24 11:21:15 -04:00
R. Timothy Edwards d157eea7f3 Fixed an error that was discovered with the drcCanonicalMaxwidth()
routine, which in turn affects various DRC rules like maxrect,
widespacing, and runlength spacing.  drcTile() was computing
the drcCanonicalMaxwidth() result for the tile and reusing it,
failing to account for the fact that within the loop over
DRCCookies, other rules might require calling drcCanonicalMaxwidth()
on a neighboring tile, or on the same tile with a different width
requirement.  Implemented a cached version, in which three results
are kept:  One for neighboring tiles (which can never be reused on
the same edge), one for the first required use of the routine for
the tile, and one for any other use required for the tile.  If
there are one or two such rules for an edge, then the routine will
work at maximum efficiency.  If there are three rules, then one
will always be a cache hit and reduce the total amount of
computation, although it will still be doing a massive amount of
redundant computation.  If this seems to be something that
occurs regularly, then it can be revisited.  The existing
implementation works fine for all the open PDKs.  Some more
advanced PDKs with a number of staged wide-spacing rules could
have issues.
2026-04-14 17:37:10 -04:00
R. Timothy Edwards ae6d26578e Fixed issues with the "macro" command that have existed since the
"tool" command was changed to be overridden by a Tcl command.  Due
to macro clients being registered with the tool name instead of
just "layout", the "macro" command with no arguments or with a
window client argument was just broken.  In the process of fixing
this, I realized that there was a conflict between the use of
"netlist" as a window name and also as the name of a tool, so I
changed the tool name to "nettool", a change which should be
transparent to the end user.  Otherwise, "macro netlist" returns
the key bindings for the window, and the only way to get the key
bindings for the tool is to make the tool active and then use
"macro" without arguments.  One remaining issue is that there is
no syntax error that will cause the list of valid windows and
tools to be printed.  Probably "macro help" should print usage
information instead of acting like "macro" with no arguments.
2026-04-13 12:26:42 -04:00
R. Timothy Edwards cb1653b157 Found that I needed to apply the same correction as the last
commit to the "tagged" GDS/CIF operator, or else this will have
exactly the same issue as "bloat-all".
2026-04-10 13:39:17 -04:00
R. Timothy Edwards a3f5e665d1 Found an extremely bad error, where the "bloat-all" GDS output
operator does a second search to reset tiles and clear the
"processed" mark.  This second search was only searching on the
types being bloated *into* and not the original types being
bloated.  This caused tiles to remain marked as "processed" which
could in turn cause the tiles to be ignored forever after, potentially
resulting in bad GDS output.
2026-04-09 11:13:30 -04:00
R. Timothy Edwards 2eea849c06 Corrected a crash condition in R-C extraction (extresist) caused
by old code that still references devices like FETs assuming
four ports.  I resolved the crash condition but have not worked
on fixing the code to properly handle a variable number of
terminals per device.
2026-04-07 21:15:56 -04:00
R. Timothy Edwards ceba050a21 Fixed the mess that is the "expand"/"unexpand" command set. This
had numerous problems, the main one being that each of the three
commands was inconsistent:  "expand toggle" inverts the expansion
of the selection and syncs with the layout.  But "expand" expands
the layout where instances overlap the box and does not sync to
the selection, and "unexpand" unexpands the layout where the box
completely surrounds instances.  Added a set of options to
"expand" and "unexpand" so that these functions can be made
consistent with each other.  All varieties of the function now
always sync the selection and the layout.
2026-04-04 20:47:04 -04:00
R. Timothy Edwards 5d35ae38b5 Corrected an issue causing MASKHINTS values to fail to be written
back to the file, instead resulting in a property key only and no
value;  this in turn produces an error when read back in.  Another
cycle of reading and writing causes the property to disappear
altogether.

Also:  Corrected another related error that claims to have truncated
the mask hints when in fact everything was working normally.
2026-04-02 14:45:08 -04:00
R. Timothy Edwards 05561b90f3 Solved three issues:
(1) There was still one place that dimensional units were not being
    printed, which was "setlabel", with both "setlabel size" and
    "setlabel offset".  This has been fixed.
(2) Fixing (1) surfaced an error in the text helper dialog, which was
    not setting units properly when checking the size and offset entries.
(3) Fixed a very long-standing problem in which port labels were showing
    up with the "pale" style of a subcell's label being drawn on top
    when the parent and child had the same label in exactly the same
    position.  This was due to a parent-first search resulting in the
    child cell being visited last, so its "pale" style label being drawn
    last.  Added a flag for label searches for display to reverse the
    search order, visiting children first and then the parent, so that
    the top cell's labels are the last to be drawn.
2026-04-01 21:17:54 -04:00
R. Timothy Edwards 9ade4c931e Updated the version to go along with the merge of two pull
requests from Darryl Miles.  The second of these should finally
put to rest all the compile-time issues related to "termio/termios"
(yay).
2026-03-26 09:23:58 -04:00
R. Timothy Edwards 7fd2ef8100 I admit I was juggling with too many balls in the air yesterday
and managed to commit some code that I thought I had tested---
but apparently what I tested was not the latest version of the
code.  So 8.3.627 is quite broken and won't even compile.  This
update fixes that.
2026-03-25 14:07:54 -04:00
R. Timothy Edwards e789f18523 Yet another pass at the problem caused by implementing DRC
exceptions;  avoided the use of "signed char" altogether by just
making the drcc_exception value a bit mask with the lower 7 bits
being the index and the upper bit being the flag for exception (0)
vs. exemption (1), with the value 0xff being reserved for "none"
(no exception or exemption).  This implementation should avoid any
issues caused by ambiguity in the use of signed vs. unsigned char.
2026-03-24 09:37:50 -04:00
R. Timothy Edwards 7ceeccef56 Corrected an issue found by Harald Pretl and solved by Claude.
Use of "char" does *not* implicitly mean "signed" on ARM
architectures.
2026-03-22 11:14:19 -04:00
R. Timothy Edwards 2d5c4be6dd Added a few lines of code to the toolkit management to work around
the issue of a device name in a netlist having different case than
the procedures defined for the device in the PDK.  The difference
in case is transparent to SPICE, so it should also be transparent
to the PDK.
2026-03-18 12:18:42 -04:00
R. Timothy Edwards 8f95efc257 Added a feature to the toolkit scripts for generated devices to
allow ideal devices in an input netlist to be mapped to
automatically generated cells.  This works if the PDK toolkit
defines a device called either "capacitor" or "resistor".  The
device must be defined such that it can determine sane parameters
for the drawn device from only a value given in the netlist
(capacitance in farads, or resistance in ohms).
2026-03-17 11:32:53 -04:00
R. Timothy Edwards 7d9167257a Corrected an error caused by a recent commit that was attempting
to avoid bogus values for array pitch in the direction in which
a cell is not arrayed:  If the array declares an ANGLE of 90 or
270, then rows and columns are effectively swapped for the
purpose of figuring out which coordinate direction should be
ignored in the input.  The original example did not use ANGLE
and so the exception was not handled.
2026-03-16 12:50:17 -04:00
R. Timothy Edwards fee4b887c0 Corrected an issue in ext2spice in which devices extracted as
ideal, unmodeled capacitors or resistors are missing a space
between the 2nd terminal and the device value in the output
netlist.  This affects the ability to produce correct output
for, for example, a metal fingered capacitor using the
"device" property to generate an ideal capacitor in the
netlist.
2026-03-15 15:40:10 -04:00
R. Timothy Edwards 04e91d640d Corrected a problem in which if a label exists that is only connected
to material in a child cell, and the label is a point or line label,
and the parent cell has no material other than the label in the
immediate area, then the "interaction area" will have zero area,
which will cause problems as area checks on a zero-sized area don't
do anything useful.  The solution is to ensure that interaction areas
do not have zero area, but will expand around point labels.  This
should not have any other implications, because the interaction area
is just a way to limit the amount of processing;  larger interaction
areas do not affect the extraction result (except in this case, where
it fixes the error).
2026-03-12 11:50:21 -04:00
R. Timothy Edwards 15943d0cb1 Implemented new cifinput/cifoutput operator "labeled" which operates
like "bloat-all" except starting with a label and expanding into a
type rather than starting with a layer.  This is equivalent to what
many tools refer to as "stamping".
2026-03-11 15:06:24 -04:00
R. Timothy Edwards 7bdd9e1d4f Reworked the method from the previous set of commits, which creates
yet another property type "plane".  This allows mask hints to be
handled like tile planes.  That is, after all, what they represent.
Although this change is transparent to the end user (apart from a
slight performance improvement that is probably not noticeable), it
allows for a number of useful future extensions, including the
ability to handle non-Manhattan geometry in mask hints, and the
ability to view and edit mask hints like any other layout.
2026-03-10 14:25:02 -04:00
R. Timothy Edwards 725c8e9235 Made a few corrections to yesterday's code. Most are minor, but
one can potentially cause a crash condition.
2026-03-09 14:40:53 -04:00
R. Timothy Edwards 73ffad3802 Implemented the new feature discussed in the github discussion #492.
This features allows two new instructions in the tech file "drc"
section:  "exception <name>|none" and "exemption <name>|none".  The
purpose of these rules is to allow DRC rule exceptions for certain
areas which are marked, usually by a GDS identifier layer.  Because
GDS identifier layers can be cast as "mask-hint" properties, the
DRC rule exceptions make use of that (recent) feature.  So rules
can be specified as "exceptions" (rule applies for layout inside
the marked area) or "exemptions" (rule is ignored for layout inside
the marked area).  Rules following the statements will have the
exception or exemption applied until another exception or exemption
statement is given.  Either "exception none" or "exemption none" will
stop applying any rule exception or exemption.  This is especially
useful for applications like SRAM where there may be a number of
rule exceptions on different layers.  The previous way to handle
that was to create new layers in magic for any layer that needed a
rule exception.  That mainly resulted in very messy tech files,
and a large number of defined layers.  This implementation is both
simpler and cleaner.
2026-03-08 20:12:58 -04:00
R. Timothy Edwards 0d9b862c0e Corrected a minor error in ext2hier.c where views with no devices
and no ports are still supposed to be output as instances if they
have been marked as abstract views.  Such views were getting output
as cell definitions but not instanced, which although is irrelevant
for simulation, would potentially cause LVS errors.
2026-03-05 09:35:28 -05:00
R. Timothy Edwards 71dc472797 Modified the toolkit code to make use of the "units" command;
otherwise, the existing code would produce results that vary
by units, with potentially incorrect label sizes and spacing
between instances when generating layout devices and subcells
from a netlist.
2026-03-04 13:34:31 -05:00
R. Timothy Edwards 2929ef583e Minor correction to the new "repeat <steps> ... endrepeat" function for
tech files, as the first implementation was repeating one too many
times.  Also:  The wrong type was being read for the number of steps,
although the resulting value was correct.
2026-03-02 12:24:46 -05:00
R. Timothy Edwards f3478cba7b Fixed a few issues related to the "save <file>.tcl":
(1) Dimension properties were not output correctly.
(2) Magic insisted that the output file was <cell>.tcl, not <file>.tcl,
    although the error was only in the messaging
(3) Magic was incorrectly renaming the cell to <cell>.tcl after writing
    the file.
2026-03-01 11:29:25 -05:00
R. Timothy Edwards ba5154698d Thought better of the recent change to make "snap" no longer change
units;  although that is a more proper usage, it also happens to
break a lot of existing scripts.  Since virtually all of these
scripts start out with "snap internal" to force units, I have kept
this single usage, when "units" is still set to "default".  That
keeps the older scripts from breaking, while hopefully scripts get
updated over time to use "units" instead of "snap".  Note that there
are still ways to make this behavior break, such as running
"units microns" to set units and then sourcing a script that assumes
that "snap internal" will change the units, which will then not
happen.  But batch scripts should be handled property with backwards-
compatibility mode.
2026-02-28 20:07:00 -05:00
R. Timothy Edwards 197763e46e Modified the output of "save <cell>.tcl" so that (1) it strips the
".tcl" off of the name, so that the cell name remains the same, and
(2) it uses "units" instead of "snap", as the latter is no longer
used for setting the unit type.
2026-02-27 11:18:27 -05:00
R. Timothy Edwards cb7855235a Added a new cifinput operator "not-square" that is useful for
differentiating between bar and square contacts on input.  Also:
added handling of the "mask-hints" operator for GDS input as
well as GDS output.  This is a bit more realistic now that the
mask hint properties are handled as scalable integers and not as
character strings.
2026-02-26 12:48:00 -05:00
R. Timothy Edwards 8f684ad5be Found and fixed the actual error underlying the problem with
grid rescaling while reading a GDS AREF record.  The previous
commit is still valid and prevents excessive warnings and
unnecessary rescaling when a bogus value is given for an array
pitch when the array has only one row or one column.  But the
scaling was still incorrect and would potentially cause an
error if an array pitch was at a finer scale than any data read
before it, forcing a valid grid rescaling.  This now works
correctly.
2026-02-25 09:59:28 -05:00
R. Timothy Edwards afca58f162 Fixed a number of places in the Tcl code where "snap" had been used
to force internal units to be used;  this usage is now deprecated
and needed to be changed to the "units" command.  Also:  Fixed a
separate issue with getting both "view bbox" and "view get" to
return values in the currently selected units.  Also:  Fixed an
issue with "property" when setting a property to a list passed as
a single value (e.g., "property FIXED_BBOX [box values]"), which
needed to null the string after each value.
2026-02-24 15:59:21 -05:00
R. Timothy Edwards c32bae1a24 Corrected a minor error from yesterday's commit that will cause
magic to complain about reading GDS_START and GDS_END properties
from a .mag file, although its fallback method handles the properties
correctly, anyway, so there is no actual impact other than the
error message.
2026-02-19 09:42:41 -05:00