Commit Graph

121 Commits

Author SHA1 Message Date
Tim Edwards 1a3caee376 (1) Added a check for unclosed boundaries when reading GDS.
This is diagnostic only and does not change the read-in
    behavior.
(2) ext2spice:  Corrected an error that had been introduced
    into version 8.3.171 that accidentally marks all devices
    as visited which causes all source/drain areas and
    perimeters to be output as zero.
(3) extract:  Sweeping changes to handling of fringe
    capacitance.  Removed the (recently added) "fringeshieldhalo"
    parameter from the tech file.  Reworked the fringe
    capacitance models based on results from the "capiche"
    project (github/RTimothyEdwards/capiche).  Fringe shielding
    is now done by clipping fringe at the boundary of a
    shielding shape, rather than trying to calculate the
    amount of shielding (as the "capiche" project proved this
    to be equivalent).  Values for partial fringing are modeled
    by atan(x), which like the sidewall (1/x) curve, extends to
    infinity and values are limited by the halo but do not
    otherwise depend on the halo.  Because of this, the halo can
    be made variable and controlled by the user for deciding on
    the tradeoff between accuracy and run time.  A new command
    option "extract halo" was added to allow this control over
    the halo distance.
2023-01-27 11:47:37 -05:00
Tim Edwards 677cd8ab5e Implemented simple drain and source length calculations as device
parameters l1 and l2.  Provides a way to pass the source or drain
length as a parameter for, for example, an extended FET drain
implemented as a resistor abutting the FET gate.  Could potentially
be used as a way to determine source/drain area and perimeter
without resorting to measurements of a shared node.
2022-12-14 21:40:24 -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
Tim Edwards 468a8ae0be Added a 2nd use of the "device" property, which has long been needed,
which instead of defining a device or subcircuit that exists inside
the cell, instead redefines the cell itself as a device or subcircuit
model that exists in the PDK.  This is used where a specific layout
subcell has its own associated device definition in the PDK.  Instead
of the "device" property value being the line that gets generated for
a device in the subcells .ext file, the property value should be the
word "primitive" optionally followed by any parameters that need to
be passed to the subcircuit call.
2022-05-04 16:43:38 -04: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 453d276f20 Cleaned up a bit of confusing diagnostic output when reading GDS.
If cells are instanced before being defined, causing the GDS parser
to rewind the cell from the top, then the "already defined" error
messages will be suppressed, since it is to be expected that cells
will be seen twice (and ignored the 2nd time).  When rewinding, an
output message is issued so that it is clear that the file contains
instances that are used before they are defined, and recommends the
"gds ordering on" setting.  Also:  Fixed the "gds ordering" command
code so that the command with no third argument returns the state
of the "gds ordering" setting instead of generating a parser error.
2022-01-14 11:07:08 -05:00
Tim Edwards 91b00a633f (1) Modified the method used for the previous commit, as it was
found to make ext2spice runtimes very long for large layouts.
The new method is equivalent but doesn't incur the overhead.
Also:  Changed a flag check which was causing the substrate node
to be output as a port for certain layouts where the substrate
node connects to no devices, and so should be optimized out.
2022-01-13 17:00:07 -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
Tim Edwards b12589d09f Fix to the previous commit, which was implemented incorrectly.
The current implementation works, but it is not clear that it
does anything differently than before the start of today's
modifications.
2022-01-12 17:19:29 -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
Tim Edwards b5f2b75768 Removed code from ext2spice that is no longer functional.
Implemented a separate check for ports when writing a subcircuit
that cross-checks against the port list in the flattened
extraction.  This allows ports that were optimized out during
flattening of the hierarchy to be removed from the cell's port
list, which cuts down on disconnected nodes in the output port
list.
2022-01-12 15:30:07 -05:00
Tim Edwards 9a17539ca7 Corrected the use of EF_SUBS_NODE to distinguish between device
substrate (bulk terminal) and global substrate.  Otherwise, the
routine in ext2hier.c that finds the substrate node will find the
first device bulk connection, not the default substrate.
2021-12-30 13:27:42 -05:00
Tim Edwards ea414c822d Got to the bottom of why area and perimeter values are no longer
output for transistors.  The problem came from a change made to
fix an issue with capacitors marked as floating nodes because some
nodes are not output as source or drain.  But those nodes are output
before the parameters, so when generating parameter output, all
nodes appear to have already been output.  Solution:  Specify an
additional bit in the "visited" mask for the node having been output
that is separate from the mask for resist classes used by the code
that writes parameter values, and use that bit as a test for whether
the node is connected to some device (not necessarily a FET source
or drain).
2021-12-20 13:12:49 -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 859879ce5d There being a specific situation where the enumeration of ports
used by "topVisit" and "subcktVisit" in ext2spice.c, probably
caused by having different names on the same port number, the
subcktVisit() routine was modified to use exactly the same
enumeration as topVisit() so that they are guaranteed to have
the same result.
2021-12-13 11:33:02 -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 f68c2c7657 One small change to the ext2spice topVisit code to ignore nodes that
have already been output;  i.e., that have EF_PORT set.  However,
since EF_PORT is now set on all implicit ports, it is likely that
this part of the code is no longer exercised at all, and may be
removed.
2021-12-06 09:52:59 -05:00
Tim Edwards 5913643ad0 Reverted most of yesterday's modifications. Instead located the
issue at the change made in revision 214.  This was done incorrectly
in two ways, one being a set of statements inside an if() block that
should have been executed always, and the other an incorrect use of
the EF_DEVTERM flag, setting it when it should not have been set.
2021-12-03 12:29:02 -05:00
Tim Edwards 6a8f1226d1 Corrected a problem with implicit substrate ports and connections;
implicit substrate connections under some conditions were not added
to the subcircuit pin list.  When this was corrected, the call to
the subcircuit was missing the implicit substrate port.  When that
was corrected, the implicit substrate port printed was the subcircuit's
local node name, not the connection from above in the hierarchy.  The
underlying problem was that the substrate was marked as a port in a
node record that was in another (flattened and unused) def and so not
seen when enumerating the def's node list.  It's possible that the
better solution is that the efNodeHashTable() should be enumerated to
write subcircuit ports, not def->def_nodes.  However, now, by using
EFHNLook(), the corresponding entry in efNodeHashTable() is found and
used.
2021-12-02 11:38:46 -05:00
Tim Edwards 6b1365708d Made another correction to the recent change in ext2spice.c where
an out-of-bounds array access occurs that can cause bad output at
best and a crash condition at worst.
2021-10-07 10:58:21 -04:00
Tim Edwards ff49ba4d2e Another correction with a line that should have been removed in a
previous commit and can cause ports in the SPICE netlist to have
names other than what the port label declared.  Expected not to be
fatal to the netlist, but it's a bit difficult to work with a
subcircuit that doesn't have the expected pin names.
2021-10-05 16:02:21 -04:00
Tim Edwards ff08df0eed Fix to new ext2spice code to prevent a crash condition when
multiple instances of a port name are present.
2021-10-05 13:25:39 -04:00
Tim Edwards c4221889ed Correction to yesterday's commit (minor issue with line length in
the SPICE netlist output of ext2spice).
2021-10-05 08:50:45 -04:00
Tim Edwards 09f335862b Added a check for interrupt in "extresist". Modified the output of
ports in SPICE so that ports are first ordered by index into a
string array, and then output.  This avoids executing an expensive
double loop.
2021-10-04 19:52:22 -04:00
Tim Edwards 73929a0bcc One more round of edits on that issue. . . 2021-09-20 20:14:25 -04:00
Tim Edwards 597ef4857a Corrected an issue caused by the commit to version 8.3.190. Although
that commit claimed to correct an issue with implicit ports not being
output, the solution often failed to properly assign the port number,
so while the implicit ports were added to the subcircuit definition,
they were often missing from the subcircuit call.
2021-08-04 13:54:08 -04:00
Tim Edwards cc16b82a79 Corrected a problem in ext2spice which has been in the code for a
very long time but never discovered;  in which any implicit port
connection into a subcell (that is otherwise labeled with ports) that
appears at the end of the node list (i.e., after all the declared
ports), will not be output, either in the subcircuit definition or
calls.
2021-07-25 13:49:13 -04:00
Tim Edwards d4a09bbc45 Correction to prior commit to remove collision between defined
flag bits for name trimming and short handling method in the
ext2spice options.
2021-07-10 21:27:19 -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 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 cde90bb4a7 Corrected a bad typo, "==" instead of "="; can cause a crash
condition when doing ext2spice.
2021-03-18 11:52:56 -04:00
Tim Edwards feddffcf45 Modified the handling of subcircuit names beginning with non-alphanumeric
characters.  Instead of removing the non-alphanumeric characters, magic
now prepends an "x" to the name.  Since this naming restriction does not
necessarily impact, say, LVS, it would probably be better to let this
behavior be enabled or disabled by a command.
2021-03-06 19:39:34 -05:00
Tim Edwards 4cc09afeac Corrected some errors relating to distributed allocation of node
area and perimeter across devices.  The distributed allocation
was missing for hierarchical output, and the function that
accumulates values per resistance class was initializing by
iterating over device classes, not resistance classes, leading
to a segfault if the number of device classes is larger than the
number of resistance classes.
2021-02-25 17:51:12 -05:00
Tim Edwards a61026588c Revert "Modified the .ext file reading and the .spice file writing so that"
This reverts commit 46baae0ce6.

Reverting the last commit, as it does not work completely the way it
is supposed to, and will most likely have to be done in a different
way.
2021-02-24 12:35:06 -05:00
Tim Edwards 46baae0ce6 Modified the .ext file reading and the .spice file writing so that
array delimiters and hierarchy separators (characters '/', '[', and ']')
that are part of instances or labels passed to magic, are preserved
from input to output, but internally marked (with a backslash escape)
so that they are not misinterpreted my magic when running ext2spice.
2021-02-23 13:46:12 -05:00
Tim Edwards 15fe4d2d29 Merged pull request #35 from Jan Belohoubek 2021-02-17 21:08:10 -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 f343863ce3 Corrected two annoying errors: (1) SPICE netlist output subcircuits
could have multiple ports of the same name.  This problem had been
worked over before, but there was an indpendent mechanism producing
the same result for a completely different reason, caused by subcells
being much larger than the cookie-cutter extraction method's extraction
regions.  Solved by tracking port names in a hash table and preventing
re-use.  (2) ext2spice was producing "no such node" errors;  like (1)
this had been previously worked on, and like (1) this mechanism was
independent.  Problem came from not passing -1 to extHierSubstrate for
the non-arrayed dimension of a 1-dimensional array.  Also:  Removed
the word "fatal" from extraction error reporting, as nearly all
extraction errors are entirely benign.  This should clear up confusion
among alarmed end-users.
2020-11-24 15:30:49 -05: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 18131e26b3 Pulled merge request from Jan Belohoubek, but corrected the problem
of needing to revert parameter definitions after swapping them
during a device source/drain swap.
2020-08-09 13:11:38 -04:00
Jan Belohoubek 6c508c25b9 swapDrainSource moved into a function to encapsulate swap-related tasks; area parameters swapped according to the D/S attributes; SPICE attribute comment printf moved to the end of export function as it allows to add more device types 2020-08-09 17:34:24 +02:00
Tim Edwards ae3c3d7baf Corrected ext2spice, which was reversing source and drain for the
"msubcircuit" extraction model, which would normally not make any
difference except that when source and/or drain are tagged with
terminal attributes, then the source and drain are swapped with
respect to what is expected in the output SPICE netlist.
2020-07-29 14:13:23 -04:00
Dan Moore 99a0575501 Changed the end-of-line comment character from ';' to '$' when
formatting a SPICE netlist for NGSPICE.  This is the documented
character as described in the NGSPICE User Manual, section 2.2.4
End-of-line comments
2020-06-27 19:50: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 ad13e48a07 Corrected ext2spice for the case where a port has been given more
than one name, because in that case one of the port records ends
up with a null pointer to a node, and causes a crash condition.
This can happen inadvertently, as when a connected node is not
specifically designated a port, but is forced to be a port
because of the connection.
2020-03-20 14:50:56 -04:00
Tim Edwards b6cb1fb54a Modified the LEF VIAGEN reading such that it can accomodate a different
order of layers than specified in the LEF/DEF spec.  It is not clear
whether this is common practice, or a bug in the tool that produced the
DEF file that prompted this change.  NOTE:  The "grow" function applied
in this case should be replaced by the actual GDS input rule sequence,
that includes the grow and shrink merge.  Otherwise, vias read from
DEF files do not match the layout from those read from GDS, even though
the mask layers represented by the layouts are the same.
2020-03-03 17:13:37 -05:00
Tim Edwards afe38c55c8 Resolved some issues with working with ext2spice using abstract
views.  Because the abstract view does not necessarily represent
actual connectivity, rely on the port indexes in the .ext file
to determine the number of ports and port order.  Do not use
SpiceNodeName() to look up the node name, or unique ports that
are deemed shorted will go missing.  Also:  Modified the read-in
of .ext files so that use names may contain backslashes.  Only
backslashes that end a line will be handled differently.
2020-01-13 12:58:04 -05:00
Tim Edwards ecfdb66417 Corrected one error in the recent fix for port enumeration in
ext2spice (hierarchy on), where the port index was not checked for
value -1 (no port) before indexing into the port list.
2019-10-31 15:19:30 -04:00
Tim Edwards fc86f44bb1 Again revisited the problem of duplicate nodes. This time, I think
I understand the problem, which is that nodes are ordered according
to precedence of EFHNBest() within a circuit, but there is no
concept of ordering between circuits.  So ports end up listing nodes
in arbitrary order, and the only way to resolve the order is to use
EFHNBest() as is done within a subcircuit.  Appears to work for
different edge cases tested.
2019-10-29 13:55:28 -04:00
Tim Edwards c342178458 Made some changes to the way that ext2spice generates subcircuit
ports, to avoid creating ports for node names that are redundant.
It would probably be better to avoid creating the redundant node
names in the first place;  however, I am less certain why these
are generated.  The incorrect additional ports all have hierarchical
names in the cell, which is a sign that they are incorrect, as the
cell itself should not have any parents.  The level of certainty
about this fix is definitely not 100%, but it was tested on a
hierarchical analog design, and setting levels of parasitic caps
caused new nodes to appear in subcircuits and in no cases did
information appear to be lost.
2019-10-29 09:44:28 -04:00
Tim Edwards 7a42b5b6ad Fixed a long-standing error in which "ext2spice merge" fails when
used with "ext2spice hierarchy on" because the device index is not
reset between calls to output cells in the hierarchy, leading to
a mismatch of the index for all cells after the first one output.
2019-10-23 09:33:37 -04:00
Tim Edwards 46f3f44849 Corrected EFArgs() so that "ext2spice run -help" works as advertised;
e.g., "-h" or "-help" is now recognized as a valid option instead of
printing a usage message by way of throwing an error.
2019-10-16 09:17:58 -04:00
Tim Edwards e9f3dcadef Added substitution for commas in SPICE output, because commas in
instance names and node names are basically fatal to running
ngspice.
2019-10-14 21:46:07 -04:00
Tim Edwards 58c4c8a32e Corrected problem in which using "ext2spice -d" (distributed
junctions) causes magic to crash.
2019-10-14 13:49:41 -04:00
Tim Edwards b0719384e4 Modified the new extraction method with multiple records for each
device type so that it is now properly backwards compatible with
the old-style "fet" records.  Also corrected the record matching
such that it properly matches according to the number of terminals
while allowing the traditional interpretation that there may be
fewer S/D type records than terminals if the S/D types are the
same for all terminals.
2019-10-14 11:09:58 -04:00
Tim Edwards 6d5d370e8c Corrected a few additional uninitialized variable situations that
had been shadowed by the previous set of fixes.
2019-06-07 15:00:39 -04:00
Tim Edwards 547f0448d9 Cleanup of a number of uninitialized variable issues flagged by
the compiler.  Some are obscure functions (plot verstatec hasn't
been used in years) but others (like SPICE distributed junctions)
are potentially significant sources of unexpected crashes on
systems that don't zero uninitialized memory.
2019-06-07 14:13:50 -04:00
Tim Edwards 53078588ae Changed the size of argv[] in efReadLine() to be 128 instead of
64 because I overran the 64 array with too many resistclasses in
a techfile.  This really should be dynamically allocated;  this
requires parsing the line to count tokens and reallocating as
needed (to be done).
2019-06-06 14:53:07 -04:00
Tim Edwards f3a95c74fe Corrected hierarchical SPICE extraction to reset the subcircuit
name-to-number mapping used for the HSPICE format between
subcircuits.  Otherwise, subcircuits with the same instance ID
remain in the table and may cause nodes to be output with a name
that collides with other names in the same subcircuit.  This only
affects output in HSPICE format.
2018-12-12 17:23:35 -05:00
Tim Edwards 648b9e54e6 Corrected "ext2spice lvs" to add "global off" as a setting, which
is normal for top level designs (no implicit label connections
should be made at the top level).
2018-10-31 15:41:22 -04:00
Tim Edwards 6f8ec21a11 Two improvements: (1) Command extension "ext2spice lvs" sets up
all the settings normally used for LVS (hierarchy on, cthresh
infinite, subcircuit top auto, etc.).  (2) Extract and extract
unique ignore cells marked as abstract views (property LEFview
is set) when checking for unconnected nets with the same name
label.
2018-10-31 14:33:24 -04:00
Tim Edwards fa17436fef Corrected a few errors in the implementation of "csubcircuit",
now fully tested and verified.
2018-10-30 21:56:05 -04:00
Tim Edwards 7dc15a7d28 Added extraction device type "csubcircuit", which should have been
added a long time ago, since capacitors use a different method for
calculating width and length than either transistors or resistors,
so subcircuits need a special class designator or else the extraction
may calculate the wrong dimensions for device width by totalling the
perimeter between the device and terminal types, as it would for a
MOSFET.
2018-10-30 16:19:20 -04:00
Tim Edwards ba2db7bbd3 Option "ext2spice subcircuit top" was implemented wrong and would
cause a crash.  Corrected the implementation as well as implemented
an option for "subcircuit top auto" that generates a subcircuit
header or not depending on the presence or absense of ports in the
top level cell.
2018-03-28 12:09:19 -04:00
Tim Edwards feaabe2a17 Possible fix to problem with substrate node being unitialized
when called after "merge conservative" is selected in ext2spice.
2017-10-20 16:07:52 -04:00
Tim Edwards cfccdb84c1 Rewrote the configuration scripts, makefiles, and some initialization
routines to use the Tcl and Tk stubs libraries.
2017-10-13 10:28:07 -04:00
Tim Edwards 088fc759c4 Set of changes updating version 8.2 to the level of 8.1, since 8.2
development had been halted since it was first created back in April.
Version 8.2 is now the official development version, with the first
development push to create a Cairo graphics interface.
2017-08-01 22:14:42 -04:00
Tim Edwards 231a299b16 Initial commit at Tue Apr 25 08:41:48 EDT 2017 by tim on stravinsky 2017-04-25 08:41:48 -04:00