Commit Graph

72 Commits

Author SHA1 Message Date
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 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
Darryl L. Miles 5b03081d03 cif: TiPlaneRect const ripple 2025-04-09 15:07:28 -04:00
Darryl L. Miles 1a84eab4ce Plane[GS]etHint() added to encapsulate access to Plane->pl_hint
This is ground work to intercept usage and validate changes in
this area.

Fixed conflicts with earler patch in extract/ExtNghbors.c
2025-04-09 15:02:59 -04:00
Darryl L. Miles 606f37cc80 Ti[GS]etClient() usage enforcement
All naked access to `ti_client` now uses the function-like-macro
to encapsulate this action.  This macro existed before this just
makes all sites utilize it.

Added additional INT and PTR variants to remove the programmer
load on thinking about casing and casts polluting the point
of use.  So the use now looks cleaner.

Equivalent prototypes:

 void TiSetClient(Tile*, ClientData)
 void TiSetClientINT(Tile*, intptr_t) /* pointertype */
 void TiSetClientPTR(Tile*, void*)

 ClientData TiGetClient(Tile*)
 intptr_t TiGetClientINT(Tile*) /* pointertype */
 void *TiGetClientPTR(Tile*)
2025-04-09 14:55:58 -04:00
R. Timothy Edwards 6b9efefc02 Added a new "orthogonal" operator to cifoutput to allow non-
manhattan shapes (especially minimum-sized ones) to be eliminated,
as these can survive a shrink-grow operation intended to get rid
of such shapes.  This implementation may not be in its final form
but should suffice for now.
2025-03-28 10:11:17 -04:00
Tim Edwards 619191c6dd Corrected a crash condition caused by yesterday's commit, if the
new CIF operator is used in a tech file.  Reworked yesterday's
commit to add more related operators, so there are now four new
ones (also renamed them):  interacting, noninteracting, overlapping,
and nonoverlapping.  "interacting" now means overlapping or touching;
so the four cases allow all variations of adjacency between the two
material types.
2025-02-05 14:49:32 -05:00
Tim Edwards a5653c8fca Added a new CIF operator "not-interact" which is complementary to
"interact", because it was trivially easy to implement and saves
processing vs. doing the same thing with two templayers and an
"and-not" operator.
2025-02-04 20:43:30 -05:00
Tim Edwards 21b810b375 Added a new CIF operator "interact" which enumerates disjoint
regions of a given type and retains only those regions which
interact with (overlap) another given type.  Both sets of types
can be either magic database types or CIF temp layers.  This will
allow the implementation of rules that were not previously
possible.
2025-02-04 17:21:26 -05:00
Darryl L. Miles ac56dd71a9 cif: use 'const' with readonly data (also consumer DBpaint)
This then required a cascade of function APIs to also now receive
const arguments.

This reduces the .data segment use of this module.
2025-01-04 11:31:17 -05:00
Darryl L. Miles b6775f902b cif: use 'const' with 'rcsid' 2025-01-04 11:31:17 -05:00
Darryl L. Miles 3f85689985 cif/CIFgen.c: fix incorrect type bool -> int
There are 3 states for CLOSE_xxxxxx with 3 different values.

Issue introduced from 2f7f76bf9 merged since tag:8.3.509

This affected the scenarios using non-zero non-one values such as:
  #define CLOSE_DONE   2

This looks the result of an original bug where the forward declaration
 had a type mismatch with the real method, so the method implementation
 prototype was taken as the correct one.  The forward decl was rewritten
 with the correct prototype signature.
Maybe this is the cause of CIF data once drawn into view does not always
 seem to always erase after disabling and a redraw ?
2025-01-04 11:20:08 -05:00
Darryl L. Miles 0ce8265570 TCL9: ClientData macro assignment and access usage 2025-01-04 11:08:01 -05:00
Darryl L. Miles 2f7f76bf9c K&R: cif/*.c bulk function implementation conversion
Beware of the MISMATCH with the prototype found in original
source, with the type declaration below.

External call sites checked to confirm argument order is
correct with the argument name order.

// nedges <> dir
bool
cifOrient(edges, nedges, dir)
    CIFPath *edges[],          /* Array of edges to be categorized. */
    int dir[],                 /* Array to hold directions. */
    int nedges)                        /* Size of arrays. */

// spacing <> border
int
CIFGetContactSize(type, edge, spacing, border)
    TileType type,
    int *edge,
    int *border,
    int *spacing)

K&R obsolete syntax removal for C23 compatibility series
2024-12-26 13:05:14 -05:00
Darryl L. Miles 4e83c7fcdd CIFgen.c:309:10: warning: prototype for ‘SetMinBoxGrid’ follows non-prototype definition
This reference is not a forward reference, the function implementation
for SetMinBoxGrid() is above this line being removed.
2024-12-26 13:05:14 -05:00
Darryl L. Miles bf45f9ea31 K&R: cif/*.c bulk forward reference function prototype conversion
K&R obsolete syntax removal for C23 compatibility series
2024-12-26 13:05:14 -05:00
Tim Edwards 48abe30ea4 Implemented a new CIF/GDS generation operator option for
"bloat-all" which is "bloat-all types1 types2 distance" where the
"distance" value is a maximum amount to grow.  It is not (that I
know of) particularly useful for generating output GDS, but it is
very useful for generating temporary layers for DRC checks,
especially things like determining tap distance for latch-up
rules.  The alternative (used in the sky130 tech file) is a
tedious step-by-step "grow" followed by "and-not".  This rule
option is much cleaner to implement and computes faster (although
it is still a boolean operator and is much slower than an edge
rule).
2024-12-25 20:46:25 -05:00
Tim Edwards 89b6f4f92b Corrected an error with the bloat-all CIF operator in which
bloat-all would fail to operate from the top layer of a contact
type due to the use of DBplane(type) instead of counting all
planes of the contact.
2024-12-16 21:52:11 -05:00
Darryl L. Miles e8f9b0af5e CIFgen.c: warning: this 'for' clause does not guard...
return keyword indention corrected
braces added to previous statement to better convey code
 intention of multiline statement

GCC14 -Wall cleanup series [-Wmisleading-indentation]
2024-10-09 21:12:55 -04:00
Tim Edwards 6162a9f459 Corrected the "bloat-all" function so that it behaves properly on
angled edges.  This is a rare case and so has never come up before,
but can happen especially on transistors with gate or diffusion
with 45 degree chamfers or flanges.  Thanks to Mark Martin for
providing the use case.
2024-10-03 20:37:43 -04:00
Darryl L. Miles 7feec63580 cif/CIFgen.c: CmdFindNetProc() Call to function with fewer arguments than declared parameters
The 'isvalid' pointer argument to CmdFindNetProc() is for an optional return value, so must be
NULL when feature is not used.

Copilot Autofix rejected: ttype = CmdFindNetProc(netname, CIFDummyUse, &bbox, FALSE, additional_arg1, additional_arg2);

commands/CmdFI.c
cfb81101 (2022-03-30 13:02:12 -0400 1584)     bool *isvalid;

commit f89d52dbcc (tag: 8.3.253)
Date:   Thu Jan 6 13:29:43 2022 -0500

CodeQL: https://github.com/dlmiles/magic/security/code-scanning/7
2024-10-01 12:36:12 -04:00
Tim Edwards e37a4f418a Based on output from a large contact array for a pad, modified the
default behavior of magic to make use of the "gds contacts true"
option to output contacts as arrays of subcells instead of
individual boundary entries, as the former is much more efficient
than the latter.  Set the option to be true by default, and set
the "gds flatglob" option to have one entry "$$*$$" corresponding
to the contact subcells created by the "gds contacts" option, so
that GDS reads and writes as it did previously (but using a
different method).  Expanded the method to include "squares-grid"
and "slots" operators (the latter should produce much more
efficient fill pattern arrays).  Implemented for both compressed
and uncompressed GDS.  Tested in all variations.
2022-11-10 14:08:58 -05:00
Alessandro De Laurenzis b306a39560 Compatibility with C99 standard
This commit makes the code (mostly) C99-compatible, enabling to compile
it without the -Wno-error=implicit-function-declaration flag. This
way, Magic becomes usable on arm64 architectures, specifically on Apple
computers with M1/M2 SoC.
2022-10-29 06:07:46 +02:00
Tim Edwards 30ab57ee79 Found a problem with the calculation for the non-Euclidean grow/
shrink routine that over-computes the diagonal position (the
equation failed to divide the intersecting angle in half).
Rewrote the equation for the correct grow distance, still
accounting for the grid limit (if set).
2022-04-19 18:20:58 -04:00
Anton Blanchard 3d41b3e98b Fix a few issues with missing or incorrect prototypes
There are a few places we either don't have a variable or
function prototype and need one, or we have one and they
don't match.
2022-02-23 21:04:19 -05:00
Anton Blanchard 4f79580248 Add missing includes
A number of places are using isspace(), tolower(), toupper() and strcmp()
without including the relevant header.
2022-01-10 14:01:36 -05:00
Tim Edwards cf47772278 Corrected the "grow-euclidean" option for grow/shrink/bloat-or so
that it correctly lands on a grid limit boundary (which the
previous commit did not do).  Note that work is still ongoing to
detect some pathological cases where the shapes end up off-grid
where two non-manhattan shapes intersect at different angles
(such as an inside corner).
2021-11-16 17:33:05 -05:00
Tim Edwards 7ffe8bc866 More or less reverted the last commit, as it was found that the
calculation for "limit" in the CIFgen routines was wrong, not the
interpretation of the "gridlimit" value in the tech file.  The
parsing of "gridlimit" has been put back the way it was before the
last commit, and the "limit" value calculations have been corrected.
2021-11-16 15:15:33 -05:00
Tim Edwards e8eb96103d Modified the Euclidean distance "grow" operator so that it honors
the grid limit setting.
2021-11-16 09:59:23 -05:00
Tim Edwards e553bbb7c3 Modified the "close" function in CIFgen.c so that it uses the
STACKPUSH/STACKPOP functions instead of recursing.  Otherwise it
has a tendency to cause the process to exceed the recursion limit.
2021-07-30 14:54:40 -04:00
Tim Edwards 55bf0ebd54 Corrected the "bridge" operator, which failed to check for "false"
tile corners in the check area to find areas needing bridges.
This prevents generation of unnecessary bridging geometry;  and
since the error made the check rotation-dependent, this may
resolve some "parent and child disagree on CIF" errors.
2021-07-28 09:40:36 -04:00
Tim Edwards 11c53bb6d5 Modified an ad-hoc rule in CIFgen stating that "squares" and similar
rules do not get hierarchical processing.  I am not sure why I added
that exception, which clearly is not like "bound" or "net" in causing
serious issues when used hierarchically.  The current counterexample
is the use in sky130A.tech for the NPC layer.  Based on that usage,
the exception has been relaxed to consider any "squares" and similar
rule during hierarchical processing if followed by a "grow" operator.
Possibly this is still not relaxed enough to capture all meaningful
use cases, but should suffice for now.
2021-07-27 16:13:54 -04:00
Tim Edwards a8fcca13ee Corrected an error in the implementation of the CIF "mask-hints"
operator that failed to set cifplane to curplane before drawing into
it.  This can cause the "mask-hints" layers to vanish, or worse,
cause a segfault.
2021-06-01 10:25:34 -04:00
Tim Edwards 324721b514 Added some options to the net selection with respect to labels.
The previous behavior was to generate hierarchical names for all
labels when copying contents of subcells.  This is "safe" for
copying selections without accidentally shorting things through
labeling, but it can make a mess of the selection.  Options are
now "select do labels" for the existing behavior, "select no labels"
to not show any labels, and "select simple labels" to show only the
root name of labels in subcells.
2021-03-04 14:00:31 -05:00
Tim Edwards dfba4601f1 Substantially revised the equations for computing bridges for the
"bridge" GDS output operator;  the previous equations were, under
some situations, failing to meet the width requirement.  Also:
corrected the "cif style" check so that it does not claim that a
style name with an exact match is ambiguous.  Also:  Corrected the
use of "grid limit", so that the limit correctly scales with the
output expander value.
2021-01-24 13:29:20 -05:00
Tim Edwards d4c3939feb Extended the "mask-hints" operator to work correctly through a
hierarchy.
2021-01-06 10:33:43 -05:00
Tim Edwards 18b4375790 Correction to yesterday's commit to fix the "bridge" operator for
CIF/GDS output.  Yesterday's commit did not completely solve the
issue.  Today's commit should.
2020-12-29 11:00:04 -05:00
Tim Edwards 44325f81e6 Corrected two errors: (1) Do not write subcircuit calls to subcircuits
that have been removed by flattening into the parent cell due to lack
of devices.  Previously the checks on writing the subcircuit and writing
the call were slightly different, leading to instances in which the
subcircuit call would be written to the netlist output without the
subcircuit being defined.  (2) Corrected an error in the "bridge" CIF/GDS
output operator.  In certain (somewhat rare) geometries, the tile behind
(instead of in front of) the corner being checked may be incorrectly
flagged as a DRC spacing error.  The fix is to ignore tiles that are
behind the corner being checked.
2020-12-28 16:54:20 -05:00
Sylvain Munaut eb945dc6ef CIFgen: Fix processing of MASKHINTS_* properties
- Don't print error if there is no more data to process
 - Fix error message: `propname` already has the
   MASKHINTS_ prefix

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2020-12-27 10:33:02 +01:00
Tim Edwards ea9d8cc3e5 Implemented first part of "mask hints", a method to allow mask
layers that are normally automatically generated to be supplemented
with additional geometry in the form of properties.  The first
commit implements a CIF operator "mask-hints" that tells CIFGenLayer
that additional geometry may be specified with a property named
"MASKHINTS_" plus the name passed to the operator as its only
argument.  A more extensive commit to be done will allow this
operator to be used on cifinput to use mask hints to retain the
exact geometry of mask layers used in the input file.
2020-12-14 16:16:37 -05:00
Tim Edwards 825ec353b1 Added missing brackets around a phrase in the "close" operator that
was causing false positive errors in DRC checks involving CIF rules
using the "close" operator, such as the minimum hole size in the
sky130A PDK.
2020-12-03 14:22:09 -05:00
Tim Edwards 83e2fe55ce Corrected an error in the "close" CIF operator, which was checking
for infinities in space tiles by checking tile dimensions against
TiPlaneRect, where in fact TiPlaneRect is slightly smaller than
the plane boundaries, so this check would always fail, causing
unpredictable behavior due to integer overflow.
2020-11-24 15:57:40 -05:00
Tim Edwards 4cac448337 Such a little typo, such a big problem. . . Fixed error from last
commit.
2020-11-17 14:29:21 -05:00
Tim Edwards 7a12bf8f60 Corrected a badly-written routine for the CIF generator for operator
bloat-all, that was resetting flags in the entire plane within the
callback for each tile processed.  This would push DRC run-times from
minutes to hours.  Also corrected another, much more minor, efficiency,
in which the connection mask was generated in the callback routine
for each tile, instead of calculating before the plane search and
passing the mask to the callback function in the client data.
2020-11-16 11:29:36 -05:00
Tim Edwards 750d6c0ecf Corrected a bad error (missing braces around a code block of more
than one line) in the "grow-min" function that was affecting GDS
output for any layers using the grow-min operator.
2020-11-13 10:24:31 -05:00
Tim Edwards b0616e9f0e Fixed two misspellings in comments. 2020-11-12 10:55:20 -05:00
Tim Edwards 75a18053f8 Modified the CIFGenLayer() routine to be aware of when it is called during
hierarchical processing from CIFGenSubcells() and CIFGenArrays(), and to
avoid certain operators that are useless and harmful when applied
hierarchically; namely squares, slots, bbox, boundary, and net.
2020-11-12 10:34:27 -05:00
Tim Edwards 73629467ed Added a forward reference to prevent a compiler warning. 2020-11-11 14:12:51 -05:00
Tim Edwards ad2857dfab Corrected the "grow-min" CIF operator to grow more than the minimum
amount as needed to land on the specified minimum manufacturing grid.
2020-11-11 14:06:12 -05:00
Tim Edwards 6b84efa86e Additional correction for the CIF "close" operator. 2020-11-10 13:28:40 -05:00