Commit Graph

55 Commits

Author SHA1 Message Date
Darryl L. Miles cfd1d567bd commands: Various fixes for TxPrintf() with !MAGIC_WRAPPER
!MAGIC_WRAPPER build for WASM exposes
2025-10-04 20:50:31 -04:00
R. Timothy Edwards b1c7b52ed2 Modified "gds flatglob" to have the value "*_CDNS_*" by default,
since this is a common artifact of foundry cells and almost
always incompatible with magic.  Modified the "port" command to
allow "port make <index>" on a label where other labels of the
same text already have the same index.  Removed deprecated
documentation and added some missing documentation, such as an
explanation of the "ext2spice subcircuit auto" option.
2025-09-26 09:18:43 -04:00
Darryl L. Miles 0376430702 command: use 'const' with readonly data
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 5c410e9dcb command: use 'const' with 'rcsid' 2025-01-04 11:31:17 -05:00
Darryl L. Miles c339e9b845 TCL9: CmdLQ.c Tcl_AppendResult(... (char*)NULL) cast sentinal
In the TCL8 to TCL9 porting information it was indicated the
sentinal NULL termination should be cast (char *) with API
call Tcl_AppendResult().

This was already in place for most of the codebase this
resolves the last few places.
2025-01-04 11:08:01 -05:00
Darryl L. Miles b8dae95515 Lookup() constify call-site
extflat/EFantenna.c: Lookup() constify call-site
drc/DRCtech.c: Lookup() constify call-site
dbwind/DBWelement.c: Lookup() constify call-site
database/DBtpaint.c: Lookup() constify call-site
commands/CmdTZ.c: Lookup() constify call-site
commands/CmdRS.c: Lookup() constify call-site
commands/CmdLQ.c: Lookup() constify call-site
commands/CmdFI.c: Lookup() constify call-site
commands/CmdE.c: Lookup() constify call-site
commands/CmdCD.c: Lookup() constify call-site
commands/CmdAB.c: Lookup() constify call-site
cmwind/CMWcmmnds.c: Lookup() constify call-site
2024-12-26 15:20:58 -05:00
Darryl L. Miles 56139b48eb K&R commands/*.c: bulk forward reference function prototype conversion
K&R obsolete syntax removal for C23 compatibility series
2024-12-26 13:13:13 -05:00
Darryl L. Miles b3d4ab7980 K&R commands/*.c: bulk function implementation conversion
Argument order and type declaration mismatches:

Label *
portFindLabel(editDef, port, unique, nonEdit)
    CellDef *editDef;
    bool unique;
    bool port;         // If TRUE, only look for labels that are ports
    bool *nonEdit;     // TRUE if label is not in the edit cell

This warrants inspection at call site CmdLQ.c:1712 as both types are bool
is it not so straightforward to check.

It looks like when PORT_MAKE is the option 'port make [index] [dir...]'
  port=FALSE is this the correct intention ?  This looks ok in that
 we're searching for labels to make (upgrade) into ports.
Where as all other 'port ....' commands are operating on items that are
 already ports, and ignoring labels.
So the K&R argument name order is also how the call-sites are using it.

void
cmdStatsHier(parent, nuses, child)
    CellDef *parent, *child;
    int nuses;

This was checked and found ok as callback to ../database/DBcount.c
DBTreeCountPaint(... hiercount, ...)

Due to this not-obvious K&R style also being used in the documentation
this was changed as well (in another commit0.

K&R obsolete syntax removal for C23 compatibility series
2024-12-26 13:13:13 -05:00
Darryl L. Miles f47a173a49 commands/CmdLQ.c: Call to function with fewer arguments than declared parameters
No AI resolution.

The NULL added is cdata which looks to be opaque callback user-defined-pointer,
this is not used in the method printPropertiesFunc() as a possible 3rd argument.

CodeQL: https://github.com/dlmiles/magic/security/code-scanning/157
2024-10-01 12:36:12 -04:00
Tim Edwards b441d668bd Corrected the "property" command parsing, which had a print statement
without an argument, resulting in random things getting printed to
the output when a property name does not exist.
2024-08-03 12:05:41 -04:00
Tim Edwards 5b29870fce Corrected an extraction issue in which an error message about
"unexpected asymmetric device" is printed prematurely, as it
is inside a loop checking over all device entries compatible
with a device type.  Also:  Flagged an issue with the "label"
keyword in the "cifinput" section of a tech file.  The "label"
keyword cannot be used in conjunction with boolean operators.
It can only connect labels on a specific GDS type to one magic
type.  Unfortunately, because this was not flagged before as
an error or warning, the incorrect usage has crept into a lot
of tech files.  This uncovers an underlying issue that labels
must be allowed to automatically reconnect types, which is
undermined by the "no-reconnect-labels" cifinput option.  That
issue will be addressed in an upcoming commit.
2023-10-16 17:29:05 -04:00
Johan Euphrosine 96eb275622 quick and dirty emscripten port 2023-07-12 00:31:37 +09:00
Tim Edwards 7a4a867d6e Extended the "paint" and "erase" commands to accept an option
"pick x y" which acts like "cursor", but operates on a database
coordinate instead of a pointer coordinate.  Made a few other
corrections to the command logging code so that it produces
valid output when the log file is sourced.
2023-07-08 17:34:00 -04: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 7d0d07db38 Changed the default behavior of the "load" command to print
verbose messages (got changed in a recent commit to a quieter
output which doesn't provide much feedback about what's going
on during a lengthy load).
2022-12-21 21:15:33 -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
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
mrg 278194ae96 Fix bugs in port first, next commands.
Previous commits changed the port IDs to an integer rather than a
bitfield. However, the first and next commands were utilizing that
a -1 became a large positive integer when masked. This resulted in
the min port operations failing. Added a default comparison with -1
to fix the problem.
2022-06-13 13:05:57 -07:00
Tim Edwards fe2eb6d390 Modified the file locking behavior so that the command "locking" is
recognized as a valid command when file locking has been disabled as
a compile-time option.  The command then generates an error on
"locking enable" but simply ignores the command "locking disable".
2022-04-25 13:23:29 -04:00
Tim Edwards 44df4fc125 Corrected another instance where running a command on a non-
writeable cell causes magic to crash.
2022-04-06 08:38:25 -04:00
Johan Euphrosine 4677aae8d6 commands/CmdLQ: fix typo 2022-02-15 14:09:56 -05:00
Tim Edwards b68744a944 Made a change to basic extraction to avoid generating an extra
node representing the global substrate on cells that are abstract
views.  Corrected a typecasting issue in ext2spice.c that throws
a compiler warning.  Added another check for a cell being editable
when painting, which is a case that was not covered by the
previous code change to address the same issue.
2022-01-13 12:56:20 -05:00
Anton Blanchard 73fee3e5fd Add missing types in function prototypes
It would be nice to convert the codebase from K&R to ANSI function
prototypes, but for now just clean up the warnings.
2022-01-10 14:04:37 -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 e4d1c29112 Reworked the file locking option as a command instead of as a
compile-time option.  The behavior can now be controlled from
within the program with "locking disable" or "locking enable".
2022-01-01 14:28:59 -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 552d6de0f7 Modification to prevent crashing on an attempt to do an area erase on
a read-only layout.
2021-12-07 14:25:50 -05:00
Tim Edwards e50dab7e52 Modified the way that ToolGetEditBox() works so that it does not
require that an edit cell be defined.  This stops a lot of commands
from failing on non-writeable cells.  There really should not be a
concept of "non-editable" cells at all, just non-writeable ones.
2021-08-04 12:05:21 -04:00
Tim Edwards fcdce0553d Corrected an error in the previous commit, and updated the version
number.
2021-03-29 11:54:47 -04:00
Tim Edwards 187c9285e2 Extended the "port" command with option "-quiet" to suppress error
output when using the "port ... index" or "port ... name" to query
values from a specific port by name or index.  The "readspice"
script has been modified to use this option to prevent unnecessary
error output from the script as it searches a layout for possible
name matches to a SPICE netlist subcircuit pin list.
2021-03-29 11:44:39 -04:00
Tim Edwards 7757384355 Modified the "label" and "setlabel" commands, giving "setlabel" an
extra option "-default" that allows defaults to be set for any
label property other than text or port-related properties.
Subsequently, the command "label <text>" will apply the given
defaults to the label.  This allows a simpler way to create
rendered labels from the command line without remembering all of
the arguments to the extended "label" command.
2021-03-16 13:37:15 -04:00
Tim Edwards d1f7e43dcc Revised DBWloadWindow (again) so that boolean flags are passed to
it as a single value "flags" (unsigned char) with meaningful flag
names.  Added new option "-fail" to the load command to allow
magic to fail on loading a cell that does not have a corresponding
file rather than the default action of creating a new cell.  Added
a flag for the "-quiet" option so that behavior on "-fail" can be
done quietly.
2021-02-10 13:05:38 -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 ba77257afa Several changes and updates: (1) Added a new keyword "required" to the
tech file format "version" section.  This can be used to specify the
version of magic that must be used to be compatible with the tech file.
This effectively supercedes the technology version number.  (2) Changed
the behavior of "make" to set the version and revision numbers on doing
"make" instead of "configure".  This allows the version to update
correctly after doing a "git pull" followed by "make" without doing
"configure" in between.  (3) Fixed a couple of issues that were flagged
as compile-time warnings.
2020-12-16 11:49:24 -05:00
Tim Edwards 06ab6b3a8a Made a change to the way that the parameterized cells are handled.
Instead of a 6-character suffix generated randomly, the 6-character
suffix is generated by a hash algorithm from the device parameters.
If the cell parameters are changed, then the cell itself changes.
If the instance name was default (derived from the cell name) then
the instance name changes accordingly.  The result is that there
cannot be two (auto-)generated cells with the same parameters but
with different cell names.
2020-10-30 11:20:19 -04:00
Tim Edwards c86d3ebb60 Another update that properly deals with the "port" command for
limiting search to non-port labels or to port labels only, depending
on the command option (which was previously not implemented properly).
2020-10-07 16:07:36 -04:00
Tim Edwards 076ee09e2e Added two new command options: "select bbox", which returns the
bounding box of the selection (somewhat unuseful, especially as the
result gets absorbed by the tag callback), and "box select", which
sets the cursor box to the bounding box of the selection (much more
useful).  Also corrected the "port" command so that the command
"port make" will search only for non-port labels.
2020-10-07 15:37:31 -04:00
Tim Edwards aac2c06dfd Corrected a problem with both the "port" command and the "lef read"
command when annotating an existing layout from a LEF database, if
there is a port in the layout that is shadowed by a label with the
same name that is not a port.
2020-09-25 22:39:50 -04:00
Tim Edwards f4b1518825 Changed the "port renumber" command option to sort ports by case-
insensitive alphabetical order instead of case-sensitive.
2020-09-02 09:20:09 -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 807c33139d Extended the "port" command with the option "renumber", which
forces all ports in a cell to be reordered in alphabetical order,
which ensures that the output of "extract" is always the same
(apart from coupling capacitance, which still ends up in randomized
order due to the use of hashing based on memory address followed
by iterating through the hash table).
2020-07-26 16:25:25 -04:00
Tim Edwards 336a7aa209 Added missing close-bracket in the readspice script, and corrected
a diagnostic error output in the port command.
2020-05-29 17:13:38 -04:00
Tim Edwards 483f15360a Added support for "PORT SHAPE" in LEF files. 2020-05-28 22:06:22 -04:00
Tim Edwards 8165519a3c Additional correction to make the "port" command options "use", "class",
and "index" operate on all ports with the same name.
2020-05-28 12:30:28 -04:00
Tim Edwards 626a6355ae Added a Tcl scripted command "readspice" that can be used to read
SPICE subcircuit definitions from a netlist file and apply the port
order in the netlist to the port labels in the corresponding cell
or cells in the magic database.  Also:  Corrected an error in the
bloat-all code introduced in a recent commit that can cause a
segfault.
2020-05-28 11:46:57 -04:00
Tim Edwards 2af38a4191 Updates from running the fix-ending-whitespace script. 2020-05-23 17:13:14 -04:00
Tim Edwards 4a0ad45627 Added a "move" command option "move origin" which will move the
coordinate system origin to the specified (current) location.
This is a much more efficient method than selecting everything in
a layout and moving it, especially for very large layouts where
selection and moving becomes prohibitive.
2020-03-20 13:40:16 -04:00
Tim Edwards 0eb3b1fe1c Corrected an error in ext2spice related to the recent modification to get
rid of redundant port entries in subcircuits.  There is still an outstanding
issue as to whether nodes and connections need to be recursively iterated
to the hierarchy bottom.  The current fix corrected the test case.  Also,
added a "-dereference" option to the "load" command to revert to the
original behavior of using only search paths from "addpath" when searching
for files to load.
2019-11-14 15:18:26 -05:00
Tim Edwards 71108a88b4 Corrected an error that prevented the "load" command from working
with the simultaneous use of "scaled" and one of the options
"-force" or "-nowindow", due to the use of a wrong index value.
2019-10-23 10:18:54 -04:00
Tim Edwards b493334c73 Preliminary changes to support extraction devices other than the original
simple FET device in extresist.  Also:  Extended the bloat-all CIF operator
again, allowing the trigger layer for the bloat operation to include both
CIF layers and magic layers (previously only magic layers were supported).
This extension is possible due to the previous extension allowing the
trigger layer and bloating layers to be on separate planes.  This operator
extension is useful for tagging geometry that is in the proximity of, but
not overlapping, geometry on another plane.
2019-10-17 16:21:56 -04:00