Commit Graph

78 Commits

Author SHA1 Message Date
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 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 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 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 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 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
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
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 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 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 075262b2ef Added the ability to read compressed .mag files (writing is not yet
supported).  Fixed the long-standing issue in which DRC does not
get stopped by the "drc off" command (the behavior for interrupting
the DRC was dependent on the DRC being turned on, and the "drc off"
command was turning it off before breaking, causing the interrupt
to be ignored).
2022-11-02 17:12:46 -04: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 113f0dfb3f Applied the same method as used in the last commit, to put all
cell properties in natural sort order when writing a .mag file.
This should remove the last bit of indeterminism in the output
of magic database files.
2022-02-01 11:58:11 -05:00
Tim Edwards ea80e30a8e Applied a string sort to the dump of cell uses when writing a .mag
file.  This makes the output of .mag files deterministic (except
possibly for properties, which may also need to be handled this
way).
2022-01-31 15:30:24 -05:00
Tim Edwards d4961f244d Modified the extraction code to work around a problem created some
time ago by cleaning up excess usage of "equiv" lines in the .ext
file output.  The hierarchical extraction code did not distinguish
between node names which were output and those that were not,
requiring a setting "extract do aliases" to force all node aliases
to be output with "equiv" statements.  So hierarchical names
might be any alias, whether output or not, and "merge" and "cap"
lines might contain references to nodes that were not output,
causing them to be disconnected nodes.  This fix handles the
"extract no aliases" (default) case by flagging node names that
are redundant and not output, and not creating hierarchical names
with them.
2022-01-14 16:13:36 -05:00
Tim Edwards 0f9dc76681 Changed FPRINT* macros to FPUTS* in DBio.c to match the change of the
underlying function from fprintf() to fputs(), which was changed for
gcc11 compatibility by Jean-Paul Chaput in github issue #123.  Also
corrected a typo from the previous commit.
2022-01-12 15:36:33 -05:00
Jean-Paul Chaput f354920133 Patch for gcc11/RHEL9 2022-01-12 15:33:42 -05:00
Tim Edwards 1fceef6acd Corrected the last commit's problem with file locking, which is that
there was no distinction between a locked file and a new cell
(initial state) before writing to disk.  This prevents any new cell
from being saved!  Also:  Revised the behavior of the "select short"
search, but this still has issues with long run-times on complex
layouts, so this is an ongoing effort.
2022-01-03 16:00:31 -05:00
Tim Edwards 1bb4cb92ea Played around with the file locking and discovered to my chagrin that
whenever a process writes a cell to disk, it immediately releases the
file lock it had on that cell, which is clearly not the intent of file
locking.  Fixed this issue.  On a related topic, revised the "cellname
writeable" command so that it can make a cell editable even if the cell
has an advisory lock and cannot be made writeable.  Perhaps there should
be a clearer distinction here between "writeable" and "editable".  Also:
Reconsidered the previous commit, which removed the "--disable-locking"
from the configuration options.  Because some operating systems may not
implement fnctl()-based file locking (Cygwin, for one, apparently doesn't),
it is still useful to be able to completely remove the function, in case
the operating system will fail to recognize the fnctl() values in the
code.  Now, file locking behavior can be permanently removed through the
configuration option, or temporarily disabled from the command line.
2022-01-01 16:53:46 -05:00
Tim Edwards 43bb499bcf Corrected an issue with the limited bitfield dedicated to port numbers;
this limited ports to 16384, which seemed reasonable at the time.
However, the sky130_sram_macro layouts connect power and ground in a
way that when coupled with "extract unique" can generate tens of
thousands of ports and overrun the bit field, showing that automation
can do the unexpected.  The solution was to split out the port number
from the label record as its own 32-bit value.
2021-12-12 22:09:31 -05:00
Tim Edwards 65747132a0 Added behavior for reading cells with or without "-dereference" to
work around the issue of loading a file containing references to
cells with the same name as cells already loaded.  This is probably
going to cause additional headaches until a proper checksum method
is implemented.
2021-11-30 12:17:21 -05:00
Tim Edwards 24e2991fe3 Corrected an error that happens if a layout file read flags a
timestamp error, causing a segfault because it runs HashKill on
a hash table that was never initialized.
2021-11-25 13:20:28 -05:00
Tim Edwards a6e57093f8 Realized a very stupid error in the handling of the "use" lines
when reading in a .mag file.  The routine was not checking for
whether a "use" entry in the file was the first one encountered
or not.  The path is only ever given for the first use of any cell
def, so for any cell after the first, the path should have already
been resolved.  This fix avoids lots of unnecessary error messages
when reading a file in a different directory.  Also, because the
routine now checks for the first use in a file, any error messages
that do occur will only be displayed for the first use, not all of
them.
2021-11-20 20:54:51 -05:00
Tim Edwards 0dcc9c6ca7 Corrected two potentially fatal errors: (1) Code doing the PDK_PATH
and HOME substitution in filenames needs to watch for a NULL
cd_file, and (2) The routine that removes the (UNNAMED) cell when
another cell is loaded needs to NULL the boxRootDef pointer or else
it ends up pointing to deallocated memory.
2021-04-24 22:13:30 -04:00
Tim Edwards 6bd96a68dc Created a method for annotating abstract views with GDS pointers.
This can be done now by reading a LEF file, followed by reading
a GDS file with the "noduplicates" option set.  In addition,
annotation of either the LEF view or a read-only view follows the
same protocol as cell paths in the .mag file, which is to replace
leading path components matching Tcl variables for PDKPATH or
PDKROOT, and replace the home directory path with a tilde.
2021-04-22 14:39:34 -04:00
Tim Edwards 59bfa6ce86 Found no fewer than three separate places that cause a pop-up prompt
for saving on a cell which is completely unmodified.  One of these
was due to the BPlane implementation, which forces an instance to be
deleted and re-placed on a bounding box recomputation, which should
not, in that case, be considered a modification.  Another always runs
DRC on a subcell upon reading rather than relying on any checkplane
entries in the file itself;  and the last one marking the timestamp
as modified stemming from an attempt to correct an O(N^2) check to
O(N).  All three cases have now been corrected.
2021-03-16 22:46:46 -04:00
Tim Edwards 114b9a59f7 Implemented more automation for attempting to find a tech file
based on the contents of a .mag file being read in, assuming
compatibility with principles of open_pdks.  The search paths
are not meddled with unless a file is read for which the technology
cannot be found (and a technology has not already been read, or at
least no database file exists in memory using any technology that
has already been read).  If so, then variables PDK_PATH and PDK_ROOT
are searched for in both the shell environment and the local Tcl
environment.  Also, if open_pdks has installed PDKs in the path
/usr/share/pdk/, then that path will be searched.  If a corresponding
technology file is found, it will be loaded.  If the path corresponds
to an open_pdks-style path, then the library paths in libs.ref will
also be added to the search paths for cells.
2021-02-25 13:37:31 -05:00
Tim Edwards 7dfe407787 Implemented a return value for the cell read-in checks with an option
to stop the search whenever a cell is not found.  Used this to implement
a new option for GDS writes, "gds undefined allow|disallow" (default
"disallow") controls whether or not GDS with undefined references will
be allowed to be written.  Similarly affects CIF and LEF writes, extraction,
and DRC (when running "drc check" from the top).
2021-01-14 15:21:39 -05:00
Tim Edwards 3b137a6d14 Added a "-quiet" option to "load" so that scripts that use "load"
to create a new cell that is not expected to exist on disk will
not generate annoying error messages.
2020-12-30 09:43:24 -05:00
Tim Edwards 1c82265244 Several enhancements: (1) Added command option "gds no_duplicates"
to allow a "gds read" command to ignore cells in the GDS which already
exist in memory.  This allows magic to be "pre-seeded" with specific
views of cells in the GDS.  Default is false, which is backwards-
compatble behavior.  (2) Changed the behavior of the the way the use
path is written to and read from a .mag file, checking the path prefix
against Tcl variables PDK_PATH, PDKPATH, PDK_ROOT, and PDKROOT, and
replacing any such leading path component with the variable name.
On reading a .mag file, any variable name at the start of the path
that matches a Tcl variable will be substituted.
2020-12-04 16:56:51 -05:00
Tim Edwards 9931244e1e Corrected what appears to be a long-standing error in the "extract
unique" code.  It was using DBEraseLabelsByContent() which would
erase all matching labels, and could potentially erase labels that
were still remaining on the list being processed, causing a segfault.
Also corrected minor errors identified by valgrind during debugging
the above-referenced problem.
2020-11-03 12:17:16 -05:00
Tim Edwards 05950b16ea Corrected a problem with the last commit, in which the check for
no common directory components between parent and child should have
been outside the while loop.
2020-09-04 11:10:44 -04:00
Tim Edwards 1ef4190589 Corrected issue with parent and child cells in completely different
directories starting from root getting the root directory "/"
removed from the front of the child cell path.
2020-09-04 09:57:16 -04:00
Tim Edwards c592784750 Accidentally managed to add some test code into the database that was
not supposed to have been committed.  It has been removed.
2020-09-03 19:30:39 -04:00
Tim Edwards 9c1c365a5e Added new command options "port first" and "port next" to make it
easier to scan through a cell's ports.  Used that capability in the
"readspice" script to handle case sensitivity problems, and to find
labels that are not ports and force them to be ports to match the
reference netlist.
2020-09-01 17:16:22 -04:00
Tim Edwards 13ab2c3e59 Modified the warning in database/DBio.c that says "Cannot open file
for writing!" so that it actually tells you what is the name of the
file that it is trying to write.
2020-07-26 10:58:36 -04:00
Tim Edwards 483f15360a Added support for "PORT SHAPE" in LEF files. 2020-05-28 22:06:22 -04:00
Tim Edwards d4c2b878f5 Fixing the same problem again. . . actual mechanism was slightly
different than I expected.
2020-05-28 21:10:42 -04:00
Tim Edwards 28d8808c65 Corrected several improper uses of StrDup() that used the first
argument as a pointer but also set the same variable to the
return value.  This is ambiguous, because the behavior depends on
whether the value being set upon return is the original value or
the reallocated value.  The result is system-dependent behavior.
2020-05-28 17:09:03 -04:00
Tim Edwards 2af38a4191 Updates from running the fix-ending-whitespace script. 2020-05-23 17:13:14 -04:00
Tim Edwards 55ff3fd1ff Modified GDS read output to avoid generating error messages on
unrecognized layers when the "readonly" read option is set.
Added support to scale elements (from the "element" command,
such as the measurement text and arrows) when the grid scales,
which was missing.  Corrected the output of persistent elements
in a .mag file so that they are correctly scaled by the scale
reducer.
2020-05-12 12:03:38 -04:00
Tim Edwards 33a40d1986 Merge branch 'master' into bplane
Conflicts:
	VERSION
	tcltk/ext2sim.sh
	tcltk/ext2spice.sh

Merged corrections to "save"/"writeall" from master branch
2020-03-23 11:04:50 -04:00
Tim Edwards 7ec87864a6 Corrected the "save" ("writeall") command, which after the fixes of
the last couple of days, was left in a state where it keeps appending
".mag" to the filename if "save" or "writeall" is executed more than
once in the same edit session.  Also, added ext2sim.sh and ext2spice.sh
to the CLEANS list in tcltk, and added both to .gitignore so they are
not tracked.  Removed them from git to stop the current tracking.
2020-03-23 10:19:34 -04:00
Tim Edwards ff0ba7f89d Merge branch 'master' into bplane
Conflicts:
	VERSION

Merged recent changes from master back into bplane, as the efficiency of
bplane for doing extraction on large layouts is unquestionably better.
Fixed the implementation of DBMoveCell() for bplane.  Corrected an error
in the bplane version of dbScaleCell() that enumerates cell uses but
does not free the list.
2020-03-22 14:07:25 -04:00
Tim Edwards ae6b627df7 One more change to add back the .mag extension when writing the
file from the contents of def->cd_file.
2020-03-21 15:34:41 -04:00
Tim Edwards 276bf1d78a Corrected a bad error from a few commits ago, probably 198, which
can deallocate the cell name and causes all sorts of unexpected and
unwanted behavior.
2020-03-21 12:40:35 -04:00
Tim Edwards fe8e229920 Corrected the DEF read routine's ROWCOL parsing. It was not treated
as an optional argument (which it is), and so defaults were not
applied, potentially leading to the wrong number of rows/columns in
a generated via if ROWCOL is not present in the DEF file.
2020-03-21 10:16:33 -04:00