Commit Graph

55 Commits

Author SHA1 Message Date
Darryl L. Miles 44bb9327a2 ExtTech.c: fix uninitialized exts_linearResist value leaks into extresist
This value appears to be initialised at only one spot in the codebase
(under very narrow conditions) but extresist will read it and make
branching decisions based on the uninitialised state.

This 'X' state propagation appears to eventually get processed in
ResWriteExtFile() near where final output formatting is occurring.

It is unclear (at this time) if it perturbs output values in a
problematic way, or if due to algorithmic reasons the data is
discarded before output anyway.  I have at least one trace run (with
multiple triggers) of printf formatters handling uninitialised data
in ResWriteExtFile().
2025-04-09 15:25:02 -04:00
Darryl L. Miles 07f9bbe1fb gcc11 -Wall -Wpedantic cleanup 2025-01-06 16:12:11 +00:00
Darryl L. Miles 14b6453707 LookupStruct() constify call-site
irouter/irTestCmd.c: LookupStruct() constify call-site
irouter/irCommand.c: LookupStruct() constify call-site
mzrouter/mzTestCmd.c: LookupStruct() constify call-site
mzrouter/mzTech.c: LookupStruct() constify call-site
router/rtrCmd.c: LookupStruct() constify call-site
plow/PlowTest.c: LookupStruct() constify call-site
plow/PlowTech.c: LookupStruct() constify call-site
plot/plotVers.c: LookupStruct() constify call-site
grouter/grouteTest.c: LookupStruct() constify call-site
garouter/gaTest.c: LookupStruct() constify call-site
extract/ExtTest.c: LookupStruct() constify call-site
extract/ExtTech.c: LookupStruct() constify call-site
extflat/EFread.c: LookupStruct() constify call-site
DRCtech.c: LookupStruct() constify call-site
debugFlags.c: LookupStruct() constify call-site
CmdSubrs.c: LookupStruct() constify call-site
geometry.c: LookupStruct() constify call-site
set.c: LookupStruct() constify call-site
2024-12-26 15:20:58 -05:00
Tim Edwards e0c95d6d78 Additional coding to handle discovery of terminal types on
different planes of a device that are connected to a multi-tile
device.  This is a more general solution than previously coded,
in which only the first tile of a device would be searched for
terminals on other planes, which was only guaranteed to work
if the device was represented by a single tile.
2024-12-06 20:51:59 -05:00
Darryl L. Miles 9ca8697659 strings.h: add #include required when strict
Due to use of strcasecmp() or similar C API.

Maybe HAVE_STRINGS_H is needed ?  If so which platforms needs this ?

clang18 default warning cleanup (strict)
2024-10-09 21:22:37 -04:00
Darryl L. Miles 967b41343b GCC14: warning: missing braces around initializer
GCC14 -Wall cleanup series [-Wmissing-braces]
2024-10-09 21:12:55 -04:00
Darryl Miles 21924ec151 extract/ExtTech.c: Too few arguments to formatting function
Fix code scanning alert no. 61: Too few arguments to formatting function (#35)

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2024-10-01 12:36:13 -04:00
Darryl Miles 66297bd7d0 extract/ExtTech.c: Too few arguments to formatting function
Fix code scanning alert no. 60: Too few arguments to formatting function (#36)

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2024-10-01 12:36:13 -04:00
Darryl Miles 2a00ab7eb8 extract/ExtTech.c: Incorrect return-value check for a 'scanf'-like function
Fix code scanning alert no. 136: Incorrect return-value check for a 'scanf'-like function (#11)

* Create codeql.yml

* Fix code scanning alert no. 136: Incorrect return-value check for a 'scanf'-like function

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

---------

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2024-10-01 12:36:12 -04:00
Tim Edwards 7a9445ec30 Corrected the extraction offset, in which a parameter like "l"
can provide a delta offset such as "l+0.06", indicating that
the extraction model has a length larger than the drawn device.
Previously the value was assumed to be in microns but did not
scale between the .ext file and the SPICE netlist.  Corrected
so that it scales like the other parameter values, being
converted to internal units and tracking the internal grid
scale.
2023-10-24 20:29:04 -04:00
Tim Edwards b899a500d5 Added a new method to the extraction which allows parameter limits
to be declared for each device model, so that different models can
be specified for different parameter ranges.  For example, this
will simplify the definition of the high-sheet-rho poly resistors
and the bipolar transistors in sky130 by removing the need for ID
marker layers;  it also allows the correct device model to be
extracted when reading data from GDS that does not contain the
extra (and not foundry-approved) ID markers.
2023-07-06 12:35:47 -04:00
Tim Edwards ca985edbd0 Corrected a typo in the previous commit that causes parameters to
be output twice for scaled devices (such as diodes in the sky130
process).  Above and beyond the typo, though, the implementation
of offsets is not very well thought out and needs to be revised.
For one, the +/- notation can be confused with signs in the
parameter expression;  that is also fixed in this commit.  But
there is currently no way to express both a scale and an offset
for a device parameter.
2023-06-23 08:39:59 -04:00
Tim Edwards 07267dc126 Extended the device parameter notation to include offsets using
'+' and '-' in the same way that '*' is currently used for specifying
a parameter scaling.  The combination of a scale and offset for the
same parameter has not (yet) been implemented.
2023-06-21 20:44:38 -04:00
Tim Edwards 482d7534a2 Reimplemented the "extract do local" option as "extract path <name>"
with "extract do local" now being equivalent to "extract path .".
This allows extraction files to be put in a subdirectory and not
clog up the current working directory.  Also:  Fixed some behavior
around the use of "ext2spice -p <path>" so that it (1) works, and
(2) is compatible with the new "extract path".  Since the ext2spice
and ext2sim commands are effectively independent of the primary
extraction, the "-p" option is needed to correspond to the use of
"extract path".  Hopefully this is seen as only a minor inconvenience.
2023-06-14 13:55:59 -04:00
Tim Edwards 33d0d53d34 Corrected an error in the extract section setup of the tech file
that allocates and deallocates a single layer mask used by the
tech reader.  Decided to work around the issue just by allocating
it only once and not releasing it---it's just a few bytes.
2023-02-22 17:56:45 -05:00
Tim Edwards be577d4318 Corrected the reading of the "defaultsidewall" statement in the
tech file "extract" section to work correctly when the offset is
negative.  Generally, a negative offset is nonphysical and is just
curve-fitting round-off error, but the existing code was failing
to divide out the factor of 1000 that had been multiplied through
when reading the tech file, resulting in a very wrong offset.
2023-02-22 15:30:50 -05:00
Tim Edwards 1a3caee376 (1) Added a check for unclosed boundaries when reading GDS.
This is diagnostic only and does not change the read-in
    behavior.
(2) ext2spice:  Corrected an error that had been introduced
    into version 8.3.171 that accidentally marks all devices
    as visited which causes all source/drain areas and
    perimeters to be output as zero.
(3) extract:  Sweeping changes to handling of fringe
    capacitance.  Removed the (recently added) "fringeshieldhalo"
    parameter from the tech file.  Reworked the fringe
    capacitance models based on results from the "capiche"
    project (github/RTimothyEdwards/capiche).  Fringe shielding
    is now done by clipping fringe at the boundary of a
    shielding shape, rather than trying to calculate the
    amount of shielding (as the "capiche" project proved this
    to be equivalent).  Values for partial fringing are modeled
    by atan(x), which like the sidewall (1/x) curve, extends to
    infinity and values are limited by the halo but do not
    otherwise depend on the halo.  Because of this, the halo can
    be made variable and controlled by the user for deciding on
    the tradeoff between accuracy and run time.  A new command
    option "extract halo" was added to allow this control over
    the halo distance.
2023-01-27 11:47:37 -05:00
Tim Edwards a9aafebfc4 Corrected the antenna checking routines, which were incorrect with
respect to calculations around diode-connected diffusion regions.
The diffusion area calculation needed to be fixed to avoid double-
counting contacts, and the value for the ratioDiffA coefficient
needed to be scaled, since it is multiplied by the diffusion area
and therefore has dimensioned units of (1/area^2) and should be
treated like all other dimensioned units in magic.
2022-11-06 11:50:05 -05:00
Tim Edwards 9d40fbfecb Corrected an error in parsing the "defaultperimeter" statement in
tech files which incorrectly parses the syntax using five
parameters.  This syntax variant does not get used often, which
is why the error went undetected for a long time.
2022-10-22 22:12:15 -04:00
Tim Edwards c001de3d9d (1) Corrected an error in generating GDS_FILE properties when
reading GDS files, caused by an unneeded change to pass both
the "original" filename and the actual filename when handling
compressed files---The original filename is unneeded.
(2) Implemented several new methods for parasitic extraction.  The
first is an option offset value to apply to sidewall calculations.
This handles issues where actual wire separation is different
from drawn wire separation, which can be significant for the
1/d calculation of sidewall coupling.  The second method is to
use the recently-added fringe halo to compute the coupling of the
fringe capacitance to nearby wires.  Prior to this change, all
fringe capacitance was applied to surfaces directly under a wire
edge as if the fringe capacitance did not extend outward from the
edge.  Now the capacitance is properly pro-rated for the position
of any overlapped shape inside the fringing field.  Finally, the
third method added is a new search algorithm for finding the
nearest shapes along the length of a boundary.  This is used for
sidewall coupling and fringe shielding, where the nearest shape
dominates the coupling, and any shapes behind are shielded and
may (to first order) be ignored.  Previously, the entire halo
was searched without regard to shapes shielding other shapes
behind, and a recent correction added an ad-hoc search for
blocking shapes that was inefficient and not always correct.
The new method is both efficient and accurate.
2022-05-28 10:33:21 -04:00
Tim Edwards d98645afc1 Added an important new method: If the keyword "fringeshieldhalo"
is specified in the extraction section of the techfile, then magic
will compute the effect of a nearby shape partially shielding the
sidewall overlap capacitance, which approaches 100% shielding as
the shapes converge to zero separation.  This method prevents
magic from vastly overestimating the fringe capacitance of closely
spaced wires, which was magic's worst problem with parasitic
accuracy.  The "fringeshieldhalo" value is the distance at which
the fringe shielding becomes negligible.  Typically, it will be
about three times the distance at which half the fringe value is
shielded.  It may be necessary at some point to make both the
fringe shielding halo and the sidewall halo values per-type values
(or per-plane, at least).  For now, it should suffice to bring
Magic's parasitic extraction back in line with other tools.
2022-03-17 17:35:41 -04:00
Tim Edwards 16c0a65adc Several important fixes to the handling of coupling capacitance,
which had become fouled up due to the changes in the way that the
substrate is defined and handled.  Worked through a large torture
test until all types of substrate coupling and overlap shielding
were resolved to be extracted as expected.
2022-02-23 20:57:30 -05:00
Tim Edwards 505155497e Resolved an issue with magic crashing during "antennacheck" due to
a routine that should have been called with a NULL argument, but
instead was called with no argument, making the behavior system-
dependent.  Revised the parsing of the "defaultareacap" and
"defaultperimeter" statements in the tech file, such that the short
version of both statements gets automatic handling of the substrate
and isolated substrate areas;  this goes back to the recent change
in extraction behavior to redefine the "substrate type" (e.g., pwell)
during extraction as defining isolated substrate areas, and not the
default substrate.  The earlier code change dealt with problems
related to extracting nodes and regions, but did not consider how
parasitic capacitance was affected.  This commit resolves that issue.
2022-02-23 15:02:40 -05:00
Tim Edwards 6ecd077ab4 Restored compiling of the non-Tcl/Tk version of magic. This has
traditionally been kept for backwards compatibility.  However, the
operation of "ext2spice" and "ext2sim" as separate programs has
become extremely difficult to maintain, and so it has been dropped
in favor of folding both into the program as commands, as was done
a long time ago in the Tcl/Tk version.
2022-02-08 16:12:07 -05:00
Tim Edwards c8c8f8b362 Slight change to the criteria for "electrical" types: Removed
device ID layers, and added substrate shield layers.
2022-01-14 17:42:21 -05:00
Tim Edwards 73314e30d7 Added some automatic handling of the "extract" section in the tech
file to generate a mask of all the types called out in the section
as being used for parasitic calculations (resistive and capacitive)
and device terminal types.  This is supplemented with a list of all
types that are specified in the "connect" and "contact" sections as
connecting to something other than themselves.  All remaining types
are considered non-electrical and removed from the list of types
that can be considered electrical nodes.  This works a bit better
than the existing method of using "resist <types> None" to specify
non-electrical types, as it is backwardly-compatible to older tech
files.  The upshot is that in the worst case, if a type needs to be
extracted as an electrical node but does not satisfy any of the
above criteria, then it should be added to the "resist" list, with
a resistance of 0 if necessary.
2022-01-14 17:30:05 -05:00
Tim Edwards 271449128a Updated the way that the technology file parser handles the
"defaultareacap" and "defaultperimeter" statements in the technology
file.  Now, the parser makes use of the configuration of the
substrate from the "substrate" line to generate a default list of
which types and planes represent the substrate, and which types and
planes represent shielding to the substrate.  This solves an issue
with the use of substrate isolation layers (e.g., "isosub" in
sky130A), because its definition and usage created substrate shields
on two planes (well and dwell), while the syntax for "defaultareacap"
and "defaultperimeter" only allow one shielding plane to be defined.
2021-12-31 11:13:59 -05:00
Tim Edwards 82f280e23e Corrected a failure (in the code for many a decade) to properly
clean up memory after running "ext2spice".  There are apparently
still memory leaks somewhere, difficult to diagnose with valgrind,
but this fix removes the most substantial leakage and allows
"ext2spice" to be run continuously, at least for a while.
2021-12-13 16:12:30 -05:00
Tim Edwards f428b7c792 Corrected a scaling error that causes all extraction dimension values
to be scaled twice when using the "extract style" command and with an
extraction style that uses micron units.  The microns-to-internal
units conversion expects an unscaled result when calling
CIFGetOutputScale(), but except when loading a tech file for the
first time, this value is scaled, and causes the double scaling.
Fixed by unscaling the CIF output before reloading the extraction
style, then scaling it afterward.
2021-08-23 13:46:19 -04:00
Tim Edwards 25166f2f7c Corrected issue with finding devices in ResMain()---there is not
necessarily a 1:1 correspondence from tile types to extracted
device names, and not necessarily a 1:1 correspondence in the other
direction, either.  So the search for devices at the location given
by the .sim file has been loosened to look for any tile type at that
location.  Matches are restricted to those in which the plane of the
type found is the same as the plane of the device recorded in the .sim
file;  this prevents matching device like MiM caps that may be in the
same location as a device in another plane.
2021-07-27 14:34:01 -04:00
Tim Edwards 123219b5f1 Corrected an error in the extresist code that will cause an infinite
recursive loop and crash magic.  Corrected a number of other issues
along the way, especially one where routines in EFantenna and extresist
make use of array EFDevTypes which was only created by ext2sim and
ext2spice, and freed when done.  Having run extresist through valgrind,
there are still issues in the code.
2021-05-21 16:33:20 -04:00
Tim Edwards 647b7cc6c7 Corrected one small inconsistency in the handling of symmetric vs.
asymmetric MOSFET definitions in the tech file "extract" section.
Corrected the nmos.tech.in file to put the resistance classes in
plane order, as otherwise the interpretation of which resistance
classes belongs to the transistor source and drain can get messed
up by the presence of buried contacts.
2021-01-17 12:52:57 -05:00
Tim Edwards 8da47b6e84 Made a change to the way ext2sim determines if a FET type is an n or
p device;  this was previously dependent only on the first character
of the extracted device model name.  Since the tech file has control
over what the device layer names are but not the extracted model
names, the device layer type name is used as a backup way to determine
if the type is n or p, if that cannot be determined from the extracted
model name.
2020-10-20 12:22:02 -04:00
Tim Edwards 32ec962535 Separated drain and source records for the esFetInfo array, to
support asymmetric FETs and other devices like bipolars that have
three distinct terminals.  This does not go as far as it should to
make the array independent of the number of declared terminals of
the device.  However, it suffices to make, e.g., parameter "a2=area"
work for a bipolar device, and to generate the right drain and source
areas and perimeters for asymmetric (e.g., extended-drain) devices.
2020-09-11 17:29:12 -04:00
Tim Edwards 6cf5f65b51 Corrected a tiny but bad error in the extract section reading of the
tech file that completely undermined the ability to describe an
asymmetric device (different materials for terminals).
2020-09-09 12:18:09 -04:00
Tim Edwards 7540854184 Corrected the handling of the "defaultsideoverlap" statement so that it
works for the first pair of types/plane being below the second pair of
types/plane (upward fringing from the top of a wire to an overlapping
wire above it), which was not being handled due to an implicit assumption
that plane1 < plane2, which does not have to be the case.
2020-06-10 10:52:54 -04:00
Tim Edwards fc9ecd2c9b Corrected a problem with an uninitialized entry in ExtCurStyle that
could cause serious errors on systems that do not auto-zero allocated
memory.  Also:  Fixed an error introduced by a recent commit to allocate
character memory for efReadLine() which frees the memory before reading
a .res.ext file, causing a crash when using "ext2spice" with the
"extresist on" option.
2020-06-05 12:46:46 -04:00
Tim Edwards 15f1c82bc9 Added two new features: (1) Default substrate name: Added an
optional name field to the "substrate" line in the extract section
of the techfile.  This is the default name of the substrate if not
connected to anything labeled.  It may use a Tcl variable (preferred).
(2) Added command option "instance orientation [-def]" that returns
the orientation of the named or selected instance.  The -def option
returns the orientation using DEF naming convention;  otherwise, the
naming used with "getcell" is generated.
2020-06-01 16:49:59 -04:00
Tim Edwards 2af38a4191 Updates from running the fix-ending-whitespace script. 2020-05-23 17:13:14 -04:00
Tim Edwards 6adb5dbacf Enhanced the "lef write" routine: (1) Calculates gate and diff
areas and writes ANTENNAGATEAREA and ANTENNADIFFAREA values.
(2) Determines "USE POWER" or "USE GROUND" from label names
matching Tcl variables $VDD and $GND, if the USE has not been
registered as a cell property (knowning the use allows magic
to avoid writing an ANTENNADIFFAREA for power rails, although
doing so should not be an issue).
2020-05-21 16:26:24 -04:00
Tim Edwards cd87b08b21 Merge branch 'master' into bplane
Conflicts:
	VERSION
	database/DBcellsrch.c
	database/DBconnect.c
	extract/ExtInter.c
	lef/Depend
	utils/Depend

Updated bplane branch with all changes to master since the bplane branch
was last modified.
2020-03-12 08:29:33 -04:00
Tim Edwards cfaccd973f Expanded the antenna rule violation setup and calculations to
include (1) specification of sidewall or surface to use for
each type individually, rather than a single method for all
types, and (2) specification of a linear model R = Ax + B for
the ratio limit when diodes are attached to the wire, where x
is the diode surface area (unitless, as this is a ratio).
2019-11-27 10:38:47 -05:00
Tim Edwards 77e8ff437b Finished first cut at an implementation of antenna rule violation
checks.  Added new command "antennacheck" and a routine that
adds feedback entries where violations are found.  Extended the
syntax of the extraction section of the techfile to support the
antenna ratios and antenna calculation methods.
2019-10-20 22:12:02 -04:00
Tim Edwards 39ab59e7ec Corrected error causing a crash when parasitic extraction is
invoked on a layout with an array of instances.  Also, continued
implementation of antenna violation checking (not done yet).
2019-10-18 14:12:52 -04:00
Tim Edwards b41c86980b Corrected a mistake with the extension of the bloat-all CIF operator
that broke the operator for the usual case of all types in the same
plane.
2019-10-16 20:53:03 -04:00
Tim Edwards 745afa900d Corrected missing NULL initializer for device substrate name, which
can result in a segfault when reloading a techfile.
2019-10-16 11:38:31 -04:00
Tim Edwards 1933c5d4a5 Corrected another problem where the device source/drain area and
perimeter were not output because of recent code that broke the
routine that assigns the resistance classes to devices.  This is
now fixed.  Thanks to Dan Moore for bringing this to my attention,
and debugging investigations.
2019-10-14 11:56:39 -04:00
Tim Edwards 4b5566af3e Corrected an error that causes alias names for layers to become the
principle layer name, which should not happen (especially in the
case of space, where layers may be aliased to "space" to make them
ignored on input).  Also:  Implemented a "-<types>" option to the
"substrate" record in the techfile to declare types which shield
layers from the substrate.  This allows types like pwell to be used
in different contexts, e.g., as part of the substrate, or as a P-well
in deep N-well, without requiring a different type.  This works in
conjunction with the recently-implemented "+<types>" ID types for
devices.  All of this may seem unnecessary but helps to reduce the
number of layers needing to be defined, and the subsequent complexity
of the DRC rulesets.
2019-09-18 20:48:33 -04:00
Tim Edwards 8c75f81cc4 Revised the method for multiple extraction models per device type
to be more robust and not depend on the ordering of the devices in
the techfile.  The extraction method now keeps a mask of which
properties of the device (source/drain types, substrate type,
identifier type) have been found, and will look only for device
records that match what is known about the device.  Added a device
identifier record which is the last record before parameters if the
record begins with "+".  This allows marker layers to be placed
over a device such that it will extract with a different type.
This helps reduce the complexity of the techfile and allows
certain specialized devices like RF or ESD to be identified without
a separate layer type for the device.
2019-08-19 14:11:02 -04:00
Tim Edwards 1d04f20f5d Moved new work on magic-8.4 (experimental merging of micromagic bplane structure
into magic-8.2) into the newly-reorganized git repo as branch "bplane".
2019-03-22 19:58:47 -04:00