Commit Graph

211 Commits

Author SHA1 Message Date
Tim Edwards dba6f99d93 Updated the revision number to go along with the merge of pull
request #325 from Daryl Miles.  Made a few simple style changes
to conform to (what is vaguely defined as) the overall programming
style for magic (passed down from John Ousterhout).
2024-10-01 12:56:31 -04:00
Darryl L. Miles e119188f23 fix: findUse can return NULL crash
The main cause of the crash was the path for UNDO_CELL_PLACE this was
trigged by performing a number of cell create/move operations (unknown
exactly what sequence).  Then a large number of "undo" operations.

There is an ASSERT in findUse() but that does not seem built into the
release (or debug CFLAGS=-g3) builds.
2024-10-01 12:43:27 -04:00
Darryl L. Miles 973c9a4d1a database/DBio.c read of variable before initialization
Due to FEOF condition and handling it is possible local variable 'c' is not
initialized before being read and compared.

SonarCloud retails
DBio.c:3049 The left operand of '==' is a garbage value
https://sonarcloud.io/project/issues?open=AZJB16rxNGfDNup0Ribf&id=dlmiles_magic
2024-10-01 12:36:13 -04:00
Darryl Miles 1fb82e7225 database/DBtiles.c: Multiplication result converted to larger type
Fix code scanning alert no. 30: Multiplication result converted to larger type (#55)

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 499ac84ac0 database/DBio.c: Redundant null check due to previous dereference
Fix code scanning alert no. 132: Redundant null check due to previous dereference (#39)

* Update DBio.c

* AI wanted to move guard 'pathptr != NULL' up to 1953, but it is assigned to guaranteed non-null in every assignment above and only incremented or dereferenced.

---------

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 82aa62e65d database/DBcellsrch.c: Wrong type of arguments to formatting function
Fix code scanning alert no. 66: Wrong type of arguments to formatting function (#33)

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
Darryl Miles 573e59da44 database/DBcellname.c: Call to function with fewer arguments than declared parameters
Fix code scanning alert no. 10: Call to function with fewer arguments than declared parameters (#14)

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
Darryl Miles a5f7cbd597 database/DBcellcopy.c: Call to function with fewer arguments than declared parameters
Fix code scanning alert no. 9: Call to function with fewer arguments than declared parameters (#15)

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
Darryl Miles 886a0212e8 database/DBtech.c: Incorrect return-value check for a 'scanf'-like function
Fix code scanning alert no. 135: Incorrect return-value check for a 'scanf'-like function (#12)

* Create codeql.yml

* Fix code scanning alert no. 135: 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
Darryl L. Miles 881115a856 database/DBio.c: Fix MAGIC_WRAPPER #endif to fix CI WASM build
Misplaced #endif causing the build to break when option enabled
error introduced in 3dc5018

Related commits:

commit 68a088943f
Date:   Tue Sep 12 11:12:00 2023 -0400

commit 3dc5018af4 (tag: 8.3.477)
Date:   Fri May 3 21:43:27 2024 -0400
2024-09-30 23:00:00 +01:00
Tim Edwards 427547c927 Changed the behavior of renaming conflicting cells from
"<name>#<num>" to "<name>__<num>", because the use of "#" is
considered illegal for cell names in GDS.
2024-09-15 17:33:51 -04:00
Tim Edwards 81b5ac2079 Added two checks when loading a file to determine if two cells are
the same:  (1) If the inodes of the filename are the same, then the
cells are the same.  This avoids treating symbolic links as
different paths with different files;  (2) If both layouts are in
git repositories and the git repository commit hashes are the same,
then the cells are considered to be the same.  This allows projects
to be cloned into other projects as dependencies and used in
multiple places without magic treating them as different layouts.
2024-06-13 15:39:27 -04:00
Tim Edwards e9db9ecbc9 Another correction that avoids a crash condition when attempting
to do an instance array resizing on an uneditable cell.
2024-05-25 21:15:01 -04:00
Tim Edwards cf5fd867f4 Corrected another error related to read-only views in which magic crashes when
attempting to place a generated cell in the layout, as pointed out by Mark Martin
in github Issue #309.
2024-05-24 12:43:36 -04:00
Tim Edwards 9dec47c9b2 Corrected a fairly long-standing error in which the MASKHINTS_ values
in the .mag file "properties" list are not handled as being in
database units during .mag file reading and writing (although they
do track internally), making them subject to being scaled incorrectly
and change between a read and a write.  Thanks to Sylvain Munaut for
identifying the problem.
2024-05-10 13:05:06 -04:00
Tim Edwards ca99d0b76a Altered the behavior of handling labels when a layer under a label
is erased.  In cases where magic would previously unattach the
label from the material and attach it to "space", now magic will
instead adjust the size of the label to stay entirely on the
material.  That avoids a common error of losing label or port
connections when the material is trimmed back.  Thanks to Philipp
Guhring for suggesting this implementation (github issue #305).
2024-05-04 21:12:55 -04:00
Tim Edwards 3dc5018af4 Changed the automatic search for tech files from the "tech" line in
a .mag file to include the original system path.  This restores the
ability to find the tech file for any cell created using the old
SCMOS technologies.  This method is as problematic as is the way
all SCMOS tech files used the same name "scmos".  But at least it
preserves backwards-compatible behavior (behavior prior to 8.3.471).
This commit corrects github issue #306.
2024-05-03 21:43:27 -04:00
Tim Edwards 0ae54b500a Added the ability to track the first CellDef to fail to read and
report it after "Failure to read in entire sub-tree".  This will
not report every failing cell (since it quits reading after the
first failure) but will avoid the existing issue of printing
nothing and leaving the user with no feedback as to which cell
was the problem.
2024-04-29 17:43:37 -04:00
Tim Edwards 3a1f4dc816 Removed an "if" statement that was apparently designed to
reduce the amount of redundant painting done by the connectivity
search algorithm, but which was preventing composed types (such
as FET gates) from getting added to a net if one of the composing
types (such as poly) was drawn over the device in an ancestor
cell.  Removing the "if" statement does not appear to have any
significant performance impact, so this change is being adopted.
2024-04-11 15:18:25 -04:00
Tim Edwards 4e5af57f3c Corrected an issue with "instance celldef" when the instance name
contains brackets which are not indicating a cell array.  Also
fixed a related issue with the PDK toolkit code, in which the
gencell routines fail if an instance name contains brackets which
are not indicating a cell array.
2024-04-05 17:47:44 -04:00
Tim Edwards 5f6ba3be69 Corrected an error when using the "instance" command with an instance
name.  The instance search routine was not rejecting internal cells,
and so would choose, e.g., a selection cell and reject it because it
was not the edit cell.
2024-01-21 11:00:19 -05:00
Mohamed Gaber 9e6d1d789e More explicit pointer truthiness check
`magic/database/DBio.c::DBOpenOnly` calls `dbReadOpen(CellDef *, bool, bool, int)` with a pointer for the second argument. While technically valid C, newer compilers (Clang 16) have recently frowned upon implicit pointer-to-int conversion, requiring the flag `-Wno-int-conversion` or else an error is raised.

Given that there is one such instance in the codebase, I think fixing it would be the simplest solution.
2023-12-04 17:10:11 +02:00
Tim Edwards fdcc178bcd After a discussion about "cifinput" rules, realized that there is
no way to implement boolean operators on labels, so any "label"
statement in the section can apply only to one magic layer.  This
is regularly violated in most (all?) techfiles (due mainly to lack
of explanation and guidance).  The addition of the "no-reconnect-
labels" option for cifinput made it worse, as it can cause a label
to be attached to the wrong layer and be stuck that way.  Even
without the option, an attachment to a non-connecting type is a
problem;  DIFF cannot simultaneously have a connection to both
ndiff and pdiff, so it will be one or the other, and the one not
connected can easily get labels moved to other nets.  To avoid
this:  (1) removed the "no-reconnect-labels" option, and (2) made
the automatic label reconnection smarter, as well as splitting it
into two different behaviors based on whether a label is being
created or manipulated from the command line (more or less the
original behavior) vs. being read from GDS or LEF.  The new rules
assume that labels attached to a GDS type will all map to the
same plane in magic.  To avoid excessive error messages from
existing tech files, a warning is issued only if "labels" changes
the plane of the target layer (a realistic solution rather than
the preferred one).  Also:  Fixed an error that causes a crash on
the "wizard" command "*watch" if the cell being observed is
read-only (see github issue #271).
2023-10-17 15:54:38 -04:00
Tim Edwards f1e60fe8b1 Found an extreme issue in "extresist" in which the algorithm spent
all of its time running area searches on zero-area rectangles,
which was causing simple extractions to run hours.  Checking for
a zero area rectangle and conditionally skipping the area search
resulted in a massive speed-up in parasitic extraction.
2023-09-23 12:57:03 -04:00
Tim Edwards a54a20ee58 Corrected an issue with "drc catchup" that causes it not to work
because commands issued during initialization set the DRC status
in a way that causes DRCContinuous() to return immediately.
Also:  Implemented a slightly different method when automatically
finding the tech file from the input .mag file that loads a
technology .magicrc file if one exists.  If not, just the .tech
file is loaded.  This replaces the method of a previous commit
that loads the technology .tcl script.  The .magicrc file will
include the .tcl script but does other things as well.
2023-09-20 10:27:07 -04:00
Tim Edwards 68a088943f Made an enhancement to the code that automatically tries to figure
out where to find the technology corresponding to a file given on
the command line: (1) Changed the default search location from
/usr/share/pdk to /usr/local/share/pdk, which is the actual default
for open_pdks (can still be overridden by environment variable
PDK_ROOT).  (2) Made the PDK name by itself preferable to the PDK
name plus any extension when searching (e.g., "sky130A" is preferred
over "sky130A_backup").  (3) Check the located directory for any
file <tech_name>.tcl and source it if it exists.  (4) Run any tag
callbacks on the "tech load" command, which rebuilds the tool icons.
2023-09-12 11:12:00 -04:00
Tim Edwards 2aab645308 Discovered an error in region and net selection that can cause
unrelated nets to be captured in the same selection, due to the
use of the label bounding box instead of the label rectangle.
The bounding box is used for display only and should not be used
for connectivity.
2023-07-29 20:36:46 -04:00
Tim Edwards 6b5bd149fc Corrected an issue with "flatten -doinplace" with no cell name
argument, which is supposed to flatten all selected instances.
After flattening, instead of deleting the instance from the
cell, it deleted the instance from the selection, leaving the
one in the cell.
2023-07-28 15:25:42 -04:00
Tim Edwards 90a3cf2d72 Corrected an issue that undermined the "locking disable" command,
and would keep files open (even though they were not marked as
locked) and not close them, causing an open file descriptor overflow
when too many files are read for the same design.
2023-07-20 14:51:05 -04:00
Tim Edwards 6caab5da37 (1) Corrected an error with extraction in which terminal area and
perimeter are not initialized, and if a terminal perimeter/area
calculation is missed (which is happening on devices with terminals
in planes other than the plane of the identifying type), then the
perimeter/area of a previously handled device will get output.
(2) Corrected an error with "flatten -inplace" in which the command
fails to deal with instance arrays.
2023-06-07 08:06:18 -04:00
Tim Edwards c1f4555ba0 Corrected behavior of "load ... -dereference" to bring back a
previous behavior that had inadvertently been changed.  In recent
versions, "load <absolute_path> -dereference" would incorrectly
apply the dereferencing to <absolute_path> rather than just its
subcells.  Cleaned up the code around DBCellRead() in the process,
so everything is more straightforward (although probably more
could be done in that regard).
2023-04-18 11:01:58 -04:00
Tim Edwards adf9a7703f Added a statement for every file load that prints the file path
of the cell.  This will greatly help in diagnosing issues when
reading cells from multiple locations including cwd, relative
paths, PDK libraries, and the search path.  Also:  Reworked
the timestamp update message so that it prints all at once at
the end of processing, not printing output for every cell
processed as it is being processed.  That prevents output from
the file read routine from getting interleaved with the
timestamp processing output.
2023-04-15 10:44:50 -04:00
Tim Edwards 1d8fcca09b Implemented a change to differentiate between "sticky" labels and
labels that are not connected to their declared layers.  It's the
latter type that need additional processing in ExtSubtree.
Limiting this processing significantly cuts down on processing
time when there are many labels in a layout, as happens with the
"def read -labels" command option.
2023-04-06 12:26:18 -04:00
Tim Edwards d8f926865d Modified the behavior of cell reading, mainly with respect to
dereferencing, and making the behavior of "load" on the command
line (i.e., loading a cell from a file) the same as the
behavior of loading a cell as a result of expanding an unloaded
instance.  In both cases, if "load -dereference" is used, and
a cell does not exist in any search path but does exist in the
original location, without dereferencing, then the cell will be
loaded from the original location.  Also:  Corrected an error
that has existed since adding the capability to read compressed
files, which causes magic to crash when attempting to run the
"crash recover" command (because that routine was mixing
compressed and regular file stream calls).
2023-03-20 21:00:35 -04:00
Tim Edwards 26da5adf98 Corrected an error in the check for coincident instances. This
check was too aggressive and would delete coincident instances
based on cell def and bounding box only.  If the cells were at
different orientation or mirrored, they would be incorrectly
flagged as coincident.  Instances read from GDS could be
deleted due to this issue.
2023-02-28 16:49:17 -05:00
Tim Edwards 3da6172706 Modified the "port renumber" command to use (case-insensitive)
natural sort instead of ASCII-based sorting, so that ports that
are numbered arrays will be indexed properly by count.  Also:
Modified the "extresist" handling of substrate to draw the default
substrate type over the entire cell area (less areas of nwell or
other conflicting type).  This allows extresist to extract the
entire substrate as a resistive network.  The result is ugly and
may warrant some aggressive network simplification, but it should
at least be realistic.
2023-02-27 22:22:09 -05:00
Tim Edwards 7b485efa9b Added code to handle string overflows in property strings. It
might be better to flag a warning, as property strings longer than
the original buffer size of 2048 are probably a bad idea.
2023-02-23 16:44:58 -05:00
Tim Edwards c7f11d2169 Important update: Reworked the extraction method to properly
isolate the terminal areas of a device (e.g., source and drain)
and calculate their area and perimeter individually for the
device (in addition to the traditional method of calculating
area and perimeter of each resistance class for the entire node).

Also:  Reworked the SPICE syntax output to generate SI values
in the range 1-1000 with the appropriate suffix (e.g., "20u")
instead of defaulting to "u" for lengths and "p" for areas.
This prevents it from producing weird units like "150000u" when
a process definition already includes a scalefactor.

Reworked the "extresist" code to use the device terminal area
and perimeter.  This fixes an error in which "extresist" would
lose these values and "ext2spice" with option "extresist on"
would generate a new netlist output with zero terminal areas
and perimeters.
2023-02-16 11:59:13 -05:00
Anton Blanchard c89b0c1ff3 Fix a few issues in leaDBSearchForTech()
Always call closedir() after a successful opendir(), and always return
a value from function.
2023-01-16 15:56:02 +11:00
Anton Blanchard eedc0c89a1 Don't cast pointer to struct and back again in DBDiagonalProc() 2023-01-16 11:00:47 +11:00
Tim Edwards 6cefbd13f1 Expanded the method for "flatten in place" to include the more
natural flattening from a selection.  That is, instead of
specifying "flatten -doinplace <cell>", you can select some
number of instances and just do "flatten -doinplace".
2022-12-22 14:53:24 -05:00
Tim Edwards 83e17706fe Added handling of mask-hints properties to the flatten-in-place
method to ensure that mask hint geometry is retained when a
cell instance is flattened into the parent cell.
2022-12-22 11:27:37 -05:00
Tim Edwards 70908a8ab5 One more correction related to the "verbose" level of the "load"
command, without which the previous commit does nothing.
2022-12-21 21:23:51 -05:00
Tim Edwards 23b8d08f86 Modified the "load" command so that "-quiet" is promoted to
"-silent", and "-quiet" now produces relatively little output
except for important warnings and errors.
2022-12-19 11:20:50 -05:00
Tim Edwards a0f502501e Corrected the method of "flatten in place" from the previous
commit to prevent port labels from being copied up from the
flattened cell into the parent, and prefixing the instance
name to text in the instance top level so that there will be
no port or label collisions in the parent cell after flattening
the child cell in place.  Also:  Changed "extract dolabelcheck"
to be the default setting.
2022-12-16 12:03:38 -05:00
Tim Edwards fb091fa03f Revised the string array for labels during output of a .mag file
from 256 to 2048.  The latter matches the maximum array used for
DEF file labels, although allocation is probably preferable.
2022-11-30 20:25:58 -05:00
Tim Edwards 256a47d7b9 Added a method for a property named OBS_BBOX to specify a minimum
area to be marked as an obstruction when writing a LEF file with
the "-hide" option.
2022-11-30 16:29:37 -05:00
Tim Edwards 01f2ce37b8 Modified the "dereference" behavior so that it does not produce
warnings when rereferencing a layout file as intended.
2022-11-22 11:05:55 -05:00
Tim Edwards 71dffb2fd2 Implemented a method to handle empty subcells that exist because a
library has been read in with the "gds readonly true" option set
because the cell contains information on where in the GDS the
cell is located, but the cell is empty because it was flattened
into the magic view and all of its contents were erased.  This can
cause issues with LVS if magic generates an empty cell into the
netlist and the LVS tool tries to compare the cells by name.  Also,
this prevents unnecessary .ext files and unnecessary merges to the
substrate of such cells (since all cells have an implied substrate).
2022-11-21 17:13:33 -05:00
Tim Edwards f066844761 Substantially revised the "def write" and "def read" routines.
Both were corrected with respect to the definition of non-default
(taper) rules.  "def write" was additionally modified to avoid
redundantly processing tiles where tile areas were merged together
to form a complete wire.  There is plenty of room for optimization,
but the output appears to be matching the layout.  Also:  Revised
the definition of "(not) visible layers" to include labels attached
to those layers, so that turning off visibility of any layer will
also hide all labels attached to that layer.
2022-11-17 20:24:39 -05:00