Commit Graph

54 Commits

Author SHA1 Message Date
Darryl L. Miles df1a27fc01 ext2sim.c: fix syntax error, missing argument name
Caused by recent commit a7dd64b24
2025-07-28 21:28:24 -04:00
Darryl L. Miles d5341659fb ext2sim: cleanup unused localvars -Wunused-variable -Wunused-but-set-variable 2025-07-27 12:49:54 -04:00
Darryl L. Miles 7028fbe546 ext2sim: whitespace only changes 2025-07-27 12:49:54 -04:00
Darryl L. Miles 0badf814c5 extraction: constify struct devMerge.next, devMergeList
Feel free to undo variables as necessary in the future as requirements change.
2025-07-27 12:49:54 -04:00
Darryl L. Miles 49115d7d06 ext2sim: gratuitous constification of localvars, struct members, prototypes
Feel free to undo variables as necessary in the future as requirements change.
2025-07-27 12:49:54 -04:00
Darryl L. Miles 7c3df3ce22 ext2sim.c: (ClientData) cast use PTR2CD() 2025-07-27 12:49:54 -04:00
Darryl L. Miles 6a0dc54af8 ext2sim.c: constify whatever the compiler let me 2025-07-27 12:49:54 -04:00
Darryl L. Miles 82a57f8714 ext2sim.c: constify string globals 2025-07-27 12:49:54 -04:00
Darryl L. Miles dc2de91668 finds.c: constify file 2025-07-27 12:49:54 -04:00
Darryl L. Miles 260e08f160 sim2simp.c: constify file 2025-07-27 12:49:54 -04:00
Darryl L. Miles 20d72e9eb2 ext2sim: constify APIs and local vars 2025-07-27 12:49:54 -04:00
Darryl L. Miles a7dd64b242 ext2sim: use strict callback prototypes 2025-07-27 12:49:54 -04:00
Darryl L. Miles 1f9ce81154 ext2sim: Makefile target for: finds sim2simp
Not a serious attempt to make these work but they appear to compile
so this helps CI to cover as much code as possible.

ext2sim_main standalone does not link (probably due to unclean cross
module dependencies that now exist due to libutil.a being a heap where
anything with no modular home ends up)
2025-07-27 12:49:54 -04:00
Darryl L. Miles 975411f40b ext2sim.c: forward declaration prototypes 2025-07-27 12:49:54 -04:00
Darryl L. Miles 4b855fef13 ext2sim: use 'const' with 'rcsid' 2025-07-27 12:49:54 -04:00
Darryl L. Miles 2f2fd85af0 ext2sim: fixup prototypes for TxError() MainExit()
Correct return and argument types.
Use of <stdarg.h> with modern compiler.
2025-07-27 12:49:54 -04:00
Darryl L. Miles bb6e55efb1 ext2sim: Ensure main() have return type and arguments 2025-07-27 12:49:54 -04:00
Darryl L. Miles 22e8ab847c K&R ext2sim/*.c: bulk function implementation conversion
K&R obsolete syntax removal for C23 compatibility series
2025-07-27 12:49:54 -04:00
Darryl L. Miles cef9e0bede ext2sim: Remove non-existent function fwd-decl
int _ext2sim_start();
2025-07-27 12:49:54 -04:00
Darryl L. Miles 61e4e155ec ext2sim.c: remove unused mergeAttr()
If this is ever restored please audit the implementation as it does
not look sound.
2025-04-09 15:11:48 -04:00
Darryl L. Miles 661b66a143 TCL9: Tcl_InitStubs(version="9.0") 2025-01-04 11:08:01 -05:00
Darryl Miles 6d0dca2551 ext2sim.c: printf style constify fmt call-site 2025-01-03 09:08:14 +00:00
Darryl L. Miles 882d82a8ae Lookup() constify call-site with Tcl_SetResult()
ext2spice/ext2spice.c: Lookup() constify call-site
ext2sim/ext2sim.c: Lookup() constify call-site
windows/windCmdAM.c: Lookup() constify call-site

Tcl_SetResult() uses cast to remove 'const' from type, the pointer
is only used to take a copy of the data, the lack of 'const' is due
to Tcl heritage when supporting C89 era compilers.

TCL9 appears to fix this, in that the macro used ends up at
Tcl_NewStringObj() which has 'const' here.
2024-12-26 15:20:58 -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 be09edb8d8 12 x warning: suggest parentheses around '&&' within '||'
The '&' has higher precedence, so the expression of the '&' side receive
extra parentheses.

ResMakeRes.c:671:37: warning: suggest parentheses around '&&' within '||'
ResMakeRes.c:942:32: warning: suggest parentheses around '&&' within '||'
ResSimple.c:201:70: warning: suggest parentheses around '&&' within '||'
ResRex.c:1036:28: warning: suggest parentheses around '&&' within '||'
ResRex.c:1038:50: warning: suggest parentheses around '&&' within '||'
ext2sim.c:1341:47: warning: suggest parentheses around '&&' within '||'
ext2spice.c:172:44: warning: suggest parentheses around '&&' within '||'
ext2spice.c:173:49: warning: suggest parentheses around '&&' within '||'
ext2spice.c:3655:50: warning: suggest parentheses around '&&' within '||'
ext2hier.c:1412:50: warning: suggest parentheses around '&&' within '||'
gcrDebug.c:638:55: warning: suggest parentheses around '&&' within '||'
selEnum.c:323:28: warning: suggest parentheses around '&&' within '||'

GCC14 -Wall cleanup series [-Wparentheses]
2024-10-09 21:12:55 -04:00
Darryl L. Miles 543bd5a5b8 ext2sim/sim2simp.c ParseAttr does not return a value
SonarCloud
ext2sim/sim2simp.c:43 non-void function 'parseAttr' should return a value
https://sonarcloud.io/project/issues?open=AZJB17kzNGfDNup0RkzS&id=dlmiles_magic
2024-10-01 12:36:13 -04:00
Darryl L. Miles d2ae7f78e8 ext2sim/ext2sim.c: EFDone() Call to function with fewer arguments than declared parameters
Passing NULL is valid in efFreeNodeList() to not perform callback..

extflat/EFdef.c:
^231a299 (2017-04-25 08:41:48 -0400  97) void
5e3c26c9 (2021-12-13 18:05:53 -0500  98) EFDone(func)
5e3c26c9 (2021-12-13 18:05:53 -0500  99)     int (*func)();

commit 5e3c26c95a (tag: 8.3.241)
Date:   Mon Dec 13 18:05:53 2021 -0500

extflat/EFdef.c:97
void EFDone(int (*func)());

extflat/EFbuild.c:2180
void efFreeNodeList(EFNode *head, int (*func)());

CodeQL: https://github.com/dlmiles/magic/security/code-scanning/11
2024-10-01 12:36:12 -04:00
Tim Edwards 89f1c4ee67 Corrected a previous implementation that was supposed to not print
warning messages about ports being electrically connected when
those ports have names that match under rules of case-insensitivity,
and the .ext file is being read for the purpose of generating a
SPICE netlist, which is case-insensitive.  Also:  Corrected a crash
condition when using "extract path <name>" when directory <name>
does not exist.
2023-07-28 09:40:41 -04:00
Tim Edwards a3f5f4db80 Changed the behavior of capacitance value output in ext2spice
and ext2sim to make use of the new esSIvalue() routine, so that
it no longer depends on a preformatted string.  Corrected an
issue where the esSIvalue() routine would output "a" for "atto"
which is not supported by ngspice.
2023-03-13 13:21:34 -04:00
Tim Edwards e72f85fd10 Corrected the ext2sim output and extresist to properly handle
2-terminal devices without complaining.  The previous handling
seemed to be technically correct other than spitting out warnings
about missing terminals.
2023-02-24 12:58:46 -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
Tim Edwards 65ef9a1ad3 Final (I hope!) corrections to the "def write" command. 2022-11-19 22:02:44 -05:00
Tim Edwards 16da74a2f9 Implemented a method in EFBuildNode() to capture nodes which are
redundant (same name, different net).  Previously, the method was
to keep the first such node and ignore all others except to add
their resistance and capacitance to the original node.  This
prevented routines like "def write" from enumerating all nets
unless they had unique names.  The new method keeps the additional
records including the node location where they can be found by
EFNodeVisit(), but flags them with EF_UNIQUE_NODE so that routines
like ext2spice or ext2sim can choose to ignore them.  This implies
that this method could be used to reimplement "extract unique"
within "ext2spice" or "ext2sim" without altering label text.  This
has not yet been implemented.
2022-11-18 21:44:06 -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 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 5e3c26c95a Tracked down two more memory leaks coming from ext2spice, due to
client data generated by ext2spice and attached to a node's
nodeClient record;  there is an initNodeClient() routine but no
corresponding freeNodeClient() routine.  Eventually had to add a
callback function passed to EFDone() and EFFlatDone() to clean up
these entries.  After doing that, valgrind reports clean for all
memory allocated within ext2spice (there are other things that are
not freed but not related to a specific command, so do not need to
be treated as leaks).
2021-12-13 18:05:53 -05:00
Tim Edwards 4d6ef8e252 Corrected the "ext2sim" output, since it was using "D" records for
diodes, whereas the .sim format does not have a record type for
diodes, but "D" is used for a delay value.
2021-10-11 13:18:11 -04:00
Tim Edwards b598ce8f94 Modified "ext2sim" behavior so that "=" statements are output
(since these are interpreted by IRSIM, the only known program to
parse .sim output)---the "ext2sim alias on" option now just moves
such statements from the ".sim" file to a ".al" file.  Corrected the
ResSimMerge() routine to reverse the nodes, so that the devices
belonging to the aliased node are added to the original node, instead
of the other way around.  This corrects "missing gate" and "missing SD"
errors that occur due to nodes connected through the substrate.
2021-09-13 12:25:38 -04:00
Tim Edwards c7077d38c3 Separated out the flag used for "ext2spice extresist on" and
"ext2sim extresist on", which was being shared;  that leads to
confusion, especially when using "ext2sim" to generate a node
name input file for "extresist".  Also:  Added a warning when two
ports are merged in a .ext file, as this can lead to numerous
incorrect entries in netlist output.
2021-09-13 10:36:01 -04:00
Tim Edwards 6136d3ff0f Implemented a command option "ext2spice short voltage|resistor|none" that
implements a method for handling ports in a subcircuit that have different
port names and indexes but are shorted together.  "none" is the default
and backwards-compatible behavior that merges ports together, which will
often cause one of the ports to be optimized out of the netlist.  "resistor"
will separate the port names with a 0-ohm ideal resistor.  "voltage" will
separate the port names with a 0-volt voltage source.  This should work
well for simulation and potentially for LVS, although its impact on LVS
has not been fully investigated.
2021-07-10 21:13:24 -04:00
Tim Edwards 35b60531e5 Corrected CalmaRead to remove a syntax error that managed to end up in
the last commit, unfortunately.  Thanks to Matt Guthaus for alerting me
to this.  Also updated parts of the extresist code that remove the
dependence on ResConDCS;  this is a minor update and should not affect
the operation of extresist.  It is preparatory to doing more work to
support additional device types like capacitors, bipolars, and diodes.
2021-06-06 21:44:52 -04:00
Tim Edwards 1c0dbc907a Recast all uses of resist-class and device class in routines using
code from extflat from type unsigned long to type TileTypeBitMask.
This increases the number of types of each to 256 and tracks the
number of types, so it should be difficult to exceed this amount.
2021-05-27 16:13:06 -04:00
Tim Edwards 59fc24729c Corrected issues in the extresist function found after the previous
commit, mostly relating to the scale of values in the ".nodes" file
produced by ext2sim.  Making this file CIF syntax seemed unnecessary,
so I removed the CIF syntax and scaling.  "extresist" can now produce
an apparently valid output on a standard cell layout.  Even with the
change, the extresist output is still only pseudo-hierarchical, so
this does not preclude the need for eliminating the .sim format file
in favor of the .ext file, but it provides a working intermediate
form.
2021-04-21 13:03:26 -04:00
Tim Edwards abb3c3b98b Some changes to ext2sim and extresist to support arbitrary device
types and substrate connections.  This is an intermediate step to
switching from a sim file format to an ext file format for input,
but resolves the worst issues of having the sim file not recognize
the devices or the substrate nodes.  Implemented by using the sim
subcircuit format introduced in IRSIM with the "user subcircuit"
package.  Implementation unfinished (work in progress).
2021-04-20 20:45:49 -04: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 01966d594e Additional modification to the devVisit routine in extflat to
change from passing the HierName to passing the HierContext (of which
HierName is a part) so that more information from HierContext (such
as the cell use being visited) can be passed to the callback
procedure (largely for diagnostic purposes).
2020-06-01 17:14:22 -04:00
Tim Edwards 2af38a4191 Updates from running the fix-ending-whitespace script. 2020-05-23 17:13:14 -04:00
Tim Edwards 80fa495103 Removed the Depend files, which were being tracked with .gitignore
pointing to Depend instead of */Depend.
2020-03-13 15:39:08 -04:00
Tim Edwards 06eef6e324 Corrected ext2sim.c calls to hierAP and others using "scale" and
declaring it to be an integer when it is actually a float.  This
will cause magic to crash when using, e.g., "ext2sim -f su".
2020-02-11 10:21:36 -05:00