Compare commits

...

2113 Commits

Author SHA1 Message Date
R. Timothy Edwards 893a36cae7 Updated the version to go along with the merge of pull requests
475, 476, and 477 (first ones for mac OS and arch Linux support
on github;  the last to modify recent code changes to work with
the last code merge for eliminating the one-off freeMagic().
2025-12-22 09:57:56 -05:00
Darryl L. Miles 3b4d66e7d7 freeMagic1() additions
These additional uses of freeMagic() also require defer-by-one using stack
storage (not global storage idiom, recently introduced).
Not sure if they were missed original or new/modified code in the past
12 months.  Some areas/line-of-code are not usually compiled, maybe that
is why they were originally missed.
2025-12-22 09:57:42 -05:00
Darryl L. Miles 5e8a3f038a CalmaWrite: fix: introduced memory leak, missed free
Appears the 'listtop' is a sentinal/entryexit value to a circular list
My recent patch does not copy original behaviour in freeing this list
entry (as well as the reset of the list).
2025-12-22 09:57:42 -05:00
Darryl L. Miles 9850c5586e GHA: main-aarch64.yml: insert apt-get update 2025-12-22 09:57:29 -05:00
Darryl L. Miles 27df5f9c5f GHA: Migrate macos-13 => macos-15-intel 2025-12-22 09:57:04 -05:00
Darryl L. Miles e9202c1d29 malloc: remove #pragma weak as MacOS does not like
Originally the use of a weak symbol was to provide a fallback for
non-inline supporting compilers.  However all compilers (we care about)
support inline keyword (which was not known at the original time of the
work).  Furthermore GCC have already worked through the solution and make
it easy to implement.

The use of __GNUC_STDC_INLINE__ pattern in this way manages the fallback
and emits a hard symbol this can be tested with:

CFLAGS="-g" ./configure; make; nm */lib*.o | grep freeMagic1

CFLAGS="-O3" ./configure; make; nm */lib*.o | grep freeMagic1

A hard 'T' symbol is emitted (to provide fallback) with all builds, but
in the -O3 all usage is inlined.  So an individual file can decide to
inline or not at the occasion (compile time options) allows.
2025-12-19 09:31:58 -05:00
Darryl L. Miles ea1a89b19c EFbuild.c: efConnectionFreeLinkedList() remove delay-by-one assumption
freeMagic1 series 2nd order find
2025-12-19 09:31:58 -05:00
Darryl L. Miles 9489b23985 freeMagic1() idiom insertion at all sites reported by static code analysis 2025-12-19 09:31:58 -05:00
Darryl L. Miles c74215ad55 scripts/defs.mak.in: FEATURE_FLAGS -DSUPPORT_DIRECT_MALLOC -DSUPPORT_REMOVE_MALLOC_LEGACY
./configure
 # If you are brave, enable with your favourite editor after ./configure
 sed -e 's/^#FEATURE_FLAGS /FEATURE_FLAGS /' -i defs.mak
 make
 make install
2025-12-19 09:31:58 -05:00
Darryl L. Miles 4201f56048 callocMagic has same API argument convention as calloc() 2025-12-19 09:31:58 -05:00
Darryl L. Miles 26372f5d50 gtTkCommon.c: SUPPORT_DIRECT_MALLOC around function pointer use of legacy malloc
Just in case I also modify the allocation to ensure it was also performed
via exactly the same method.
2025-12-19 09:31:58 -05:00
Darryl L. Miles ef419258ab SUPPORT_DIRECT_MALLOC and SUPPORT_REMOVE_MALLOC_LEGACY
This supports three build modes:

No additional -D options, default legacy mode

-DSUPPORT_DIRECT_MALLOC, magic will use direct calls to libc malloc/free
 and will leave in place the symbols now renamed as mallocMagicLegacy()
 freeMagicLegacy() and callocMagicLegacy().

-DSUPPORT_DIRECT_MALLOC -DSUPPORT_REMOVE_MALLOC_LEGACY as above but will
 remove the three legacy functions from the binary to provide assurance
 they can not be used.

The system malloc is thread-safe the legacy magic malloc has a global
deferred free pointer and the mmap() allocate has a free-list that is
not thread-safe making use of free not thread-safe.
This could of course be improved with the use of
atomic_compare_and_exchange operations but for what gain ?

Then there is the additional function call overhead (of the indirection)
and a few tests/branches inserted into a commonly used code paths around
memory allocation, it hides the call site of the malloc/free usage from
the compiler which maybe have special optimization cases.

The existing malloc/free makes static code analysis around memory
allocation more problematic, also use of runtime analysers will operate
better with a fail-fast to bad memory usage.
2025-12-19 09:31:58 -05:00
R. Timothy Edwards 97134848ab A few minor changes to message reporting, plus some additional
support for compressed formats, specifically when given on the
command line (which is handled in a Tcl script, not in the C
code).
2025-12-19 09:30:35 -05:00
R. Timothy Edwards 00c692b140 Added better support for compressed .mag files. While magic doesn't
generate compressed .mag files itself, it is often very useful to
compress a massive layout file to save disk space or to hit a github
size target.  The code change looks for files with either ".mag" (default)
or ".mag.gz" extensions.  No check is made to see if both files might
exist at the same time and have incompatible content;  it is up to the
end user to manage the file compression.
2025-12-11 09:55:28 -05:00
R. Timothy Edwards 203ece1a16 Fixed the "interacting" GDS output operator (which includes
"noninteracting", "overlapping", and "nonoverlapping") which
were incorrectly ignoring tiles outside the search area.
Otherwise they will miss areas that pass outside of the the
search area and return back inside somewhere else.
2025-12-01 15:16:14 -05:00
R. Timothy Edwards 22a230edc9 Found a mistake in the original edit for time stamps from two
commits back, and fixed it.  Also found that the version was
changed between today's first two commits, which it should not
have been, so dialed it back.
2025-11-29 15:49:17 -05:00
R. Timothy Edwards 7f1217596e Missed one additional place in the last commit where timestamps
need to be predecated on the read/write status of cells.
2025-11-29 15:01:21 -05:00
R. Timothy Edwards ff718c3ecf Got rid of one problem with timestamps, which was the requirement
to force an update on a child cell to match the timestamp of the
parent.  This is no longer done on read-only cells, although it
probably ought to be applied to all cells.  A timestamp should
change when a cell has been modified, but a parent cell should never
force a child cell to update its timestamp if the child cell has
not been modified.  The main problem is that "drc check" runs checks
on all child cells, and they then are marked as modified without
consideration of whether the child's DRC status changed.  A better
solution would be to avoid unnecessary updates by detecting a
change in DRC results, but for now, just disabling updates on
read-only cells (which can't be updated anyway) should suffice.
2025-11-29 13:24:23 -05:00
R. Timothy Edwards 98aa2f760a Corrected an error from a recent commit: An attempt to add array
checks when checking for exactly overlapping instances of the same
cell def was faulty and resulted in magic no longer detecting when
unarrayed instances exactly overlap.  Now both conditions (arrayed
and not arrayed) should be handled correctly.
2025-11-25 12:57:46 -05:00
R. Timothy Edwards 441d933148 Updated version to go along with the merge of pull request #473
from Sylvain Munaut.
2025-11-23 17:06:56 -05:00
Sylvain Munaut 9d3fb61cf3 defRead: Accept usename longer than 511 char
The previous code always read in a defined size buffer and any
name longer gets cut which causes issue during extraction because
any collision on the truncated name causes components to get "lost".

So here instead we keep a local stack buffer of 512 byte and use it
if possible, but for longer string we allocate some space on the heap
temporarily.

Some later error processing had to be refactored a bit to make sure
we can always clean-up after ourselves once we're done with the
buffer.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2025-11-23 20:14:21 +01:00
R. Timothy Edwards a1fb779314 Added a LEF section to nmos.tech, provided by Dave in fossi-chat.org. 2025-11-19 17:49:43 -05:00
R. Timothy Edwards abd3975997 Corrected the (very old) "nmos.tech" file, which had GDS layer
assignments for output but not for input.  Also, one layer was
given two different GDS numbers for GDS output, which was
incorrect.
2025-11-19 17:42:40 -05:00
R. Timothy Edwards 227f264838 Fixed the error that causes problems with the tile allocation.
The error was in selStretchEraseFunc2() which was calling
DBErase().  But DBErase() can call DBSrPaintArea() and thereby
start another search of the same plane while the plane is
already in a search.  This is absolutely invalid.  However, it
is simple just to use selStretchEraseFunc2() to collect a mask
of the types that need to be erased and pass that back to the
caller, and apply DBErase() to each type in the mask, outside
of the DBSrPaintArea() search.  With this fix, the tile
allocation is no longer causing problems, and the code to add
tiles deallocated by TiJoinX and TiJoinY to the free tile list
has been uncommented again.
2025-11-09 12:52:03 -05:00
R. Timothy Edwards c87e5baff4 Rolling back part of the last commit; the correction to the tile
allocation fixes the issue with memory being grabbed constantly
and never released, but re-surfaces an error with tiles being
used after being freed.  This is assumed to be a long-standing
bug that has not been found yet.  Meanwhile, the error that uses
up excess memory is better than the error that causes layouts to
get completely screwed up.
2025-11-08 17:24:09 -05:00
R. Timothy Edwards 957d7edd64 A number of things in one commit:
1) Added a "*showmem" "wizard" command to get a dump of all memory
   being used by tiles in the database.
2) Made a slight correction to the way magic detects exact overlap
   of instances of the same cell.  This probably does not make any
   actual difference in practice.
3) Corrected an uninitialized variable in dbReComputeBboxFunc().
4) Changes DBSrCellPlaneArea() to use a static BPEnum variable, so
   that it does not waste time allocating and freeing memory for
   the same thing over and over again.
5) Corrected a memory leak in the tech file "extract" section that
   loses memory every time the extraction style is changed.
6) Corrected the tile join routines to fix a bad memory leak in the
   tile allocation and recovery---a fix which was mentioned in issue
   #414 but which had not yet been implemented.  This has now been
   tested and confirmed to work.
2025-11-07 11:00:22 -05:00
R. Timothy Edwards 969137d1e2 Corrected an unfortunate error from the previous commit due to
missing copying one line with a conditional.  The error results
in "bloat-all" DRC checks reporting false positive errors.  This
commit fixes that error.
2025-11-03 15:06:54 -05:00
R. Timothy Edwards f3adea8c65 Made a few corrections to recent code additions. Also added
more points to accept interrupts during DRC checks, and
modified the tech file parser to allow the full syntax for
magic layers that is allowed elsewhere (e.g., "(*ndiff,poly)/a")
(this applies to magic layers, not GDS layers).  Fixed a
clipping error in the bloat-all function which was causing
non-manhattan geometry to produce bad results, which would
cause false-positive DRC errors when used in a CIF-DRC rule.
2025-10-31 17:37:02 -04:00
R. Timothy Edwards 246c0ea7a4 Extended the "maxwidth" DRC rule to take an optional set of layers
that exclude the maxwidth rule from taking effect.  This is
especially useful for implementing a maxwidth rule on top metal
that does not apply to pads, using the passivation cut layer to
prevent the maxwidth rule from being applied.
2025-10-30 16:39:54 -04:00
R. Timothy Edwards 47778971ee And one more fix to the method, for which I added a variation of
DBNMSrPaintPlane() where if "tile" is non-NULL then "plane" can be
NULL;  the hint tile does not get set but the routine can be called
without knowing the plane other than that the tile is in it somewhere.
2025-10-30 13:18:12 -04:00
R. Timothy Edwards cccd79ab0d One correction to the last commit---The additional check is not
limited to the DRC_REVERSE case but must be done in both the
forward and reverse cases.
2025-10-30 12:37:00 -04:00
R. Timothy Edwards 51b9846120 Made a correction to the DRC error checking on a non-Manhattan
edge.  This was catching geometry unrelated to the error when doing
a spacing check between geometry on different planes.  In the
reverse-edge case, magic needed to run an additional search over
the area on the other side of the original edge that triggered
the rule to effectively clip that corner of the triangle from the
search area.
2025-10-30 12:07:29 -04:00
R. Timothy Edwards 1afd48e840 Corrected an error in which an invalid client name passed to the
"macro" command will crash magic.  This will happen if, for
example, magic is compiled without OpenGL support, in which case
the "wind3d" client does not exist, and parsing the default
macros from the system .magicrc file will cause an immediate
crash.
2025-10-29 09:32:03 -04:00
R. Timothy Edwards 99a5a28a3e Added a drc check to the gencell change procedure, as it appears
that otherwise DRC is not re-checked after a gencell update.  It
is not clear to me why checks are not done otherwise.
2025-10-28 15:10:03 -04:00
R. Timothy Edwards 0ac4d3a465 Found a way to work around the problem of having subcell DRC
errors show up as "See error definition in subcell", which has
been the case since I modified the code to prevent showing DRC
errors in subcells that have been resolved by the hierarchy
above them.  DRC errors are now intelligently searched
downward in the heirarchy when enumerated for "drc why".
Also changed the DRC check tile definition to offset such that
there is a tile centered on the origin, instead of the origin
being between four tiles.  Since most layouts are subcells and
most subcells are small relative to the DRC check tile area,
and most subcells are placed near the origin, then most subcells
will appear in only one tile, which speeds up the DRC process
somewhat.
2025-10-23 17:11:44 -04:00
R. Timothy Edwards 42aa06f8f5 Corrected what seems to be a long-standing error in which
DRCCheckThis() is called in order of top to bottom of the hierarchy
when called from drcCheckFunc() although it was changed to order
DRCPendingRoot from bottom to top.  drcCheckFunc() then does it
backwards.  Fixing this appears to have resolved some weird errors
with DRC errors not showing up when doing "drc check" (initially)
and DRC errors disappearing when making changes to a generated
cell.  Appears to be okay now.
2025-10-22 17:27:00 -04:00
R. Timothy Edwards 4d2912a406 Corrected the return value of spcWriteValue() (recently added)
from "bool" to "void" (does not return a value).
2025-10-21 09:15:05 -04:00
R. Timothy Edwards b668b02a1f Corrected a problem in which "cellname delete" never cleared the
cell name from the cell name hash table.  So when "cellname rename"
was changed recently to prevent changing the name of a cell that
already exists, the suggested recipe for R-C extraction no longer
works:  "load x; flatten y; load y; cellname delete x; cellname
rename y x".  Solved by adding a HashRemove() function to the
cell deletion routine.  Thanks to Egor Lukyachenko for reporting
the issue (Github issue tracker #467).
2025-10-20 11:03:03 -04:00
R. Timothy Edwards 6b8f5d1d67 Modified the toolkit behavior so that a default callback to update
the dialog (and run limit checks) is installed by default on
checkboxes and selection menus, as it is already done for entry
boxes.  Otherwise it is possible to make a selection (like changing
a device type) that invalidates the existing values, but if Apply
is hit immediately afterward, then no checks will be run and the
values may be used as-is even if invalid.  This does not prohibit
the use of "add_dependency" to change the callback behavior.
2025-10-16 17:08:15 -04:00
R. Timothy Edwards c977e4cf76 Corrected an error introduced yesterday by a hasty fix, which
ended up breaking the "extresist" function by failing to parse
the comment line of a .sim file.  This is now fixed.
2025-10-15 10:00:02 -04:00
R. Timothy Edwards 9327e319da Corrected ext2sim to handle the new "dsubcircuit" device type,
added in a recent commit.  The extension was handled by
"ext2spice" but "ext2sim" was missed.  Without it, "extresist"
will fail for any circuit containing a device defined in the
tech file extract section with "dsubcircuit".
2025-10-15 08:31:58 -04:00
R. Timothy Edwards 0e84616af8 Corrected an error that allows a cell to be renamed with the name
of an existing cell, which does not appear to be a fatal problem,
but must be causing a memory leak.  Also:  Corrected an error in
extresist when reading .sim files, in code that is slated to be
overhauled, so this is just a patch to avoid a crash condition.
2025-10-14 10:36:07 -04:00
R. Timothy Edwards c42db8e71b Modified the key input redirection so that it captures and
handles Control-u in the same way that tkcon does, so that when
typing via redirection into the console, Control-u will delete
the entire command back to the prompt. (See github issue #456.)
2025-10-10 10:39:40 -04:00
R. Timothy Edwards 27c423c2ed Substantially revised the "macro" command callback functions and
the "tool" implementation.  Previously, the "tool" implementation
would overwrite the button bindings for the mouse.  The problem
with that is that if the user customizes one or more of the
bindings, such as using the mouse wheel for zooming instead of
panning, then the custom macro gets obliterated when the tool
changes.  The reimplementation creates multiple macro sets which
are unique to each tool.  The "enable_tools" function sets up
the initial unique default bindings for each tool.  The user
can then customize the bindings for any tool, and the
implementation no longer requires the constant changing of key
bindings.  Note that the new implementation is slightly less
efficient because the macro tables are found by string hash
based on the name of the tool or client type, not the integer
client ID.  The reduction in efficiency is balanced by the
increased flexibility of the macros.
2025-10-09 15:43:54 -04:00
Darryl L. Miles 53e7dfe04c ext2spice.c: ifdef for !MAGIC_WRAPPER build 2025-10-08 20:56:41 -04:00
R. Timothy Edwards 9ca81f8ea6 Modified the "tag" command to add an optional subcommand "add" or
"replace" as the 2nd argument.  This allows a simpler 'tag add
<command> <value>' than the existing awkward 'tag <command>
"[tag <command>]; <value>'.  Using "add" also helps avoid
mistakes like one that was in the code for a long time which
overwrites one of the helper window callbacks.  With this done,
added some additional callbacks to the "library manager" to
update when a new file is created by "select save" or "writeall".
Also added "Refresh" buttons to these windows, just in case.
Implemented a zoom function on the mouse scroll wheel when the
Control key is pressed.  This is a stop-gap for a problem with
overriding button bindings that re-establish themselves when the
tool (box, wiring, etc.) changes.  That needs to have a more
comprehensive solution (such as tool-specific bindings).
2025-10-08 17:11:27 -04:00
R. Timothy Edwards d822353e85 One additional fix, since the previous fix needed to be made in
both ext2spice.c AND ext2hier.c.
2025-10-08 10:08:29 -04:00
R. Timothy Edwards 4951f013d5 Corrected the output of the new "dsubcircuit" device which was
generating output for one of the device nodes twice in the
netlist.
2025-10-08 10:04:38 -04:00
R. Timothy Edwards d3a0228958 Added a new device type "dsubcircuit" which basically behaves like
"csubcircuit" but swaps the first two pins (with the device
identifier layer becoming the 2nd pin and the other terminal the
first), which is needed for n-type diodes modeled as subcircuits
where the subcircuit pin order matches the order of pins for a
SPICE n-type diode component.  Previously "msubcircuit" was used
for this purpose, but will calculate the wrong L and W.  While
use of L and W for diodes is rare, this device type also works for
reversed capacitors (where the bottom or non-identifying layer
terminal is in the first pin position of the subcircuit).
2025-10-07 16:45:22 -04:00
R. Timothy Edwards 656d27b17a Added a new "devresist" type "terminal" to account for resistor
terminal resistance, for cases where the resistor value is
estimated and output along with (or instead of) the physical
length and width or area and perimeter.  Corrected the "area"
and "perimeter" type handling so that they combine in parallel,
not in series (note that "perimeter" resistance is just an area
resistance with the depth of the material factored in).
2025-10-07 12:12:33 -04:00
R. Timothy Edwards 3631892cfa One more minor change to the behavior just implemented: A value
for a resistor or capacitor is optional but is valid SPICE and not
just limited to CDL format, so it is now allowed to add "r=" at
the end of a resistor or capacitor component (not subcircuit) to
generate the optional component value.
2025-10-06 20:37:30 -04:00
R. Timothy Edwards 8c323803b7 Additional modification to write out a resistor or capacitor value
as-is, without a parameter name and before any device model name or
substrate pin, according to CDL syntax, if the parameter has been
specified without a parameter name (e.g., "r=" instead of "r=r").
Corrected an error in the extract code which put the substrate node
name in front of parameters instead of after.  This was previously
unexercised because only in CDL format does a resistor or capacitor
model have parameters listed by name.
2025-10-06 17:42:34 -04:00
R. Timothy Edwards acdfb256a1 Made a change to CDL format output to place the substrate parameter
in front of the device name, which is a very inconsistent way to
make the syntax, but whatever.
2025-10-06 16:40:19 -04:00
R. Timothy Edwards 5e74ecf9fa Added code to avoid a segfault if a resistor or capacitor is
specified without a list of substrate connection types, but
the "s=" parameter is used, resulting in an attempt to access a
substrate node that does not exist.
2025-10-06 14:14:05 -04:00
R. Timothy Edwards d6d8620a7c Added new statements "connect" and "disconnect" to the extract
section of the tech file, which can be used to alter the layer
connectivity tables from the default.  This can be used, for
example, to disconnect substrate and well from taps, to
generate a netlist that checks for soft-connect errors.
2025-10-06 11:50:38 -04:00
R. Timothy Edwards a2390167e6 Updated the version to go along with the merge of pull request #455
from Darryl Miles.
2025-10-04 20:50:51 -04:00
Darryl L. Miles 3cfc24f4b9 AppImage: AppRun use #!/usr/bin/env bash
There are Linux systems without bash installed at /bin/sh or it is
in a non-standard location.
2025-10-04 20:50:31 -04:00
Darryl L. Miles 7e12bec49d txInput.c: comment #endif markers 2025-10-04 20:50:31 -04:00
Darryl L. Miles 5f1f92f30d GHA: update canary-matrix.yml
Removes ubuntu-20.04 config (no longer available on GitHub CI)
added clang-19 and gcc-13
removed no_gc_gu, as all 'gl' (GL) options require 'gu' (GLU)
added build for --enable-readline-bundled
added X11+Cairo
2025-10-04 20:50:31 -04:00
Darryl L. Miles 15faa19346 configure: autoconf regen (2.69) --enable-readline-bundled GR_SRCS 2025-10-04 20:50:31 -04:00
Darryl L. Miles af7b6bf119 graphics: minor change to Makefile and configure
This splits and groups DEPSRCS better so errors are not seen trying to
include files that are not present with no intention to build that
source file.
2025-10-04 20:50:31 -04:00
Darryl L. Miles 8b0616eaf5 readline: add configure --enable-readline-bundled option
Cleanup autoconf handling, should always work as expected.
Use of --enable-readline-bundled when readline is needed will use
copy in subdir.
2025-10-04 20:50:31 -04:00
Darryl L. Miles 2b62123459 SimRsim.c: removal of pre-POSIX.1-2001 select() interface ifdefs
POSIX.1-2001 introduced fd_set for use with select() and all current
systems support POSIX.
2025-10-04 20:50:31 -04:00
Darryl L. Miles 2259ef626d SimRsim.c: EMSCRIPTEN fix for select/fd_set
The compiler has started to error on casting int* to fd_set*
Since WASM build has presense of fd_set then the ifdef have been
switched away from the legacy (pre 2000) method.
2025-10-04 20:50:31 -04:00
Darryl L. Miles 3c9987f460 CmdFI.c: CmdGoto() correct printf output
non-tktcl build check
2025-10-04 20:50:31 -04:00
Darryl L. Miles f4212d8e0e graphics: cleanup various warnings 2025-10-04 20:50:31 -04:00
Darryl L. Miles a16c667290 txInput.c: USE_READLINE constify rl_completion_function
There is a use case of fully .rodata data table of strings but also
a dynamic version built at runtime.
2025-10-04 20:50:31 -04:00
Darryl L. Miles 6e2babd141 txInput.c: constify localvars
non-tktcl build check
2025-10-04 20:50:31 -04:00
Darryl L. Miles b80279c6db grOGL1.c: HashLookOnly() using X11 Window type a key on LLP64 needs cast 2025-10-04 20:50:31 -04:00
Darryl L. Miles 722209b1ae parser.c: ParsSplit() constify (const char **remainder) 2025-10-04 20:50:31 -04:00
Darryl L. Miles 692c0f2339 grX11su3.c: warning for ClientData compare
MAGIC_WRAPPER build option
2025-10-04 20:50:31 -04:00
Darryl L. Miles dbdec3aa17 readline/Makefile: lib target (for no-tktcl build option) 2025-10-04 20:50:31 -04:00
Darryl L. Miles f7d2debb98 txOutput.c: $PAGER handling constify 2025-10-04 20:50:31 -04:00
Darryl L. Miles 0f047b89ce txMain.c: readline needs function shim for prototype difference TxGetChar
USE_READLINE build option
2025-10-04 20:50:31 -04:00
Darryl L. Miles 3b57ae1179 txMain.c: MAGIC_WRAPPER constify fix 2025-10-04 20:50:31 -04:00
Darryl L. Miles dc45242d46 database: DBTypeLongNameTbl() constify data (const char*) 2025-10-04 20:50:31 -04:00
Darryl L. Miles 6d8c3eee1a database: DBTechAddPlane() constify API (const char*) 2025-10-04 20:50:31 -04:00
Darryl L. Miles c8fe30398b database: DBTechInitPlane() consumer (DBPlaneLongNameTbl constify) 2025-10-04 20:50:31 -04:00
Darryl L. Miles 5093182f4a database: DBPlaneShortName() return const char * 2025-10-04 20:50:31 -04:00
Darryl L. Miles 4864a80179 database: DBTypeShortName() return const char * 2025-10-04 20:50:31 -04:00
Darryl L. Miles 70054ccde2 EFread.c: ANSI prototype efReadDef() 2025-10-04 20:50:31 -04:00
Darryl L. Miles c007d8077c EFbuild.c: ANSI prototype efBuildDevNode() 2025-10-04 20:50:31 -04:00
Darryl L. Miles da216195b3 SimSelect.c: fix theoretical potential to write to .rodata string
We make a copy of readonly string on function entry and use that instead.
strrchr() is a bit of an annoying API, takes const char* but returns char*
but it is the same string.  One for static analysis or C++.

SimSelectArea() argument unused.
2025-10-04 20:50:31 -04:00
Darryl L. Miles 5fe586100b extflat: ANSI prototype efBuildDevice() and constify (const Rect*) 2025-10-04 20:50:31 -04:00
Darryl L. Miles c7ef7d743a CmdRS.c: SimGetNodeCommand() returns (const char *) now 2025-10-04 20:50:31 -04:00
Darryl L. Miles df7b9079bd CmdFindLabel: fix off-by-one error with: findlabel -glob name
Thanks @d-m-bailey Mitch Bailey for reporting
2025-10-04 20:50:31 -04:00
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
Darryl L. Miles b1424bfaf3 plow: add ANSI prototypes plowMergeBottom() plowMergeTop()
This exposes the incorrect call sites, that are also fixed here.
2025-10-04 20:50:31 -04:00
Darryl L. Miles aef23fd5f3 plotRutils.c: use #include <math.h> 2025-10-04 20:50:31 -04:00
Darryl L. Miles 1dfe1ed645 SimSelect.c: constify (const char*) TLE.tl_nodeName TLE.tl_simLabel 2025-10-04 20:50:31 -04:00
Darryl L. Miles 9c5cf1a567 magic.h: DLONG_PREFIX add other Linux 64bit ifdefs 2025-10-04 20:50:31 -04:00
Darryl L. Miles 55931e8811 GHA: .github/workflows/main-aarch64.yml 2025-10-04 20:50:31 -04:00
R. Timothy Edwards bb131f14d0 One additional modification to output the message about duplicate
cells as a "note" if "gds noduplicates" has been set, and a
"warning" otherwise.  This makes error handling of magic's
output a bit easier.
2025-10-01 15:38:41 -04:00
R. Timothy Edwards 78f7d22796 A number of changes:
1) Corrected spurious error messages about cells already existing
   in GDS when using "flatten" or "flatglob".
2) Fixed handling of resistance as a subcircuit parameter
3) Added area and perimeter resistance for a device;  this is done
   through the "devresist" statement in the tech file, which is an
   extension of the original "fetresist" statement.  Where "fetresist"
   only supported type "linear", "devresist" supports types "area"
   and "perimeter".
4) Support for CDL syntax, including generating subcircuit-like
   parameters for components starting with SPICE-standard prefixes
   like M, R, C, etc., adding "/" between pins and subcircuit name,
   and saving the file as ".cdl" instead of ".spice".
5) Estimated L and W for devices whose geometry is complex and do not
   reduce to a simple rectangle.  L and W are estimated as the square
   root of the area.
6) Changed the method of extracting L and W for diodes to use the same
   method as capacitors.  Note that diodes are not usually specified
   by L and W, but if they are, this will produce the right result.
7) Corrected the reported filename and line number when printing error
   messages related to errors inside a technology file, when the
   technology file uses "include" to combine multiple files.
2025-10-01 15:17:49 -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
R. Timothy Edwards 5de118b762 Corrected the greatest common factor routine that is run when
doing "save", which was missing checks on properties representing
coordinates (e.g., FIXED_BBOX) resulting in those values
potentially getting truncated by scaling the output to an
incompatible common factor.  Thanks to Sylvain Munaut for finding
the issue!
2025-09-17 12:20:13 -04:00
R. Timothy Edwards 00e3bbd12a Corrected the tech loader, which was failing to set the file
prefix when doing a reentrant load, causing include files to not
be found.  Fixed a divide-by-zero issue that occurs when some
tech file sections are not loaded to the abovementioned error.
2025-09-11 10:51:14 -04:00
R. Timothy Edwards 0022c502c8 Correction to dbReComputeBboxFunc() to fix a potential issue with
an uninitialized bounding box value.
2025-09-10 16:54:25 -04:00
R. Timothy Edwards 741216d6f3 Added a new command "archive" that works roughly like the "crash"
command, but with some critical differences, since the "crash"
command is designed for crash backups.  "crash" will save in a
temp file and removes the file after a successful recovery.
"archive" can be used at any time to make a complete snapshot of
a layout in a single file, or to read back that snapshot.
There is a "writeall" option that will make a snapshot including
layout of all read-only (PDK) cells.
2025-09-10 12:40:40 -04:00
R. Timothy Edwards 6195c20d3d Fixed an egregious error introduced by the "save <file>.tcl"
command handling in the previous commit, that can cause a crash
whenever "writeall" is called while a cell's filename is still
NULL.  Thanks to Daniel Estevez for reporting the error.
2025-09-08 09:22:14 -04:00
R. Timothy Edwards 59a1953f3c Modified the GDS read routine to give location information when
a self-intersecting or reversing path is seen in the input.
Added a new feature in which "save <cell>.tcl" will create a
file of magic commands that will re-create the cell when sourced
as a command file.
2025-09-05 17:51:46 -04:00
R. Timothy Edwards b1095b323c Added a command option for "select move" without specifying the
X and Y values, in which case the selection is moved to the
current pointer position.  This allows a different implementation
of the "copy" command as "select move; select keep", which avoids
the problem that "copy" has of modifying the selection with layer
interactions with the existing layout.
2025-08-27 09:57:22 -04:00
R. Timothy Edwards e9f2628f41 Reworked the "def read" command such that it creates a new CellDef
for the DEF file contents, and loads the cell into the layout
window when done.  That makes it consistent with other similar
functions such as "gds read".  Existing scripts which create (by
loading) a new cell before reading the DEF should not be affected
by the change.
2025-08-26 14:48:27 -04:00
R. Timothy Edwards e04307c085 Corrected an issue in computing the extended (includes area of
label text) vs. non-extended bounding box of a cell when doing
"getcell" (and probably a number of other commands/functions, as
well).  A function was always computing the extended bounding box
and then setting both the normal and extended bounding boxes of
the cell to this value, resulting in incorrect cell selections.
2025-08-26 11:00:20 -04:00
R. Timothy Edwards d2acdac901 Corrected an error accidentally introduced a few commits ago in
(commit 4084a6a246) in which a
misplaced close-brace altered the way that "getcell" handles
some orientation cases.  Thanks to Sylvain Munaut for discovering
the error.
2025-08-21 10:44:24 -04:00
R. Timothy Edwards 8d762b4f59 Corrected an error that accidentally misses an input line from a
LEF macro if the FOREIGN statement ends without the optional
coordinates.
2025-08-20 15:01:57 -04:00
R. Timothy Edwards 0301bdec9e Made a simple change to "extresist" to set the REDUNDANT flag on
nodes which are created due to having multiple ports with different
names on the same wire (electrically connected pins).  This prevents
"extresist" from double-counting the wire.
2025-08-19 10:00:05 -04:00
R. Timothy Edwards 4084a6a246 Modified the syntax of the "getcell" command to make the
arguments unambiguous, and to allow coordinates to be given in
any units.  To do this, the (seldom if ever used) passing of a
label as a reference point was changed to require the "label"
keyword before the label name, avoiding the code having to
disambiguate arguments from label text.  This now makes it
possible to specify the coordinates in microns, lambda, etc.,
units.
2025-08-15 10:24:31 -04:00
R. Timothy Edwards 117ca41b8a Corrected an error in the substrate generation for extraction, where
non-manhattan geometry was not being transformed into the parent
orientation.  This went unnoticed for some time due to testing on
PDKs where substrate and well were not allowed to have non-orthogonal
edges.
2025-08-14 08:51:36 -04:00
R. Timothy Edwards 0fb19e568c Extended the "spacing" and "edge"/"edge4way" rules to take an
option "manhattan_dist" that causes corner checks to assume a
manhattan distance measure.  This is useful for checking
distances involving generated edges that are created by a CIF
"grow" operator.  For "spacing", "manhattan_dist" is equivalent
to "touching_illegal", as a use-case for forcing manhattan
distance measurements in corners has not been found for other
"spacing" options.
2025-08-13 11:34:29 -04:00
R. Timothy Edwards 5791ae3701 Made a small change to the "cifmaxwidth" rule check implementation
to ignore non-Manhattan (split) tiles.  This avoids creating false-
positive DRC results on split tiles which are larger in X and Y
than the max-width distance.  False negatives are possible but
correctly implementing a "maxwidth" rule for non-orthogonal areas
requires a completely different algorithm.
2025-08-11 12:10:09 -04:00
R. Timothy Edwards b4912fd550 Updated the version to go along with the merge of pull request
version 8.3.521 that, due to an argument size mismatch, causes
device parameters in netlist output to be printed as zero.
Also added a small extension to the list of extraction types
to include "device veriloga", which has the same syntax as
"device subcircuit" but generates a component type "N"
(Verilog-A component) in the netlist output.
2025-08-07 11:54:49 -04:00
Darryl L. Miles 56598ca0f4 ext2spice.c: bugfix esOutputResistor() uses name without initialization
Constification of APIs has shown up this bug.
spcdevOutNode() uses 'name' as a read-only string, used for
EFHNConcatLook() as 'errorStr' which is used to prefix error log
messages.

EFHNConcatLook() will already defer resolving hierName for the message.

So the only useful thing to indicate to the user is the procedure that
was trying to do the lookup.
2025-08-06 22:58:30 +01:00
Darryl L. Miles c6fe62f64a ext2spice.c: cleanup unused localvars -Wunused-variable -Wunused-but-set-variable 2025-08-06 22:58:30 +01:00
Darryl L. Miles ad5383c307 ext2spice.c: cleanup -Wunused-local-typedefs yesnoType 2025-08-06 22:58:30 +01:00
Darryl L. Miles ab24761d88 ext2hier.c: cleanup unused localvars -Wunused-variable -Wunused-but-set-variable 2025-08-06 22:58:30 +01:00
Darryl L. Miles 66f281c5e1 extflat/EFhier.c: workaround K&R cb_extflat_hiervisitresists_t 2025-08-06 22:58:30 +01:00
Darryl L. Miles 5bdff336e9 EFhier.c: constify local vars efHierVisitSingleResist() 2025-08-06 22:58:30 +01:00
Darryl L. Miles d4e4930de3 EFhier.c: convert to ANSI efHierVisitSingleResist() 2025-08-06 22:58:30 +01:00
Darryl L. Miles e6f04ebb46 EFhier.c: convert to ANSI efHierVisitResists() 2025-08-06 22:58:30 +01:00
Darryl L. Miles 8c61014677 extflat/EFvisit.c: workaround K&R cb_extflat_visitresists_t 2025-08-06 22:58:30 +01:00
Darryl L. Miles 7a122c8619 extflat: implement cb_extflat_hiersrarray_t for efHierSrArray() efVisitSingleResist() 2025-08-06 22:58:30 +01:00
Darryl L. Miles 420a24ef33 extflat: integrate cb_extflat_hiervisitresists_t for EFHierVisitResists()
Additionally the HierName's hierName1 and hierName2 arguments have been
made 'const' to help convey the receiver can not modify the referenced
data passed.
2025-08-06 22:58:30 +01:00
Darryl L. Miles 0141a99af5 extflat: integrate cb_extflat_visitresists_t for EFVisitResists()
Additionally the HierName's hierName1 and hierName2 arguments have been
made 'const' to help convey the receiver can not modify the referenced
data passed.
2025-08-06 22:58:30 +01:00
Darryl L. Miles 0bb29ae5f8 extflat/EFhier.c: workaround K&R ca_hiervisitdevs_proc 2025-08-06 22:58:30 +01:00
Darryl L. Miles d59a87bafa extflat/EFvisit.c: workaround K&R cb_extflat_visitdevs_t 2025-08-06 22:58:30 +01:00
Darryl L. Miles 6bbcd65c5f extflat: integrate cb_extflat_hiervisitdevs_t for EFHierVisitDevs() 2025-08-06 22:58:30 +01:00
Darryl L. Miles e1be3fe7d2 extflat: integrate cb_extflat_visitdevs_t for EFVisitDevs() 2025-08-06 22:58:30 +01:00
Darryl L. Miles 6876c007f5 extflat.h: include EFint.h (need to provide types ready for ANSI prototypes) 2025-08-06 22:58:30 +01:00
Darryl L. Miles 301a5329db extflat: nodeSpiceHierName() constify API 2025-08-06 22:58:30 +01:00
Darryl L. Miles 6df8257505 extflat: nodeSpiceName() constify API 2025-08-06 22:58:30 +01:00
Darryl L. Miles e3bd60eba6 extflat: DevParam.(const char*)param_name consumer, nodeSpiceName() 2025-08-06 22:58:30 +01:00
Darryl L. Miles d78d7eddfd extflat: nodeSpiceName() consumer 2025-08-06 22:58:30 +01:00
Darryl L. Miles aa0b033053 extflat: spcdevOutNode() constify API 2025-08-06 22:58:30 +01:00
Darryl L. Miles 22b96d5112 EFantenna.c: antennacheckVisit cb_extflat_visitdevs_t 2025-08-06 22:58:30 +01:00
Darryl L. Miles a00a5eb1b2 EFantenna.c: convert to ANSI antennacheckVisit() 2025-08-06 22:58:30 +01:00
Darryl L. Miles fddb458339 extflat: forward declaration arguments added 2025-08-06 22:58:30 +01:00
Darryl L. Miles 05876c63d2 EFtypes.h: new header file to provide types for extraction subsystem
This is needed to allow K&R to be removed and struct prototypes to
exist that have fully declared (argument) types.

It maybe necessary (in the future) to have public types and module
internal type in separate header files, but it is unclear if such a
clear split exists.

Copyright plate taken from extflat.h
2025-08-06 22:58:30 +01:00
Darryl L. Miles f031d16f50 database.h: refactor struct ArrayInfo defn into it arrayinfo.h
EFint.t has an ugly ifndef _DATABASE_H that is very include order
dependent (brittle to failure) so this moves the (struct ArrayInfo) type
definition into its own file, which has standard ifndef once file guards.
So include file order no longer matters.

Copyright plate taken from database.h.in
2025-08-06 22:58:30 +01:00
Darryl L. Miles 66d6931120 EFint.h: remove nonexistent function decl EFRootDef() 2025-08-06 22:58:30 +01:00
Darryl L. Miles a31018f721 ext2spice: use strict callback prototypes 2025-08-06 22:58:30 +01:00
Darryl L. Miles ddc0adcb41 extcheck: use strict callback prototypes 2025-08-06 22:58:30 +01:00
Darryl L. Miles 22ffeee2a4 extcheck: forward declaration arguments added 2025-08-06 22:58:30 +01:00
Darryl L. Miles d7fa508067 extcheck: use 'const' with 'rcsid' 2025-08-06 22:58:30 +01:00
Darryl L. Miles 05c242a28f K&R extcheck/*.c: bulk function implementation conversion 2025-08-06 22:58:30 +01:00
Darryl L. Miles b8170ea851 appimage: README.md update (add example on how to run inside docker)
While AppImage attempts to be a more portable way of running
applications across linux installations, sometime is maybe necessary
to run inside docker.

So examples are provided, which also provides testing regime to
validate how the AppImage can be quickly tested.
2025-08-06 10:44:33 -04:00
Darryl L. Miles a9a9efca57 appimage: AppRun minor change for more seamless docker use
Removes NOFILE warning (by default) when running under TCL8 but
still allows user to override with "export MAGIC_ULIMIT_NOFILE="
before running docker with extra argument '-e MAGIC_ULIMIT_NOFILE'.
2025-08-06 10:44:33 -04:00
Darryl L. Miles 2e4a9fd2d2 GHA: appimage: bring back tag --list -n message in release info
For example the message string here.

$ git tag --list -n 8.3.536
8.3.536         "Tagging version 8.3.536"

This could contain additional information relating to the authenticity
and signing info should that feature be used.  Which is useful to see
with the release info.

Also git_previous_tag resolution is allowed to fail to an empty string.
2025-08-06 10:44:33 -04:00
Darryl L. Miles 48dccc68c6 tile.c: fix TiFree() non-inline symbol should always be emitted
This is considered external public API for the tiles module, so
while internal magic code might inline all call sites internally
for performance the DSO (tclmagic.so) should always provide the
API symbol even if it does not use it.

This affects EL7 (gcc 4.8.5) and older:
 #define __GNUC_GNU_INLINE__ 1

This does not affect newer GCC from EL8 (gcc 8.5.0) and later has:
 #define __GNUC_STDC_INLINE__ 1

This can be seen as:

./Magic-8.3.536-x86_64-EL7.AppImage
/tmp/.mount_Magic-FDdbKA/bin/wish: symbol lookup error: /tmp/.mount_Magic-FDdbKA/lib/magic/tcl/tclmagic.so: undefined symbol: TiFree

This fixes the oversight introduced around commit f8ef715608
2025-08-06 10:44:33 -04:00
Darryl L. Miles b577619395 ext2spice: parallelDevs constify API (const devMerge*) 2025-08-06 10:42:55 -04:00
Darryl L. Miles 7ab4911514 Revert "Added a type cast in ext2spice/ext2hier.c to avoid having the"
This reverts commit a3d02d92cc.
2025-08-06 10:42:55 -04:00
R. Timothy Edwards 3472474617 Re-implemented parts of the DRC angle check to make it consider
that all layer types passed to a single "angles" statement in the
tech file are mutually non-interacting.  That is, "angles allm1 45"
will check angles on edges between metal1 and space, but not edges
between metal1 and via (which makes sense, given that a via is an
area into which to place contact cuts, and its edge is not a
physical boundary).
2025-08-06 09:22:12 -04:00
R. Timothy Edwards a3d02d92cc Added a type cast in ext2spice/ext2hier.c to avoid having the
compiler complain about a "const" variable passed to a routine
not declaring "const".
2025-08-04 16:38:41 -04:00
Darryl L. Miles 1653b982af CodeQL FileMayNotBeClosed.ql flock.c may also leak 'fd' in error paths
This is due to the transfer of ownership of the 'fd' into libz/gzip
but the error handling wasn't always being checked.
2025-08-04 16:31:07 -04:00
Darryl L. Miles 0dac3fd19c path.c: CodeQL File{MayNot,Never}BeClosed.ql file-handle resource leaks
Guided by CodeQL static code analyser.

FileMayNotBeClosed.ql
FileMayNeverBeClosed.ql

Multiple paths exist that seems to be equivalent, some of those
paths handled the error path, some of them didn't.

CodeQL will still report a concern (instead of multiple concerns)
so this has been commented to clarify when the libz handle setup
is successful, the ownership of the 'fd' changed.
2025-08-04 16:31:07 -04:00
R. Timothy Edwards 63ad80b8bc Added the keyword "COVER" to the list of keywords expected for a
PIN entry in a DEF file when read by "def read".  Previously,
"PLACED" and "FIXED" were handled, but "COVER" was missed.  Magic
treats all three the same way.
2025-08-04 16:13:36 -04:00
R. Timothy Edwards 2630ebcde1 Reverted a change made to "select area" earlier in the year, which
changed the behavior from selecting subcells if they are unexpanded
to selecting subcells regardless of the expansion state.  The
change was short-sighted and the implementation hard to use.  There
is a need, I think, for a selection method that effectively
unexpands instances, selects everything, and re-expands afterward.
But it's not clear if it is better to select all touching instances
or instances inside the box area;  maybe only interacting
instances (instances with non-space content inside the box).
Regardless, it needs more thought, and meanwhile, the original
behavior works better.
2025-08-04 14:39:10 -04:00
Darryl L. Miles 4e08d178dc appimage: allow git tags with annotation to match expected SHA for ChangeLog
The situation is due to the difference for tags with message / annotation:

$ git tag -l -n1 8.3.534
8.3.534         "Tagging version 8.3.534"

$ git show-ref -s -d refs/tags/8.3.534
4426cc859e
1ec8b6ee1a refs/tags/8.3.534^{}

$ git rev-list -n1 refs/tags/8.3.534
1ec8b6ee1a

Use of rev-lsit will always get the commit ID we expect to see for
the workflow, so we allow either of the SHA above to match at the
point of failure.
2025-08-01 10:58:04 -04:00
Darryl L. Miles 3e5502b936 readline/Makefile: clean fix to unwanted error message 2025-08-01 10:55:50 -04:00
R. Timothy Edwards 8ed7394431 Corrected some basic paint code related to drawing over top non-
Manhattan tiles.  After splitting a non-Manhattan tile crossing
a search area to paint, the routine was automatically merging
tiles to the right.  This is incorrect for tiles inside the search
area, as it can cause the search algorithm to miss unvisited tiles
whose origins are to the left of the split tile, resulting in part
of the area not getting painted.
2025-08-01 10:47:01 -04:00
Darryl L. Miles 1ec8b6ee1a appimage: GHA more debugging for fetch --tags issue 2025-07-29 14:41:49 -04:00
R. Timothy Edwards f52d90346e Updated the version to go along with the merge of pull request #428
from Darryl Miles, which overhauled the Makefile and cleaned up a
lot of long-standing minor issues.
2025-07-29 10:56:54 -04:00
Darryl L. Miles b16bcb35bf Makefile: make -j ordering fix 2025-07-29 10:50:32 -04:00
Darryl L. Miles a77c4906f8 Makefile: fix 'force' target to ensure serialization 2025-07-29 10:50:32 -04:00
Darryl L. Miles 8eb2ec9ead Makefile: allow 'modules' and 'libs' to build in parallel
Removes the shell serialisation `for .. in ..` expression

This provides another significant speed up, after */Depend was made
parallel.  x3+ speedup over -j1.
2025-07-29 10:50:32 -04:00
Darryl L. Miles a81184e205 Makefile: cleanup targets: standard tcl
No need for submake.
2025-07-29 10:50:32 -04:00
Darryl L. Miles bcd17d4f85 Makefile: removed errnous echo message for make.log 2025-07-29 10:50:32 -04:00
Darryl L. Miles f513a0ca3b Makefile: check make depend is parallel 2025-07-29 10:50:32 -04:00
Darryl L. Miles 4aee95e092 autoconf: utilize HAVE_SYS_IOCTL_COMPAT_H HAVE_TERMIO_H 2025-07-29 10:50:32 -04:00
Darryl L. Miles 92b4d6a1f7 configure: autoconf regen (2.69) AC_CHECK_HEADERS sys/ioctl_compat.h sgtty.h 2025-07-29 10:50:32 -04:00
Darryl L. Miles 730d327702 configure.in: AC_CHECK_HEADERS sys/ioctl_compat.h sgtty.h 2025-07-29 10:50:32 -04:00
Darryl L. Miles be6483bf4b GHA: main-macos.yml brew install gnu-sed 2025-07-29 10:50:32 -04:00
Darryl L. Miles 8485820526 GHA: main.yml: emit defs.mak into CI logging 2025-07-29 10:50:32 -04:00
Darryl L. Miles 54bbedfdbb INSTALL_MacOS.md: Update to install gnu-sed
The platform /usr/bin/sed does this:

/usr/bin/sed -e "/#/D" -e "/ \//s/ \/.*\.h//" -e "/  \\\/D" -i Depend$PPID.tmp
sed: -I or -i may not be used with stdin

But a filename was specified, so the error should be file does not exist
2025-07-29 10:50:32 -04:00
Darryl L. Miles b1e2913435 Makefile: sed => ${SED}
This will find GNU make in preference if available on the platform.
2025-07-29 10:50:32 -04:00
Darryl L. Miles f179d1240e Makefile: rm => ${RM} 2025-07-29 10:50:32 -04:00
Darryl L. Miles 6f304318ec Makefile: ln => ${LN} 2025-07-29 10:50:32 -04:00
Darryl L. Miles 6b0bc5bbdc SunOS: FOPEN rename to magicFOPEN due to sys/file.h definition
Example build issue using SunOS Solaris solaris 5.11 11.4.42.111.0 i86pc i386
with gcc version 5.5.0 (GCC).

It turns out the definition is not used by the magic codebase.  So only the
macro name is changed by this commit.

This platform also has a definition for FREAD but the MacOS patch can be used
to rename that.

 In file included from DBio.c:51:0:
 ../utils/magic.h:141:0: warning: "FOPEN" redefined
      #define FOPEN    gzopen
  ^
 In file included from DBio.c:30:0:
 /usr/include/sys/file.h:74:0: note: this is the location of the previous definition
  #define FOPEN  0xffffffff
  ^

 In file included from DBio.c:51:0:
 ../utils/magic.h:144:0: warning: "FREAD" redefined
      #define FREAD(a,b,c,d)    gzread(d,a,b*c)
  ^
 In file included from DBio.c:30:0:
 /usr/include/sys/file.h:75:0: note: this is the location of the previous definition
  #define FREAD  0x01 /* <sys/aiocb.h> LIO_READ must be identical */
  ^
2025-07-29 10:50:32 -04:00
Darryl L. Miles 778201fbc2 DBio.c: HAVE_STRUCT_DIRENT_D_TYPE direct->d_type 2025-07-29 10:50:32 -04:00
Darryl L. Miles c3054f265b configure: autoconf regen (2.69) LIBS 2025-07-29 10:50:32 -04:00
Darryl L. Miles a8f5291bd7 defs.mak.in: restore autoconf LIBS functionality
This is a standard autoconf variable, it was probably disabled due to
how the graphics/Makefile works and the more complex detection taking
place there.

Needed to use it to add -lpthread to some platforms (freebsd/openbsd)
to make it build out the box.
2025-07-29 10:50:32 -04:00
Darryl L. Miles aaa477e44a configure: autoconf regen (2.69) AC_STRUCT_DIRENT_D_TYPE 2025-07-29 10:50:32 -04:00
Darryl L. Miles f45aeb6cee configure.in: AC_STRUCT_DIRENT_D_TYPE 2025-07-29 10:50:32 -04:00
Darryl L. Miles 9f0f5f5b4e configure: autoconf regen (2.69) AC_PATH_PROG(PERL,) AC_SUBST(PERL) 2025-07-29 10:50:32 -04:00
Darryl L. Miles ec7d0fc79a configure.in: AC_PROG_PERL 2025-07-29 10:50:32 -04:00
Darryl L. Miles d2449dc971 configure: autoconf regen (2.69) AC_PROG_SED 2025-07-29 10:50:32 -04:00
Darryl L. Miles e51189911b configure.in: AC_PROG_SED (looking for GNU sed) 2025-07-29 10:50:32 -04:00
Darryl L. Miles 3ca0b616c0 Makefile: toplevel 'make techs' target to process scmos during build
Previously it would only build the 'scmos' subdir when the
'make install' target is running, which is done sudo.  This
would result in a number of files in scmos/cif_template/objs
to be owned by 'root'.

Renamed TECH to TECHS which is inline with the other caregories
MODULES and LIBS.
2025-07-29 10:50:32 -04:00
Darryl L. Miles 412d0570e2 configure: autoconf regen (2.69) ALLOCA NDEBUG DEBUG
also --enable-assertions --enable-debug
also termio.h termios.h sys/ioctl.h
2025-07-29 10:50:32 -04:00
Darryl L. Miles 9f1398dfcb utils/magsgtty.h: detect termio/ioctl headers
Linux is not based on BSD and this file appears to exist to manage
historic BSD conventions concerning termios.
2025-07-29 10:50:32 -04:00
Darryl L. Miles c5ebd7d3c0 makedbh.in _DATABASE_H => _MAGIC__DATABASE__DATABASE_H 2025-07-29 10:50:32 -04:00
Darryl L. Miles 2db18509c5 header file #endif guard middle program once style consistency 2025-07-29 10:50:32 -04:00
Darryl L. Miles d55a2b74ac header file #ifndef guard namespace consistency (global change)
This add an effective namespace prefix to the guard ifndef
2025-07-29 10:50:32 -04:00
Darryl L. Miles 5e17855f31 header file #ifndef guard presence consistency 2025-07-29 10:50:32 -04:00
Darryl L. Miles 3294524111 header file #endif guard trailer comment consistency
oa/magicInit.h
utils/malloc.h
2025-07-29 10:50:32 -04:00
Darryl L. Miles de1b76cb11 niceabort.c: include <time.h> remove preC89 declarations 2025-07-29 10:50:32 -04:00
Darryl L. Miles b6e70f9632 utils/magic_alloca.h: with autoconf AC_FUNC_ALLOCA
Unclear what the correct Copyright header should be on this one,
given most of the lines in the file are from the autoconf
documentation.
2025-07-29 10:50:32 -04:00
Darryl L. Miles f88c7a86cb utils/magic_zlib.h: limit #include <zlib.h> to files that need it
Remove limited use HAVE_ZLIB wrapper API into separate header as
utils.h is used in many places and most source files don't need
to drag in the header file from this external dependency.

Copyright date(s) taken from original source file / git blame.
2025-07-29 10:50:32 -04:00
Darryl L. Miles 4a1da7fe7c utils/magic_assert.h: separate assert.h and ASSERT
This is a low level thing that other lowlevel API (platform shims for
strlen_s() and ctime_r() want to make use of, without any application
global pollution).

Copyright date(s) taken from git blame information for moved lines.
2025-07-29 10:50:32 -04:00
Darryl L. Miles 4d2def46f4 configure.in: whitespace cleanup align --help columns 2025-07-29 10:50:32 -04:00
Darryl L. Miles 49caa3267b configure: --enable-debug make this a user accessible config
This should help with automated CI testing as well, where a suite
can be run and debug enabled and checked, just via a specific
CI setup.
2025-07-29 10:50:32 -04:00
Darryl L. Miles dd49ca21d2 configure: --enable-assertions make this a user accessible config
This should help with automated CI testing as well, where a suite
can be run and assertions enabled and checked, just via a specific
CI setup.
2025-07-29 10:50:32 -04:00
Darryl L. Miles 2a78de8cb9 magic/Makefile: MAGIC_BUILDDATE and inherit values when possible
Went the whole way and make it inherit from toplevel Makefile.
2025-07-29 10:50:32 -04:00
Darryl L. Miles 4e7396162d scripts/configure: autoconf regen (2.69) MAKE_xxxxx generation 2025-07-29 10:50:32 -04:00
Darryl L. Miles d13fa6872e MAKE_xxxxx: to skip building OBJs part of configure 2025-07-29 10:50:32 -04:00
Darryl L. Miles bd541d3e6f rules.mak: fix module Depend and build rules
The ../database/database.h dependency is already described (only when
necessary) inside the Depend file for the specific complication unit.
Not all objects are affected by database.h changes, so it doesn't need
to be forced as a dependency for all OBJS.

Depend itself was never rebuilt when a source file changed.  This now
happens, however technically the superior MAKE process needs to restart
so it includes the new updated copy of Depend file we just updated.
However in practice when developing, modifying #include directives does
not happen often and doing 'make; make' will fix the issue performing
an incremental build both times.  So a minor caveat.

Previously when a single source file was changed the entire module was
recompiled, but we have a Depends file to manage the incremental build
problem and we are not really using it (if we always recompile the entire
module due to any one file change, there would be no need for Depends).

Now when developing, a single *.c file change results in the Depends
being rebuilt, then the single file compiled, then the module relinked.
This is exactly the kind of incremental build speedup having a Depends
file is designed to achieve.

Additionally the use of a direct pipeline to create the file does not
manage error scenarios.  MAKE itself is driven by file existance and
their timestamps for targets, so even if 'make depend' failed, it
would still create an output file that MAKE can not distunguish
between a well formed (possibly empty) Depend file and an incorrectly
created partial.  So building in a *.tmp file first and only if all the
commands are successful then rename to target filename.  This has the
effect of making 'make depend' able to fail now.
2025-07-29 10:50:32 -04:00
Darryl L. Miles d1ff3671cd rules.mak: include ${DEPEND_FILE} only if the file exists
This is a modified fix to the "make clean; make clean" issue.
'clean' is not the only target affected.
2025-07-29 10:50:32 -04:00
Darryl L. Miles 3aebbbd038 Makefile: various consistency matters
Using defined variables ${RM} for common tools
error handling
ensuring default target (is not install)
2025-07-29 10:50:32 -04:00
Darryl L. Miles 8b7e0aaec6 Makefile: whitespace only change 2025-07-29 10:50:32 -04:00
Darryl L. Miles 2947e7ea3d Makefile: database.h removal by toplevel Makefile 2025-07-29 10:50:32 -04:00
Darryl L. Miles f0ade2fc55 Makefile: lookup VERSION local variable once
This was more a clarity matter as relocatable autoconf makes all
references to the path look longer and more unweildly making it
a variable makes shorter and easier to read work through.

Especially when related to risks with RM arguments using the output
of a shell call in the argument list.  What could go wrong ?
2025-07-29 10:50:31 -04:00
Darryl L. Miles 394a01e0d4 Makefile: make depend (will now parallelize via -j)
This target consumes ~50% of the total build time due to the
serialization of the shell for loop method.

Also the removal of the */Depend is deferred to the subdir
Makefile's responsibility.
2025-07-29 10:50:31 -04:00
Darryl L. Miles a18acc4772 Makefile: exit 1 && libs: Makefile deps 2025-07-29 10:50:31 -04:00
Darryl L. Miles acefe4811f readline/Makefile: move up before with no scheme
rename symlink(s) use phony targets, delegate the symlink creation
management command sequence to a single point in the project inside
the readline/Makefile
2025-07-29 10:50:31 -04:00
Darryl L. Miles 80c043db79 configure: wrapper CFLAGS inherit if already set
It is usual for the user to have control of CFLAGS like:
  CFLAGS="-O2" ./configure
2025-07-29 10:50:31 -04:00
Darryl L. Miles ebf2db91b1 defs.mak.in: DFLAGS_MAGICVERSION
This seems needed in multiple places so made a variable on its own.
2025-07-29 10:50:31 -04:00
Darryl L. Miles 4b094e4632 defs.mak.in: OBJS split into C_OBJS CXX_OBJS
This split has the effect (with modified .o.c Makefile rule of
correctly using the $CC for .c files and not try to build .cpp
with C compiler, which fails in oa/** for example.
2025-07-29 10:50:31 -04:00
Darryl L. Miles 73a6ac1650 defs.mak.in: Remove -I. from default compiler options
This can only cause trouble being a global default setting.

All project include files are qualified with a path prefix to help
disambiguate duplication of header file names to effectively provide
a namespace.

When removing it nothing seemed break.  Maybe more configurations
should be tested.  They were all ok.
2025-07-29 10:50:31 -04:00
Darryl L. Miles 271aef82bd defs.mak.in: replace backtick with $(shell ...)
Previously the variable resolution was passed to compiler command line
when ideally this only needs to be resolved once per build and the
entrie build uses the same value.

Compiler command line is computed at least once per file (plus Depends
pass), so this is forking at least 5 extra times during the build.

This improves things somewhat so resolution is performed less.

This may have the effect of making the build appear faster when
ccache is working.  As the command line options maybe seen as a
constant.
2025-07-29 10:50:31 -04:00
Darryl L. Miles 0dccf5826d defs.mak.in: ARFLAGS = cr (removed 'v') 2025-07-29 10:50:31 -04:00
Darryl L. Miles f15e7675cd defs.mak.in: Add RMDIR MKDIR MV LN SED common tools 2025-07-29 10:50:31 -04:00
Darryl L. Miles 62149adc16 DBTechname.c: fix !MAGIC_WRAPPER incorrect use of TxPrintf() warning 2025-07-28 21:28:24 -04:00
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 dd5fa02556 fix: add missing #include <unistd.h>
Fallout from removing it from tiles.h
2025-07-28 21:28:24 -04:00
Darryl L. Miles b042383664 appimage: GHA action/checkout fetch-tags=true workaround
Still battling again GHA checkout with tags.
2025-07-28 21:28:24 -04:00
R. Timothy Edwards 1cc4d83425 Corrected an issue with "bloat-all ... [dist]" in which an attempt
not to re-process processed tiles made an incorrect assumption,
causing tiles not to be re-processed when the clip area changed,
such that areas would be missed.  It is not clear that in its
corrected version, "bloat-all ... [dist]" is any more efficient
than the original implementation of an incremental series of bloat
+ AND.  At least the syntax in the tech file is much simplified.
2025-07-28 11:53:44 -04:00
Darryl L. Miles 68e1c76f88 appimage: GHA fetch-tags=true
The ChangeLog history summary is showing more information than wanted.
2025-07-27 21:06:19 -04:00
Darryl L. Miles 4b9d3f3003 appimage: remove libfuse2 desktop-file-utils
as not required with current AppImage builder.
2025-07-27 21:06:19 -04:00
Darryl L. Miles 5b81fbe7fe appimage: whitespace only cleanup 2025-07-27 21:06:19 -04:00
Darryl L. Miles e701b6d594 appimage: use git show for hash of current checkout state
This switches the 'remotes/origin/HEAD' and uses the current HEAD of the
current checked out git repo.

Revised the sed rule that is transforming (to be more specific on the
 matching regex /-\d+-g/ than just the first /-/):

8.3.530-7-gb64321d4 => 8.3.530+7-gb64321d4 (replace first '-' with '+'
 to indicate it is tag plus this many commits)
8.3.530 => 8.3.530 (no change)
2025-07-27 21:06:19 -04:00
Darryl L. Miles 62a99f6167 appimage: The AppImageTool changes their releases distribution point
This switches to the 'continuous' tag release, that will auto update.

This broke the very old AppImage7 tool since that release not return
HTTP/404.  But I updated all to use their current recommendation.
2025-07-27 21:06:19 -04:00
R. Timothy Edwards 9fe7bf4ab7 Fixed an issue with a non-boolean variable in DBtiles.c being
cast as "bool", causing issues with the proper/strict use of
the "bool" type.  Changed the version back so that it will
update the github mirror tonight, since the current version
appears to be working.
2025-07-27 21:02:40 -04:00
R. Timothy Edwards 43bc006338 Reducing VERSION back to the previous value so that a mirror copy of the
bad code won't be made to github in case the issue with stdbool isn't
resolved by tonight.
2025-07-27 16:52:57 -04:00
R. Timothy Edwards 669604ace3 Updated the version number to go along with merges of pull requests
from Darryl Miles and Torleif Skoar.
2025-07-27 12:54:25 -04:00
Torleif Skår f76826eff8 cif_templates: Fix Makefile race condition with objs directory creation
Fixes racy-ness seen intermittently when building,
where the objs folder doesn't exist when
targets try to write to it.
2025-07-27 12:53:02 -04:00
Darryl L. Miles 189c9f2452 ext2spice: forward declaration arguments or removal
Remove unnecessary forward declaration:
 extHierSDAttr() as ext2spice.h has prototype
2025-07-27 12:52:12 -04:00
Darryl L. Miles 659ec36d2d ext2spice: Makefile use EXT2SPICE_MAIN for deprecated standalone 2025-07-27 12:52:12 -04:00
Darryl L. Miles df6bc6bc51 ext2spice: use 'const' with 'rcsid' 2025-07-27 12:52:12 -04:00
Darryl L. Miles 828cec7bca K&R ext2spice/*.c: bulk function implementation conversion
int spcnAP() follows K&R param ordering
int spcnAPHier() follows K&R param ordering

TODO mergeAttr() sharing references (does this setup a future potential
use-after-free concern?)
2025-07-27 12:52:12 -04:00
Darryl L. Miles f77c4cbaa1 ext2spice.h: move function prototype after arg type decls 2025-07-27 12:52:12 -04:00
Darryl L. Miles 2d889b3e9d ext2spice.h: one line per declaration 2025-07-27 12:52:12 -04:00
Darryl L. Miles 1cab3852f1 K&R ext2spice.h: conversion to ANSI 2025-07-27 12:52:12 -04:00
Darryl L. Miles e258b21251 K&R ext2spice: remove non-existent function prototypes
extern int _ext2spice_start();
 extern EFNode *spcdevHierSubstrate();
2025-07-27 12:52:12 -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 27a91ee5a3 net2ir: use 'const' with 'rcsid' 2025-07-27 12:47:15 -04:00
Darryl L. Miles b6ec131355 K&R net2ir/** 2025-07-27 12:47:15 -04:00
Darryl L. Miles 105f8a728d K&R magic/** 2025-07-27 12:46:38 -04:00
Darryl L. Miles 0b29b1cc12 fix GrTextSizePtr API interface return type consistency
commit 86b5d591d from 20241004 by me, modified return type of
GrTextSize API in the graphics from 'void' to 'int' to convey
and error scenario to indicate when 'r' was not filled in for
the caller, but this is a multi graphics driver API interface
so requires all downstream graphics engines to also support
the return type change.

This API can error and indicates when 'Rect *r' was
successfully updated.
2025-07-27 12:45:51 -04:00
Darryl L. Miles 2173d03b14 netlist.c: whitespace only cleanup 2025-07-27 12:44:42 -04:00
Darryl L. Miles d7935930ad F42: fix for etext symbol glibc 2.29+
The man page end(3) changed as well over time to support the new definition.

This was revised from 2.41+ to 2.29+ as it seems top relate to a mix of
Kernel / Glibc / Compiler and the new defintion probably works on any
older system.
2025-07-27 12:44:42 -04:00
Darryl L. Miles 3fd0798312 CalmaRdpt.c: -Wall -O3 savedef used uninitialized
GCC11 -Wall -Wpedantic -O3
2025-07-27 12:43:59 -04:00
Darryl L. Miles 5d8cfdc760 CalmaRdpt.c: -Wall -O3 snprintf("polygon%5d")
Finds this a problem still.

GCC11 -Wall -Wpedantic -O3
2025-07-27 12:43:59 -04:00
Darryl L. Miles 046401cbd8 Use HAVE_SYS_TIME_H and TIME_WITH_SYS_TIME from autoconf where possible 2025-07-27 12:43:04 -04:00
Darryl L. Miles 957904a389 configure: autoconf regen (2.69) AC_HEADER_TIME 2025-07-27 12:43:04 -04:00
Darryl L. Miles c695980145 configure.in: Add AC_HEADER_TIME 2025-07-27 12:43:04 -04:00
Darryl L. Miles df0623a435 include <unistd.h> where necessary in files using API calls
When global <sys/mman.h> was removed from tile.h it also removed
<unistd.h> nearby.  This exposes the lack of <unistd.h> being
included where needed using APIs like close()/read()/unlink()/isatty()
the WASM build seems to show this as the header file set is structured
differently.
2025-07-27 12:42:05 -04:00
Darryl L. Miles 4023ed9da0 tiles: Remove TiJoinFree() now that TiJoin[XY]1() exists and all use-cases utilize 2025-07-27 12:42:05 -04:00
Darryl L. Miles fd50bc1f4d TiJoin[XY]1 API introduction at all call sites 2025-07-27 12:42:05 -04:00
Darryl L. Miles 489f4fe057 tile.h: move #include <sys/mman.h> into tile.c
tile.h is included by a large part of the project, but the definitions
in sys/mman.h are only needed by the implementation code inside tile.c
so this reduces project wide include dependencies.
2025-07-27 12:42:05 -04:00
Darryl L. Miles f8ef715608 tiles: Make TiFree() easier to inline for compiler
Removal of unnecessary function call indirection into TileStoreFree()
since TiFree() is has multiple implementation already and we can
customize TiFree() directly as required.

Move the function definitions into the tile.h to they are visible to
compiler during code generation to consider inline potential.

This has made global 'Tile *TileStoreFreeList' more visible.
2025-07-27 12:42:05 -04:00
Darryl L. Miles db8e790aea TiJoin[XY]1() API introduction 2025-07-27 12:42:05 -04:00
Darryl L. Miles a6fd0ed320 DBtiles.c: DBFreePaintPlane() remove the TiFree() deferred assumption
The comment indicates the expectation that TiFree() is deferred-by-one,
which would be true if freeMalloc() was used but since the custom mmap()
allocator technically this is not true.

The TiFree() allocator is single-threaded and separate from libc so the
assumption is still kind of true but for different reasons
(single-threaded).

But since it doesn't really cost anything (other than a few lines of
code a human needs to read) the compiler would be expected to perform a
load (which it was going to do anyway) into a caller-saves register over
the function call.
Most of the other function state is invalidated anyway due to the heavy
linked-list navigation and low number of local variables, I would not
think there is much register allocation pressure.

TODO this code can be tested by confirming zero allocations are active
and by invalidating (poison) all fields inside TiFree().
2025-07-27 12:42:05 -04:00
Darryl L. Miles 15e5b36f52 tile.h: TiFreeIf/TiFree1() API 2025-07-27 12:42:05 -04:00
Darryl L. Miles 1eb2231bbf configure: autoconf regen (2.69) AC_C_INLINE AC_C_RESTRICT 2025-07-27 12:42:05 -04:00
Darryl L. Miles 52d3feac73 configure.in: AC_C_INLINE AC_C_RESTRICT 2025-07-27 12:42:05 -04:00
R. Timothy Edwards d4f487266f Updating the version number to go along with the merge of a bunch
of pull requests (about half of those pending) from Darryl Miles.
2025-07-26 20:54:46 -04:00
Darryl L. Miles c534eb318d magic/main.c: add missing ifdef SCHEME_INTERPRETER 2025-07-26 17:48:31 -04:00
Darryl L. Miles cc57510019 textio/txCommands.c: add missing ifdef SCHEME_INTERPRETER 2025-07-26 17:48:31 -04:00
Darryl L. Miles bcc9852cba configuration: #ifdef LEF_MODULE
Enclosed symbols only seem available with when this ifdef.
2025-07-26 17:48:31 -04:00
Darryl L. Miles bfefc7196e configuration: #ifdef CIF_MODULE
Enclosed symbols only seem available with when this ifdef.
2025-07-26 17:48:31 -04:00
Darryl L. Miles 22c074537d configuration: #ifdef ROUTE_MODULE
Enclosed symbols only seem available with when this ifdef.
2025-07-26 17:48:31 -04:00
Darryl L. Miles 534a56376a DBcellsrch.c: #ifdef ROUTE_MODULE around hook to update MZAttachHintPlanes()
When building without this module MZInit() does not get called and
MZAttachHintPlanes() does not guard against that situation.

To allow unused code to be pruned from final binary, better to remove
the cross module hook breaking the dependency.
2025-07-26 17:48:31 -04:00
Darryl L. Miles 142b7e5a78 tclmagic.c: memleak Tcl ref counting over Eval memory leak
API docs indicate the original usage seems ok.
Calling Tcl_GetIndexFromObj() is allowed with a refcount == 0.
But in actual usage it leaks the Tcl_NewStringObj() memory across the
Tcl_EvalObjv() call like the object accounting system doesn't work on
that anymore (because the use of Tcl_EvalObjv() disrupted things).

Looking at the code nearby it increments refs (for all recently created
objs) and decrements around Tcl_EvalEx() for the actual data the 'eval'
needs pinned and is working on.

If we just repeat this same pattern but with 'objv0' the memory leak is
gone.  The decrement must wake it up / make it remember what to do.
So this required covering all the exit paths to decrement as well.
2025-07-26 17:46:59 -04:00
Darryl L. Miles 7029971c33 configure: autoconf regen (2.69) AC_HEADER_STDBOOL 2025-07-26 17:44:45 -04:00
Darryl L. Miles bfbdf45b88 C23: use AC_HEADER_STDBOOL #include <stdbool.h> 2025-07-26 17:44:45 -04:00
Darryl L. Miles 35d455fd72 C23: CmdSubrs.c fixup deprecated isascii() 2025-07-26 17:44:45 -04:00
Darryl L. Miles 9e181f0d2e rtrTravers.c: missing const
This is to remove the constness warning.
2025-07-26 17:38:19 -04:00
Darryl L. Miles a53f71d5c6 GHA: appimage10: Add support for EL10 2025-07-26 17:29:19 -04:00
Darryl L. Miles b7dd2f0e9c GHA: appimage9: Add support for EL9 2025-07-26 17:29:19 -04:00
Darryl L. Miles c5e0165e5e GHA: appimage8: Add support for EL8 2025-07-26 17:29:19 -04:00
Darryl L. Miles b9296074b2 GHA: appimage7: fixup relocated files 2025-07-26 17:29:19 -04:00
Darryl L. Miles 96b89a53b7 GHA: appimage7: appimage/* => appimage/7/* (relocate EL7) 2025-07-26 17:29:19 -04:00
Darryl L. Miles 6c952f98eb GHA: appimage7: Maintenance update
Upgrade Tcl to 8.6.16
Use versioning to include tag, indication of timestamp and git hash.
Rename to include '7' in the labeling (as it is EL7 based)
Improve log output to keep information about versions used.
Update README.md a little.
2025-07-26 17:29:19 -04:00
Darryl L. Miles ea5f1ed3f1 tiles/tile.h: Remove unused inlines breaking older GCC
This was breaking on older GCCs (such as GCC 4.8.x used for
AppImage with CentOS7).
2025-07-26 17:29:19 -04:00
Darryl L. Miles 66e72c748a CIFParsePath() prototype change to simply return of created data
Previously this was returning two values, a 'bool' and a data
structure that is created.  Now it simply returns the data
structure which makes it easier to reason about who takes
ownership of the memory and when, also that no address-of can
be supplied that has any side-effect that interacts with how
the method works / the returned result.

-extern bool CIFParsePath(CIFPath **pathheadpp, int iscale);
+extern CIFPath *CIFParsePath(int iscale);

Previous related comments:

Easier to reason about, there can be no interaction from *pathheadpp
and the various functions called, which maybe the first concern to
the next reader as visibility of new data is limited to that of a
local variable of the function.
2025-06-26 16:09:43 +01:00
R. Timothy Edwards eb81da6c56 Updated the version to go along with pull request #406 from Darryl
Miles (updates for github actions).
2025-06-19 09:55:57 -04:00
Darryl L. Miles ab73c716a4 GHA: main.yml (move to ubuntu-22.04) 2025-06-17 16:35:34 +01:00
Darryl L. Miles f947543fe3 GHA: canary-matrix.yml: remove sunseted ubuntu-20.04 runner 2025-06-17 16:35:27 +01:00
Darryl L. Miles 9551167e10 GHA: canary-matrix.yml: use set -o pipefail 2025-06-17 16:35:24 +01:00
Darryl L. Miles 5e32174dbb GHA: appimage.yml (move to ubuntu-latest) 2025-06-17 16:17:29 +01:00
R. Timothy Edwards 490fc6f9d7 Added a quick hack solution from Darryl Miles to prevent the
database corruption discovered recently that was uncovered by a
commit on Jan. 31 and is caused by DBMergeNMTiles0() using a
freed tile (reported in github issue #404).
2025-06-12 19:54:33 -04:00
R. Timothy Edwards 5ecc55b37d Added some alternative key bindings to the keypad for "stretch"
commands, because the keypad numerical values no longer work
regardless of the setting of Num Lock.  The keypad arrow keys
alone implement "move", while Shift + keypad arrow keys
implement "stretch".
2025-05-22 08:47:03 -04:00
R. Timothy Edwards f1f4b82a30 Corrected an error caused by extending the parsing of the FOREIGN
keyword in LEF.  FOREIGN may take an origin offset, but it is
optional.  The routine to check that there were no offset values
in the statement incorrectly checked for a NULL token instead of
a value ";" which would indicate an end-of-statement.
2025-05-16 19:36:16 -04:00
R. Timothy Edwards 02669de267 Updated the version number to go along with a bunch of pull request
merges for PRs by Darryl Miles.
2025-04-09 15:27:18 -04:00
Darryl L. Miles 31400dd45f plotPNM.c: Fix crash due to uninited rtl_args.outfile
I introduced this issue in recent commit e88dcba1c
2025-04-09 15:26:54 -04:00
Darryl L. Miles e592122199 ASSERT fixes (typo in variable and bad integer casting)
routerLayer => routeLayer (my typo from a recent commit, compile fix)
MINFINITY compiler warning
2025-04-09 15:26:06 -04:00
Darryl L. Miles 44bb9327a2 ExtTech.c: fix uninitialized exts_linearResist value leaks into extresist
This value appears to be initialised at only one spot in the codebase
(under very narrow conditions) but extresist will read it and make
branching decisions based on the uninitialised state.

This 'X' state propagation appears to eventually get processed in
ResWriteExtFile() near where final output formatting is occurring.

It is unclear (at this time) if it perturbs output values in a
problematic way, or if due to algorithmic reasons the data is
discarded before output anyway.  I have at least one trace run (with
multiple triggers) of printf formatters handling uninitialised data
in ResWriteExtFile().
2025-04-09 15:25:02 -04:00
Darryl L. Miles 2c9e3a558d git rm SimSelect.c.new (was this always here?) 2025-04-09 15:23:21 -04:00
Darryl L. Miles 739f0f27fe sim: DBCellSrArea() cb_database_cellsrarea_t SimCellTileSrFunc() 2025-04-09 15:23:21 -04:00
Darryl L. Miles 56bdf9ce28 sim: DBSrPaintArea() cb_database_srpaintarea_t SimSelectFunc() 2025-04-09 15:23:21 -04:00
Darryl L. Miles dceb5cfad7 database.h.in: dbSrConnectFunc()/dbSrConnectStartFunc() add public prototype 2025-04-09 15:23:21 -04:00
Darryl L. Miles ef123be806 database.h.in: dbcUnconnectFunc() add public prototype 2025-04-09 15:23:21 -04:00
Darryl L. Miles fa1f1583df database: DBPrintUseId() K&R removal 2025-04-09 15:23:21 -04:00
Darryl L. Miles cface55c5b sim: various cleanups (non existent funcs) 2025-04-09 15:23:21 -04:00
Darryl L. Miles 67f7db9540 sim: remove declaration for getenv() 2025-04-09 15:23:21 -04:00
Darryl L. Miles b5ac7e4f92 sim: use pid_t where appropiate 2025-04-09 15:23:21 -04:00
Darryl L. Miles 559eb94f3e sim: use 'const' with 'sccsid' 2025-04-09 15:23:21 -04:00
Darryl L. Miles ef79d33dd4 database.h.in constify various TileTypeBitMask* data usages 2025-04-09 15:23:21 -04:00
Darryl L. Miles 6ec826fb8b sim: constify various APIs 2025-04-09 15:23:21 -04:00
Darryl L. Miles 1fbba4408f K&R sim/*.c: bulk function implementation conversion
K&R obsolete syntax removal for C23 compatibility series
2025-04-09 15:23:21 -04:00
Darryl L. Miles b3384f9104 K&R sim.h: conversion to ANSI
K&R obsolete syntax removal for C23 compatibility series
2025-04-09 15:23:21 -04:00
Darryl L. Miles be09d8d402 SimRsim.c: update with const API change to utils module 2025-04-09 15:23:21 -04:00
Darryl L. Miles 120cea3921 SimRsim.c: remove declaration SimGetReplyLine() as it is in sim.h 2025-04-09 15:23:21 -04:00
Darryl L. Miles 10f82355f5 txCommands.c TxGetInputEvent() rework main loop to iterate less
Original version would iterate exhaustively, even when it was not
necessary.

This version seeks to do the minimum amount of iteration work based
on the information available.
2025-04-09 15:19:25 -04:00
Darryl L. Miles 3c3ebcfd2b txCommands.c txInputDevRec FD select() usage overhaul
There are numerous concerns with the original code from a read through.

The #define TX_MAX_OPEN_FILES 20 is badly named, the txCommand.c uses
fd_set to hold active FD for each device, and makes no attempt to bounds
check the 'fd' or 'fd_set' of any TxAdd1InputDevice() is in range.

The real name of this variable should be TX_MAX_INPUT_DEVICES as it
related to the fixed compile time slots available for devices, each input
device must have at least one active FD and it can be in the range
that fd_set allows, which is 0..1023 on linux.

So based on this being the original intention, due to the way the code is
constructed and API calls made available, the file has been reworked
to allow all these considerations at the same time.

Now the design should be FD clean for FDs in the range 0..1023 instead of
being artificially clamped to the first 20 FDs being valid input devices.

Renaming of variable 'i' to 'fd' when it relates to an fd number, so all
uses of FD_XXXX() should use fd, this helps clarify the different domain
the number relates to.
When 'i' is used it relates to the index into the txInputDevRec array.
A large part of the concerns relate to trying to mix the two numbering
domains interchangeably, just using a different name really clears up
understanding to the reader.

Other items that look like errors TxDelete1InputDevice() will
shuffle-remove entries with no active FD, but it is iterating an array
it is also modifying, so it looks like it would have incorrectly skipped
the next item that should be inspected just after a shuffle-removal
occurred.

The various iterators that works from 0..TX_MAX_OPEN_FILES incorrectly
limited the visibility of the routines to the first 20 FDs instead of
the full FD_SETSIZE the TxAddInputDevice API call allows to be
registered.

Passing in TxAdd1InputDevice with an fd above 19 would have resulted in
everything looking successful until select() was used, then the kernel
would likely not sleep/wait because the input fd_set would look blank due
to being clipped by nfds=TX_MAX_OPEN_FILES (instead of that plus 1).

The use of TX_MAX_OPEN_FILES in select instead of TX_MAX_OPEN_FILES+1 for
the 'nfds' field would have meant a device with fd=19 would not work as
the design intended.

The define definition has been removed from the module public header,
I assume it was there for use by another module, but the incorrect
select() usage has been corrected over there in a previous commit.
So now the define can be maintained near the array it relates to.

While the code might looks less 'efficient' as it is now sweeping all
1024 FDs when input devices during add/remove (hopefully there maybe some
compiler auto-vectorization/tzcnt use there).  The main event loop is
slightly more 'efficient' (especially for the single device with input
fd=0 case) as it will only check the 1 FD each input event loop iteration,
not check all 20 FDs for data readyness everytime.
2025-04-09 15:19:25 -04:00
Darryl L. Miles 6d2d4353d3 select() API usages add ASSERT() to validate fd number is in-range
This encapsulates the expectation the 'fd' is in the permitted range for
the standard sizes 'fd_set'.

This is so there is some form of detection with issues in this area, if
the RLIMIT_NOFILE limit is increased.
2025-04-09 15:19:25 -04:00
Darryl L. Miles 8d6571066d grMain.c select() usage fix and protect from higher numbered fd's
The old code would only work is the fileno(stream) returned an fd
in the range 0 <= 19.  It would silently fail, if the fd was in
the range 20..1023 because FD_SET() would work and syscall select()
would be limited to only look at the first 20 fd's.  Ignoring any
fd's higher even if set.
This would theoretically cause high CPU usage due to select()
never blocking because there are no active fd's in the fd_set
as far as the kernel interprets the request and the kernel would
immediately return.

But reading the code the 1st argument to select() seems self
limiting for no good reason.  It should be fileno(stream)+1 as
documented in man select(2).

Added the assertion as well, because we are trying to allow magic
to use fd's beyond the standard environmental limits.  So it
becomes an assertion condition if the fd is outside the range
0..1023 because the FD_SET() macro will not operate correctly /
undefined-behaviour.

I can't find any user of this func in the codebase right now.

If you look at sim/SimRsim.c and the use of select() there, it is
correctly using select() to wait on a single fd over there.  This
commit changes this code to match this correct usage.
2025-04-09 15:19:25 -04:00
Darryl L. Miles bcd81c74b2 tclmagic.c: RLIMIT_NOFILE to 4096 on startup (only for TCL9 envs) 2025-04-09 15:19:25 -04:00
Darryl L. Miles f5f59846da configure: autoconf regen (2.69) getrlimit setrlimit sys/resource.h 2025-04-09 15:19:25 -04:00
Darryl L. Miles c676c6b1d3 configure.in: getrlimit setrlimit sys/resource.h 2025-04-09 15:19:25 -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 e7c46102d6 ext2spice: mergeAttr() fix, leak removal and restore original intention 2025-04-09 15:11:48 -04:00
Darryl L. Miles b3617f603d extract: DBSrCellPlaneArea() cb_database_srcellplanearea_t extContainsCellFunc() 2025-04-09 15:07:28 -04:00
Darryl L. Miles 321b2d61c7 extract: DBSrCellPlaneArea() const Rect * arg2 2025-04-09 15:07:28 -04:00
Darryl L. Miles 5c8510355f extract: DBSrCellPlaneArea() cb_database_srcellplanearea_t extContainsCellFunc 2025-04-09 15:07:28 -04:00
Darryl L. Miles 5b03081d03 cif: TiPlaneRect const ripple 2025-04-09 15:07:28 -04:00
Darryl L. Miles 16efabe9ee calma: TiPlaneRect const ripple 2025-04-09 15:07:28 -04:00
Darryl L. Miles 00b479301f tiles: TiPlaneRect const ripple 2025-04-09 15:07:28 -04:00
Darryl L. Miles 51ec834f6c This attempts to remove the number of active lines of code, branches from
the TiAlloc() and TiFree() code path.

The rationale of the changes:

Performing the one-time initialization check (first call to
mmapTileStore()) for every TiAlloc() is unnecessary if the decision code
is reworked to allow NULL pointers to exist in the computation and still
make the correct decision.

Use of 'unsigned long' for pointer arithmetic is not compatible with _WIN64
compiler model LLP64.  Changed to 'pointertype'.

The computations addition/subtraction/greater-than were performed
multiple times.  Seemed a convoulted method when a single operation
should be good enough.

The use of a single-linked-list with HEAD and TAIL does not make sense.
My gut is telling me that for the purpose of memory allocation a LIFO is
better as a free-and-reuse of the most recently freed item is more likely
to already be in the CPU cache and the oldest freed item is more likely
to have been evicted from CPU cache.  So given the use of a custom
allocator and no support to reclaim/compact or manage fragmentation
other factor didn't carry any weight.
Technically TiAlloc() returns undefined memory and the first action of
the caller is to write new values, but the point remains that write is
more likely to cause eviction of something else from cache with the
original FIFO scheme.
Due to the free list use during TiFree() there is a write to each alloc
which will make the cache-line hotter in the cache (less likely to have
been evicted) when using LIFO scheme than FIFO scheme.

Further more the use of HEAD and TAIL had a far more complex
TileStoreFree() than was necessary even for such a list.  A 4 line
method turned into 7 with multiple conditions tested when branching.
The TileStoreFreeList/TileStoreFreeList_end were public symbols which may
also impact the freedom the compiler has to optimise around them.

Using LIFO single-linked-list resulted in the removal of
TileStoreFreeList_end and associated simplification.

Use of 'static' for the methods mmapTileStore() and getTimeFromTileStore()
these are not public API so adding the 'static' give the compiler a hint
these methods maybe inlined as they are not accessile from outside this
compliation unit.

The -O3 assembly result looks quite healthy in achieving the original
goal of instruction and branch reductions with the compiler able to
inline all 3 methods into a single TiAlloc().
2025-04-09 15:07:28 -04:00
Darryl L. Miles 1c3a059031 tiles: TileStoreFreeList_end removal 2025-04-09 15:07:28 -04:00
Darryl L. Miles e1238633ac tiles: simplify TileStoreFree() and TileStoreFreeList_end management 2025-04-09 15:07:28 -04:00
Darryl L. Miles b9dd4bfb7c tiles: reorder TileStoreFree() 2025-04-09 15:07:27 -04:00
Darryl L. Miles 52fced3544 K&R: tile/*.c bulk function implementation conversion
K&R obsolete syntax removal for C23 compatibility series
2025-04-09 15:07:27 -04:00
Darryl L. Miles 69df88520c bplane: constify BPEnumInit() 2025-04-09 15:07:27 -04:00
Darryl L. Miles 650d800b12 tiles: use 'const' with 'rcsid' 2025-04-09 15:07:27 -04:00
Darryl L. Miles 686adc13b3 tiles: unclear why TileStoreFreeList is an exported global
Looks private internal implementation detail that may benefit from
compiler single compile unit optimisations.
2025-04-09 15:07:27 -04:00
Darryl L. Miles 0f19a20c8c tiles: pointer arithmetic with 'unsigned long' is too narrow for _WIN64
is mmap() is available the type 'size_t' is better suited
2025-04-09 15:07:27 -04:00
Darryl L. Miles 34dfd3686b tiles: treat ti_client as pointer and use macros 2025-04-09 15:07:27 -04:00
Darryl L. Miles cc6e7ebe84 tiles: constify data and API call arguments as appropriate 2025-04-09 15:07:27 -04:00
Darryl L. Miles d082c67b03 K&R tile.h: conversion to ANSI
K&R obsolete syntax removal for C23 compatibility series
2025-04-09 15:07:27 -04:00
Darryl L. Miles e8ad7c9ac8 tiles: remove non-existent function prototype TiSrArea() 2025-04-09 15:07:27 -04:00
Darryl L. Miles 1a84eab4ce Plane[GS]etHint() added to encapsulate access to Plane->pl_hint
This is ground work to intercept usage and validate changes in
this area.

Fixed conflicts with earler patch in extract/ExtNghbors.c
2025-04-09 15:02:59 -04:00
Darryl L. Miles f942ae6e78 TiGetClient() excessive use hotspots
This is reducing nearby calls to TiGetClient() API when the value
can be looked up one time and stored in a local variable to make
other decisions about.

This is due to TiGetClient() potentially having a slightly higher
cost to call than previously, this is a kind of peephole
optimization approach (if I can see multiple getters used within
the window it got optmized).

'ticlient' was used for retrieval as ClientData so that future
greps across the codebase for `ti_client` should only match naked
access.
2025-04-09 14:55:58 -04:00
Darryl L. Miles 606f37cc80 Ti[GS]etClient() usage enforcement
All naked access to `ti_client` now uses the function-like-macro
to encapsulate this action.  This macro existed before this just
makes all sites utilize it.

Added additional INT and PTR variants to remove the programmer
load on thinking about casing and casts polluting the point
of use.  So the use now looks cleaner.

Equivalent prototypes:

 void TiSetClient(Tile*, ClientData)
 void TiSetClientINT(Tile*, intptr_t) /* pointertype */
 void TiSetClientPTR(Tile*, void*)

 ClientData TiGetClient(Tile*)
 intptr_t TiGetClientINT(Tile*) /* pointertype */
 void *TiGetClientPTR(Tile*)
2025-04-09 14:55:58 -04:00
R. Timothy Edwards 6e83cbe2d3 Added handling of coordinates in a FOREIGN statement in a LEF
macro.  Based on observation of cells in PDKs where ORIGIN and/or
FOREIGN are non-zero, added code that forces a correction of LEF
macro coordinates to match the GDS coordinates, with an
equivalent negative shift of the LEF macro ORIGIN to compensate.
Normally, both ORIGIN and FOREIGN will be zero and the added code
will do nothing.  Note that this code does not handle the
additional optional orientation.  A LEF macro with a different
coordinate system than its GDS is already weird;  a LEF macro
with a different rotation than its GDS is hopefully something
that nobody ever does in practice.  If needed, I'll cross that
bridge when I come to it.
2025-03-29 15:46:23 -04:00
R. Timothy Edwards 6b9efefc02 Added a new "orthogonal" operator to cifoutput to allow non-
manhattan shapes (especially minimum-sized ones) to be eliminated,
as these can survive a shrink-grow operation intended to get rid
of such shapes.  This implementation may not be in its final form
but should suffice for now.
2025-03-28 10:11:17 -04:00
R. Timothy Edwards dde7144966 Modified the behavior of SelectCopy() so that it surveys cell
instance names in both the selection and in the root edit CellDef,
and then wipes duplicate names from the selection and regenerates
unique IDs.  This avoids the unexpected behavior displayed by
magic in which a "copy" function renames the *original* instance
and gives the original name to the copied instance.  This is not
only unexpected, but causes an error in which "undo" after
multiple copies fails to remove earlier copies because the name
change was not recorded, and the instance can no longer be found
by name.
2025-03-26 14:45:46 -04:00
Darryl L. Miles 705b4da105 TxParseString() refactor to 1-arg public form
Only the txCommands.c file needs the 3-arg form locally
2025-02-23 10:24:40 -05:00
Darryl L. Miles 9aef87c355 database: TxDialog() constification ripple 2025-02-23 10:24:40 -05:00
Darryl L. Miles aa35a612b0 tclmagic.c: match new textio prototypes for constified implementations 2025-02-23 10:24:40 -05:00
Darryl L. Miles 6ed8f17136 textio: create callback typedef cb_textio_input_t 2025-02-23 10:24:40 -05:00
Darryl L. Miles c8ca1d242e txOutput.c: FILR -> FILE (typo fix)
Long standing typo, I guess no configuration compiles this code.
2025-02-23 10:24:40 -05:00
Darryl L. Miles 1166a56cff textio: getenv() comes from <stdlib.h> remove declaration 2025-02-23 10:24:40 -05:00
Darryl L. Miles 934fe32436 textio: constify various internal
This maybe a little gratuitous (as I'm not convinced all changed lines
are being compiled)
2025-02-23 10:24:40 -05:00
Darryl L. Miles c92ded99df textio: constify various data 2025-02-23 10:24:40 -05:00
Darryl L. Miles 7e1692800b textio: contify various APIs 2025-02-23 10:24:40 -05:00
Darryl L. Miles 906e02c898 K&R textio/*.c: bulk forward reference function prototype conversion
K&R obsolete syntax removal for C23 compatibility series
2025-02-23 10:24:40 -05:00
Darryl L. Miles 8cce1bdb7e K&R textio: conversion to ANSI
K&R obsolete syntax removal for C23 compatibility series
2025-02-23 10:24:40 -05:00
Darryl L. Miles 6c6e48a9a3 textioInt.h: add assumed prototype for Tcl_printf() 2025-02-23 10:24:40 -05:00
Darryl L. Miles f63dc318a7 textio: removed prototypes for non-existant functions
extern void TxVisChar();
extern void TxPromptOnNewLine();
extern TxCommand *TxDeviceStdin();
extern TxCommand *TxButtonMaskToCommand();

Found during K&R removal of textio/**
2025-02-23 10:24:40 -05:00
Darryl L. Miles 12c6ccc97b ResReadSim.c remove existing fclose() as conflict with recent change
After futher review of this function it looks like the existing
fclose() is not in the correct place, and recent patches have
added fclose() to this function in better places (covering all
returns) but did not take into account the existing misplaced
fclose().
2025-02-23 10:23:51 -05:00
Darryl L. Miles dd84be9172 CmdCD.c: fix missing 'else' from my recent commit e88dcba1c 2025-02-23 10:23:51 -05:00
Darryl L. Miles 78f2c0696c wiring: forward declaration prototypes and consistency 2025-02-23 10:21:41 -05:00
Darryl L. Miles 154c3efa5c wiring: use 'const' with 'rcsid' 2025-02-23 10:21:41 -05:00
Darryl L. Miles 922abe6b8d wiring: constify API call arguments where possible
mark cb_database_buttonhandler_t
2025-02-23 10:21:41 -05:00
Darryl L. Miles 81d526562c dbwind: DBWAddButtonHandler() cb_database_buttonhandler_t
constify API call arguments as appropiate
2025-02-23 10:21:41 -05:00
Darryl L. Miles 4f54bcf4f4 K&R wiring/*.c: bulk function implementation conversion
K&R obsolete syntax removal for C23 compatibility series
2025-02-23 10:21:41 -05:00
Darryl L. Miles 5058152c8f K&R wiring.h wireInt.h: conversion to ANSI
K&R obsolete syntax removal for C23 compatibility series
2025-02-23 10:21:41 -05:00
Darryl L. Miles 92c4fc35db ResMain.c: use-after-free: simple reorder of statements 2025-02-23 10:20:41 -05:00
Tim Edwards 48708c52a4 Removed two unused statements from EFantenna.c, per the discussion
in github pull request #377.
2025-02-23 10:15:48 -05:00
Darryl L. Miles 983f4cb76f lef: constify remaining .data into .rodata 2025-02-22 21:48:17 -05:00
Darryl L. Miles ac37927186 lef: constify static data and LefNextToken() return
LefHelper_DBTechNameType_LefLower() identified and introduced during
conversion to const data usage.

Only side-effect is some log messages will use original verbatim token
now instead of lowercase version (but this seems ok when file parsing,
to quote the problematic information source verbatim)
2025-02-22 21:48:17 -05:00
Darryl L. Miles 451dab4b9b lef: constify strings in data structures of lef module 2025-02-22 21:48:17 -05:00
Darryl L. Miles ed87c3a98b lef: cleanup mark unnecessary call to function with no side-effects
Maybe these function call can be removed or at least their return
value discarded (as the returned value is never used).
2025-02-22 21:48:17 -05:00
Darryl L. Miles 56bf27548d lef: cleanup remove unused local/static variables
Many appear to be the result of copy-and-paste from a similar func
nearby.
2025-02-22 21:48:17 -05:00
Darryl L. Miles 9d0cd63a4e lef: use 'const' with 'rcsid' 2025-02-22 21:48:17 -05:00
Darryl L. Miles ad6ecb5bbb lef/*.h: constify string function arguments 2025-02-22 21:48:17 -05:00
Darryl L. Miles 695692b620 K&R lef/*.c: bulk forward reference function prototype conversion
K&R obsolete syntax removal for C23 compatibility series
2025-02-22 21:48:17 -05:00
Darryl L. Miles 05a5b169bc defWrite.c: defHNsprintfPrefix() constify implementation 2025-02-22 21:48:17 -05:00
Darryl L. Miles 4930e0307a tcllef.c: missing include textio/textio.h (due to TxPrint usage) 2025-02-22 21:48:17 -05:00
Darryl L. Miles 19e03fc4f8 K&R lef/*.c: bulk function implementation conversion
Some function parameters (char *sname) have been made const due
referencing const data sources.

K&R obsolete syntax removal for C23 compatibility series
2025-02-22 21:48:17 -05:00
Darryl L. Miles a1f7e4ed5e lef: post K&R constify ripple
These functions are using data that is already const.
2025-02-22 21:48:17 -05:00
Darryl L. Miles f7c550e82f defRead.c: DefRead() incorrect arg0 to LefParseEndStatement() 2025-02-22 21:48:17 -05:00
Darryl L. Miles 25ec9fccef K&R lef.h lefInt.h: conversion to ANSI
K&R obsolete syntax removal for C23 compatibility series
2025-02-22 21:48:17 -05:00
Darryl L. Miles acf0e474e8 K&R lefInt.h: missing prototype removal
Function does not appear to exist:
 extern char *LefGetInput();

K&R obsolete syntax removal for C23 compatibility series
2025-02-22 21:48:17 -05:00
Darryl L. Miles a764fdbbd1 CodeQL MemoryMayNotBeFreed.ql grTCairo1.c GrTCairoPlotSVG()
created use of 'alloc' local variable to track when an allocation occurred
so exit path logic is more straight forward for compiler/analyser to see
potential optimisations.

the previous version was probably working just fine
2025-02-22 21:35:23 -05:00
Darryl L. Miles e565b4c360 CodeQL MemoryMayNotBeFreed.ql NMnetlist.c NMWriteNetlist()
created use of 'alloc' local variable to track when an allocation occurred
so exit path logic is more straight forward for compiler/analyser to see
potential optimisations.

no attempt to free memory was made previously
2025-02-22 21:35:23 -05:00
Darryl L. Miles 37fa75dd77 CodeQL MemoryMayNotBeFreed.ql ResRex.c ResCheckSimNodes()
created use of 'alloc' local variable to track when an allocation occurred
so exit path logic is more straight forward for compiler/analyser to see
potential optimisations.
2025-02-22 21:35:23 -05:00
Darryl L. Miles c33b6be2bb CodeQL MemoryMayNotBeFreed.ql rtrChannel.c RtrChannelRoute()
Unclear with all the flip operations if there is some kind of attachment
(exchange of channels), the other 2 channels created in the function
are also cleaned up.
2025-02-22 21:35:23 -05:00
Darryl L. Miles b5d068b0ea CodeQL MemoryMayNotBeFreed.ql rtrCmd.c CmdRoute() 2025-02-22 21:35:23 -05:00
Darryl L. Miles cb9333804a CodeQL MemoryMayNotBeFreed.ql rtrCmd.c CmdRoute()
temporary channel created to run command is not cleaned up
2025-02-22 21:35:23 -05:00
Darryl L. Miles 822a95ab35 CodeQL MemoryMayNotBeFreed.ql antennacheckVisit()
Looks like straight forward exit path doesn't cleanup locally malloc
block.
2025-02-22 21:35:23 -05:00
Darryl L. Miles 7508a9e6b7 CodeQL MemoryMayNotBeFreed.ql calma/**
Looks straight forward lost pointer to recently malloced block
2025-02-22 21:35:23 -05:00
Darryl L. Miles 99c448407c CodeQL LargeParameter.ql: large objects returned (around fd_set usage)
now using pointers (fd_set*)
constify API where possible
2025-02-22 21:31:22 -05:00
Darryl L. Miles 6a537c4659 CodeQL IncorrectNotOperatorUsage.ql rtrDcmppose.c rtrCLEAR() usages
Maybe it was a single bit and '!' operator inverted a single bit, but it
 appears to be a 4-bit mask today.

TODO check rtrMARKED() this looks like it uses '&' operator is in use
 but from the context of a bitmask maybe this should be '|' operator.
2025-02-22 21:31:22 -05:00
Darryl L. Miles ca9229b35a CodeQL MissingNegativtyTest.ql ttype>=0 ResSimSubckt()
This variable is used as array index, but the extGetDevType() API allows
a negative return to occur.
2025-02-22 21:31:22 -05:00
Darryl L. Miles ad1d9923f9 CodeQL MissingNegativtyTest.ql magictype>=0 defWrite.c
defnodeVisit()
defblockageVisit()

This variable is used as array index, but the DBTechNameType() API allows
a negative return to occur.
2025-02-22 21:31:22 -05:00
Darryl L. Miles 38b25c5d34 CodeQL InconsistentNullnessTest.ql ourgl != NULL
ourgl local variable is set to a non-NULL value (first initialization)
in code that is in lines below where it is dereferenced in a loop.
Somewhere in the loop there is a point where the precondition of ourgl
being set to non-null is expected.
ASSERT added.
2025-02-22 21:31:22 -05:00
Darryl L. Miles d18b40d401 CodeQL LateNegativeTest.ql defRead.c routerLayer>=0
Code nearby tests 'routeLayer' for negativeness, but it is set and then
used as array index without such a test.
ASSERT added.
2025-02-22 21:31:21 -05:00
Tim Edwards 8ebad7d1a9 Implemented the fix to an expression that should have been logical-
AND and not bitwise-AND, as pointed out in PR #376 by Darryl Miles.
2025-02-22 21:15:45 -05:00
Darryl L. Miles a60259ab63 CodeQL FileMayNotBeClosed.ql PaCheckCompressed() apparently leaks an 'fd'
CodeQL complains of a _potential_ leak (I can't see it), seems false
positive but also a clear case to use POSIX access(R_OK) instead.
2025-02-22 21:02:49 -05:00
Darryl L. Miles e88dcba1c5 CodeQL File{MayNot,Never}BeClosed.ql file-handle resource leaks
Guided by CodeQL static code analyser.

FileMayNotBeClosed.ql
FileMayNeverBeClosed.ql

The trick with "if(fp != stdout)" is problematic (to analyser) as
technically 'stdout' can be a global pointer that COULD be modified any
time, so it might have changed between the fopen() and fclose() calls so
the close MAY NEVER occurs (which is problem the analyzer can see).

So local state is maintained as a bool which will also clarify to the
compiler see the intention without concern for external stdout
modification.

Some items appear to be out and out leaks when certain commands are use.
2025-02-22 21:02:49 -05:00
Tim Edwards 7960020f7c Updated the HTML documentation on the "wire" command to add the
new syntax implemented earlier today that preserves interactive
wiring moves when logging commands.
2025-02-22 21:00:04 -05:00
Darryl L. Miles 554327f1d3 plowSrShadowXxx() callback plowShowShadow() correct return type
was void, now int.
2025-02-22 20:58:59 -05:00
Darryl L. Miles 97ff043c1a plowInitRule() pass by-pointer const TileTypeBitMask* instead of by-value
sizeof(TileTypeBitMask) == 32
2025-02-22 20:58:59 -05:00
Darryl L. Miles 93054eb4e6 plowPropagateRect() pass by-pointer const TileTypeBitMask* instead of by-value
sizeof(TileTypeBitMask) == 32
2025-02-22 20:58:59 -05:00
Darryl L. Miles 8ee328811c plowSrShadowInitial() pass by-pointer const TileTypeBitMask* instead of by-value
sizeof(TileTypeBitMask) == 32
2025-02-22 20:58:59 -05:00
Darryl L. Miles 86bb97948f plowSrShadowBack() pass by-pointer const TileTypeBitMask* instead of by-value
sizeof(TileTypeBitMask) == 32
2025-02-22 20:58:59 -05:00
Darryl L. Miles cfd71f1b5d plowSrShadow() pass by-pointer const TileTypeBitMask* instead of by-value
sizeof(TileTypeBitMask) == 32
2025-02-22 20:58:59 -05:00
Darryl L. Miles d149c83a8a plowSrOutline() pass by-pointer const TileTypeBitMask* instead of by-value
sizeof(TileTypeBitMask) == 32
2025-02-22 20:58:59 -05:00
Darryl L. Miles cf0f9311ab plowFindWidthBack() pass by-pointer const TileTypeBitMask* instead of by-value
sizeof(TileTypeBitMask) == 32
2025-02-22 20:58:59 -05:00
Darryl L. Miles 2ff6d6113d plowFindWidth() pass by-pointer const TileTypeBitMask* instead of by-value
sizeof(TileTypeBitMask) == 32
2025-02-22 20:58:59 -05:00
Darryl L. Miles bc5a4a0fb1 Plow() pass by-pointer const TileTypeBitMask* instead of by-value
sizeof(TileTypeBitMask) == 32
2025-02-22 20:58:59 -05:00
Darryl L. Miles 6db34b6aa9 gaMazeRoute() pass by-pointer const TileTypeBitMask* instead of by-value
sizeof(TileTypeBitMask) == 32
2025-02-22 20:58:59 -05:00
Darryl L. Miles 97189f6219 irRoute.c: LayerInTouchingContact() pass by-pointer const TileTypeBitMask* instead of by-value
sizeof(TileTypeBitMask) == 32
2025-02-22 20:58:59 -05:00
Darryl L. Miles 90c03738ce ExtPerim.c: extEnumTilePerim() pass by-pointer const TileTypeBitMask* instead of by-value
sizeof(TileTypeBitMask) == 32
2025-02-22 20:58:59 -05:00
Darryl L. Miles e8d7888300 extract.h/EFVisit.h include database.h for TileTypeBitMask
This has a knock on effect of causing EFvisit.c to require database.h
to be defined BEFORE the EFint.h due to an identical copy of ArrayInfo
type being present in both files.

Maybe there should be database_arrayinfo.h ?  To remove the copy.
2025-02-22 20:58:59 -05:00
Tim Edwards 144c22f579 Added the ability to translate pointer-based "wire" commands from
interactive wiring into coordinate-based commands.  Added new
command extensions for "wire leg", "wire vertical", "wire type",
and "wire horizontal".  Modified the command logging such that
"wire show" (which does not modify layout) does not get logged,
which avoids unnecessary logging of mouse movement.
2025-02-22 17:06:06 -05:00
Tim Edwards c4a2a54cb7 Corrected a syntax error in the old (non-Tcl/Tk) grX11su1.c code
that was introduced with a slew of updates back in October, as
noticed and reported (with solution) by J. Schonberg.
2025-02-15 22:20:50 -05:00
Tim Edwards 09ff52cdc0 One additional fix which allows "gds write" to continue after a
cell is found to be missing, if "gds allow undefined" has been
set.
2025-02-15 13:49:14 -05:00
Tim Edwards 41d77558b7 Fixed an error in which using the command option "gds allow undefined"
will cause a segmentation fault.
2025-02-15 13:43:01 -05:00
Tim Edwards df84a36659 Added code to handle the case where GDS_FILE points to a filename
that has since been compressed and given a ".gz" extension.
Removed code that uses a system call to "gunzip" and "gzip" when
the target file is compressed, since the compression is handled
in the code.
2025-02-12 16:28:43 -05:00
Tim Edwards 38b3d53b5f Modified the behavior of "select area subcell" so that it no longer
requires that subcells be unexpanded in order to select them.  This
seems to be more in line with what one would expect from the
documented description of the "select area" command, and more in
line with common-sense expectations.
2025-02-09 14:51:40 -05:00
Tim Edwards cd80d38d52 Fixed a rather long-standing error, which is that when scaling of
"MASK_HINTS" was implemented, it was put into a routine that
scales all coordinate-related properties, including "FIXED_BBOX",
but the original code that scaled only "FIXED_BBOX" was never
removed, resulting in the bounding box getting incorrectly scaled
twice by any grid scaling.
2025-02-09 12:48:22 -05:00
Tim Edwards 619191c6dd Corrected a crash condition caused by yesterday's commit, if the
new CIF operator is used in a tech file.  Reworked yesterday's
commit to add more related operators, so there are now four new
ones (also renamed them):  interacting, noninteracting, overlapping,
and nonoverlapping.  "interacting" now means overlapping or touching;
so the four cases allow all variations of adjacency between the two
material types.
2025-02-05 14:49:32 -05:00
Tim Edwards a5653c8fca Added a new CIF operator "not-interact" which is complementary to
"interact", because it was trivially easy to implement and saves
processing vs. doing the same thing with two templayers and an
"and-not" operator.
2025-02-04 20:43:30 -05:00
Tim Edwards 21b810b375 Added a new CIF operator "interact" which enumerates disjoint
regions of a given type and retains only those regions which
interact with (overlap) another given type.  Both sets of types
can be either magic database types or CIF temp layers.  This will
allow the implementation of rules that were not previously
possible.
2025-02-04 17:21:26 -05:00
Tim Edwards 72368a3d13 Added a fallback method for "extresist" whenever a device terminal
connection to a net that has been decomposed into a resistor array
cannot be found.  This indicates some fundamental error in the way
extresist works.  However, it should not be producing an invalid
and unsimulatable netlist.  Instead, it makes an arbitrary connection
from the device terminal to the resistor array and adds an entry in
the output netlist (.res.ext file).  This results in a poor
representation of the resistor network to that terminal, but an
otherwise simulatable netlist.  A warning is issued to note that an
arbitrary connection has been made.  This is most typically a
"garbage in, garbage out" situation in which insufficient information
exists in a layout to inform magic on which direction current is
traveling through a net.  However, it should be possible to rewrite
the extresist code so that magic makes somewhat informed decisions
about current paths and produces a halfway decent representation of
the actual net, instead of just giving up on the detailed extraction.
2025-01-15 10:38:10 -05:00
Tim Edwards 4445663cb1 Modified a routine to return a valid string when attempting to
generate a name for an instance that is set to NULL.  It is not
clear to me by an instance would have a NULL name, but apparently
it can happen, and should not crash magic.
2025-01-12 17:36:05 -05:00
Tim Edwards 1cec414618 Added the contents of the "readline" module back. This is
generally unused, as it is incompatible with the Tcl/Tk build of
magic.  However, I had not intended to remove it, only move the
name from "readline-4.3" to "readline".  But "readline/readline"
was in .gitignore, which caused the contents to be removed from
the repository.  This commit restores those files, and also
prevents the readline directory Makefile from making a symbolic
link called "readline" to itself, which was causing compile-time
issues.  The readline code is only kept for backwards compatibility
with ancient versions of magic not using the Tcl/Tk interpreter.
2025-01-10 09:58:57 -05:00
Tim Edwards 82a1dc98b4 Updated the version to go along with the merge of pul request 2025-01-10 09:21:28 -05:00
Mamoru TASAKA cb2a79d6b1 gcc: support -Werror=format-security
Support gcc -Werror=format-security which is used by default on Fedora.

ext2spice/ext2spice.c: format not a string literal and no format arguments
extflat/EFargs.c: likewise
windows/windCmdNR.c: likewise
2025-01-10 14:19:52 +09:00
Tim Edwards 2afa222414 Updated the version number to go along with the merge of several
pull requests from Darryl Miles.
2025-01-07 14:02:58 -05:00
Darryl L. Miles f010d4d20b resis.h: create RESTRUE to replace use of TRUE macro ((bool)1)
Looks to be used as integer bitmask which is flagged by compiler warning
as dubious, when using compiler provided type 'bool' from stdbool.h
in C99 instead of unsigned char type.

C29 bool type compatibility
2025-01-07 14:02:07 -05:00
Darryl L. Miles 4887f71ca3 CIFread.h: fix struct cifrstyle.crs_layers type bool -> enum (unsigned char)
The type is actually an enum (assumed to be int by default) but relies
on the magic typedef to (unsigned char) so we make this explicit and
better document what the real type is.

I guess in the past it was really a bool with only 2 states NONE|TEXT.

C29 bool type compatibility
2025-01-07 14:02:07 -05:00
Darryl L. Miles b1a9e10be7 feat: quit [exit_status], option support
Affecting process exit status.
2025-01-07 13:58:45 -05:00
Darryl L. Miles faadb774b4 docs: quit -noprompt
Was looking to implement this feature and found it was already
implemented but is a secret feature.

Updated documentation and modified implementation so it is possible
a user can discover the feature via usage such as "quit -help -invalid"
like other commands.
2025-01-07 13:58:45 -05:00
Darryl L. Miles b694827bcb feat: flush [-noprompt], option support 2025-01-07 13:58:45 -05:00
Darryl L. Miles cfdd50aa63 Revert "commands/CmdFI.c: added CmdFlush_NoConfirm option to disable flush prompt"
This reverts commit 772bfe2f71.

See #341
2025-01-07 13:58:45 -05:00
Darryl L. Miles 3fc1c7e452 gcc11 -Wall -Wpedantic document for the next person 2025-01-06 16:33:22 +00:00
Darryl L. Miles 065f31f689 gcc11 -Wall -Wpedantic cleanup (post __attribute__ DLONG_PREFIX) 2025-01-06 16:27:10 +00:00
Darryl L. Miles 6afadf9809 gcc11 -Wall -Wpedantic cleanup (post __attribute__) 2025-01-06 16:25:38 +00:00
Darryl L. Miles 48c99a7b1d gcc11 -Wall -Wpedantic cleanup (post TCL9) FUN2CD() CD2FUN()
FUN2CD() on a function pointer still raises -Wpedantic warning due to the
officially undefined behaviour as defined by C standards.

So added FUN2CD() and CD2FUN() to at least mark the call-sites to help
with identification and ignoring -Wpedantic based on the source file
context given in the compiler output.
2025-01-06 16:25:15 +00:00
Darryl L. Miles c21e182b2c gcc11 -Wall -Wpedantic cleanup (post TCL9) 2025-01-06 16:24:57 +00:00
Darryl L. Miles aa5ddbaa58 database/database.h.in: const PaintResultType *resultTbl
Probably forgot to edit database.h.in template file (and edited
database.h) when working locally.
2025-01-06 16:24:02 +00:00
Darryl L. Miles 7e9d4cc15e ihash.c: cleanup warning use of void* with pointer arithmetic
Use of (void*) with pointer arithmetic warning removal.

But more so as it is in a macro (all be it local to file) which will
take on the form of the type passed as argument when the 'offset' looks
to be always be specified in bytes.
2025-01-06 16:21:22 +00:00
Darryl L. Miles 60c64db33a extflat: K&R various converted to ANSI (mainly due to bool use) 2025-01-06 16:18:41 +00:00
Darryl L. Miles ff9487de1f hash.c: K&R conversion to ANSI and constify arguments / callback
cb_heap_kill_t callback typedef created

Invoked from HeapKill()

No active callback implementation in the codebase.

callback interface (from hash.h):
  marked @invoke call-site
2025-01-06 16:15:58 +00:00
Darryl L. Miles d9cfd64d60 utils/*.c: K&R conversion to ANSI 2025-01-06 16:14:34 +00:00
Darryl L. Miles 07f9bbe1fb gcc11 -Wall -Wpedantic cleanup 2025-01-06 16:12:11 +00:00
Tim Edwards 3df2aaaa16 Modified the code in ext2spice.c that prints parameter values;
the former code attempted to determine the precision and generate
an output without unnecessary trailing zeros.  Unfortunately there
were counterexamples that fail to be formatted correctly, as found
by Mark Martin, and which generate output that has roundoff error.
Reimplemented the method using code found on StackOverflow, which
appears to solve the problem more robustly.
2025-01-06 11:49:29 -05:00
Tim Edwards 32138ccbc7 Modified some lines in tkcon.tcl that make it compatible with both
Tcl 8.6 and Tcl 9.0, fixing some features that got broken with an
attempt to update the script for version 9.0.
2025-01-04 14:09:58 -05:00
Tim Edwards e334fb919f Updating the revision number to go along with the merging of a
series of pull requests from Darryl Miles.
2025-01-04 11:45:11 -05:00
Darryl L. Miles af5b7f10cf lef/defWrite.c: reworked kareefardi_fix-def-write 2025-01-04 11:42:07 -05:00
Kareem Farid a6aac9c309 fix infinite def write
Signed-off-by: Kareem Farid <kareefardi@users.noreply.github.com>
2025-01-04 11:42:07 -05:00
Darryl L. Miles efcf36f348 Remove superfluous parenthesis around regular type declarations 2025-01-04 11:31:17 -05:00
Darryl L. Miles 1241e95dab debug/debug.c: constify and add prototype 2025-01-04 11:31:17 -05:00
Darryl L. Miles 195dda1e06 debug/hist.c: constify and add prototype 2025-01-04 11:31:17 -05:00
Darryl L. Miles eb89ab181c debug: use 'const' with 'rcsid' 2025-01-04 11:31:17 -05: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 6b4d409d74 cmwind: 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 34038ee687 cmwind: use 'const' with 'rcsid' 2025-01-04 11:31:17 -05:00
Darryl L. Miles ac56dd71a9 cif: use 'const' with readonly data (also consumer DBpaint)
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 4e768d5a3d CIFrdpoly.c: qsort 'compar' function argument prototype fix
This makes it strictly conform to function pointer prototype.
2025-01-04 11:31:17 -05:00
Darryl L. Miles b6775f902b cif: use 'const' with 'rcsid' 2025-01-04 11:31:17 -05:00
Darryl L. Miles a616dbc113 calma: use 'const' with 'rcsid' 2025-01-04 11:31:17 -05:00
Darryl L. Miles 4cd1235575 calma: 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 378755e083 CalmaRdpt.c: simplfy use of sprintf()
This replacement pattern is easier to reason about and less error prone.
2025-01-04 11:31:17 -05:00
Darryl L. Miles 46eb71491c GHA: MacOS maintenance update
GHA obsoleted macos-12 so we move to macos-13 for Intel.  Building with oldest
Intel image to provide feedback of continued expected support on that platform,
while ARM64 builds with latest to check the other end of their SDKs.

Lock the TCL version via brew to 8.6+ (currently the project is not expected to
build on TCL9 until other work is completed) so this is causing build failure.

Added additional diagnostics to show the location of executables/DSOs if they
got built from the tree.

Introduced GHA timeout clamping (MacOS default shell seems not to behave under
CI as well as Linux does, re signal/pipe handling)

'brew install tcl-tk@8' appears to append the @8 to the installed path such as
/usr/local/opt/tcl-tk@8 which configure needs to know.  configure_mac updated
to detect this now TCL9 is the default version that maybe installed at the old
location.  Then there is the issue of both TCL versions being installed
side-by-side on the same system causing more issues over selection.
2025-01-04 11:23:39 -05:00
Darryl L. Miles 3f85689985 cif/CIFgen.c: fix incorrect type bool -> int
There are 3 states for CLOSE_xxxxxx with 3 different values.

Issue introduced from 2f7f76bf9 merged since tag:8.3.509

This affected the scenarios using non-zero non-one values such as:
  #define CLOSE_DONE   2

This looks the result of an original bug where the forward declaration
 had a type mismatch with the real method, so the method implementation
 prototype was taken as the correct one.  The forward decl was rewritten
 with the correct prototype signature.
Maybe this is the cause of CIF data once drawn into view does not always
 seem to always erase after disabling and a redraw ?
2025-01-04 11:20:08 -05:00
Darryl L. Miles 76a515ca25 HACK tkcon.tcl to get it running 2025-01-04 11:08:01 -05:00
Darryl L. Miles c2a5a84a03 Revert "TCL9: *.tcl changes $::tcl_platform"
This reverts commit 8adbd75760aeeb4f39507dcd3e746287381b7b38.
2025-01-04 11:08:01 -05:00
Darryl L. Miles 7e5d0b0688 TCL9: FIXME OPTIONAL magic.h ClientData
This did not work as expected.  Maybe that indicate this should have
a slighlt restructure so the tcl.h definition is always given a chance
to provide type.

Or maybe autoconf should detect the type and provide in config.h ?
2025-01-04 11:08:01 -05:00
Darryl L. Miles 3931c4aff1 TCL9: *.tcl changes $::tcl_platform 2025-01-04 11:08:01 -05:00
Darryl L. Miles 272dda3c84 TCL9: TxResetTerminal(bool force) added arguments
This seems like it has 2 use cases.

Internal console management around reprinting command prompt, but many
 modes of operation delegate the prompt processing to tkcon or readline.
Process termination to restore the termios.
2025-01-04 11:08:01 -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 4a32a82841 TCL9: Tcl_GetIntFromObj() call checked
This API uses address of operator to Tcl API with (int) type, but
does not use Tcl_Size in TCL9, it remained an (int) type.
2025-01-04 11:08:01 -05:00
Darryl L. Miles 661b66a143 TCL9: Tcl_InitStubs(version="9.0") 2025-01-04 11:08:01 -05:00
Darryl L. Miles 77a7afc8e2 TCL9: Tcl_SetExitProc() API was removed
The Tcl_Exit() replacement proc takes charge of calling exit()

So this function can be easily migrated to libc atexit() which will
now run during exit() not just before.  Which seems ok for the purpose
of restoring the termios state of the tty.

This solution seems compatible with TCL8 as well so all calls to this
removed API are removed.

Note this patch also removes the invalidation (of the callback so
the deefault use of Tcl_Exit() is restored) before returning from
this function.  atexit() usage can not be invalidated after
registration but that can be controlled with application flag
checked inside the callback function if needed.
I have observed scenarios where I need to issue 'reset' manually
after exiting magic, still understanding better the build types
and scenarios that triggers this.
2025-01-04 11:08:01 -05:00
Darryl L. Miles 0ce8265570 TCL9: ClientData macro assignment and access usage 2025-01-04 11:08:01 -05:00
Darryl L. Miles 79f2ab0f4b TCL9: ClientData macro header file changes
Header files documentation indicates the macros are of type ClientData
but previously did not cast to ensure that. So now follow this intention.
2025-01-04 11:08:01 -05:00
Darryl L. Miles 17fe81107a TCL9: plugin createProc() function signature change ImgLayerCreate()
Tk_ImageType.createProc() uses new Tcl_Size type now.
2025-01-04 11:08:01 -05:00
Darryl L. Miles db7a1fe20a TCL9: Tk_ConfigureWidget() function signature change 2025-01-04 11:08:01 -05:00
Darryl L. Miles e81ead5ad2 TCL9: Tcl_Size type introduction 2025-01-04 11:08:01 -05:00
Darryl L. Miles 33b9c63c41 TCL9: Tcl_xxxxxxx() API changes around Tcl_SaveResult() 2025-01-04 11:08:01 -05:00
Darryl L. Miles e27b8a9d19 TCL9: CONST84 removal (all current compilers support const keyword)
Legacy compiler support macro provided by TCL from a time when 'const'
did not exist.

This looks like it was put in place around the time of TCL 8.4
(from 2002 until 2013) which introduced APIs with 'const' types,
that were previously non-const.  Probably due to legacy compiler
support across target platforms at the time.

Since the minimum TCL level is hardwired to 8.5 (from 2007 until
2016) it does not seem like that compatiblity is a current
requirement.
2025-01-04 11:08:01 -05:00
Darryl L. Miles 2066077c4e TCL9: CONST removal (all current compilers support const keyword)
Legacy compiler support macro provided by TCL from a time when 'const'
did not exist.
2025-01-04 11:08:01 -05:00
Darryl L. Miles d999e20b73 TCL9: Tk_Offset() macro removal
Modern compiler have support for 'offsetof' keyword.
2025-01-04 11:08:01 -05:00
Darryl L. Miles 60463e31be TCL9: _ANSI_ARGS_ compatibility macro removal 2025-01-04 11:08:01 -05:00
Darryl L. Miles 93c16c8431 TCL9: magic.h ClientData type change helper macros
Now a (void *) but previously an integer.

These macros resolve the codebase allowing it to be built against both
tcl8 (8.5, 8.6) and tcl9 (9.0).

tar -zxvf tcl9.0.0-src.tar.gz
cd tcl9.0.0/unix
./configure --enable-symbols --prefix=/opt/tktcl9
make install

tar -zxvf tk9.0.0-src.tar.gz
cd tk9.0.0/unix
./configure --enable-symbols --prefix=/opt/tktcl9 --with-tcl=/opt/tktcl9/lib
make install

cd magic
./configure --with-tk=/opt/tktcl9/lib --with-tcl=/opt/tktcl9/lib
2025-01-04 11:08:01 -05:00
Darryl Miles a756fe08bd ext2spice.c: printf style constify fmt call-site 2025-01-03 09:08:14 +00:00
Darryl Miles 6520aa19a3 extflat.h: efReadError() printf ATTR_FORMAT_PRINTF_1 2025-01-03 09:08:14 +00:00
Darryl Miles 2bac418b44 EFerr.c: printf style constify fmt call-site 2025-01-03 09:08:14 +00:00
Darryl Miles 8c28342322 ext2hier.c: printf style constify fmt call-site 2025-01-03 09:08:14 +00:00
Darryl Miles 6d0dca2551 ext2sim.c: printf style constify fmt call-site 2025-01-03 09:08:14 +00:00
Darryl Miles fd5511d622 DRCtech.c: printf style constify fmt call-site 2025-01-03 09:08:14 +00:00
Darryl Miles c4373d74aa LIBtextio.c: printf style constify fmt call-site 2025-01-03 09:08:14 +00:00
Darryl Miles ff73a1328f txOutput.c: printf style constify fmt call-site 2025-01-03 09:08:14 +00:00
Darryl Miles 0259fdc990 tclmagic.c: printf style constify fmt call-site 2025-01-03 09:08:14 +00:00
Darryl L. Miles 5770da2abd geometry.c: TxError() constify call-site 2025-01-03 09:08:14 +00:00
Darryl Miles 1aee10ef4d utils/magic.h: ANALYSER_xxxxxxxxxx __attribute__ 2025-01-03 09:08:14 +00:00
Darryl Miles 2fcd024bdb utils/magic.h: ATTR_SENTINEL __attribute__ ((sentinel)) 2025-01-03 09:08:14 +00:00
Darryl L. Miles 91bb9935f9 grOGL1.c: use ATTR_UNREACHABLE to help analyser 2025-01-03 09:08:14 +00:00
Darryl L. Miles c8974ed2ec utils/main.h: MainExit() add ATTR_NORETURN hint 2025-01-03 09:08:14 +00:00
Darryl L. Miles 31d7130833 utils/magic.h: ATTR_UNREACHABLE ATTR_NORETURN
Add optional compiler support for these attribute hints.
2025-01-03 09:08:14 +00:00
Darryl L. Miles fc02f57d73 magic.h: add macro __unused__
__attribute__((unused))

use like:

void myFunc(int arg0, __unused__(arg1)) { ... }
2025-01-03 09:08:14 +00:00
Darryl Miles bf96348502 printf: vararg functions use 'const' for format string 2025-01-03 09:08:14 +00:00
Darryl Miles 94ec5cf98f printf: use compiler __attribute__((format (printf,fff,aaa))) 2025-01-03 09:08:14 +00:00
Tim Edwards f80540af46 Applied patch from Darryl Miles that prevents a segfault on an
error in "extresist".  The underlying error still exists and
causes a "Bad Device" error but no longer crashes magic.  See
github Issue #353.
2024-12-26 16:39:23 -05:00
Tim Edwards df19d62f51 Corrected code in DBtpaint2.c handling the setup of paint/erase
tables for contacts, where an error was pointed out by Darryl
Miles (github issue #339).
2024-12-26 16:28:43 -05:00
Tim Edwards 8371d797ad Revised some code from PR#352 in response to questions from Darryl
Miles.  Updated the version number to go along with the merge of
a number of pull requests done today.
2024-12-26 15:29:54 -05:00
Darryl L. Miles 55d15ffaa5 extflat/EFdef.c: hash constify freeMalloc() constness cast
This is a result of hash.[ch] constification
2024-12-26 15:20:59 -05:00
Darryl L. Miles a11352970f dbwind/DBWelement.c: constify args to AppendFlag/AppendString
non-static file local functions
2024-12-26 15:20:59 -05:00
Darryl L. Miles bbc52ecd41 util/hash.c: fix use after free (not quite)
Dereference of 'h' after calling freeMagic(h)
Found while putting in cast.

Initially this is what was thought however....

freeMagic() has this one allocation to free latency, which is a matter
to resolve another day.
2024-12-26 15:20:58 -05:00
Darryl L. Miles fadd2d98b4 irouter/irCommand.c: fix SetNoisyDI() usage
WARNING 64bit to 32bit truncation

Was directly overwriting a 32bit storage location with a 64bit value.
2024-12-26 15:20:58 -05:00
Darryl L. Miles fd5050b2b5 util/lookup*.c: fix integer pointer arithmetic not using pointertype
This would be a bug on WIN64 and other LLP64 models.
2024-12-26 15:20:58 -05:00
Darryl L. Miles f22ecda44a set.c: SetNoisyBool() constify and add prototype 2024-12-26 15:20:58 -05:00
Darryl L. Miles 2b69b07860 set.c: SetNoisyDI() constify and add prototype 2024-12-26 15:20:58 -05:00
Darryl L. Miles f51ad56aea set.c: SetNoisyInt() constify and add prototype 2024-12-26 15:20:58 -05:00
Darryl L. Miles 5b97638ac7 port.c: MagAtof() constify and add prototype 2024-12-26 15:20:58 -05:00
Darryl L. Miles 14a8409e40 utils.h: Wait()/WaitPid() add prototype 2024-12-26 15:20:58 -05:00
Darryl L. Miles bd51438c15 database/DBio.c: PaExpand() constify update call-site 2024-12-26 15:20:58 -05:00
Darryl L. Miles 265ace5c9f path.c: PaEnum() constify and add prototype 2024-12-26 15:20:58 -05:00
Darryl L. Miles 6bccbef0d4 path.c: PaSubsWD() constify and no prototype exists
This function does not appear used across the codebase.
No prototype exists in utils.h
2024-12-26 15:20:58 -05:00
Darryl L. Miles c77d3852d5 path.c: PaOpen() constify and add prototype 2024-12-26 15:20:58 -05:00
Darryl L. Miles fd7eab2193 path.c: PaZOpen() constify and add prototype 2024-12-26 15:20:58 -05:00
Darryl L. Miles d077368436 path.c: PaLockOpen() constify and add prototype 2024-12-26 15:20:58 -05:00
Darryl L. Miles 875d825afb path.c: PaLockZOpen() constify and add prototype 2024-12-26 15:20:58 -05:00
Darryl L. Miles bfb411d19f path.c: nextName() constify and add prototype 2024-12-26 15:20:58 -05:00
Darryl L. Miles feef9730f3 path.c: PaExpand() constify and add prototype 2024-12-26 15:20:58 -05:00
Darryl L. Miles 6a6f85862e path.c: PaAppend() constify and add prototype 2024-12-26 15:20:58 -05:00
Darryl L. Miles fca164715e PaCheckCompressed() constify implementation 2024-12-26 15:20:58 -05:00
Darryl L. Miles e22e5d63b9 PaCheckCompressed() removed API quirkiness
When constifying there is this inconsistent quirk in this API returning
'filename' or a malloced storage.  When special handling needs to be
made by the caller to detect this to decide if it needs a free.

This appears to done to save a strdup().

Make it always return a malloc block so the API contract is
strightforward to the caller.  A non-NULL return requires
free() by the caller.
2024-12-26 15:20:58 -05:00
Darryl L. Miles e7bfa72298 args.c: ArgStr() constify and add prototype 2024-12-26 15:20:58 -05:00
Darryl L. Miles 2ba1d20ab4 utils/match.c constify Match() and add prototype 2024-12-26 15:20:58 -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 6851f27284 extract/ExtBasic.c: Lookup() constify call-site 2024-12-26 15:20:58 -05:00
Darryl L. Miles 3dbcb0759e Lookup() constify call-site
plow/PlowCmd.c: Lookup() constify call-site
plot/plotVers.c: Lookup() constify call-site
plot/plotMain.c: Lookup() constify call-site
plot/plotCmd.c: Lookup() constify call-site
netmenu/NMnetlist.c: Lookup() constify call-site
netmenu/NMcmdLZ.c: Lookup() constify call-site
netmenu/NMcmdAK.c: Lookup() constify call-site
lef/lefTech.c: Lookup() constify call-site
lef/lefCmd.c: Lookup() constify call-site
irouter/irRoute.c: Lookup() constify call-site
irouter/irCommand.c: Lookup() constify call-site
router/rtrCmd.c: Lookup() constify call-site
resis/ResRex.c: Lookup() constify call-site
gcr/gcrShwFlgs.c: Lookup() constify call-site
windows/windCmdSZ.c: Lookup() constify call-site
2024-12-26 15:20:58 -05:00
Darryl L. Miles c2d533af3b windows/windCmdNR.c: Lookup() constify call-site (extern data) 2024-12-26 15:20:58 -05:00
Darryl L. Miles 586e9f1e36 Lookup() constify WindGetCommandTable() returns 'const'
This commit related to the dynamic creation of data that is used
to parse commands and options via Lookup.

windows/windows.h: Lookup() constify call-site
tcltk/tclmagic.c: Lookup() constify call-site
graphics/W3Dmain.c: Lookup() constify call-site
windows/windSend.c: Lookup() constify call-site
windows/windMain.c: Lookup() constify call-site
windows/windInt.h: Lookup() constify call-site
textio/txMain.c: Lookup() constify call-site
2024-12-26 15:20:58 -05: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 a3dce62887 LookupFull() constify call-site
lef/lefRead.c LookupFull() constify call-site
lef/defRead.c LookupFull() constify call-site
graphics/grDStyle.c: LookupFull() constify call-site
2024-12-26 15:20:58 -05:00
Darryl L. Miles 14b6453707 LookupStruct() constify call-site
irouter/irTestCmd.c: LookupStruct() constify call-site
irouter/irCommand.c: LookupStruct() constify call-site
mzrouter/mzTestCmd.c: LookupStruct() constify call-site
mzrouter/mzTech.c: LookupStruct() constify call-site
router/rtrCmd.c: LookupStruct() constify call-site
plow/PlowTest.c: LookupStruct() constify call-site
plow/PlowTech.c: LookupStruct() constify call-site
plot/plotVers.c: LookupStruct() constify call-site
grouter/grouteTest.c: LookupStruct() constify call-site
garouter/gaTest.c: LookupStruct() constify call-site
extract/ExtTest.c: LookupStruct() constify call-site
extract/ExtTech.c: LookupStruct() constify call-site
extflat/EFread.c: LookupStruct() constify call-site
DRCtech.c: LookupStruct() constify call-site
debugFlags.c: LookupStruct() constify call-site
CmdSubrs.c: LookupStruct() constify call-site
geometry.c: LookupStruct() constify call-site
set.c: LookupStruct() constify call-site
2024-12-26 15:20:58 -05:00
Darryl L. Miles fb8f7b94aa LookupStructFull() constify call-site
txInput.c: LookupStructFull() constify call-site
DBlabel.c: LookupStructFull() constify call-site
2024-12-26 15:20:58 -05:00
Darryl L. Miles f5b41a06d6 utils/lookup*.c: constify the API
extern int Lookup(const char *str, const char * const *table);
extern int LookupAny(char, const char * const *);
extern int LookupFull(const char *, const char **);
extern int LookupStruct(const char *str, const LookupTable *table_start, int size);
extern int LookupStructFull(const char *str, const char * const *table, int size);
2024-12-26 15:20:58 -05:00
Darryl L. Miles aa43cc164e geometry.h: constify global wellknown Geometry data values
This then rippled through into callers

Fixed merge conflicts in cif/CIFrdutils.c and cif/CIFread.h
2024-12-26 15:20:39 -05:00
Darryl L. Miles a224c7e21a GeoDisjoint() unify return type of callback to bool
GeoDisjoint() handles this as 'bool' type internally so make all
consumer call-sites consistent with this type.
2024-12-26 15:10:35 -05:00
Darryl L. Miles fd6c30a380 geometry.c: constify and add prototypes 2024-12-26 15:10:35 -05:00
Darryl L. Miles efb5d9001c util/hash.[ch]: const hash 'key' for API and internal type
This is mainly to modify the function signature to accept const
data pointers to keys.

Patch required to ease use of const by API consumers.
2024-12-26 15:10:35 -05:00
Darryl L. Miles 91da638579 utils/strdup.c: StrDup() and mode constifiy impl 2024-12-26 15:10:35 -05:00
Darryl L. Miles 77f04b4e80 K&R debug.h: conversion to ANSI
K&R obsolete syntax removal for C23 compatibility series
2024-12-26 13:15:29 -05:00
Darryl L. Miles c7f99e076e DBcount.c: DBTreeCountPaint() unify return type of hiercount() callback
The call-site does not expect a return value.
The use case in command/Cmdwizard.c is written to be void.

So a resolution was needed.
2024-12-26 13:13:14 -05:00
Darryl L. Miles bd03a550d3 CmdCD.c: DBOrientUse() called with too many arguments.
Comment added to come back to later.

DBOrientUse(cellname, dodef/*, orient*/);
2024-12-26 13:13:13 -05:00
Darryl L. Miles f08793ddd7 CmdTZ.c: use strict prototype for qsort() compar callback function 2024-12-26 13:13:13 -05:00
Darryl L. Miles 2123f7090d CmdCD.c: removed unnecessary fwd decl for function in included header
commands.h contains the prototype for cmdFlushCell() which is already
being included in CmdCD.c
2024-12-26 13:13:13 -05:00
Darryl L. Miles 7ebaba6b39 DBcount.c: clarify function documentation of hiercount() callback
DBTreeCountPaint(def, count, hiercount, cleanup, cdata)
 callback hiercount()

The K&R function prototype syntax in the documentation might confuse
reader into which argument order is correct (as a modern developer
might be out of practice with interpreting K&R syntax)
2024-12-26 13:13:13 -05:00
Darryl L. Miles 3a41bf6ae2 DBWprocs.c: removed fwd decl for non-existant function
void DisplayWindow();

Found during K&R removal of commands/**
2024-12-26 13:13:13 -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 afd1b0b2df K&R commands: 2 x missing forward declaration removal
Functions do not appear to exist:
 extern void DisplayWindow();
 extern void DisplayWindow();

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 8a4464f443 commands.h: add #include "textio/txcommands.h"
The type TxCommand is used in the function signatures.

K&R obsolete syntax removal for C23 compatibility series
2024-12-26 13:13:13 -05:00
Darryl L. Miles 06b5870035 K&R commands.h: conversion to ANSI
K&R obsolete syntax removal for C23 compatibility series
2024-12-26 13:13:13 -05:00
Darryl L. Miles 866699f353 K&R commands.h: 3 x missing prototype removal
Functions do not appear to exist:
 extern MagWindow *CmdGetRootBox();
 extern void CmdAddSlop();
 extern void CmdDoMacro();

K&R obsolete syntax removal for C23 compatibility series
2024-12-26 13:13:13 -05:00
Darryl L. Miles 7a7d1ab25b K&R cmwind/*.c: bulk function implementation conversion
K&R obsolete syntax removal for C23 compatibility series
2024-12-26 13:07:52 -05:00
Darryl L. Miles 2a4c66e222 K&R CMWundo.c: move typedef to before forward declaration usage
K&R obsolete syntax removal for C23 compatibility series
2024-12-26 13:07:52 -05:00
Darryl L. Miles 0e715ce98e K&R: cmwind/*.c bulk forward reference function prototype conversion
K&R obsolete syntax removal for C23 compatibility series
2024-12-26 13:07:52 -05:00
Darryl L. Miles b716aaa59d K&R: cmwind.h conversion to ANSI
K&R obsolete syntax removal for C23 compatibility series
2024-12-26 13:07:52 -05:00
Darryl L. Miles 83f7a71ff3 GHA: canary-matrix.yml 2024-12-26 13:06:26 -05:00
Darryl L. Miles 102f7ad3f2 CIFrdcl.c: bool to int filetype
This direction was chosen due to #define integer use of special values
instead of TRUE/FALSE.  This makes the prototype and use consistent
removing compiler warning from recent K&R removal.
2024-12-26 13:05:14 -05:00
Darryl L. Miles 2f7f76bf9c K&R: cif/*.c bulk function implementation conversion
Beware of the MISMATCH with the prototype found in original
source, with the type declaration below.

External call sites checked to confirm argument order is
correct with the argument name order.

// nedges <> dir
bool
cifOrient(edges, nedges, dir)
    CIFPath *edges[],          /* Array of edges to be categorized. */
    int dir[],                 /* Array to hold directions. */
    int nedges)                        /* Size of arrays. */

// spacing <> border
int
CIFGetContactSize(type, edge, spacing, border)
    TileType type,
    int *edge,
    int *border,
    int *spacing)

K&R obsolete syntax removal for C23 compatibility series
2024-12-26 13:05:14 -05:00
Darryl L. Miles ff412b74d8 K&R graphics/W3Dmain.c: too few args in CIFNameToMask()
K&R obsolete syntax removal for C23 compatibility series
2024-12-26 13:05:14 -05:00
Darryl L. Miles f92d9d469f K&R: cif/*.h move function prototypes to the correct file
The data types CIFPath and CIFReadStyle are part of CIFread.h
and all users outside include CIFread.h already.

K&R obsolete syntax removal for C23 compatibility series
2024-12-26 13:05:14 -05:00
Darryl L. Miles 4e83c7fcdd CIFgen.c:309:10: warning: prototype for ‘SetMinBoxGrid’ follows non-prototype definition
This reference is not a forward reference, the function implementation
for SetMinBoxGrid() is above this line being removed.
2024-12-26 13:05:14 -05:00
Darryl L. Miles bf45f9ea31 K&R: cif/*.c bulk forward reference function prototype conversion
K&R obsolete syntax removal for C23 compatibility series
2024-12-26 13:05:14 -05:00
Darryl L. Miles 89ed5d735c K&R: CIFread.h conversion to ANSI
K&R obsolete syntax removal for C23 compatibility series
2024-12-26 13:05:14 -05:00
Darryl L. Miles ca2d6d40dd K&R: CIFint.h conversion to ANSI
K&R obsolete syntax removal for C23 compatibility series
2024-12-26 13:05:14 -05:00
Darryl L. Miles b8c3060f3b K&R: cif.h conversion to ANSI
K&R obsolete syntax removal for C23 compatibility series
2024-12-26 13:05:14 -05:00
Darryl L. Miles a1ae272dc5 K&R: prototype for non-existent function: CIFGetDefaultContactSize()
Remove prototype from header file to correct error.

K&R obsolete syntax removal for C23 compatibility series
2024-12-26 13:05:14 -05:00
Darryl L. Miles 114ddf1b0c grX11su1.c: GrX11IconUpdate() potential -1 out-of-bound access
SonarCloud
Access of 'char' element in the region at index -1
https://sonarcloud.io/project/issues?open=AZJB163RNGfDNup0Ri4r&id=dlmiles_magic
2024-12-26 13:01:24 -05:00
Darryl L. Miles 3a35d4d28d grTOGL1.c: GrTOGLIconUpdate() potential -1 out-of-bound access
SonarCloud
Access of 'char' element in the region at index -1
This was not picked up, even though similar code was.
2024-12-26 13:01:24 -05:00
Darryl L. Miles 89fa935416 grTk1.c: GrTkIconUpdate() potential -1 out-of-bound access
SonarCloud
Access of 'char' element in the region at index -1
This was not picked up, even though similar code was.
2024-12-26 13:01:24 -05:00
Darryl L. Miles ef7f989da6 grTCairo1.c: GrTCairoIconUpdate() potential -1 out-of-bound access
SonarCloud
Access of 'char' element in the region at index -1
This was not picked up, even though similar code was.
2024-12-26 13:01:24 -05:00
Darryl L. Miles ee9d4df081 lefRead.c: LefError() add ASSERT(type) for incorrect caller usage
'type' maybe used as array index without being initialized.

Sonarcloud
Array subscript is undefined
https://sonarcloud.io/project/issues?open=AZJB17LDNGfDNup0Rjyn&id=dlmiles_magic
2024-12-26 13:01:24 -05:00
Darryl L. Miles 86b5d591d6 grOGL3.c: add GrOGLTextSize() error return
'textrect' is not filled in when GrOGLTextSize() fails.

Add error return and abort groglPutText() easrly on error.

graphics/grOGL3.c:783 Rect textrect;

SonarCloud
The right operand of '+' is a garbage value
https://sonarcloud.io/project/issues?open=AZJB160qNGfDNup0Riv5&id=dlmiles_magic
2024-12-26 13:01:24 -05:00
Darryl L. Miles 56317e6583 grOGL3.c: font, The left operand of '==' is a garbage value
SonarCloud
The left operand of '==' is a garbage value
https://sonarcloud.io/project/issues?open=AZJB160qNGfDNup0Riv4&id=dlmiles_magic
2024-12-26 13:01:24 -05:00
Darryl L. Miles 55413d6b3a grOGL1.c: GrOGLIconUpdate() potential -1 out-of-bound access
SonarCloud
Access of 'char' element in the region at index -1
https://sonarcloud.io/project/issues?open=AZJB16z6NGfDNup0Rist&id=dlmiles_magic
2024-12-26 13:01:24 -05:00
Darryl L. Miles da80d5c75d grOGL1.c: pipehandler() XEvent processing NULL deref
SonarCloud
Access to field 'w_flags' results in a dereference of a null pointer (loaded from variable 'mw')
https://sonarcloud.io/project/issues?open=AZJB16z6NGfDNup0Risq&id=dlmiles_magic
2024-12-26 13:01:24 -05:00
Darryl L. Miles 26d6af464a grDStyle.c: newres, Branch condition evaluates to a garbage value
'newres' initialization is performed the wrong side of the label
to be effective to the code that uses it.

SonarCloud
Branch condition evaluates to a garbage value
https://sonarcloud.io/project/issues?open=AZJB16zUNGfDNup0RiqG&id=dlmiles_magic
2024-12-26 13:01:24 -05:00
Darryl L. Miles 60f308826d grDStyle.c: GrLoadStyles() scount, The left operand of '<' is a garbage value
The use of 'scount' in this function looks complex, it seems to be reset to
zero sometimes and incremented at others.  Analysis shows there is a possible
path where is maybe used uninitialized.

Setting to zero seems like a good choice.

SonarCloud
grDStyle.c:514 The left operand of '<' is a garbage value
https://sonarcloud.io/project/issues?open=AZJB16zUNGfDNup0RiqE&id=dlmiles_magic
2024-12-26 13:01:24 -05:00
Darryl L. Miles bbe447423b gaStem.c: type, The left operand of '==' is a garbage value
Theoretical use of unintialized data.

Added 'default' case into switch to throw ASSERT(), otherwise
when assertions disabled treat consistently as GEO_NORTH.

SonarCloud
The left operand of '==' is a garbage value
https://sonarcloud.io/project/issues?open=AZJB17fSNGfDNup0Rkoh&id=dlmiles_magic
2024-12-26 13:01:24 -05:00
Darryl L. Miles 1e916ee361 ExtBasic.c: oppdir, The right operand of '==' is a garbage value
BD_xxxxx are a bitmask.  So it makes sense due to equality check to
set to zero so it becomes a no-op situation.

I assume lb->dir not matching one of the 4 BD_xxxxx labels would be
a data error anyway and should never occur.

SonarCloud
The right operand of '==' is a garbage value
https://sonarcloud.io/project/issues?open=AZJB16p0NGfDNup0RiW9&id=dlmiles_magic
2024-12-26 13:01:24 -05:00
Darryl L. Miles 6eff1c2132 extflat/EFname.c: EFHNBest() add argument ASSERT to convey intention
Adding ASSERT() to arguments to ensure passed arguments are non-NULL
better conveys API intent to both mitigate this false positive
but also allow analysis to inspect caller for correct usage.

SonarCloud
Null pointer passed as 1st argument to string length function
https://sonarcloud.io/project/issues?open=AZJB167jNGfDNup0RjGw&id=dlmiles_magic
2024-12-26 13:01:24 -05:00
Darryl L. Miles 6a513d01a1 EFname.c: potential dereference of a null pointer
Theoretical NULL pointer deref, assumes no iteration occurs.
Seems like false positive from incorrect caller use, from
passing suffix==NULL.

SonarCloud
Access to field 'hn_parent' results in a dereference of a null pointer (loaded from variable 'prev')
https://sonarcloud.io/project/issues?open=AZJB167jNGfDNup0RjGu&id=dlmiles_magic
2024-12-26 13:01:24 -05:00
Darryl L. Miles db85521449 EFbuild.c:1330 ASSERT(nn) added
ASSERT(nn) added to indicate programming intention.

SonarCloud
Access to field 'efnn_node' results in a dereference of a null pointer (loaded from variable 'nn')
https://sonarcloud.io/project/issues?open=AZJB168PNGfDNup0RjKF&id=dlmiles_magic
2024-12-26 13:01:24 -05:00
Darryl L. Miles fcb8bf57c6 ext2spice.c: pname used before initialization
In order for pname to be assigned a value the loop must have performed
an interation.  The order of assignment and use of 'pname' is not the
natural order you'd expect.  It also looks like the TxPrint message
may display the incorrect port name from the previous loop iteration.

The code block looks like the resolution of 'pname' has no side-effects.
So should be done first so the correct port name is output in the log message.

SonarCloud
2nd function call argument is an uninitialized value
https://sonarcloud.io/project/issues?open=AZJB17lqNGfDNup0Rk6f&id=dlmiles_magic
2024-12-26 13:01:24 -05:00
Darryl L. Miles 97913ab08c calma/CalmaWrite.c: calmaProcessBoundaryZ() Dereference of null pointer
Theoretical NULL pointer deref.  Seems like false positive as a
BOUNDARY record does not make sense with no points.

This guards against a potential crash from a bad data model.

SonarCloud
Dereference of null pointer
https://sonarcloud.io/project/issues?open=AZJB17hwNGfDNup0Rkub&id=dlmiles_magic
2024-12-26 13:01:24 -05:00
Darryl L. Miles dd6bb9baf4 calma/CalmaWrite.c: calmaProcessBoundary() Dereference of null pointer
Theoretical NULL pointer deref.  Seems like false positive as a
BOUNDARY record does not make sense with no points.

This guards against a potential crash from a bad data model.

SonarCloud
Dereference of null pointer
https://sonarcloud.io/project/issues?open=AZJB17hXNGfDNup0Rktk&id=dlmiles_magic
2024-12-26 13:01:24 -05:00
Darryl L. Miles a3a40bee73 main-macos.yml add Prepare archive and Upload archive steps 2024-12-26 12:52:26 -05:00
Darryl L. Miles ecba1b38d2 main-macos.yml add Summary step 2024-12-26 12:52:26 -05:00
Darryl L. Miles fa07bd0067 main-macos.yml log output extract CONFIGURE_ARGS 2024-12-26 12:52:25 -05:00
Darryl L. Miles be2f8f9a19 main-macos.yml install libglu freeglut on x86_64 2024-12-26 12:52:25 -05:00
Darryl L. Miles f1acfee34a MacOSX diagnostics Search 2024-12-26 12:52:25 -05:00
Darryl L. Miles 90b61caff0 GHA: main.yml move MacOSX to its own workflow 2024-12-26 12:52:25 -05:00
Darryl L. Miles e54111cf6f configure.in: X11 detection and option order
The -L option needs to be placed before the -l it needs to affect.
This maybe important on MacOSX where a nonstandard/optional package
provides X11 support so the locations are not in system locations.
2024-12-26 12:52:25 -05:00
Darryl L. Miles 3f1344570c MacOSX diagnostics Kick The Tyres 2024-12-26 12:52:25 -05:00
Darryl L. Miles dc79b14739 scripts/configure_mac --x-includes=... --x-libraries=... 2024-12-26 12:52:25 -05:00
Darryl L. Miles bfc82e43db MacOS: FREAD rename to magicFREAD due to sys/fcntl.h definition
Example build issue using MacOS 12 (Xcode 14.2 from MacOSX.platform).

In file included from grTk1.c:23:
In file included from ../utils/main.h:26:
In file included from ../windows/windows.h:26:
../utils/magic.h:143:13: warning: 'FREAD' macro redefined [-Wmacro-redefined]
    #define FREAD(a,b,c,d)    gzread(d,a,b*c)
            ^
/Applications/Xcode_14.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/fcntl.h:110:9: note: previous definition is here
 #define FREAD           0x00000001
2024-12-26 12:52:25 -05:00
Darryl L. Miles 48f8707753 GHA: main-macos.yml 2024-12-26 12:52:25 -05:00
Carsten Wulff 772bfe2f71 commands/CmdFI.c: added CmdFlush_NoConfirm option to disable flush prompt 2024-12-26 12:49:33 -05:00
Darryl L. Miles d79533a255 K&R calma: move internal prototypes and typedef to calmaInt.h
K&R obsolete syntax removal for C23 compatibility series
2024-12-26 12:44:50 -05:00
Darryl L. Miles d92e2b70b6 K&R CalmaWrite.c: move typedef to before forward declaration usage
K&R obsolete syntax removal for C23 compatibility series
2024-12-26 12:44:50 -05:00
Darryl L. Miles 5f55ab825a K&R CalmaWriteZ.c: move typedef to before forward declaration
K&R obsolete syntax removal for C23 compatibility series
2024-12-26 12:44:50 -05:00
Darryl L. Miles 979c810c38 K&R calma: missing HAVE_ZLIB ifdef around function using type gzFile
K&R obsolete syntax removal for C23 compatibility series
2024-12-26 12:44:50 -05:00
Darryl L. Miles 603ce8b887 K&R CalmaRead.c: too many args for calmaLookCell()
K&R obsolete syntax removal for C23 compatibility series
2024-12-26 12:44:50 -05:00
Darryl L. Miles a9ea08a597 K&R calma/*.c: bulk function implementation conversion
K&R obsolete syntax removal for C23 compatibility series
2024-12-26 12:44:50 -05:00
Darryl L. Miles f3ace65a78 K&R calma/*.c: bulk forward reference function prototype conversion
K&R obsolete syntax removal for C23 compatibility series
2024-12-26 12:44:50 -05:00
Darryl L. Miles 7696f673df configure: autoconf regen (2.69) to add HAVE_SYS_TIME_H 2024-12-26 12:44:50 -05:00
Darryl L. Miles cd63fa3c14 K&R calma: remove system header time() K&R style prototype
time.h has existed since C89 so is a standard header expected
to always be available.

sys/time.h was an optional header that historically only some
platforms provided.

If there is a conflict on specific platforms it is better to
'#if !defined()' that specific niche platform with the problem
if both headers are included in the same compile unit.  But I
don't think this is a problem in modern times.

So this results in a resolution that removes #ifdef around
time.h and the detection by configure for the availabiltiy
of sys/time.h.

K&R obsolete syntax removal for C23 compatibility series
2024-12-26 12:44:50 -05:00
Darryl L. Miles 3f4eb4120e K&R calma: prototype for non-existent function: calmaMergeBoundaries()
Remove forward declaration prototype to correct error.

K&R obsolete syntax removal for C23 compatibility series
2024-12-26 12:44:50 -05:00
Darryl L. Miles f0b6231017 K&R calma: prototype for non-existent function: calmaWriteMarkFunc()
Remove forward declaration prototype to correct error.

K&R obsolete syntax removal for C23 compatibility series
2024-12-26 12:44:50 -05:00
Darryl L. Miles 1fdd8bc185 K&R calmaInt.h: conversion to ANSI
K&R obsolete syntax removal for C23 compatibility series
2024-12-26 12:44:50 -05:00
Darryl L. Miles 40b317979d K&R calma.h: conversion to ANSI
K&R obsolete syntax removal for C23 compatibility series
2024-12-26 12:44:50 -05:00
Darryl L. Miles 5ee3b180d3 K&R calma: missing prototype: calmaWriteContacts()
Rename existing prototype method name to correct error.

K&R obsolete syntax removal for C23 compatibility series
2024-12-26 12:44:50 -05:00
Tim Edwards 48abe30ea4 Implemented a new CIF/GDS generation operator option for
"bloat-all" which is "bloat-all types1 types2 distance" where the
"distance" value is a maximum amount to grow.  It is not (that I
know of) particularly useful for generating output GDS, but it is
very useful for generating temporary layers for DRC checks,
especially things like determining tap distance for latch-up
rules.  The alternative (used in the sky130 tech file) is a
tedious step-by-step "grow" followed by "and-not".  This rule
option is much cleaner to implement and computes faster (although
it is still a boolean operator and is much slower than an edge
rule).
2024-12-25 20:46:25 -05:00
Tim Edwards 89b6f4f92b Corrected an error with the bloat-all CIF operator in which
bloat-all would fail to operate from the top layer of a contact
type due to the use of DBplane(type) instead of counting all
planes of the contact.
2024-12-16 21:52:11 -05:00
Tim Edwards 5ebbed4c12 Corrected the run-length wide-spacing rule so that it correctly
identifies areas which meet the proper definition of run-length
(both edges are parallel for the run-length distance or more).
Previously, errors were getting triggered for geometry where
only one edge exceeded the run-length distance.
2024-12-12 14:10:03 -05:00
Tim Edwards 37dfe07edf Extended the "cifmaxwidth" function to include the option "both",
which has the same meaning as the "maxwidth" function ("both"
checks either tile dimension to see if it exceeds the maximum).
This is a simple per-tile check and assumes that violations do
not occur across multiple tiles.  This should be sufficient for
most checks.
2024-12-08 12:14:38 -05:00
Tim Edwards dc87a8c693 Corrected two errors with the wiring tool: (1) Ignore
"angles"-type width rules when calculating the default metal
width DRC rule (this width when present will always be
larger than the minimum metal width), and (2) If an exiting
wire is larger than the contact size, then set the contact
size such that the contact PLUS the surrounding metal is the
width of the exiting wire.  The existing code sets the
contact size itself to the width of the exiting wire, such
that when surrounding material is added, the contact is
larger than it needs to be.  The fix to (1) will also fix
other places where the default DRC width rule is computed,
which includes LEF and DEF handling and computing rendered
text sizes when reading GDS.
2024-12-06 21:45:02 -05:00
Tim Edwards e0c95d6d78 Additional coding to handle discovery of terminal types on
different planes of a device that are connected to a multi-tile
device.  This is a more general solution than previously coded,
in which only the first tile of a device would be searched for
terminals on other planes, which was only guaranteed to work
if the device was represented by a single tile.
2024-12-06 20:51:59 -05:00
Tim Edwards 0a67151292 Extended the device parameters to allow a terminal width that is
different from the device (i.e., gate) width, for devices that do
not define a MOS-like gate spanning the width of the device.  This
is restricted to the assumption that the terminal is rectangular
and therefore a simple width and length can be derived from the
area and perimeter.  Also, length is defined as the smaller
dimension and width as the larger dimension.  For additional
restrictions, see the updated documentation.  This was added to
allow correct width and length extraction of a bipolar emitter
window, but may be more generally useful.
2024-12-06 16:42:43 -05:00
Tim Edwards 9184ccd395 Corrected an error in which DRC rules for width of material drawn
at a 45 degree angle will shadow the DRC rule for the material
drawn orthogonally (that is, the DRC rule for the distance between
orthogonal shapes will be eliminated from the rule deck).
2024-12-02 10:00:20 -05:00
Tim Edwards 8b34aa78a9 Corrected a long-standing crash condition that happens when a
generated cell is modified multiple times.  If the original cell
is orphaned (no longer used anywhere in the design), it is deleted.
However, an instance of the cell may exist in the secondary
select buffer if the cell was previously moved or copied, and
an attempt to do another move or copy will clear the secondary
select buffer, encounter the deleted cell, and crash the program.
2024-11-26 13:43:27 -05:00
Tim Edwards ea29aa3306 Modified behavior of the "property device" value. It was
previously ignoring the parameters of the entire cell including
the device being overridden by the property, causing the output
to be wrong.  The parameters should always be written out to the
.ext file, including the device whose output is being overridden.
2024-11-19 16:16:48 -05:00
Tim Edwards 1fdca3a57a Tracked down an obscure error that was causing a property
mismatch in the SkyWater sky130_fd_io__top_pwrdetv2 circuit
because a resistor with ends shorted together was being assigned
an incorrect length and width.  This was due to the similarity
in characteristics of the boundary vector between a shorted
resistor and an annular resistor.  The terminals need to be
checked for shorted ends to disambiguate the two cases.
2024-11-14 22:22:27 -05:00
Tim Edwards 22c22228b3 Coded around an issue where the antenna violation checker comes up
with zero gate error (and was reporting an infinite antenna ratio).
For now, just ignoring the zero-area case.  However, since the
procedure is supposed to be looping through nets connected to
specific devices in the .ext file, then every entry is supposed to
have non-zero area, so there is some underlying problem here that
needs to be fixed.
2024-11-07 11:59:07 -05:00
Tim Edwards a35993a81b Corrected a long-standing but rare error in which diagonal tiles
surrounding a device tile may cause the device to be extracted
with the wrong node (picking up the node from the wrong side of
the diagonal tile).  Added extra handling to capture the case
where two ports on two different nets are merged when using
"ext2spice short" (previously it was handling only ports on the
same net).  Also:  Removed the redundant readline-4.3 from the
readline/ directory;  only readline/readline is left, which is
version 4.3.
2024-11-02 11:00:05 -04:00
Tim Edwards b7942cffe6 Revised the previous commit after discussion with Darryl Miles on
the possible ways that other textio routines could affect the
string contents.
2024-10-10 17:48:59 -04:00
Tim Edwards 0864f8b728 Corrected an error introduced in yesterday's commits by a combination
of a syntax cleanup and an incorrect declaration.  See github issue
2024-10-10 15:27:52 -04:00
Tim Edwards d0eb5349a5 Updated the version to go along with a bunch of pull request
merges from syntax and error cleanup work done by Darryl Miles
(thanks, Darryl!).
2024-10-09 21:38:03 -04:00
Darryl L. Miles 95d3e9f85d CalmaRead.c: warning: variable 'libnameptr' is used uninitialized
The local variable 'libnameptr' is used from the 'goto done;' label cleanup
but it may not be initiailzied at the time of the first use of the label.

When evaluating this I also notice the global 'calmaErrorFile' when closed
does not have the handle invalidated.

CalmaRead.c:233:9: warning: variable 'libnameptr' is used uninitialized whenever 'if' condition is true
CalmaRead.c:231:9: warning: variable 'libnameptr' is used uninitialized whenever 'if' condition is true
CalmaRead.c:225:9: warning: variable 'libnameptr' is used uninitialized whenever 'if' condition is true

clang18 -Wall warning cleanup [-Wsometimes-uninitialized]
2024-10-09 21:34:12 -04:00
Darryl L. Miles d5ef80acda gaStem.c: warning: variable '...' is used uninitialized
An error return indication was added, as there as no other way to abort
execution but indicate to caller the data was not filled in.

No call sites have been modified to check the error return as the
assertion is still in place and expects to catch this unexpected scenario.

gaStem.c:914:2: warning: variable 'start' is used uninitialized whenever switch default is taken
gaStem.c:914:2: warning: variable 'min' is used uninitialized whenever switch default is taken
gaStem.c:914:2: warning: variable 'max' is used uninitialized whenever switch default is taken

clang18 -Wall warning cleanup [-Wsometimes-uninitialized]
2024-10-09 21:34:12 -04:00
Darryl L. Miles 38c14a0ad9 gaMain.c: warning: variable 'errs' is used uninitialized
gaMain.c:287:9: warning: variable 'errs' is used uninitialized whenever 'if' condition is true

clang18 -Wall warning cleanup [-Wsometimes-uninitialized]
2024-10-09 21:34:12 -04:00
Darryl L. Miles 7fd116c828 tclmagic.c: warning: variable 'arg0' is used uninitialized
tclmagic.c:448:9: warning: variable 'arg0' is used uninitialized whenever 'if' condition is false

clang18 -Wall warning cleanup [-Wsometimes-uninitialized]
2024-10-09 21:34:12 -04:00
Darryl L. Miles 35604400ed irRoute.c: warning: variable '...' is used uninitialized
"shouldn't happen" but if it did.

irRoute.c:594:2: warning: variable 'startPt' is used uninitialized whenever switch default is taken
irRoute.c:719:2: warning: variable 'destRect' is used uninitialized whenever switch default is taken

clang18 -Wall warning cleanup [-Wsometimes-uninitialized]
2024-10-09 21:34:12 -04:00
Darryl L. Miles 1bb6a7f6c5 plotPNM.c: warning: variable 'strip' is used uninitialized
The compiler warning concerns the use of 'goto done;' has cleanup
that accesses 'strip' before initialization.

While evaluating this I also notice the other 2 variables 'rtile'
and 'lkstep' are globals, but their pointers are not invalidated
at the time of free.

plotPNM.c:821:6: warning: variable 'strip' is used uninitialized whenever 'if' condition is true

clang18 -Wall warning cleanup [-Wsometimes-uninitialized]
2024-10-09 21:34:12 -04:00
Darryl L. Miles 60e78f4ab4 CalmaWriteZ.c: warning: variable 'rtype' is used uninitialized
CalmaWriteZ.c:418:5: warning: variable 'rtype' is used uninitialized whenever 'if' condition is true

clang18 -Wall warning cleanup [-Wsometimes-uninitialized]
2024-10-09 21:34:12 -04:00
Darryl L. Miles fca0c2945d CalmaWrite.c: warning: variable 'rtype' is used uninitialized
CalmaWrite.c:442:5: warning: variable 'rtype' is used uninitialized whenever 'if' condition is true

clang18 -Wall warning cleanup [-Wsometimes-uninitialized]
2024-10-09 21:34:12 -04:00
Darryl L. Miles fece689c43 CalmaRdpt.c: warning: variable 'rtype' is used uninitialized
CalmaRdpt.c:525:5: warning: variable 'rtype' is used uninitialized whenever 'if' condition is true
CalmaRdpt.c:792:5: warning: variable 'rtype' is used uninitialized whenever 'if' condition is true

clang18 -Wall warning cleanup [-Wsometimes-uninitialized]
2024-10-09 21:34:12 -04:00
Darryl L. Miles 2b06c8cee5 CalmaRdcl.c: warning: variable 'rtype' is used uninitialized
FEOF condition of PEEKRH causes variable to possibly not get
initialized before use.

CalmaRdcl.c:372:5: warning: variable 'rtype' is used uninitialized whenever 'if' condition is true

clang18 -Wall warning cleanup [-Wsometimes-uninitialized]
2024-10-09 21:34:12 -04:00
Darryl L. Miles 2f22ec6293 set.c: warning: variable 'result' is used uninitialized
set.c:124:9: warning: variable 'result' is used uninitialized whenever 'if' condition is false

clang18 -Wall warning cleanup [-Wsometimes-uninitialized]
2024-10-09 21:34:12 -04:00
Darryl L. Miles ea41b21f67 macros.c: warning: variable 'kc' is used uninitialized
macros.c:557:12: warning: variable 'kc' is used uninitialized whenever 'if' condition is false

clang18 -Wall warning cleanup [-Wsometimes-uninitialized]
2024-10-09 21:34:12 -04:00
Darryl L. Miles 817efbbccc txCommands.c: warning: variable ... is used uninitialized whenever
Maybe ASSERT are not always active, so defensive coding solution.

txCommands.c:883:6: warning: variable 'but' is used uninitialized whenever switch default is taken
txCommands.c:888:6: warning: variable 'act' is used uninitialized whenever switch default is taken

clang18 -Wall warning cleanup [-Wsometimes-uninitialized]
2024-10-09 21:34:12 -04:00
Darryl L. Miles fa3a01c486 selOps.c: warning: variable 'type' is used uninitialized
selOps.c:1942:11: warning: variable 'type' is used uninitialized whenever 'if' condition is false

clang18 -Wall warning cleanup [-Wsometimes-uninitialized]
2024-10-09 21:34:12 -04:00
Darryl L. Miles 3919cc5b63 PlowRandom.c: warning: variable 'f2' is used uninitialized
PlowRandom.c:301:9: warning: variable 'f2' is used uninitialized whenever 'if' condition is true

clang18 -Wall warning cleanup [-Wsometimes-uninitialized]
2024-10-09 21:34:12 -04:00
Darryl L. Miles 4206ed2436 grTOGL3.c: warning: variable 'font' is used uninitialized
grTOGL3.c:230:5: warning: variable 'font' is used uninitialized whenever switch default is taken

clang18 -Wall warning cleanup [-Wsometimes-uninitialized]
2024-10-09 21:34:12 -04:00
Darryl L. Miles 4520112a55 grTk3.c: warning: variable 'font' is used uninitialized
grTk3.c:203:5: warning: variable 'font' is used uninitialized whenever switch default is taken

clang18 -Wall warning cleanup [-Wsometimes-uninitialized]
2024-10-09 21:34:12 -04:00
Darryl L. Miles 7feb298f7a ExtBasic.c: warning: variable ... is used uninitialized whenever
ExtBasic.c:408:7: warning: variable 'urx' is used uninitialized whenever '||' condition is true
ExtBasic.c:417:7: warning: variable 'ury' is used uninitialized whenever '||' condition is true

clang18 -Wall warning cleanup [-Wsometimes-uninitialized]
2024-10-09 21:34:12 -04:00
Darryl L. Miles 4380310e5b EFvisit.c: warning: misleading indentation;
I think the warning is bringing to attention the hidden fall-thru
case situation.

EFvisit.c:897:50: warning: misleading indentation; statement is not part of the previous 'if'

clang18 -Wall warning cleanup  [-Wmisleading-indentation]
2024-10-09 21:34:12 -04:00
Darryl L. Miles cbf97f77ee DRCcif.c: 'thislayer' is used uninitialized
DRCcif.c:1193:17: warning: variable 'thislayer' is used uninitialized whenever 'for' loop exits because its condition is false
DRCcif.c:1255:17: warning: variable 'thislayer' is used uninitialized whenever 'for' loop exits because its condition is false

clang18 -Wall warning cleanup [-Wsometimes-uninitialized]
2024-10-09 21:34:12 -04:00
Darryl L. Miles 489de7fdb4 CmdCD.c: 'option' is used uninitialized
CmdCD.c:3693:14: warning: variable 'option' is used uninitialized whenever 'if' condition is false
CmdCD.c:3691:9: warning: variable 'option' is used uninitialized whenever 'if' condition is true

clang18 -Wall warning cleanup [-Wsometimes-uninitialized]
2024-10-09 21:34:12 -04:00
Darryl L. Miles fc49b40c52 netlist.c: etext symbol for __clang__
clang does this differently, this method mirrors the linux man page.

clang18 default warning cleanup (strict)
2024-10-09 21:22:37 -04: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 8f2acb83f9 plotHP.c: warning: incompatible pointer types passing 'int *' to ...
Perform pointer arithmatic with (int *) first then cast just for calling function.

plotHP.c:335:25: warning: incompatible pointer types passing 'int *' to parameter of type 'unsigned char *'
plotHP.c:339:25: warning: incompatible pointer types passing 'int *' to parameter of type 'unsigned char *'
plotHP.c:343:25: warning: incompatible pointer types passing 'int *' to parameter of type 'unsigned char *'

clang18 default warning cleanup [-Wincompatible-pointer-types]
2024-10-09 21:22:37 -04:00
Darryl L. Miles 165f1b35b4 ExtBasic.c: warning: incompatible pointer types passing 'NodeRegion *' ...
The NodeRegion is an extended form of LabRegion (which is smaller) and
has the same layout.  So we cast into the smaller type.

ExtBasic.c:1025:31: warning: incompatible pointer types passing 'NodeRegion *' (aka 'struct nreg *') to parameter of type 'LabRegion *' (aka 'struct lreg *')
ExtBasic.c:2291:29: warning: incompatible pointer types passing 'NodeRegion *' (aka 'struct nreg *') to parameter of type 'LabRegion *' (aka 'struct lreg *')
ExtBasic.c:2335:46: warning: incompatible pointer types passing 'NodeRegion *' (aka 'struct nreg *') to parameter of type 'LabRegion *' (aka 'struct lreg *')
ExtBasic.c:2339:47: warning: incompatible pointer types passing 'NodeRegion *' (aka 'struct nreg *') to parameter of type 'LabRegion *' (aka 'struct lreg *')

clang18 default warning cleanup [-Wincompatible-pointer-types]
2024-10-09 21:22:37 -04:00
Darryl L. Miles ade50dfc88 irRoute.c: warning: expression which evaluates to zero treated as a null pointer ...
Use of FALSE instead of NULL on a pointer type.

irRoute.c:1101:19: warning: expression which evaluates to zero treated
  as a null pointer constant of type 'RouteContact *'
  (aka 'struct routecontact *')

clang18 default warning cleanup [-Wnon-literal-null-conversion]
2024-10-09 21:22:37 -04:00
Darryl L. Miles 4460c5f1f5 DBio.c: warning: 'sscanf' may overflow; destination buffer in argument ...
DBio.c:2358:21: warning: 'sscanf' may overflow; destination buffer in
  argument 4 has size 2048, but the corresponding specifier may require
  size 2049

clang18 default warning cleanup [-Wfortify-source]
2024-10-09 21:22:37 -04:00
Darryl L. Miles ef48e40f39 lefRead.c:1334:63: warning: too few arguments in call to 'LefPaintPolygon'
When keep!=FALSE a malloc list is returned, so this looks like a memory leak.

clang18 default warning cleanup
2024-10-09 21:17:28 -04:00
Darryl L. Miles f734e27587 selOps.c:1000:70: warning: too many arguments in call to 'selShortFindForward'
Unclear if there is a programming intention here that hasn't been
implemented.

clang18 default warning cleanup
2024-10-09 21:17:28 -04:00
Darryl L. Miles b723dc15d8 DBio.c:1604:65: warning: too many arguments in call to 'dbReadOpen'
DBio.c:1604:52: warning: expression which evaluates to zero treated as
 a null pointer constant of type 'int *' [-Wnon-literal-null-conversion]

DBOpenOnly() function only has one use which always passed name==NULL.

clang18 default warning cleanup
2024-10-09 21:17:28 -04:00
Darryl L. Miles 59bfe8f6c0 DBcellsrch.c:2249:22: warning: too many arguments in call to 'dbMovePlane'
clang18 default warning cleanup
2024-10-09 21:17:28 -04:00
Darryl L. Miles c1aeaa9be5 DRCtech.c:4141:21: warning: suggest parentheses around comparison in operand of '=='
the expression (a == b == 1) works out like:

a, b = result (XNOR)
0, 0 = 1
0, 1 = 0
1, 0 = 0
1, 1 = 1

GCC14 -Wall cleanup series [-Wparentheses]
2024-10-09 21:12:55 -04:00
Darryl L. Miles 04bc9032b9 plotPNM.c:521:5: warning: statement with no effect
GCC14 -Wall cleanup series [-Wunused-value]
2024-10-09 21:12:55 -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 239366d4b6 grTk3.c: warning: suggest parentheses around '-' in operand of '&'
GCC14 -Wall cleanup series [-Wparentheses]
2024-10-09 21:12:55 -04:00
Darryl L. Miles 4bfed56924 17 x warning: suggest parentheses around assignment used as truth value
gaStem.c:225:9: warning: suggest parentheses around assignment used as truth value
gaStem.c:350:9: warning: suggest parentheses around assignment used as truth value
grouteMain.c:363:12: warning: suggest parentheses around assignment used as truth value
grouteMaze.c:573:17: warning: suggest parentheses around assignment used as truth value
groutePath.c:127:13: warning: suggest parentheses around assignment used as truth value
irCommand.c:901:12: warning: suggest parentheses around assignment used as truth value
irCommand.c:999:12: warning: suggest parentheses around assignment used as truth value
irCommand.c:1275:13: warning: suggest parentheses around assignment used as truth value
irCommand.c:1375:13: warning: suggest parentheses around assignment used as truth value
irCommand.c:1931:17: warning: suggest parentheses around assignment used as truth value
rtrDcmpose.c:435:12: warning: suggest parentheses around assignment used as truth value
rtrPin.c:174:17: warning: suggest parentheses around assignment used as truth value
rtrStem.c:373:21: warning: suggest parentheses around assignment used as truth value
rtrStem.c:479:9: warning: suggest parentheses around assignment used as truth value
rtrStem.c:952:17: warning: suggest parentheses around assignment used as truth value
gcrInit.c:239:9: warning: suggest parentheses around assignment used as truth value
net2ir.c:123:13: warning: suggest parentheses around assignment used as truth value

GCC14 -Wall cleanup series [-Wparentheses]
2024-10-09 21:12:55 -04:00
Darryl L. Miles a6e1596ba6 22 x warning: suggest parentheses around assignment used as truth value
lefTech.c:107:16: warning: suggest parentheses around assignment used as truth value
lefTech.c:160:16: warning: suggest parentheses around assignment used as truth value
lefTech.c:426:16: warning: suggest parentheses around assignment used as truth value
lefTech.c:453:16: warning: suggest parentheses around assignment used as truth value
lefTech.c:486:16: warning: suggest parentheses around assignment used as truth value
lefWrite.c:190:9: warning: suggest parentheses around assignment used as truth value
lefWrite.c:303:12: warning: suggest parentheses around assignment used as truth value
lefWrite.c:315:12: warning: suggest parentheses around assignment used as truth value
lefWrite.c:377:16: warning: suggest parentheses around assignment used as truth value
lefWrite.c:439:16: warning: suggest parentheses around assignment used as truth value
lefWrite.c:1222:12: warning: suggest parentheses around assignment used as truth value
lefWrite.c:2246:12: warning: suggest parentheses around assignment used as truth value
defWrite.c:415:12: warning: suggest parentheses around assignment used as truth value
defWrite.c:447:12: warning: suggest parentheses around assignment used as truth value
defWrite.c:2039:16: warning: suggest parentheses around assignment used as truth value
defWrite.c:2104:16: warning: suggest parentheses around assignment used as truth value
defWrite.c:2478:16: warning: suggest parentheses around assignment used as truth value
defWrite.c:2498:20: warning: suggest parentheses around assignment used as truth value
defWrite.c:3066:16: warning: suggest parentheses around assignment used as truth value
defWrite.c:3084:28: warning: suggest parentheses around assignment used as truth value
defWrite.c:3111:28: warning: suggest parentheses around assignment used as truth value
lefRead.c:651:12: warning: suggest parentheses around assignment used as truth value

GCC14 -Wall cleanup series [-Wparentheses]
2024-10-09 21:12:55 -04:00
Darryl L. Miles 76d8c8c911 35 x warning: suggest parentheses around assignment used as truth value
PlowRules1.c:439:9: warning: suggest parentheses around assignment used as truth value
PlowTech.c:645:17: warning: suggest parentheses around assignment used as truth value
PlowTech.c:652:17: warning: suggest parentheses around assignment used as truth value
PlowTech.c:1019:17: warning: suggest parentheses around assignment used as truth value
ResReadSim.c:270:13: warning: suggest parentheses around assignment used as truth value
ResReadSim.c:871:9: warning: suggest parentheses around assignment used as truth value
ResRex.c:1840:17: warning: suggest parentheses around assignment used as truth value
getrect.c:72:9: warning: suggest parentheses around assignment used as truth value
getrect.c:79:9: warning: suggest parentheses around assignment used as truth value
getrect.c:86:9: warning: suggest parentheses around assignment used as truth value
getrect.c:93:9: warning: suggest parentheses around assignment used as truth value
hash.c:732:16: warning: suggest parentheses around assignment used as truth value
heap.c:328:17: warning: suggest parentheses around assignment used as truth value
heap.c:344:17: warning: suggest parentheses around assignment used as truth value
netlist.c:323:17: warning: suggest parentheses around assignment used as truth value
niceabort.c:121:9: warning: suggest parentheses around assignment used as truth value
path.c:1102:12: warning: suggest parentheses around assignment used as truth value
pathvisit.c:245:13: warning: suggest parentheses around assignment used as truth value
pathvisit.c:295:17: warning: suggest parentheses around assignment used as truth value
tech.c:656:17: warning: suggest parentheses around assignment used as truth value
ext2spice.c:1591:16: warning: suggest parentheses around assignment used as truth value
ext2spice.c:1622:16: warning: suggest parentheses around assignment used as truth value
ext2spice.c:1813:12: warning: suggest parentheses around assignment used as truth value
ext2spice.c:1862:12: warning: suggest parentheses around assignment used as truth value
ext2spice.c:3808:16: warning: suggest parentheses around assignment used as truth value
CalmaRdio.c:437:9: warning: suggest parentheses around assignment used as truth value
CalmaWrite.c:396:9: warning: suggest parentheses around assignment used as truth value
CalmaWrite.c:1772:29: warning: suggest parentheses around assignment used as truth value
CalmaWriteZ.c:372:9: warning: suggest parentheses around assignment used as truth value
CalmaWriteZ.c:1608:29: warning: suggest parentheses around assignment used as truth value
CIFrdtech.c:209:9: warning: suggest parentheses around assignment used as truth value
CIFrdtech.c:214:9: warning: suggest parentheses around assignment used as truth value
CIFrdtech.c:220:9: warning: suggest parentheses around assignment used as truth value
CIFrdtech.c:226:9: warning: suggest parentheses around assignment used as truth value
CIFrdutils.c:1258:12: warning: suggest parentheses around assignment used as truth value

GCC14 -Wall cleanup series [-Wparentheses]
2024-10-09 21:12:55 -04:00
Darryl L. Miles 64772655dc 38 x warning: suggest parentheses around assignment used as truth value
EFdef.c:110:12: warning: suggest parentheses around assignment used as truth value
EFdef.c:154:12: warning: suggest parentheses around assignment used as truth value
EFdef.c:167:12: warning: suggest parentheses around assignment used as truth value
EFflat.c:546:17: warning: suggest parentheses around assignment used as truth value
EFflat.c:798:12: warning: suggest parentheses around assignment used as truth value
EFflat.c:930:13: warning: suggest parentheses around assignment used as truth value
EFflat.c:1152:12: warning: suggest parentheses around assignment used as truth value
EFflat.c:1157:13: warning: suggest parentheses around assignment used as truth value
EFhier.c:84:12: warning: suggest parentheses around assignment used as truth value
EFhier.c:261:12: warning: suggest parentheses around assignment used as truth value
EFhier.c:489:12: warning: suggest parentheses around assignment used as truth value
EFhier.c:682:12: warning: suggest parentheses around assignment used as truth value
EFname.c:325:12: warning: suggest parentheses around assignment used as truth value
EFname.c:584:13: warning: suggest parentheses around assignment used as truth value
EFname.c:632:16: warning: suggest parentheses around assignment used as truth value
EFname.c:765:16: warning: suggest parentheses around assignment used as truth value
EFname.c:977:12: warning: suggest parentheses around assignment used as truth value
EFsym.c:113:13: warning: suggest parentheses around assignment used as truth value
EFsym.c:164:9: warning: suggest parentheses around assignment used as truth value
EFvisit.c:322:12: warning: suggest parentheses around assignment used as truth value
EFvisit.c:627:12: warning: suggest parentheses around assignment used as truth value
EFvisit.c:881:16: warning: suggest parentheses around assignment used as truth value
EFvisit.c:917:12: warning: suggest parentheses around assignment used as truth value
grTk1.c:1325:9: warning: suggest parentheses around assignment used as truth value
grTk1.c:1342:9: warning: suggest parentheses around assignment used as truth value
grTk1.c:1757:9: warning: suggest parentheses around assignment used as truth value
grTk1.c:1766:9: warning: suggest parentheses around assignment used as truth value
grTk5.c:177:12: warning: suggest parentheses around assignment used as truth value
grTOGL1.c:1095:9: warning: suggest parentheses around assignment used as truth value
grTOGL1.c:1111:9: warning: suggest parentheses around assignment used as truth value
grTOGL1.c:1542:13: warning: suggest parentheses around assignment used as truth value
grTOGL1.c:1551:13: warning: suggest parentheses around assignment used as truth value
grTOGL5.c:201:12: warning: suggest parentheses around assignment used as truth value
grTCairo1.c:1093:13: warning: suggest parentheses around assignment used as truth value
grTCairo1.c:1109:13: warning: suggest parentheses around assignment used as truth value
grTCairo1.c:1493:21: warning: suggest parentheses around assignment used as truth value
grTCairo1.c:1502:21: warning: suggest parentheses around assignment used as truth value
grTCairo5.c:202:16: warning: suggest parentheses around assignment used as truth value

GCC14 -Wall cleanup series [-Wparentheses]
2024-10-09 21:12:55 -04:00
Darryl L. Miles e3bfe8c59e 42 x warning: suggest parentheses around assignment used as truth value
EFbuild.c:466:9: warning: suggest parentheses around assignment used as truth value
EFbuild.c:662:20: warning: suggest parentheses around assignment used as truth value
EFbuild.c:682:24: warning: suggest parentheses around assignment used as truth value
EFbuild.c:690:24: warning: suggest parentheses around assignment used as truth value
EFbuild.c:1760:12: warning: suggest parentheses around assignment used as truth value
EFbuild.c:1973:9: warning: suggest parentheses around assignment used as truth value
EFbuild.c:2062:12: warning: suggest parentheses around assignment used as truth value
EFbuild.c:2063:13: warning: suggest parentheses around assignment used as truth value
EFbuild.c:2091:12: warning: suggest parentheses around assignment used as truth value
EFbuild.c:2134:12: warning: suggest parentheses around assignment used as truth value
EFbuild.c:2135:13: warning: suggest parentheses around assignment used as truth value
EFread.c:673:12: warning: suggest parentheses around assignment used as truth value
ExtArray.c:693:12: warning: suggest parentheses around assignment used as truth value
ExtArray.c:800:13: warning: suggest parentheses around assignment used as truth value
ExtBasic.c:4569:9: warning: suggest parentheses around assignment used as truth value
ExtBasic.c:4949:13: warning: suggest parentheses around assignment used as truth value
ExtBasic.c:5032:12: warning: suggest parentheses around assignment used as truth value
ExtCell.c:218:13: warning: suggest parentheses around assignment used as truth value
ExtCouple.c:222:12: warning: suggest parentheses around assignment used as truth value
ExtCouple.c:278:12: warning: suggest parentheses around assignment used as truth value
ExtCouple.c:467:9: warning: suggest parentheses around assignment used as truth value
ExtHard.c:379:12: warning: suggest parentheses around assignment used as truth value
ExtHard.c:458:12: warning: suggest parentheses around assignment used as truth value
ExtHier.c:740:16: warning: suggest parentheses around assignment used as truth value
ExtHier.c:831:12: warning: suggest parentheses around assignment used as truth value
ExtHier.c:841:13: warning: suggest parentheses around assignment used as truth value
ExtHier.c:851:17: warning: suggest parentheses around assignment used as truth value
ExtHier.c:865:34: warning: suggest parentheses around assignment used as truth value
ExtLength.c:264:12: warning: suggest parentheses around assignment used as truth value
ExtLength.c:276:12: warning: suggest parentheses around assignment used as truth value
ExtLength.c:878:9: warning: suggest parentheses around assignment used as truth value
ExtMain.c:499:12: warning: suggest parentheses around assignment used as truth value
ExtMain.c:970:12: warning: suggest parentheses around assignment used as truth value
ExtNghbors.c:298:13: warning: suggest parentheses around assignment used as truth value
ExtSubtree.c:683:12: warning: suggest parentheses around assignment used as truth value
ExtTest.c:457:21: warning: suggest parentheses around assignment used as truth value
ExtTest.c:466:21: warning: suggest parentheses around assignment used as truth value
ExtTimes.c:216:12: warning: suggest parentheses around assignment used as truth value
ExtTimes.c:226:12: warning: suggest parentheses around assignment used as truth value
ExtTimes.c:235:12: warning: suggest parentheses around assignment used as truth value
ExtYank.c:236:34: warning: suggest parentheses around assignment used as truth value
ExtYank.c:238:42: warning: suggest parentheses around assignment used as truth value

GCC14 -Wall cleanup series [-Wparentheses]
2024-10-09 21:12:55 -04:00
Darryl L. Miles 6cdb9ad167 36 x warning: suggest parentheses around assignment used as truth value
bpMain.c:265:11: warning: suggest parentheses around assignment used as truth value
CmdSubrs.c:413:12: warning: suggest parentheses around assignment used as truth value
CmdSubrs.c:759:13: warning: suggest parentheses around assignment used as truth value
CmdFI.c:1600:12: warning: suggest parentheses around assignment used as truth value
DBcell.c:109:12: warning: suggest parentheses around assignment used as truth value
DBcellname.c:2512:9: warning: suggest parentheses around assignment used as truth value
DBcellsrch.c:95:12: warning: suggest parentheses around assignment used as truth value
DBio.c:3998:9: warning: suggest parentheses around assignment used as truth value
DBlabel2.c:228:9: warning: suggest parentheses around assignment used as truth value
DBWelement.c:195:12: warning: suggest parentheses around assignment used as truth value
DBWelement.c:197:13: warning: suggest parentheses around assignment used as truth value
DBWelement.c:295:12: warning: suggest parentheses around assignment used as truth value
DBWelement.c:297:13: warning: suggest parentheses around assignment used as truth value
DBWelement.c:637:12: warning: suggest parentheses around assignment used as truth value
DBWelement.c:639:13: warning: suggest parentheses around assignment used as truth value
DBWelement.c:679:12: warning: suggest parentheses around assignment used as truth value
DBWelement.c:681:13: warning: suggest parentheses around assignment used as truth value
DRCtech.c:1219:17: warning: suggest parentheses around assignment used as truth value
DRCtech.c:1368:17: warning: suggest parentheses around assignment used as truth value
DRCtech.c:1471:17: warning: suggest parentheses around assignment used as truth value
DRCtech.c:1543:17: warning: suggest parentheses around assignment used as truth value
DRCtech.c:1676:17: warning: suggest parentheses around assignment used as truth value
DRCtech.c:1772:21: warning: suggest parentheses around assignment used as truth value
DRCtech.c:1919:17: warning: suggest parentheses around assignment used as truth value
DRCtech.c:2099:17: warning: suggest parentheses around assignment used as truth value
DRCtech.c:2324:17: warning: suggest parentheses around assignment used as truth value
DRCtech.c:2713:17: warning: suggest parentheses around assignment used as truth value
DRCtech.c:2830:17: warning: suggest parentheses around assignment used as truth value
DRCtech.c:2944:17: warning: suggest parentheses around assignment used as truth value
DRCtech.c:3097:21: warning: suggest parentheses around assignment used as truth value
DRCtech.c:3144:21: warning: suggest parentheses around assignment used as truth value
DRCtech.c:3181:21: warning: suggest parentheses around assignment used as truth value
DRCtech.c:3215:9: warning: suggest parentheses around assignment used as truth value
DRCtech.c:3227:21: warning: suggest parentheses around assignment used as truth value
DRCtech.c:3261:21: warning: suggest parentheses around assignment used as truth value
DRCtech.c:3459:17: warning: suggest parentheses around assignment used as truth value

GCC14 -Wall cleanup series [-Wparentheses]
2024-10-09 21:12:55 -04:00
Darryl L. Miles 518b5f45d8 bpEnum.h: warning: suggest parentheses around assignment used as truth value
Removes 1312 warning lines from build output due to inline nature of use.

bplane/bpEnum.h:509:10: warning: suggest parentheses around assignment used as truth value
bplane/bpEnum.h:513:10: warning: suggest parentheses around assignment used as truth value
bplane/bpEnum.h:517:10: warning: suggest parentheses around assignment used as truth value
bplane/bpEnum.h:521:10: warning: suggest parentheses around assignment used as truth value
bbplane/bpEnum.h:525:10: warning: suggest parentheses around assignment used as truth value

GCC14 -Wall cleanup series [-Wparentheses]
2024-10-09 21:12:55 -04:00
Darryl L. Miles d94cd72538 37 x warning: array subscript has type 'char'
Compiler is expressing range concern with the warning mitigated by using
unsigned C array offsets.  This also draws attention to the range concern
when reading the code and making changes.

DBundo.c:263:45: warning: array subscript has type 'char'
DBundo.c:279:49: warning: array subscript has type 'char'
DBundo.c:317:52: warning: array subscript has type 'char'
DBundo.c:318:64: warning: array subscript has type 'char'
DBundo.c:324:52: warning: array subscript has type 'char'
DBundo.c:325:64: warning: array subscript has type 'char'
DBundo.c:329:50: warning: array subscript has type 'char'
DBundo.c:330:58: warning: array subscript has type 'char'
DBundo.c:338:52: warning: array subscript has type 'char'
DBundo.c:339:64: warning: array subscript has type 'char'
DBundo.c:345:52: warning: array subscript has type 'char'
DBundo.c:346:64: warning: array subscript has type 'char'
DBundo.c:350:50: warning: array subscript has type 'char'
DBundo.c:351:58: warning: array subscript has type 'char'
DBundo.c:371:52: warning: array subscript has type 'char'
DBundo.c:372:64: warning: array subscript has type 'char'
DBundo.c:378:52: warning: array subscript has type 'char'
DBundo.c:379:64: warning: array subscript has type 'char'
DBundo.c:383:50: warning: array subscript has type 'char'
DBundo.c:384:58: warning: array subscript has type 'char'
DBundo.c:392:52: warning: array subscript has type 'char'
DBundo.c:393:57: warning: array subscript has type 'char'
DBundo.c:399:52: warning: array subscript has type 'char'
DBundo.c:400:57: warning: array subscript has type 'char'
DBundo.c:403:53: warning: array subscript has type 'char'
DBundo.c:407:50: warning: array subscript has type 'char'
DBundo.c:408:58: warning: array subscript has type 'char'
EFbuild.c:1048:32: warning: array subscript has type 'char'
EFbuild.c:1056:32: warning: array subscript has type 'char'
ExtBasic.c:2358:43: warning: array subscript has type 'char'
ExtBasic.c:2493:43: warning: array subscript has type 'char'
ExtBasic.c:2519:43: warning: array subscript has type 'char'
ExtBasic.c:2644:43: warning: array subscript has type 'char'
ExtBasic.c:2678:43: warning: array subscript has type 'char'
ResPrint.c:143:43: warning: array subscript has type 'char'
plotRutils.c:713:34: warning: array subscript has type 'char'
plotRutils.c:786:29: warning: array subscript has type 'char'

GCC14 -Wall cleanup series [-Wchar-subscripts]
2024-10-09 21:12:55 -04:00
Darryl L. Miles 9225fa6cf1 4 x warning: suggest explicit braces to avoid ambiguous 'else'
Give compiler the extra braces it recommends.

DBio.c edited as my original change was caught out by the incorrect
indention of the 'else' keyword and my modification would have caused a
NULL deref.   Exactly the kind of issue this warning is trying to prevent.

CmdTZ.c:417:20: warning: suggest explicit braces to avoid ambiguous 'else'
DBio.c:1422:12: warning: suggest explicit braces to avoid ambiguous 'else'
DBpaint2.c:285:12: warning: suggest explicit braces to avoid ambiguous 'else'
DBpaint2.c:384:12: warning: suggest explicit braces to avoid ambiguous 'else'

GCC14 -Wall cleanup series [-Wdangling-else]
2024-10-09 21:12:55 -04:00
Darryl L. Miles 7dfdf5aa63 CIFrdcl.c: warning: comparison between two arrays
Added pointer casts to hint to compiler the programmer intention
is to compare as pointers to the start of the array (and not be
concerned the programmer is overlooking the contents of the array).

GCC14 -Wall cleanup series [-Warray-compare]
2024-10-09 21:12:55 -04:00
Darryl L. Miles b654647fdc PlowTest.c: warning: enumeration value 'PC_ERROR' not handled in switch
False positive.

Added no-op case statement, but code above looks the case should never
execute due return from function.

GCC14 -Wall cleanup series [-Wswitch]
2024-10-09 21:12:55 -04:00
Darryl L. Miles bd75ddf32c mzMain.c: warning: this 'else' clause does not guard...
Use of macro idiom: if(1) { ... } else
  which has dangling else keyword to allow trailing semicolon at
  use site, is not a good pattern.

Replaced with idiom: do { ... } while(0)
  which should achieve the same purpose but now cause compile
  error when used incorrectly at use site.

GCC14 -Wall cleanup series [-Wmisleading-indentation]
2024-10-09 21:12:55 -04:00
Darryl L. Miles 88d36bfd1e geofast.h: warning: this 'else' clause does not guard...
Use of macro idiom: if(1) { ... } else
  which has dangling else keyword to allow trailing semicolon at
  use site, is not a good pattern.

Replaced with idiom: do { ... } while(0)
  which should achieve the same purpose but now cause compile
  error when used incorrectly at use site.

GCC14 -Wall cleanup series [-Wmisleading-indentation]
2024-10-09 21:12:55 -04:00
Darryl L. Miles e8f9b0af5e CIFgen.c: warning: this 'for' clause does not guard...
return keyword indention corrected
braces added to previous statement to better convey code
 intention of multiline statement

GCC14 -Wall cleanup series [-Wmisleading-indentation]
2024-10-09 21:12:55 -04:00
Darryl L. Miles 0cde303563 ResReadSim.c: warning: this 'if' clause does not guard...
break keyword indention corrected, braces added to better
convey code intention of multiline statement.

GCC14 -Wall cleanup series [-Wmisleading-indentation]
2024-10-09 21:12:55 -04:00
Darryl L. Miles 967b41343b GCC14: warning: missing braces around initializer
GCC14 -Wall cleanup series [-Wmissing-braces]
2024-10-09 21:12:55 -04:00
Darryl L. Miles 3300f45a22 DRCtech.c: warning: use of logical '&&' with constant operand
Looks like logic error hiding behind warning

DRCtech.c:4365:22: warning: use of logical '&&' with constant
 operand [-Wconstant-logical-operand]
DRCtech.c:4365:22: note: remove constant to silence this warning

clang18 default warning cleanup
2024-10-09 20:50:00 -04:00
Darryl L. Miles da2c7b719e DRCsubcell.c: fix: warning: value computed is not used
Looks like a logic bug hidden in the warning.

GCC14 -Wall cleanup series [-Wunused-value]
2024-10-09 20:50:00 -04:00
Darryl L. Miles 3477480ab0 NMbutton.c: fix: warning: statement with no effect
Looks like a logic bug hidden in the warning.

GCC14 -Wall cleanup series [-Wunused-value]
2024-10-09 20:50:00 -04:00
Darryl L. Miles c749d01eb7 rtrStem.c: fix: warning: statement with no effect
Looks like a logic bug hidden in the warning.

GCC14 -Wall cleanup series [-Wunused-value]
2024-10-09 20:50:00 -04:00
Darryl L. Miles cebb1a5277 lefTech.c: fix: default value logic error
Looks like a logic bug, hiding behind this compiler warning

lefTech.c:507:21: warning: suggest parentheses around assignment used as truth value
lefTech.c:509:21: warning: suggest parentheses around assignment used as truth value

GCC14 -Wall cleanup series [-Wparentheses]
2024-10-09 20:50:00 -04:00
Darryl L. Miles 4ea0f6a9b7 DBcellcopy.c: fix warning: self-comparison always evaluates to false
Looks like a straighforward logic bug from a recent (2023) change.

GCC14 -Wall cleanup series [-Wtautological-compare]
2024-10-09 20:50:00 -04:00
Darryl L. Miles 015f03307a appimage/Dockerfile: fix CentOS7 based docker build due to EOL
CentOS7 went EOL on June 30, 2024 this builds out of vault.centos.org
2024-10-09 20:40:28 -04:00
Darryl L. Miles 65a0dc45dc graphics: windowname[] potential buffer overrun warning
GCC14 loud default warnings series
2024-10-09 20:39:12 -04:00
Darryl L. Miles 63256f1a44 DBio.c: resolve warnings and use snprintf()
GCC14 loud default warnings series [-Wformat-overflow=]
2024-10-09 20:39:12 -04:00
Darryl L. Miles 1c326c9141 grouteCrss.c: '%s' directive writing up to 1023 bytes into a region of size 227
GCC14 loud default warnings series [-Wformat-overflow=]
2024-10-09 20:39:12 -04:00
Darryl L. Miles 6a08b31149 defWrite.: '%.10g' directive writing between 1 and 17 bytes into a region of size 12
GCC14 loud default warnings series [-Wformat-overflow=]
2024-10-09 20:39:12 -04:00
Darryl L. Miles 9f88450243 niceabort.c: '%s' directive writing up to 199 bytes into a region of size 177
GCC14 loud default warnings series [-Wformat-overflow=]
2024-10-09 20:39:12 -04:00
Darryl L. Miles 29bd23d40b txOutput.c:408: warning: missing sentinel in function call
GCC false positive, seems pedantic over it being NULL not 0.

GCC14 loud default warnings series [-Wformat=]
2024-10-09 20:39:12 -04:00
Darryl L. Miles bf916d2647 SimRsim.c: directive writing 1 byte into a region of size between 0 and 255
GCC14 loud default warnings series [-Wformat-overflow=]
2024-10-09 20:39:12 -04:00
Darryl L. Miles b81e04eed4 ResPrint.c: '%s' directive writing 2 bytes into a region of size between 1 and 1000
GCC14 loud default warnings series [-Wformat-overflow=]
2024-10-09 20:39:12 -04:00
Darryl L. Miles 41913fbd78 ExtUnique.c: '_uq' directive writing 3 bytes into a region of size between 1 and 1024
GCC14 loud default warnings series [-Wformat-overflow=]
2024-10-09 20:39:12 -04:00
Darryl L. Miles 66734bbaee ExtHier.c: format '%ld' expects argument of type 'long int', but .. 'dlong'
GCC14 loud default warnings series
2024-10-09 20:39:12 -04:00
Darryl L. Miles b3cb528e46 ExtBasic.c: comparison between pointer and integer
GCC14 loud default warnings series
2024-10-09 20:39:12 -04:00
Darryl L. Miles 1ae4518846 DLONG_PREFIX is %ld on x86_64 LP64
GCC14 loud default warnings fix
2024-10-09 20:39:12 -04:00
Darryl L. Miles 32a7323287 SimSelect.c: type defaults to 'int' in declaration of 'RsimErrorMsg'
GCC14 --without-tk --without-tcl
Related issue: https://github.com/RTimothyEdwards/magic/issues/323
2024-10-09 20:35:19 -04:00
Darryl L. Miles 932deeaf2d readline: define _XOPEN_SOURCE at the top of files
It is a requirement to define feature_test_macros(7) as soon as possible
before including any files, otherwise the headers may not allow further
configuration, as reconfiguration maybe denied.  You need to pick the
standard you wish to work with for the compilation unit (the file).

This can be seen with an error for lack of symbol `wcwidth()` from wchar.h

Moving the order slightly fixes the compile failure issue.
See feature_test_macros(7) for more info.

GCC14 --without-tk --without-tcl (without system libreadline-dev)
2024-10-09 20:35:19 -04:00
Darryl L. Miles 54f49829f2 graphics: multiple definition of `various_x11_symbols'
Solution is to make the grX11thread.c and grX11su1[5].c versions
the official location.  Another solution maybe to split them into
their own file grX11common.c that would be shared.

Multiple configurations tested, tested configurations assume X11
is available.  The configuration wording indicates X11 must be
available for all graphics enabled build configurations.

Affected symbols appear to have multiple definitions:
grCursors
grXdpy
grXscrn
pipeRead
pipeWrite
Xhelper
grVisual

GCC14 and linker will not link the final executable due to this.

GCC14 --without-tk --without-tcl
Related issue: https://github.com/RTimothyEdwards/magic/issues/323
2024-10-09 20:35:19 -04:00
Darryl L. Miles e5c3e703c3 HashLookOnly(): passing argument 2 of 'HashLookOnly' makes pointer from integer without a cast
Also HashFind()

GCC14 --without-tk --without-tcl
Related issue: https://github.com/RTimothyEdwards/magic/issues/323
2024-10-09 20:35:19 -04:00
Darryl L. Miles c90bde4961 DBWelement.c: passing argument 1 of 'TxPrintf' from incompatible pointer type
GCC14 --without-tk --without-tcl
Related issue: https://github.com/RTimothyEdwards/magic/issues/323
2024-10-09 20:35:19 -04:00
Darryl L. Miles 23930909b1 database/DBio.c: error: assignment to 'char *' from 'ClientData'
GCC14 --without-tk --without-tcl
Related issue: https://github.com/RTimothyEdwards/magic/issues/323
2024-10-09 20:35:19 -04:00
Darryl L. Miles 8994a68e61 DBPropGet(): error: assignment to 'char *' from 'ClientData'
GCC14 --without-tk --without-tcl
Related issue: https://github.com/RTimothyEdwards/magic/issues/323
2024-10-09 20:35:19 -04:00
Darryl L. Miles 0a4e2a5a27 HashGetValue: warning: comparison between pointer and integer
GCC14 --without-tk --without-tcl
Related issue: https://github.com/RTimothyEdwards/magic/issues/323
2024-10-09 20:35:19 -04:00
Tim Edwards de5c54e20b Added a missing description of the "flatten" property, which is
documented briefly in the "flatten" command reference page, but
no in the "property" command reference page.
2024-10-09 20:34:08 -04:00
Tim Edwards a3b61abe2b Corrected an error in which "extract unique noports" and
"extract unique notopports" both fail to work correctly because
an attempt some time ago to avoid issuing warnings about shorted
port names when using those options was changed in the wrong
line.
2024-10-07 11:48:27 -04:00
Tim Edwards 6162a9f459 Corrected the "bloat-all" function so that it behaves properly on
angled edges.  This is a rare case and so has never come up before,
but can happen especially on transistors with gate or diffusion
with 45 degree chamfers or flanges.  Thanks to Mark Martin for
providing the use case.
2024-10-03 20:37:43 -04:00
Darryl L. Miles 80f051f79d GHA: CI WASM build use --disable-compression
I assume it can't link to libz anyway, you'd need to rebuild libz
for WASM target (or use a the Web API for GZIP).
2024-10-01 21:18:55 -04:00
Darryl L. Miles 7589bdba10 GHA: BUMP actions/upload-artifact@v4 (from v3) 2024-10-01 21:18:55 -04:00
Darryl L. Miles 08affbe032 GHA: BUMP actions/checkout@v4 (from v2) 2024-10-01 21:18:55 -04:00
Darryl L. Miles a467154fec Update appimage.yml (rename job) 2024-10-01 21:18:55 -04:00
Tim Edwards e2c3eb3e20 Corrected the previous commit, which did not fix the problem that
it claimed to fix, but caused an incorrect DRC maxwidth check
instead.  The problem appears to be correctly resolved now.
Also:  Tracked down a recently-introduced minor issue in which
the interactive DRC stops running after issuing "drc check" and
does not resume until another key or mouse even occurs.  This
turned out to be caused by the work on the "logcommands" command,
which should have used "*bypass" before "logcommands suspend"
and "logcommands resume", since the "*bypass" indicates that
the command has no impact on layout and should not interrupt
the DRC checker.
2024-10-01 21:14:12 -04:00
Tim Edwards 3e0ad4ff58 Finally got around to restoring the behavior of the toolbar with
respect to using the 3rd mouse button to hide a layer, and
indicating the layer is hidden by blanking the icon (which works
better with the new scrollable icon list, but got broken by the
same).  Also:  Added a previously missing behavior, which is to
correctly update the icon settings based on using the command
"see" and "see no" with layer aliases (e.g., "allm1").
2024-10-01 16:01:28 -04:00
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 3638d382d6 fix: lef write crash (when cells with labels in space pNum==-1)
The issue here is can pNum==-1 which causes a crash.
2024-10-01 12:43:27 -04:00
Darryl L. Miles 18a4dddc2b fix: read of uninitialized data at inChar[0]
This is a defensive fix, might cause unexpected program exit if triggered.
The loop will iterate at least once when nbytes==0, but this value
indicates XLookupString did not fill in any data, so the entire buffer
is undefined.

Using memset() before or inChar[0]=0 after XLookupString did not fix
the issue.  Using inChar[0]=0 immediately before the loop did fix as
well.  But this patch seems to be the best approach.
2024-10-01 12:43:27 -04:00
Darryl L. Miles 1ca23ca0a2 fix: Accessing uninitialized variable
Trigger condition maybe that no labels exist in the project, so the
loop never iterates.
2024-10-01 12:43:27 -04:00
Darryl L. Miles 8e0f34c6f1 debug/hist.c Access .. results in a dereference of a null
Maybe this is only a bug if a call to HistAdd() is made before HistCreate().

SonarCloud
debug/hist.c:147 Access to field 'hi_cum' results in a dereference of a null pointer (loaded from variable 'h')
https://sonarcloud.io/project/issues?open=AZJB17kdNGfDNup0RkzB&id=dlmiles_magic
2024-10-01 12:36:13 -04:00
Darryl L. Miles 60fe6427da graphics/grX11su1.c: Dereference of null pointer
Looks like the code below requires w!=NULL to do anything useful.
So when w==NULL we don't continue processing X11 Event.

SonarCloud
graphics/grX11su1.c:895 Dereference of null pointer
https://sonarcloud.io/project/issues?open=AZJB163RNGfDNup0Ri4p&id=dlmiles_magic
2024-10-01 12:36:13 -04:00
Darryl L. Miles 01f9f2246b graphics/grX11su1.c: Dereference of null pointer
Looks like the code below requires w!=NULL to do anything useful.
So when w==NULL we don't continue processing X11 Event.

SonarCloud
graphics/grX11su1.c:842 Dereference of null pointer
https://sonarcloud.io/project/issues?open=AZJB163RNGfDNup0Ri4o&id=dlmiles_magic
2024-10-01 12:36:13 -04:00
Darryl L. Miles cb31675174 utils/geometry.c: non-void function does not return a value in all control paths
Had to pick a value to return by default.  This is a probably should never happen ?

SonarCloud
utils/geometry.c:589 non-void function does not return a value in all control paths
https://sonarcloud.io/project/issues?open=AZJB16DGNGfDNup0Rg7u&id=dlmiles_magic
2024-10-01 12:36:13 -04:00
Darryl L. Miles bfd818fbd3 textio/txInput.c non-void function does not return a value
This function is related to libreadline rl_pre_input_hook callback
which is invoked as (not making use of any function return value):

readline.c:    (*rl_pre_input_hook) ();

The general prototype for this function is:

rltypedefs.h:typedef int rl_hook_func_t PARAMS((void));

So the resolution is to provide a known value as the return value, which
resolves the concern.

SonarCloud
textio/txInput.c:550 non-void function does not return a value
https://sonarcloud.io/project/issues?open=AZJB17NwNGfDNup0Rj5G&id=dlmiles_magic
2024-10-01 12:36:13 -04:00
Darryl L. Miles ab747a0f8c grouter/groutePin.c: multiple: non-void function does not return a value
Multiple reports exists in this file

Affected functions:
 GLInitPins() now returns void
 glPinArrayInit() now returns void
 GLLinkPins() now returns void
 glPinArrayLink() now returns void
 GLFixStemPins() now returns void
 glPinArrayFixStems() now returns void

SonarCloud
https://sonarcloud.io/project/issues?open=AZJB17L0NGfDNup0Rj0D&id=dlmiles_magic
2024-10-01 12:36:13 -04:00
Darryl L. Miles 8b2efd5d7d gcr/gcrDebug.c Opened stream never closed. Potential resource leak
A false positive in practice, made clearer by using a 2nd variable
with attention drawing name.

SonarCloud
gcr/gcrDebug.c:429 Opened stream never closed. Potential resource leak
https://sonarcloud.io/project/issues?open=AZJB17OzNGfDNup0Rj-t&id=dlmiles_magic
2024-10-01 12:36:13 -04:00
Darryl L. Miles 0cea17e801 utils/magic.h pointertype prefer use of 'long' instead of 'int'
It is usual for a pointer to require the largest width, while some
platforms might have an 'int' that is smaller than a pointer width.

This reverses the detection order to find.

Note since C99 there is <stdint.h> with type 'intmax_t' which
serves a similar purpose.

SonarCloud reports a concern with this on many lines where used.
"An integral type is too small to hold a pointer value."
https://sonarcloud.io/project/issues?open=AZJB17ZoNGfDNup0RkY_&id=dlmiles_magic
2024-10-01 12:36:13 -04:00
Darryl L. Miles a0aea2aa2e gcr/gcrDebug.c Add a field width specifier to this "%s" placeholder.
Unbounded local buffer used in fscanf() string extraction call.
Add width to specified to ensure truncation as 24 character instead
of buffer overflow.

SonarCloud https://sonarcloud.io/project/issues?open=AZJB17OzNGfDNup0Rj9x&id=dlmiles_magic
2024-10-01 12:36:13 -04:00
Darryl L. Miles 29ee094074 graphics/grOGL1.c Dereference of null pointer
Looks like the code below requires mw!=NULL to do anything useful.
So when mw==NULL we don't continue processing X11 Event.

SonarCloud
graphics/grOGL1.c:563 Dereference of null pointer
https://sonarcloud.io/project/issues?open=AZJB16z6NGfDNup0Riss&id=dlmiles_magic
2024-10-01 12:36:13 -04:00
Darryl L. Miles be258c6557 graphics/grOGL1.c: non-void function does not return a value
Making oglSetProjection() return void, like toglSetProjection()

SonarCloud
graphics/grOGL1.c:408 non-void function does not return a value
https://sonarcloud.io/project/issues?open=AZJB16z6NGfDNup0Riro&id=dlmiles_magic
2024-10-01 12:36:13 -04:00
Darryl L. Miles ae0cdd9fea graphics/grClip.c Branch condition evaluates to a garbage value
This is technically a false positive as grClipPoints() will always
initializes a value to ok1 and ok2 when called.  The function is in
the same compile unit, so probably the compiler can see this as well
and potentially not perform the initiailization begin performed in
this commit.

But to quieten and remove this item from the analysis report
assigning an initialization value.

SonarCloud
graphics/grClip.c:451 Branch condition evaluates to a garbage value
https://sonarcloud.io/project/issues?open=AZJB160MNGfDNup0Rit4&id=dlmiles_magic
2024-10-01 12:36:13 -04:00
Darryl L. Miles 10442b6534 graphics/cairo_orig/grTCairo5.c uninitialized local variable
Looks like old code.  Based on cairo_fill() action state this is initialized to
no-op by default.

SonarCloud
graphics/cairo_orig/grTCairo5.c:107 The left operand of '!=' is a garbage value
https://sonarcloud.io/project/issues?open=AZJB16wANGfDNup0RiiZ&id=dlmiles_magic
2024-10-01 12:36:13 -04:00
Darryl L. Miles 5e00e3fe1b graphics/cairo_orig/grTCairo3.c uninitialized value
Looks like old code.  Looks like local variable 'j' could be removed.
Initialization lowers the severity of concern in this area.
The 'j' variable is now written but never read.

SonarCloud
graphics/cairo_orig/grTCairo3.c:492
The left expression of the compound assignment is an uninitialized value. The computed value will also be garbage
https://sonarcloud.io/project/issues?open=AZJB16voNGfDNup0Rig_&id=dlmiles_magic
2024-10-01 12:36:13 -04:00
Darryl L. Miles a9b707460b garouter/gaChannel.c use of unintialized or incorrect variable
This resolution assumes that all records and values of ch->gcr_type are expected
to be one of the 3 cases in the switch.  The bug it on the first iteration it is
possible 'tot' and 'clear' is just not initializaed and on a subsequent iteration
it is possible it ot setup to the previous interation values.

SonarCloud
garouter/gaChannel.c:385:3rd function call argument is an uninitialized value
https://sonarcloud.io/project/issues?open=AZJB17fFNGfDNup0RkoE&id=dlmiles_magic
2024-10-01 12:36:13 -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 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 L. Miles 48853b98a3 calma/CalmaRead.c missing initialization
An FEOF exit path exists in READRH() which causes the output
variable(s) to not be assigned a value, then the code makes
a decision (branch) based on uninitialized data.

SonarCloud detection
CalmaRead.c:359:The left operand of '!=' is a garbage value
https://sonarcloud.io/project/issues?open=AZJB17gSNGfDNup0Rkp5&id=dlmiles_magic
2024-10-01 12:36:13 -04:00
Darryl L. Miles 290887912f ext2spice/ext2hier.c: Wrong type of arguments to formatting function
Applied the same fixes as other commits already merged into file.

Copilot Autofix: Error contact support...

CodeQL: https://github.com/dlmiles/magic/security/code-scanning/38
        https://github.com/dlmiles/magic/security/code-scanning/39
        https://github.com/dlmiles/magic/security/code-scanning/41
2024-10-01 12:36:13 -04:00
Darryl L. Miles 62ebf49758 mzrouter/mzEstimate.c: (intmax_t) %lx Wrong type of arguments to formatting function
Copilot Autofix rejected: TxPrintf("\ntile %p\t\t  (x: %d to %d, y: %d to %d)\n",

CodeQL: https://github.com/dlmiles/magic/security/code-scanning/102
2024-10-01 12:36:13 -04:00
Darryl L. Miles 7509802b3d mzrouter/mzDebug.c: (intmax_t) %lx Wrong type of arguments to formatting function
Copilot Autofix rejected: TxPrintf("tile %p  (x: %d to %d, y: %d to %d)\n"

CodeQL: https://github.com/dlmiles/magic/security/code-scanning/101
2024-10-01 12:36:13 -04:00
Darryl Miles 2c8c60510b plot/plotRutils.c: Multiplication result converted to larger type
Fix code scanning alert no. 56: Multiplication result converted to larger type (#67)

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 14a1b21fb6 extract/ExtHier.c: Wrong type of arguments to formatting function
Fix code scanning alert no. 159: Wrong type of arguments to formatting function (#66)

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 L. Miles 4dc708aea2 ext2spice/ext2spice.c: Multiplication result converted to larger type
Applying similat fix to others in the file, promote to double ASAP.

Copilot Autofix: Retry and if the problem persists contact support.

CodeQL: https://github.com/dlmiles/magic/security/code-scanning/46
2024-10-01 12:36:13 -04:00
Darryl Miles 98b5f57ea0 ext2spice/ext2spice.c: Multiplication result converted to larger type
Fix code scanning alert no. 48: Multiplication result converted to larger type (#63)

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 3becc0e03f ext2spice/ext2spice.c: Multiplication result converted to larger type
Fix code scanning alert no. 47: Multiplication result converted to larger type (#62)

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 a6db54c0b7 ext2spice/ext2spice.c: Multiplication result converted to larger type
Fix code scanning alert no. 45: Multiplication result converted to larger type (#61)

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 7e04089872 ext2spice/ext2spice.c: Multiplication result converted to larger type
Fix code scanning alert no. 44: Multiplication result converted to larger type (#60)

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 cde5418e7d ext2spice/ext2spice.c: Multiplication result converted to larger type
Fix code scanning alert no. 43: Multiplication result converted to larger type (#59)

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 9327388ae0 ext2spice/ext2hier.c: Multiplication result converted to larger type
Fix code scanning alert no. 42: Multiplication result converted to larger type (#65)

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 147ca7a61f ext2spice/ext2hier.c: Multiplication result converted to larger type
Fix code scanning alert no. 40: Multiplication result converted to larger type (#64)

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 fe39d889f0 plot/plotRutils.c: Multiplication result converted to larger type
Fix code scanning alert no. 54: Multiplication result converted to larger type (#56)

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 86a6551f9b ext2spice/ext2hier.c: Multiplication result converted to larger type
Fix code scanning alert no. 37: Multiplication result converted to larger type (#58)

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 82bec60ccf ext2spice/ext2hier.c: Multiplication result converted to larger type
Fix code scanning alert no. 36: Multiplication result converted to larger type (#57)

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 691c27081f drc/DRCcif.c: Multiplication result converted to larger type
Fix code scanning alert no. 34: Multiplication result converted to larger type (#54)

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 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 d8b886aa1d debug/debugFlags.c: Wrong type of arguments to formatting function
Fix code scanning alert no. 67: Wrong type of arguments to formatting function (#45)

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 846f2b4cb1 debug/debugFlags.c: Wrong type of arguments to formatting function
Fix code scanning alert no. 68: Wrong type of arguments to formatting function (#46)

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 40f96faff8 plot/plotPNM.c: Multiplication result converted to larger type
Fix code scanning alert no. 55: Multiplication result converted to larger type (#47)

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 5ffc74d915 lef/defWrite.c: Multiplication result converted to larger type
Fix code scanning alert no. 53: Multiplication result converted to larger type (#48)

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 1a351efd56 extract/ExtBasic.c: Multiplication result converted to larger type
Fix code scanning alert no. 52: Multiplication result converted to larger type (#49)

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 00086817a4 extract/ExtCouple.c: Multiplication result converted to larger type
Fix code scanning alert no. 51: Multiplication result converted to larger type (#50)

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 d6cc790d48 extflat/EFvisit.c: Multiplication result converted to larger type
Fix code scanning alert no. 50: Multiplication result converted to larger type (#51)

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 6cae64edc5 drc/DRCbasic.c: Multiplication result converted to larger type
Fix code scanning alert no. 35: Multiplication result converted to larger type (#53)

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 5a8cdb68d0 ext2spice/ext2spice.c: Multiplication result converted to larger type
Fix code scanning alert no. 49: Multiplication result converted to larger type (#52)

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 f809b2dfac graphics/grTk1.c: Wrong type of arguments to formatting function
Fix code scanning alert no. 98: Wrong type of arguments to formatting function (#44)

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 9096946a12 windows/windDebug.c: Wrong type of arguments to formatting function
Fix code scanning alert no. 130: Wrong type of arguments to formatting function (#43)

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 3848ec7b4e extract/ExtHier.c: Wrong type of arguments to formatting function
Fix code scanning alert no. 71: Wrong type of arguments to formatting function (#37)

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 L. Miles 2703f55449 extract/ExtTest.c: Too few arguments to formatting function
A bit of a guess based on context.

CodeQL: https://github.com/dlmiles/magic/security/code-scanning/58
        https://github.com/dlmiles/magic/security/code-scanning/59
2024-10-01 12:36:13 -04:00
Darryl Miles 4ddd0624cb gcr/gcrDebug.c: Wrong type of arguments to formatting function
Fix code scanning alert no. 97: Wrong type of arguments to formatting function (#41)

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 L. Miles fc20977fa5 gcr/gcrDebug.c: (intmax_t) %ld Wrong type of arguments to formatting function
Mutiple items per line.

CodeQL: https://github.com/dlmiles/magic/security/code-scanning/87
2024-10-01 12:36:13 -04:00
Darryl L. Miles aa703a67b7 resis/ResDebug.c: %.2f Wrong type of arguments to formatting function
Applied same fix as other patch for line below;

Copilot Autofix: did not infer the same fix for same vaiable from line next to it.

CodeQL: https://github.com/dlmiles/magic/security/code-scanning/158
2024-10-01 12:36:13 -04:00
Darryl Miles d1dc038cb7 windows/windDisp.c: Redundant null check due to previous dereference
Fix code scanning alert no. 133: Redundant null check due to previous dereference (#40)

* Update windDisp.c

* DLM - AI wanted to guard the '*area' dereference in if() statement, but the code path above has address of '&' operator for the assignment to 'area' so it must always be non-null.  So I rejected this approach and removed the extra null check, replacing it with an assert().

---------

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 f976005d2d resis/ResMerge.c: Too few arguments to formatting function
Fix code scanning alert no. 64: Too few arguments to formatting function

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 3c90bbbe1f lef/defWrite.c: Call to function with fewer arguments than declared parameters
Fix code scanning alert no. 23: Call to function with fewer arguments than declared parameters (#38)

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 L. Miles f69b02b092 sim/SimExtract.c: extEnumTilePerim() Call to function with fewer arguments than declared parameters
This is a complete guess based on function parameter types and the locallity of the 'pNum' value.

This error predates the 2017 Initial Commit git history.

Copilot Autofix rejected: extEnumTilePerim(tile, devptr->exts_deviceSDTypes[i],
   SimTransTerms, (ClientData) &transistor, (ClientData) NULL );

CodeQL: https://github.com/dlmiles/magic/security/code-scanning/26
2024-10-01 12:36:13 -04:00
Darryl Miles fdc81f5eec windows/windDebug.c: Wrong type of arguments to formatting function
Fix code scanning alert no. 129: Wrong type of arguments to formatting function (#24)

* Update windDebug.c

* AI wanted "%p", DLM changed to (intmax_t) "%lx"

---------

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 cf90d50999 grouter/grouteMaze.c: Wrong type of arguments to formatting function
* Fix code scanning alert no. 99: Wrong type of arguments to formatting function

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* Update grouteMaze.c

---------

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 77c1082886 grouter/grouteTest.c: Wrong type of arguments to formatting function
Fix code scanning alert no. 100: Wrong type of arguments to formatting function (#31)

* Update grouteTest.c

* AI suggested just "%p", DLM modified to used intmax_t cast.

---------

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 21924ec151 extract/ExtTech.c: Too few arguments to formatting function
Fix code scanning alert no. 61: Too few arguments to formatting function (#35)

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 66297bd7d0 extract/ExtTech.c: Too few arguments to formatting function
Fix code scanning alert no. 60: Too few arguments to formatting function (#36)

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 L. Miles 4359aa8d4b commands/CmdWizard.c: %x => (intmax_t) %lx
Wrong type of arguments to formatting function

Looks like SPICE comment, change maintains hex without 0x prefix in portable way.

Copilot Autofix rejected: TxPrintf("%p\n", tp);

CodeQL: https://github.com/dlmiles/magic/security/code-scanning/65
2024-10-01 12:36:13 -04:00
Darryl L. Miles 4f5eb7da2d ext2spice/ext2spice.c: %x => (intmax_t) %lx
Wrong type of arguments to formatting function

Looks like SPICE comment, change maintains hex without 0x prefix in portable way.

Copilot Autofix rejected: TxError("** %s (%p)\n", nsn, node);

CodeQL: https://github.com/dlmiles/magic/security/code-scanning/70
2024-10-01 12:36:12 -04:00
Darryl Miles 0619cf4291 extract/ExtBasic.c: Incorrect return-value check for a 'scanf'-like function
Fix code scanning alert no. 140: Incorrect return-value check for a 'scanf'-like function (#23)

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 c16c770d7a extract/ExtBasic.c: Incorrect return-value check for a 'scanf'-like function
Fix code scanning alert no. 138: Incorrect return-value check for a 'scanf'-like function (#22)

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 91ec4e4cb8 resis/ResRex.c: Wrong type of arguments to formatting function
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 9f39380b6a resis/ResDebug.c: Wrong type of arguments to formatting function
Fix code scanning alert no. 109: Wrong type of arguments to formatting function (#27)

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 6946ea6845 plow/PlowTest.c: Wrong type of arguments to formatting function
Fix code scanning alert no. 106: Wrong type of arguments to formatting function (#30)

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 384e59ea98 plow/PlowTest.c: Wrong type of arguments to formatting function
Fix code scanning alert no. 104: Wrong type of arguments to formatting function (#29)

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 318993cb7b plow/PlowTest.c: Wrong type of arguments to formatting function
Fix code scanning alert no. 103: Wrong type of arguments to formatting function (#28)

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 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 L. Miles e896377ead extflat/EFantenna.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/16
2024-10-01 12:36:12 -04:00
Darryl L. Miles 4d81a77bf3 extcheck/extcheck.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: none (grep found this?)
2024-10-01 12:36:12 -04:00
Darryl L. Miles c8e00ef494 ext2spice/ext2spice.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/20
        https://github.com/dlmiles/magic/security/code-scanning/21
        https://github.com/dlmiles/magic/security/code-scanning/22
2024-10-01 12:36:12 -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
Darryl L. Miles 1360f962a1 calma/CalmaRdcl.c: calmaFindCell() Call to function with fewer arguments than declared parameters
The 'predefined' pointer argument to calmaFindCell() is for an optional return value, so must be
NULL when feature is not used.

Copilot Autofix rejected: newdef = calmaFindCell(newname, someSecondArgument);

calma/CalmaRdcl.c
1c822652 (2020-12-04 16:56:51 -0500 1359)     bool *predefined; /* If this cell was in memory before the GDS
1c822652 (2020-12-04 16:56:51 -0500 1360)                        * file was read, then this flag gets set.
1c822652 (2020-12-04 16:56:51 -0500 1361)                        */

commit 1c82265244 (tag: mpw-one-a, tag: 8.3.92)
Date:   Fri Dec 4 16:56:51 2020 -0500

CodeQL: https://github.com/dlmiles/magic/security/code-scanning/6
        https://github.com/dlmiles/magic/security/code-scanning/5
2024-10-01 12:36:12 -04:00
Darryl L. Miles 7feec63580 cif/CIFgen.c: CmdFindNetProc() Call to function with fewer arguments than declared parameters
The 'isvalid' pointer argument to CmdFindNetProc() is for an optional return value, so must be
NULL when feature is not used.

Copilot Autofix rejected: ttype = CmdFindNetProc(netname, CIFDummyUse, &bbox, FALSE, additional_arg1, additional_arg2);

commands/CmdFI.c
cfb81101 (2022-03-30 13:02:12 -0400 1584)     bool *isvalid;

commit f89d52dbcc (tag: 8.3.253)
Date:   Thu Jan 6 13:29:43 2022 -0500

CodeQL: https://github.com/dlmiles/magic/security/code-scanning/7
2024-10-01 12:36:12 -04:00
Darryl L. Miles ce1e027c55 resis/ResSimple.c: ResGetDevice(): Call to function with fewer arguments than declared parameters
gparams.rg_ttype seems to be the only value of the correct type that has connectivity with the callsite.

Copilot Autofix rejected: ResGetDevice(gparams.rg_devloc, /* second argument */);

resis/ResSimple.c
9aa39f82 (2021-05-25 22:41:52 -0400 1039)           resDevice *res = ResGetDevice(gparams.rg_devloc);

commit 9aa39f820f (tag: 8.3.169)
Date:   Tue May 25 22:41:52 2021 -0400
2024-10-01 12:36:12 -04:00
Darryl L. Miles d297b99953 select/selOps.c: CmdFindNetProc() Call to function with fewer arguments than declared parameters
The 'isvalid' pointer argument to CmdFindNetProc() is for an optional return value, so must be
NULL when feature is not used.

Copilot Autofix rejected: ttype = CmdFindNetProc(lab1, use, &rect, FALSE, additionalArg);

commands/CmdFI.c
cfb81101 (2022-03-30 13:02:12 -0400 1584)     bool *isvalid;

commit f89d52dbcc (tag: 8.3.253)
Date:   Thu Jan 6 13:29:43 2022 -0500

CodeQL: https://github.com/dlmiles/magic/security/code-scanning/25
2024-10-01 12:36:12 -04:00
Darryl L. Miles fff3be2f29 utils/main.c: DefRead() Call to function with fewer arguments than declared parameters
Resolution maintains behaviour closest to original behaviour from a37fc1e2

Copilot Autofix no offered.

related git blame lef/defRead.c:
cfb81101 (2022-03-30 13:02:12 -0400 2388)     bool annotate;
f7df5e7c (2022-06-24 15:22:53 -0400 2389)     bool noblockage;

related commits:

commit cfb81101ec
Date:   Wed Mar 30 13:02:12 2022 -0400

commit f7df5e7c86 (tag: 8.3.315)
Date:   Fri Jun 24 15:22:53 2022 -0400

commit a37fc1e242
Date:   Thu Mar 5 14:29:54 2020 -0500

CodeQL: https://github.com/dlmiles/magic/security/code-scanning/29
2024-10-01 12:36:12 -04:00
Darryl L. Miles 3db35216b9 utils/main.c: LefRead() Call to function with fewer arguments than declared parameters
Looks like -1 is accepted as placeholder, maybe it should be the
temporary->fn (filename mtime?).

Copilot Autofix rejected: LefRead(temporary->fn, FALSE, NULL);

related git blame utils/main.c:
8e80644d (2022-01-22 13:30:11 -0500 2078)     int lefTimestamp;         /* If not -1, use the value pointed to
8e80644d (2022-01-22 13:30:11 -0500 2884)     int lefTimestamp;

related commit:
commit 8e80644dd7
Date:   Sat Jan 22 13:30:11 2022 -0500

CodeQL: https://github.com/dlmiles/magic/security/code-scanning/28
2024-10-01 12:36:12 -04:00
Darryl L. Miles 49f4daa715 utils/main.c: Call to function with fewer arguments than declared parameters
Copilot Autofix rejected: DBFileRecovery(MainFileName);

database/DBio.c looks to take NULL as a value for automatic recovery.

Related commits:
commit 231a299b16 (tag: 8.2.0)
Date:   Tue Apr 25 08:41:48 2017 -0400
    Initial commit at Tue Apr 25 08:41:48 EDT 2017 by tim on stravinsky
2024-10-01 12:36:12 -04: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
Darryl Miles 88a1a9b166 utils/undo.c: Wrong type of arguments to formatting function
Fix code scanning alert no. 120: Wrong type of arguments to formatting function (#17)

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 9f052c0e4d utils/undo.c: Wrong type of arguments to formatting function
Fix code scanning alert no. 117: Wrong type of arguments to formatting function (#16)

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 8f60ed472b textio/txCommands.c: Wrong type of arguments to formatting function
Fix code scanning alert no. 116: Wrong type of arguments to formatting function (#19)

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 a307e9d052 textio/txCommands.c: Wrong type of arguments to formatting function
Fix code scanning alert no. 115: Wrong type of arguments to formatting function (#20)

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 9295240047 textio/txCommands.c: Wrong type of arguments to formatting function
Fix code scanning alert no. 114: Wrong type of arguments to formatting function (#21)

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 c89455782b cmwind/CMWcmmnds.c: Incorrect return-value check for a 'scanf'-like function
Fix code scanning alert no. 134: Incorrect return-value check for a 'scanf'-like function (#13)

* Create codeql.yml

* Fix code scanning alert no. 134: 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 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 Miles 2a00ab7eb8 extract/ExtTech.c: Incorrect return-value check for a 'scanf'-like function
Fix code scanning alert no. 136: Incorrect return-value check for a 'scanf'-like function (#11)

* Create codeql.yml

* Fix code scanning alert no. 136: 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 Miles e66e3b32ad extract/ExtBasic.c: Incorrect return-value check for a 'scanf'-like function
Fix code scanning alert no. 149: Incorrect return-value check for a 'scanf'-like function (#10)

* Create codeql.yml

* Fix code scanning alert no. 149: 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 Miles 96c7e283c0 gcr/gcrDebug.c: Incorrect return-value check for a 'scanf'-like function
Fix code scanning alert no. 137: Incorrect return-value check for a 'scanf'-like function (#9)

* Create codeql.yml

* Fix code scanning alert no. 137: 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 Miles 4ca98dc31b graphics/grCMap.c: Incorrect return-value check for a 'scanf'-like function
Fix code scanning alert no. 150: Incorrect return-value check for a 'scanf'-like function (#8)

* Create codeql.yml

* Fix code scanning alert no. 150: 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>

* Update grCMap.c

* AI suggested '< 1', DLM edited to '<= 0' easier for a human to reason about ?

---------

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 39e76f3f31 graphics/grDStyle.c: Incorrect return-value check for a 'scanf'-like function
Fix code scanning alert no. 151: Incorrect return-value check for a 'scanf'-like function (#7)

* Create codeql.yml

* Fix code scanning alert no. 151: 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>

* Update grDStyle.c

* AI suggested '< 1', DLM edited to '<= 0' easier for a human to reason about ?

---------

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 64d94ae588 router/rtrCmd.c: Incorrect return-value check for a 'scanf'-like function
Fix code scanning alert no. 156: Incorrect return-value check for a 'scanf'-like function (#6)

* Create codeql.yml

* Fix code scanning alert no. 156: 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 Miles 4374a1918e lef/defWrite.c: Too few arguments to formatting function
Fix code scanning alert no. 63: Too few arguments to formatting function (#3)

* Create codeql.yml

* Fix code scanning alert no. 63: Too few arguments to formatting 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 Miles 51b8161a21 lef/defWrite.c: Too few arguments to formatting function
Fix code scanning alert no. 62: Too few arguments to formatting function (#1)

* Create codeql.yml

* Fix code scanning alert no. 62: Too few arguments to formatting 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 Miles fed93c200d gcr/gcrShwFlgs.c: Likely overrunning write
Fix code scanning alert no. 2: Likely overrunning write (#5)

* Fix code scanning alert no. 2: Likely overrunning write

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* Update gcrShwFlgs.c

* AI added snprintf(), DLM increased buffer for enough space for rounded/aligned 64bit %p

---------

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 f3b08ad470 Corrected an error that was introduced in the August 3 commit and
which prevents the "Ctrl-P" key from raising the .params window;
the underlying error is that the original error in the "property"
command was a disagreement about where "argstart" is placed.  The
command was fixed to make the "property" command work correctly.
However, the solution made "argstart" wrong when using the command
"cellname property".  Now both uses are handled correctly.
2024-09-25 21:26:41 -04: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 974621ebe7 Corrected a missing pointer to integer cast in code that was
added fairly recently when getting rid of crashes related to
commands operating on non-edit cells.  The lack of a cast was
prevening compilation on systems with more rigorous error
checking.
2024-08-30 01:48:38 -04:00
Tim Edwards 0c36365db8 Revised the file opening routine with respect to the search paths.
Previously, a file path beginning with "/", "./", or "../" would be
searched for verbatim and no searching would be done over paths.
This behavior now occurs for a leading "/" only.  File paths with
"./" or "../" will search for the file with the path verbatim, then
proceed to search for the file with each search path prepended to
the filename as usual.  This solves a problem for reusable, non- PDK
IP blocks, where the IP block may have an abstract view pointing to
a GDS file which is specified as being located at "../gds/<file>".
This file would not be found if the IP block was included into
another project.  Now it can be done if the path to the IP is given
by "addpath".
2024-08-16 17:45:10 -04:00
Tim Edwards f3bfde60f0 Change to ext2spice which should solve the problem of ports no
longer being output in order after flattening a circuit.
2024-08-06 11:17:27 -04:00
Tim Edwards 155f19a6d8 Corrected an issue causing a crash condition when using "extract
unique" on a flattened layout (some labels end up NULL and the
NULL condition needs to be checked).  Also remembered to update
VERSION, which was missed on the last commit.
2024-08-04 11:37:54 -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 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 291ba96285 Corrected a bad statement running Tcl_NewListObj() that fails to
assign the result to anything, causing later uses of variable
"lobj" to have an unitialized value and potentially causing a
crash condition.  Thanks to Risto Bell for pointing out the
error.
2024-05-13 21:51:59 -04:00
Tim Edwards e4c28ef3bf Corrected an issue introduced in version 8.3.471 when trying to fix
some of the "select" command syntax;  the code change caused the
"select top cell" command to behave the same as "select cell".
There was no specific code for handling "top", so now there is.
2024-05-12 15:54:40 -04:00
Tim Edwards f0c3ec33d6 Modified the "lef nocheck" command to take the argument "*", meaning
that no nets will be checked for antenna gate and diffusion area,
and no antenna properties will be output to the LEF file.  This can
greatly speed up LEF output file generation for a large design.
Thank you to Tamas Hubai for the code patch.
2024-05-11 20:48:35 -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 fd2b1eb9ee Added code that when running "extract unique" always prefers to
change a non-port label name instead of a port name whenever it
finds one of each with the same text on different nets.
2024-05-07 16:20:35 -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 efccdbf341 Made some changes to the extresist code to handle the case where
a transistor's first tile record is a well or substrate type;
normally this is avoided, but if that's the only device terminal
that connects to the node, it will be used.  Also changed the
code to not report a failure when space is found under the
device, when space is allowed as a substrate type.  Instead it
will print a message that the substrate is not being extracted as
a resistive network.  However, note that the correct solution is
to do what the regular "extract" code does, which is to paint the
substrate type in the cell area first, so that there are valid
tile types to use for extracting the substrate network.
2024-05-04 20:16: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 fe9ca3a4ce Corrected the routine that parses MASKHINTS_* in cell properties to
avoid an infinite loop in the case that the mask hint does not have
a number of values that is a multiple of 4.
2024-05-01 13:45:00 -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 41e65b5214 Committing a patch to prevent segfaulting during "extresist" when
non-Manhattan geometry is analyzed for resistance extraction.
This patch merely prevents the crash condition.  It does not
solve the root of the problem, which is that split tiles can
belong to two different nets, but the tile can hold extraction
information for at most one of those nets.
2024-04-16 20:51:52 -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 82d64aa4b1 Corrected an issue with passing a Tcl script as a command-line
argument.  For interactive magic in the Tcl/Tk wrapper, the
"-nowindow" option was appended to the command line.  But for
Tcl scripts on the command line, all arguments following the
script name are considered arguments of the script.  So the
"-nowindow" argument has to be inserted at the beginning of
the command line as the first argument after "magic".
2024-04-10 20:51:05 -04:00
Tim Edwards 60049f3702 Modified the "select" command routine to get rid of the very hack
method of messing with the argument count when using qualifiers
like "less" and "more".  Now it keeps a separate count of the
number of non-qualifier arguments.
2024-04-08 17:59:53 -04:00
Tim Edwards 38d890c407 Made a slight modification to the "lef write -hide" routine;
previously, MASTERSLICE layers would not be added to obstruction
layers made by "-hide".  However, an nwell, for example, that
stuck outside of a prBoundary *would* be recorded, which was
inconsistent.  Resolved this by allowing MASTERSLICE layers
in the OBS block, but only for layers that are not a substrate
type.  NOTE:  It may be better to just insist that a MASTERSLICE
layer define an obstruction type in the "lef" section of the
tech file, and treat it like routing obstructions.  Alternatively,
one may question whether special obstruction types are needed at
all, as one could simply define an obstruction as a type without
a port label.
2024-04-08 14:10:46 -04:00
Tim Edwards 71f4dd2f9f Discovered that the non-Euclidean distance checks had not been
completely implemented for the "cifwidth" and "cifspacing" rules,
resulting in those rules being Manhattan distance checks.  Finished
the implementation (duplicating code from DRCbasic.c, with
appropriate scaling to CIF coordinates).
2024-04-06 16:36:31 -04:00
Tim Edwards 8b3524575f Corrected the failure to copy mask hints to the flattened DRC yank
cell.  Otherwise, DRC errors corrected by mask hints will get
flagged.
2024-04-06 15:03:37 -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 9800d98dee Corrects "ext2spice hierarchy off" when subcircuits with ports are
present.  Note, however, this fix breaks the use of "ext2spice
subcircuit descend off" because subcircuits are always descended
into.  It's not clear that "subcircuit descend off" worked at all
before, anyway.  That still needs fixing.
2024-04-02 21:55:57 -04:00
Tim Edwards d0f6dab896 Corrected issue from github issue tracker #297, where "Import SPICE"
fails on instances with names containing brackets.
2024-04-01 16:42:10 -04:00
Tim Edwards bfd938b5e2 Correction to the previous bug fix: The layer was correct and
did not need to be changed, but the line below it that depended
on the layer being a contact type was wrong;  the contact had
to be identified independently of the last layer type, which
might not be the contact cut type.
2024-03-20 22:15:41 -04:00
Tim Edwards fede9d5c4d Fixed an error when reading a DEF file using generated vias in a
non-default rule.  The code was first failing to identify the via
cut type from the generated via record, and then it was failing
to return to the non-default rule width after the route exits the
via.  Both issues have been fixed.  Thanks to Sylvain Munaut for
providing a reproducible test case.
2024-03-20 17:19:45 -04:00
Tim Edwards 54773957c9 Corrected an issue with annotating a layout from a LEF file; if
new port labels are created for an existing port, then they must
take the existing port number.  The code was previously causing
collisions between port numbers on different pins.
2024-03-18 16:25:49 -04:00
Tim Edwards cb73ebfab0 Corrected an error in lefWrite where SelectClear() is called
without SelectRootDef being set, which causes SelectClear() to
return without doing anything.  However---question is why
SelectClear() needs SelectRootDef to be non-NULL since it is
clearing the selection, not the selection source.  For now, just
patching the failing case, not trying to mess with the whole
selection mechanism.
2024-03-08 12:28:29 -05:00
Tim Edwards eeeaf49ec7 Corrected an error in defGetType() that incorrectly looks at a
lefLayer's "via" record even when the layer might not be a via,
causing potential issues with uninitialized variables.  Not sure
if this is related to the bug that started this investigation,
but it was the only thing that looked relevant.
2024-03-08 09:33:13 -05:00
Tim Edwards 191bff6c47 Modified the schematic-to-layout script to be better at being
used in a re-entrant manner.  Applied to an existing layout,
it will no longer keep generating new instances and ports over
top existing ones.  Could use improvement by attempting to
retain the location of a device when the instance changes
device type (such as when a device parameter was changed in
the netlist).  However, the current set of changes should
help, whether the re-entrant use is purposeful or accidental.
2024-02-27 15:41:17 -05:00
Tim Edwards 3691b53dde Was given a use case by Carsten Wulff (github issue #289) that
fails in the bplane code for subcell binning.  It is still not
clear why this example causes a failure when the bplane code
has been working for so long.  However, simply checking for the
BT_ARRAY bit at one additional point in the code prevents the
crash condition and appears not to have caused any issue with
the database.
2024-02-19 12:54:51 -05:00
Tim Edwards 814fb6f18d Corrected two separate issues with R-C extraction: (1) There was
a method that failed to work on devices with complex shapes on the
device recognition layer, such as snake-geometry resistors.  (2)
The use of contact type "xpc" in the sky130 tech file as its own
contact residue caused the contact tracing in extresist to fail.
I opted to keep the unorthodox contact description in the tech
file and wrote an extension to a routine in extresist to handle
the case.
2024-02-18 14:04:21 -05:00
Tim Edwards 038f02d2b2 Updated the version to go along with the merge of pull request #288
from Ryan Schmidt, changing regular expression strings in the python
preprocessor to raw string types so that they don't produce warnings
in python 3.12.
2024-01-23 15:34:05 -05:00
Ryan Carsten Schmidt 8a93d6136b
Use raw strings in preproc.py
Avoids "SyntaxWarning: invalid escape sequence" with Python 3.12.
2024-01-23 09:38:23 -06:00
Tim Edwards b08c785c1d One correction to the previous commit to restore the original
behavior when a child coordinate is not specified;  otherwise,
the original code's setting of the child reference point to the
bounding box lower left causes the lower left point to be
used always, which is not how the getcell command is supposed to
function.
2024-01-21 16:29:02 -05:00
Tim Edwards 7f5571768f Corrected a long-standing error, which caused "getcell child <point>"
to place a cell in a meaningless position for any rotation and flip
combination other than zero.  The issue was that the reference point
was not rotated along with the cell.
2024-01-21 15:54:49 -05: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
Tim Edwards 63109229f4 Corrected an error in the "cifarea" rule that had previously been
fixed for "cifwidth" and "cifspacing", in which the rule distance
is incorrectly multiplied by the expander (in the case of area,
multiplied by the expander squared).
2024-01-14 17:35:39 -05:00
Tim Edwards 6b8239e258 Corrected a recently-discovered error in the "minimum area" DRC rule.
The fractional part of the rule distance (modulus after scaling)
does not fit in the unsigned char variable unless it is first
divided by the scalefactor (also requires multiplying up by the same
amount when scaling the other direction).  The truncation of the
unsigned char value was causing the minimum area value to be off by
a small amount, causing false negatives (no DRC violation is shown
when metal area is slightly smaller than the minimum allowed).
2024-01-14 15:19:39 -05:00
Tim Edwards a816da60f9 Updated the HTML command reference files to refer to magic version 8.3,
since all of the title images still had 8.2, and the title text still
said 7.3 or 7.4, having not been updated for a long time.
2024-01-09 16:37:00 -05:00
Tim Edwards 006c07082b Inadvertently introduced a segfault on exit on the last commit,
while trying to get rid of a compiler warning.  Fixed by this
update.
2024-01-01 15:36:05 -05:00
Tim Edwards 8f9c328150 Got rid of two compiler warnings; one recently introduced, the
other from some time ago.
2023-12-30 15:00:18 -05:00
Tim Edwards 68e537b968 Added a tile unfracture routine at the end of CIFMakeManhattanPath
that resolves issues of excessive tile fracturing during read-in
of GDS (or CIF) polygons and paths that have non-manhattan geometry.
This was particularly noticeable when reading the GF180MCU corner
I/O cell, which ended up being something close to a worst-case
scenario.
2023-12-30 14:10:09 -05:00
Tim Edwards 0cd4a10036 Updated version to go along with the merge of pull request #283
from Vasil Yordanov, which changes the toolbar icon into a
scrollable list with layer names, much better than the former
minimalist array of icons.
2023-12-15 15:58:20 -05:00
Vasil Yordanov affd68aad9 EDIT: wrapper maketoolbar method refactored into a separate script, with changes to the toolbar. Reorder layers functionality added as well 2023-12-15 15:54:05 -05:00
Tim Edwards 943e0d4d8d Updated version to go along with the merge of pull request #282 from
Donn (corrects a pointer incorrectly passed to dbReadOpen() that
should have been a boolean).
2023-12-04 10:33:05 -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 83ed73ac52 One more change to the "extresist" code which prevents extresist
from substituting a regular label for a port during a node merge,
which can cause ports to become orphaned.
2023-11-27 16:18:43 -05:00
Tim Edwards 84af801608 Fixed two independent errors, both of which can cause devices to be
missing from a netlist generated by ext2spice with the "extresist"
option enabled.  The first had to do with some parts of nets being
given alias names for a net, and the second was caused during
"extresist" and would also result in error messages about devices
missing terminals.
2023-11-24 16:51:26 -05:00
Tim Edwards 21336607e0 Added checks for GDS scalefactor (DBU) both when reading GDS in
"gds readonly true" mode and when writing a GDS file in full-dump
mode.  Reading or writing a file with an incompatible DBU is now
prohibited.  This is not a great solution, as it forces the
original file to be rewritten with a different DBU.  Preferably
there should be code to scale the units during a dump, but that
needs to be coded.
2023-11-21 09:44:16 -05:00
Tim Edwards 5352a23577 Updated the SPICE import routine in the toolkit so that it will
correctly handle subcircuits that are used before they are
defined, and will determine whether the imported spice does or
does not contain a top level, and either return to the top level
or any top level cell found in the netlist.
2023-11-15 11:46:22 -05:00
Tim Edwards d09b0e8c51 Corrected an error that can prevent capacitances to substrate from
being output if the substrate node is declared as a port.
2023-11-14 20:10:57 -05:00
Tim Edwards 11080465ad Corrected the Tcl exit hook routine so that it passes on the
client data value as the exit status value (this was not at
all clear from the documentation and required a bit of
experimentation).  The fix allows Tcl scripts to exit magic
with a non-zero status by invoking "exit" in Tcl.
2023-11-11 13:09:59 -05:00
Tim Edwards 7db77d47f1 Yet another fix to the ext2spice code handling output formatting
of SI values, this time to put the precision and the value in the
order that is generally more accepted.  The gcc compiler, at
least, doesn't seem to care which order they are given in.
2023-11-10 12:52:55 -05:00
Tim Edwards 1131085d0f Added "u" as a recognized suffix to dimensions, meaning the same
thing as "micron" or "um", since it is regularly used that way.
2023-11-10 09:45:32 -05:00
Tim Edwards 67d68717ca Corrected a typo in the ext2spice code as pointed out (with
corretion) user cgurleyuk on github.
2023-11-10 08:01:51 -05:00
Tim Edwards 8445f3eb5d Corrected ext2spice to avoid incorrect precision when writing out
values.  The "%.3g" format was changed to "%.*g" with a variable
precision that accounts for the actual precision required by the
manufacturing grid.
2023-11-05 11:00:30 -05:00
Tim Edwards 0894248e0a Updated version to go along with the merge of pull request #278
from user pinu-73 (updates to the MacOS install instructions
with additional information and explanation).
2023-11-02 10:11:10 -04:00
Dikshant 40e6a28ff6 appended macOS install file for XQuartz Display issue. 2023-11-02 18:08:03 +05:30
Tim Edwards df6333bb7b Modified the "makedbh.in" script ("makedbh", after running
configure) so that it does not use python-3.6-style f-strings,
and so is backwardly compatible with any python-3 revision.
2023-10-28 12:14:26 -04:00
Tim Edwards 22ea7a924f Corrected an extraction error that can cause an infinite loop
depending on the order of extraction devices.  Specifically, the
case of a source-drain tied FET was breaking out of a loop when
it should have been breaking out of a double loop.
2023-10-27 14:32:44 -04:00
Tim Edwards 7a9445ec30 Corrected the extraction offset, in which a parameter like "l"
can provide a delta offset such as "l+0.06", indicating that
the extraction model has a length larger than the drawn device.
Previously the value was assumed to be in microns but did not
scale between the .ext file and the SPICE netlist.  Corrected
so that it scales like the other parameter values, being
converted to internal units and tracking the internal grid
scale.
2023-10-24 20:29:04 -04:00
Tim Edwards 610c86a234 When writing a GDS file, there is a statement printed about each
cell being generated.  This statement does not disambiguate the
case where a cell is being ripped verbatim from GDS instead of
being generated from the magic database.  This print statement
has been split into two cases, and where a cell is being ripped
verbatim, the name of the file is indicated.  This provides better
information to the user.
2023-10-24 10:36:57 -04:00
Tim Edwards 98f3b39dc2 Two small tweaks on plot filename behavior: (1) "plot svg" without
a filename causes an error instead of generating a trash filename
or crashing, while (2) "plot pnm" with a filename that has the ".pnm"
extension does not add another ".pnm" extension to the end of it.
2023-10-17 20:01:39 -04: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 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
Tim Edwards 8798a3256c Corrected an error in which DRCStatus is set outside of an #ifdef
for MAGIC_WRAPPER, which is required.
2023-10-12 15:14:13 -04:00
Tim Edwards eda5f506f3 Made another change to the netlist-to-layout procedure so that it
better supports re-entrant use, especially for the use case where
the import was abandoned before saving, or the generated cells
were not saved (which is easy to do, because the top level cell
is always written out to disk, but the rest of the cells will only
be written when "writeall" is executed).  The new code detects
input cells that did not have any layout file (has flag "not-found"
after loading) and deletes them and their instances so that they
can be regenerated from scratch.
2023-10-06 19:38:53 -04:00
Tim Edwards 9e7c104d29 Corrected a small error in the device generator toolkit that fails
to pick up properties from an existing cell and prints an error
message instead.  This will likely cause non-default properties
of an instance to be lost if the SPICE import is used in a
re-entrant manner (not exactly a common use-case).
2023-10-06 17:51:40 -04:00
Tim Edwards ce6f7840db Backed up the version by one minor revision because I accidentally
upped it twice in one day.
2023-09-29 17:47:03 -04:00
Tim Edwards 2aa7380cb6 Changed the fix from the last commit by solving the problem in a
different way.  Added a routine to remove all layers of a contact
from all planes except the contact's base plane before finding
and processing contacts.  This causes ExtFindRegions() to find
and process only one tile on one plane per contact, so there are
no redundant contact entries.  Also, any overlapping stacked
contacts are resolved, which avoids the very common error of
contacts not being processed at the correct size because they
are being processed per tile for chopped-up areas.
2023-09-29 12:41:54 -04:00
Tim Edwards dacbfc4e1f Found that "extresist" double-counts contacts because no attempt
was made to limit the ExtFindRegions() search to one plane per
contact.  Fixed this simply by doubling the resistance per via
so that the final result is correct.
2023-09-29 10:48:05 -04:00
Tim Edwards b156e79b2c Corrected a toolkit error where the callback to check parameter
bounds should be called whenever an entry is changed and either
the entry window loses focus or the <Enter> key is pressed.
This had ended up disabled when the scrollbar was added to the
dialog window, causing the window hierarchy to change, which
invalidated the regexp used to identify the entry and checkbox
widgets.
2023-09-29 09:38:48 -04:00
Tim Edwards 088bb828ac Corrected an error in the original resistor network simplifying
routine that marks resistors in loops to prevent infinite
recursion, but later incorrectly eliminates those resistors.
Also:  Changed the "tolerance" command to affect only the R-C
time constant tolerance.  Added a "threshold" command option
that limits output of small resistors.  This can help reduce
large networks that are otherwise not reducible by the three
methods of reduction (serial, parallel, and delta-wye), but
does affect output values (slightly).  This will probably need
to be revisited at some point.
2023-09-28 17:15:27 -04:00
Tim Edwards 656b5dbabe Corrected an error in the calculation of the number of contact
cuts per contact area during parasitic resistance extraction.
Previously, the result was divided by the via pitch twice,
resulting in most contact areas being reported as a single
cut.
2023-09-28 12:38:08 -04:00
Tim Edwards 7aa846443a Corrected an issue with the implementation of nondefault rules
in DEF read and write.  The NONDEFAULT LAYER WIREEXT was assumed
to refer to the default wire extension at segments, when instead
it refers to the wire extension only at vias.  The wire
extension at segments is presumably defined by the nondefault
segment (and wire extension at vias remains unimplemented, which
is probably not a big issue because everyone puts the wire
extensions into the via definitions anyway).
2023-09-26 21:26:31 -04:00
Tim Edwards b244d45688 Fixed an error that causes magic to segfault when doing "def write"
on a layout that is caused by either having no .ext file, having
labels attached to space, or possibly both.
2023-09-25 14:18:21 -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 68d6632836 Documented the "def write -anal" command option, which had
previously been implemented without being documented.
2023-09-22 16:31:36 -04:00
Tim Edwards 7e5dbd17cd Fixed another issue in which sticky labels on a non-electrical
type (like "comment") show up as nodes in the .ext file, which
they shouldn't.
2023-09-22 16:03:53 -04:00
Tim Edwards 4557dd1639 Modified the "def write" function so that obstruction layers are
output as blockages.  That allows obstruction layers to be placed
in a layout specifically for the purpose of being output as a
blockage.  Otherwise, an obstruction layer is generally considered
non-electrical and will not show up as a node in the extraction
file, so obstruction layers were being missed entirely by "def
write".  Also:  Where "def write" complains about floating labels,
made an exception for labels on non-electrical layers (like
"comment").
2023-09-22 15:51:38 -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 cb25afc5ff Modified the behavior of "gds read" (and by extension "cif read")
so that it does not fail if an edit cell is not loaded, but
simply loads the default unnamed edit cell.  This is somewhat bad
behavior in the case of reading GDS, since if the GDS is a library
and does not have a top level cell that matches the name of the
GDS library, then the edit cell that is loaded when the "gds read"
command is issued remains unchanged, so it didn't need to be there
in the first place.  Fixing this to behave better would require a
bit of additional work.
2023-09-13 16:40:40 -04:00
Tim Edwards 50b1e01cfc Corrected the scrollbar function on the parameterized device
generation dialog window.  The window is now made to fit the
list of parameters when it is made, but can be reduced in size
which allows the scrollbar to function.  Event bindings for the
mouse scrollwheel were added so that it can subsitute for the
scrollbar within the parameter window.
2023-09-13 11:28:07 -04:00
Tim Edwards 93eeb1b703 Documented the "extract halo" command option (which was missed at
the time the option was implemented), and also implemented (and
documented!) a similar command option "extract stepsize" for
reporting or changing the extraction step size.
2023-09-13 10:03:20 -04:00
Tim Edwards dfe3a4defd Added a "Place" button in the cell manager after realizing that
other commands like "Place Instance" and "Library Manager" do not
track cells in the internal database, and so are unable to place
a cell instance that does not have a corresponding file on disk
(e.g., a cell read from GDS or LEF).
2023-09-12 11:52:15 -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 a8cc403e4b Modified "lef write -hide" behavior to fix problems that occur
when a label has no area and magic has to go searching for the
label area.  The resulting behavior is better but is not really
a substitute for adding ports on the proper layers in the proper
locations for routing connections.
2023-09-11 14:34:42 -04:00
Tim Edwards d624b76712 Updated the version to go along with Donn's pull request #266
(fixes some issues around python3 on the Mac, python3 conflicting
with that found by /usr/bin/env, and an issue around "make clean"
attempting to rebuild the Depend files).
2023-08-29 15:50:38 -04:00
Donn 86630fcc02 Allow Python 3 to not be in PATH, Fix `clean` re-building dependencies
* Adds Python 3 to macOS requirements
* Gate include of `DEPEND_FILE` in `rules.mak` on whether the target is `clean` or not (the include isn't pre-processed; it will attempt to build everything in the include otherwise)
* Make `makedbh` a configurable file- the shebang now uses the discovered path for Python3
2023-08-29 22:43:11 +03:00
Tim Edwards 8e25303db4 Corrected what looks like a very long-standing error in the DRC
engine.  Rule checks of triggering rules are not subject to
clipping to the clip area.  However, they *must* be clipped to
the (larger) overall DRC check area, because no layout is valid
outside of that area.  This clipping was missed, allowing
triggering rules to trigger on areas outside the valid layout,
resulting in mysterious false-positive DRC errors.  This has
been fixed.
2023-08-27 14:21:02 -04:00
Donn 02e16b8bce Build Updates
This is a series of updates to make building magic far less of a headache:

* Drop `csh`/`tcsh` dependency and detection from `./configure`.
* Rewrite makedbh in Python.
* Rewrite printmans in POSIX sh.
* Stop deleting Depend before every compile (which causes some files to recompile and thus increases recompile times significantly)
* Add Depend to CLEANS in scripts/defs.mak.in
* Turn POSIX suffix rule in magic/rules.mak to a pattern rule with proper prerequisites
2023-08-25 12:24:14 -04:00
Tim Edwards cb00ede59d Corrected defRead.c so that "read def" will read multiple "+ ROUTED"
(and similar) independent routed segments in the SPECIALNETS section
(which was already working correctly for regular NETS).  This solves
github issue tracker issue #264 from Christian Haufe.
2023-08-25 12:15:58 -04:00
Tim Edwards f4d7646c1e Changed Lookup() to LookupFull() in all the LEF and DEF read routines.
Lookup() is used for command-line parsing in magic and accepts any
unique string that matches a partial keyword.  LEF and DEF do not
allow partial keywords, so only LookupFull() is appropriate to use
for LEF and DEF file parsing.  This fixes issue #263 from Christian
Haufe.
2023-08-25 09:48:24 -04:00
Tim Edwards 71e6bc5dd5 Added an include for <wchar.h> which is needed for readline to avoid
an implicit declaration error.
2023-08-08 13:44:37 -04:00
Tim Edwards 13a7cc32e2 Corrected an issue with the last commit for fixing the "extresist"
command for use with "extract path";  the cellname was being cleared
after generating the filename with the extract path, but was being
used afterward, so it needed to be reverted back to the original
value, not just free'd.  Otherwise "extresist" will fail to produce
any results.
2023-08-07 15:37:04 -04:00
Tim Edwards 22fbb28656 Corrected one major error which will cause magic to fail to find the
".res.ext" file from "extresist" after using "extract do local" (and
probably with "extract path" as well).  Fixed this, and also made
sure that "extresist" writes the ".res.ext" file to the same location
as ".ext" always, so that handling is consistent throughout the
full R-C extraction process, across the use of "extract", "ext2sim",
"extresist", and "ext2spice".
2023-08-06 16:53:07 -04:00
Tim Edwards 952b20d2a2 Corrected an issue where code expected sticky labels to be at the
front of the list during extraction, except that after copying
they're not.  Removed the expectation, although that causes the
entire linked list of labels to be parsed and may cause excessive
run-times in pathological situations.  Keep an eye out for
unintended consequences.
2023-08-01 13:59:46 -04:00
Tim Edwards 96ea4aa2fb Made a minor change to the handling of device nodes in EFBuildDevNode()
to catch cases where a device terminal is connected to the global
substrate node even when the terminal is not specifically a substrate
terminal (e.g., diode cathode or bipolar collector) and  mark them with
the "substrate is port" flag.
2023-07-31 12:11:04 -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 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 d4f8fe04c5 Corrected the variable string "RCS" in tkcon.tcl, which had
become truncated, causing the "About" menu item in the console
to generate an error message.  Since the tkcon.tcl used in my
other software packages like IRSIM was correct, I just pulled
the RCS string from there, and it seems to be okay now.  This
solves github issue #259.
2023-07-25 17:15:11 -04:00
Tim Edwards 0afe4d87d4 Corrected an error introduced by the code added recently for support
of command logging, which caused the "select cell <instance>" command
option to become invalid;  this command option is used by the
parameterized cell generator and makes it impossible to edit the
parameterized cells.
2023-07-21 15:35:58 -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 36fa9aabd1 Implemented a new command option "gds magscale" to reinterpret the
meaning of the MAG record in GDS files.  Most available GDS
documentation is decidedly vague about what MAG means.  Most
layout tools seem to interpret a MAG of 1 as corresponding to a
text height of 1um.  However, there are a few tools that
interpret it as 1 centimicron, and there's no reason to assume
that any given interpretation is correct.  "gds magscale" allows
the scale to be redefined.
2023-07-19 20:33:01 -04:00
Tim Edwards 8b3bb1ae77 Updated the version to go along with pull request #256 from Proppy. 2023-07-11 16:52:03 -04:00
Johan Euphrosine 7794b1b3cb textio: add missing TxErrorV call 2023-07-12 05:42:55 +09:00
Johan Euphrosine 1bdf173391 textio: add TxErrorV variant 2023-07-12 05:21:20 +09:00
Johan Euphrosine e249e7a0e3 configure: cleanup diff 2023-07-12 05:04:18 +09:00
Johan Euphrosine eb9dcbcd01 calma: fix linux build? 2023-07-12 04:53:07 +09:00
Johan Euphrosine f5793bbefb configure: add asmjs-unknown-emscripten target 2023-07-12 04:44:37 +09:00
Johan Euphrosine a11d2cbaa1 github/workflows: add simple_build_wasm 2023-07-12 01:11:50 +09:00
Johan Euphrosine 96eb275622 quick and dirty emscripten port 2023-07-12 00:31:37 +09:00
Tim Edwards c3ec56725b Corrected a few errors from the previous commit (support for
logging commands without any pointer or screen coordinate
references).
2023-07-08 21:58:12 -04: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 3890181ebe Completed the small set of command extensions to make sure all
commands that make use of the pointer position have an equivalent
command that operates solely on layout coordinates, or otherwise
avoids needing a pointer position.  Added the command option
"down <instance>" to avoid using the pointer to disambiguate
selections.  Added the command option "select ... at x y" to
do paint or cell selections at a specific coordinate instead of
the pointer position.
2023-07-08 13:59:00 -04:00
Tim Edwards d3b314d877 Corrected an error in the previous commit. Implemented a new form
of the "edit" command that takes an instance name as an argument.
This is the first of a small series of command extensions to
provide the capability to replace any command that is dependent on
the pointer position with an equivalent command that is not, for
the purpose of removing pointer and screen coordinate dependencies
from the log file created by "logcommands".
2023-07-08 12:47:09 -04:00
Tim Edwards 081058a41b Corrected an issue in which ports which have the same name under
the assumption of case insensitivity (e.g., VSS, Vss, and vss)
are kept separate even when writing SPICE netlists, which are
case insensitive.  The code fix both avoids flagging these ports
when running ext2spice, and more importantly, allows the use of
"ext2spice short" without these ports ending up separate in the
output netlist.
2023-07-08 12:14:57 -04:00
Tim Edwards b899a500d5 Added a new method to the extraction which allows parameter limits
to be declared for each device model, so that different models can
be specified for different parameter ranges.  For example, this
will simplify the definition of the high-sheet-rho poly resistors
and the bipolar transistors in sky130 by removing the need for ID
marker layers;  it also allows the correct device model to be
extracted when reading data from GDS that does not contain the
extra (and not foundry-approved) ID markers.
2023-07-06 12:35:47 -04:00
Tim Edwards cc4eef4eb1 Added a (obvious, in retrospect) additional automatic handling of
nets to be avoided for running antenna gate and diffusion area
checks when doing "lef write", which is to check if the pin of
the net is flagged with use "power" or use "ground".  This avoids
the need to use the (recently added) "lef nocheck" option (although
that still exists as an additional way to control which nets do and
do not get checked).
2023-07-05 12:37:56 -04:00
Tim Edwards c8a2d06e08 Finally got around to fixing the "logcommands" command, which has
been broken ever since moving to the Tcl/Tk wrapped version.  Added
some new features that allow background commands from the window
handling (like pointer tracking) to be omitted from the log file
via a suspend/resume function.  Added a header file and a few
commands at the top of the log file that align the log file contents
with the screen and box state at the start of logging.  This makes
a log file which can be "played back" by sourcing it from the magic
console prompt.  Per request from Harald Pretl.
2023-06-28 21:31:24 -04:00
Tim Edwards ca469510d5 Found that extNodeName() prefers the first name in a region's label
list for output, but that the code in ExtRegion.c does not sort a
region's label list to keep ports at the beginning of the list.  So
any net with multiple labels may end up with a non-port label as
the name of the node, which eventually becomes the name of the port.
A quick fix keeps these lists sorted.
2023-06-27 15:35:57 -04:00
Tim Edwards 3ae24e8a8c Extended the method of the previous commit to include the command
option "drc find <text>", to find the next error of a specific
type based on the contents of the DRC error message (e.g.,
"drc find li.1").
2023-06-26 21:17:51 -04:00
Tim Edwards 60a378842f Corrected one array overrun error caused by using the command
"drc printrules".  Implemented a new "drc" command option called
"drc ignore", which can be used to suppress reporting of specific
rules, for both "drc why" and "drc find".  This can help with
finding an error buried among a large number of other errors.
2023-06-26 20:47:37 -04:00
Tim Edwards ca985edbd0 Corrected a typo in the previous commit that causes parameters to
be output twice for scaled devices (such as diodes in the sky130
process).  Above and beyond the typo, though, the implementation
of offsets is not very well thought out and needs to be revised.
For one, the +/- notation can be confused with signs in the
parameter expression;  that is also fixed in this commit.  But
there is currently no way to express both a scale and an offset
for a device parameter.
2023-06-23 08:39:59 -04:00
Tim Edwards 07267dc126 Extended the device parameter notation to include offsets using
'+' and '-' in the same way that '*' is currently used for specifying
a parameter scaling.  The combination of a scale and offset for the
same parameter has not (yet) been implemented.
2023-06-21 20:44:38 -04:00
Tim Edwards 482d7534a2 Reimplemented the "extract do local" option as "extract path <name>"
with "extract do local" now being equivalent to "extract path .".
This allows extraction files to be put in a subdirectory and not
clog up the current working directory.  Also:  Fixed some behavior
around the use of "ext2spice -p <path>" so that it (1) works, and
(2) is compatible with the new "extract path".  Since the ext2spice
and ext2sim commands are effectively independent of the primary
extraction, the "-p" option is needed to correspond to the use of
"extract path".  Hopefully this is seen as only a minor inconvenience.
2023-06-14 13:55:59 -04:00
Tim Edwards 9b131fa96c Corrected an issue that produces potentially incorrect output
from ext2spice due to "equiv" statements in the .ext file.  The
algorithm was not properly keeping the port as the preferred
name of the node, resulting in the non-preferred name being
used instead of the port name in the output.  This would happen
only if there was a label on a net that had a different name than
the port name.  The error became much more prevalent after changing
the extract behavior to make "extract do aliases" default.  Also
fixed a somewhat related minor error in which magic would print an
error message about ports being shorted together on the same kind
of net where both a port and a (different) label were attached to
the net.  Since the non-port label is not a preferred name, then
there should be no warning message.  The warning is only intended
for cases where two (or more) ports are truly shorted together.
2023-06-13 17:14:36 -04:00
Tim Edwards 31b3c0d8b4 Extended the "lef" command to include a new option "lef nocheck"
to create a list of net names to ignore for antenna gate and
diffusion area checks.  This allows the nets not to have to be
selected in their entirity but selected by chunk only.  This
reduces the time to write LEF on a large layout back to approximately
what it was before the change to include the hidden area from "-hide"
in the antenna area checks.  Plus, it greatly reduces the time to
generate LEF for large layouts when not using the "-hide" option.
2023-06-13 11:28:46 -04:00
Tim Edwards 5300f322de Added code to calculate area and perimeter of layers that are not
on the same plane as a device identifier layer.  This (finally!)
allows proper calculation of area and perimeter of diodes and
bipolars, for example.
2023-06-09 15:31:58 -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 666c3c2c97 Corrected an issue in which the device merging routine can generate
NaN results for devices which are not FETs (specifically, devices
that are declared using "msubckt" but are not FETs, although there
may have been a related issue with non-FET devices not getting the
correct M count), due to the device having zero measured width or
length.  NOTE:  This may need more investigation.  If a subcircuit
device's method of merging cannot be understood, then such devices
should never extract with "merge aggressive", and should always
merge conservatively if and only if all parameters match.
2023-05-21 12:13:01 -04:00
Tim Edwards c514f5ce0b Apparently forgot to push the last set of changed. Fixes a null
return value in EFbuild.c and adds a couple of sanity checks.
2023-05-18 09:25:37 -04:00
Tim Edwards 44b269e037 Modified the handling of substrate ports so that an existing port
number for a substrate port does not get reassigned, which will
cause port ordering issues.
2023-05-08 09:51:13 -04:00
Tim Edwards 79dc621626 Added a warning message if attempting to extract an empty cell,
so that it is not so mysterious as to why no output was generated.
2023-04-28 09:24:04 -04:00
Tim Edwards c4124b033f Corrected a potential crash condition in extflat which can show up
when reading .ext files with "equiv" statements in them.  The
generation of "equiv" statements was expanded recently, making it
more likely for this issue to show up.  There may be devices in
a file that have a terminal node pointing to the node that gets
removed, and these must be updated to point to the node that
remains after merging.  This requires a full loop over all
devices and so could have a potentially large impact;  but in
general there are not many equiv statements (implying multiple
different labels attached to the same node) and so it is unlikely
that there would be a noticeable performance hit in practice.
2023-04-27 20:47:55 -04:00
Tim Edwards e66b2e1338 Rearranged the "lef write" routine so that the search for antenna
gate and diffusion area on each pin is done before erasing parts
of the cell that are to be hidden by obstruction layers.  That
preserves the antenna information even when "-hide" is used.  This
corrects the issue raised by Kareem Farid in the github issue
tracker #236.
2023-04-26 10:24:13 -04:00
Tim Edwards a33d7b78b5 Corrected an error in search for substrate under a device. If
"space" is considered part of the substrate, then the check for
planes to search should exclude "space" from the type mask
first.  Otherwise, all planes get searched, not just the substrate.
Also:  The same routine can falsely flag a device terminal as
substrate if a split tile is marked as the device's region.  This
was also fixed.
2023-04-24 17:30:40 -04:00
Tim Edwards bf7f1ab39e Updated version with the merge of pull request #235 from Brad Smith. 2023-04-22 14:14:20 -04:00
Brad Smith c8940ab219 Allow for bash in locations other than /bin 2023-04-22 14:13:57 -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 cff2b97678 Changed the default extraction options to include "do aliases" by
default, since not setting it can have unfortunate consequences
for cells that don't declare ports and have multiple conflicting
labels on a node.
2023-04-16 12:18:16 -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 380b9245f3 changed MAXTOKEN in ResReadSim.c from 256 to 1024, having
encountered an issue where a label in a flattened layout
exceeded 256 characters, ended up in the .sim file, and was
truncated when read back during "extresist".  The change to 1024
is a stop-gap measure because ultimately I want to replace the
use of .sim files with .ext files using the routines in extflat/,
which would deprecate everything in ResReadSim.c.
2023-03-25 16:11:46 -04:00
Tim Edwards 8ab5d465e9 Removed an unused variable declaration. 2023-03-25 15:53:32 -04:00
Tim Edwards 7b9809e567 Fixed the "flatten" command so that "-dotoplabels" works as advertised,
and doesn't crash magic.
2023-03-25 15:06:25 -04:00
Tim Edwards fc62a63d41 Corrected errors in the extresist code and in extflat, both of which
can result in negative resistors due to integer overflow.  In all
cases, the target was floating-point and it was only necessary to
recast everything to float first.
2023-03-25 11:01:52 -04:00
Tim Edwards 8fb96db14c Found one additional issue in the extraction that causes incorrect
partitioning of unshielded areas reaching outward from any given
edge, caused by using a boundary value in the 2nd recursion call
that had been modified for the 1st recursion call and so was no
longer valid.
2023-03-24 17:11:27 -04:00
Tim Edwards 30184cb506 Finally tracked down several bugs in the sidewall walking routines
that had been causing negative capacitances to substrate to be
generated for certain complex geometries.
2023-03-24 09:51:22 -04:00
Tim Edwards f0c94d59f3 Minor adjustment to output from esSIvalue() to avoid round-off error
causing the SI suffix not to be the expected one.  Adjusted the
bounds where each SI suffix is used to keep output in the range of
0.1 to 100, although the boundary is very subjective.  Made a
correction to the extresist code to scan through all device records
for a tile type.  However, (1) there are cases being missed, and (2)
this should not be necessary since all device types should be able
to be known exactly from the contents of the .sim file.  Needs more
work.
2023-03-23 15:38:31 -04:00
Tim Edwards 6dd5f4d7e3 Corrected problem caused by adding a scrollbar to the parameters
window in the toolkit, which was to the "tkwait" command, which
waits for a change in state.  What was intended was to wait for
a change in state to visible only;  once visible, the "tkwait"
command should not invoked or else the process will block.
2023-03-22 15:28:00 -04:00
Tim Edwards 58c6a32a6c Applied patch from Donn that converts strcpy() calls in ext2spice
to "safer" strncpy() calls to prevent string buffer overflow.
Also:  Reimplemented the loop in the GDS write routine that counts
ports and then outputs them in order.  It was possible to hang
magic for a long time by giving a port a very, very large index
number.  The new implementation uses qsort() to sort the ports
by index, which is obviously much more efficient for the worst
case (and efficient enough for all normal cases).
2023-03-21 22:04:30 -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 10448788f9 Found another error causing negative capacitances and fixed it,
but the search continues for another mechanism that continues to
do the same thing.
2023-03-17 21:59:47 -04:00
Tim Edwards ca0cb1322a A couple of corrections to the last commit, where the equation for
computing the amount of fringe shielding was wrong.  This fixes
one of my example cases, but not the other one, so I still need to
pin down a condition that can result in negative capacitance.
2023-03-17 20:47:08 -04:00
Tim Edwards edb05fb3d1 More corrections to the method of calculating fringe capacitance
inside a halo area.  The previous implementation used a linear
accounting of error to determine the amount of shielding, but
since the shielding is nonlinear, this is a poor approximation
and regularly overestimates the shielding and leads to negative
capacitances.  The corrected method makes many more calls to
the atan() function and the performance impact for extraction
will need to be evaluated.
2023-03-17 13:51:33 -04:00
Tim Edwards e9d434597a Corrected issue with the commit of version 8.3.378, which can
cause a crash when extracting some devices like bipolars with
terminals on different plance.
2023-03-15 14:36:15 -04:00
Tim Edwards a2687d4385 Corrected an issue from the last commit, which is that the default
ground node name (which is static) gets put on the node list and
is improperly deallocated.  Corrected by simply allocating the
string for the default substrate node instead of using the static
string.
2023-03-14 12:53:22 -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 c077e1acef Removed from the "lef" HTML document some mentions of property names
that aren't actually handled by the "lef write" command.  The three
mentions are "LEFsource", "LEFuse", and "LEFshape", all of which
refer to names of pin properties, not macro properties.  These
mentions were probably left over from early work.
2023-03-13 10:18:17 -04:00
Tim Edwards 913c830dee Corrected the extraction of length and width of devices that are
(truly) missing a terminal (such as a MOSCAP made with a gate
extending into but not crossing a diffusion region).  Added the
most requested GUI feature, which is a vertical scrollbar on the
parameterized device window (could be improved by maximizing
window height without exceeding display height).
2023-03-12 16:57:47 -04:00
Tim Edwards e10901e32b Updated the version to go along with the merge of pull request
222 from Sean Cross.  Corrected a few places where the blanket
conversion "Region"->"ExtRegion" picked up some comment lines
that were unrelated to the structure name.
2023-03-10 11:14:23 -05:00
Sean Cross 1e7da74672 rename Region to ExtRegion
On Macos, Tk includes X11, which has this define:

    #if !defined(MAC_OSX_TK)
    #   include <X11/X.h>
    #endif
    #ifdef MAC_OSX_TK
    #   include <X11/X.h>
    #   define Cursor XCursor
    #   define Region XRegion
    #endif

This causes the keywords `Cursor` and `Region` to be reserved, which
prevents magic from building.

Rename `Region` to `ExtRegion` as suggested by @RTimothyEdwards in
https://github.com/RTimothyEdwards/magic/issues/195#issuecomment-1298870983
and https://github.com/RTimothyEdwards/magic/pull/222#pullrequestreview-1334900670

Signed-off-by: Sean Cross <sean@xobs.io>
2023-03-10 11:07:55 -05:00
Tim Edwards 5e5879c53d Made a simple but important change to "readspice.tcl" to unexpand
the cell being reworked for port numbering.  Otherwise *all*
labels are selected, which can take a very long time depending on
how many labels are in the layout.  Note:  Need a "select area
ports" function, and better yet, rework the whole label database
so that magic no longer has to run compute-intensive routines
like DBEraseLabelsByContent().
2023-03-08 11:14:22 -05:00
Tim Edwards a8c3117020 Implemented and revised the "CIFhier" property to override the
"cif *hier write disable" and "cif *array write disable" commands
for a specific cell def and its descendents.  The revision ensures
that all descendents apply the override.  The "cif write" command
uses a stack instead of recursion, which makes it difficult to
apply the same method.  Currently the method only works for the
"gds write" command, and implementing the feature for "cif write"
is deemed not worth the effort.
2023-03-07 11:16:49 -05:00
Tim Edwards 73398e7e0b Corrected a buffer overrun situation in ExtBasic.c when printing
the "connected other node to. . ." message when terminals of a
device are shorted.  A long enough node name, especially one
created by concatenating hierarchy when flattening a cell, can
easily overrun the short 256-byte string buffer.  Fixed by
changing strcat() to strncat().
2023-03-05 16:39:58 -05: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 0058000c22 Corrected "ext2spice" to mark nodes on resistors from "extresist"
so that they do not get marked as "FLOATING" nodes when writing out
the parasitic capacitances at the end.
2023-02-28 13:11:32 -05:00
Tim Edwards eb36edf35a Corrected the ext2spice device output for device length, which
somehow acquired a typo which made it write "w=".  Resolves
issue #223 from Mitch Bailey.
2023-02-28 09:34:25 -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 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 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 33d0d53d34 Corrected an error in the extract section setup of the tech file
that allocates and deallocates a single layer mask used by the
tech reader.  Decided to work around the issue just by allocating
it only once and not releasing it---it's just a few bytes.
2023-02-22 17:56:45 -05:00
Tim Edwards be577d4318 Corrected the reading of the "defaultsidewall" statement in the
tech file "extract" section to work correctly when the offset is
negative.  Generally, a negative offset is nonphysical and is just
curve-fitting round-off error, but the existing code was failing
to divide out the factor of 1000 that had been multiplied through
when reading the tech file, resulting in a very wrong offset.
2023-02-22 15:30:50 -05:00
Tim Edwards d4790d2f31 Corrected the "measure" (Tcl scripted) command to fix an error
when internal units no longer match lambda units.  The text
would match the dimension of the cursor box, but the measurement
lines would be drawn assuming a lambda scale, not the internal
scale.
2023-02-20 16:06:18 -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 87702ac98a Reworked the previous commit in a way that makes more sense, as
the problem only occurs when handling the legacy "fet" device.
2023-02-13 13:41:58 -05:00
Tim Edwards 5fcd4441c1 Corrected the "extresist" command behavior to ensure that
transistor records match between the ".ext" file and the ".res.ext"
file for the number of terminals per device.  Previously, the first
device type for the layer type was always being used, and if it had
fewer terminals (e.g., a MOScap), then one terminal would go missing
in the output.
2023-02-13 10:57:43 -05:00
Tim Edwards adda4092d6 Updated version to go along with the merge of pull request #217 from
Anton Blanchard.
2023-02-02 09:18:22 -05:00
Anton Blanchard c495b618b2 Remove cast of pointer to struct and back again. 2023-02-02 15:34:52 +11:00
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 8d08cb2f2f One small revision to the last commit, to make the command option
"gds polygon subcells true" the same as "gds polygon subcells
temporary" instead of "gds polygon subcells keep".  This works
well for gf180mcu in open_pdks to keep the existing behavior
but won't break the GDS input on an older version of magic.
2023-01-17 20:23:11 -05:00
Tim Edwards be59d787a1 Modified the "gds subcell polygon" command option to split into
three types:  "none", "temporary", and "keep" (instead of "true"
or "false").  "none" now reverts back to the original behavior,
because it was found that saving polygons in subcells prevents
them from participating in boolean operations.  The "keep"
option is the original option (polygons kept in subcells), and
"temporary" is the one recently introduced (which puts polygons
in subcells and then flattens them).  This restores the original
method while retaining the recently implemented method.  However,
a proper solution needs to be found that deals with the problem
of boolean operators.
2023-01-17 20:14:38 -05:00
Tim Edwards 05ad386500 Updated the version to go along with the merge of pull request
213 from Anton Blanchard (1. Don't cast pointer to struct and back
again in DBDiagonalProc(), 2.  Fix compiler warning in
drcMaskSpacing(), 3. Fix a few issues in leaDBSearchForTech(),
4. Remove spurious ";" from PlotPS()).
2023-01-16 22:11:15 -05:00
Anton Blanchard f181d97315 Remove spurious ; from PlotPS() 2023-01-16 16:00:56 +11: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 e4e115b23e Fix compiler warning in drcMaskSpacing()
why should be an int.
2023-01-16 11:02:58 +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 f06f3b47db Added an experimental option for the cifoutput tech file section to
force magic to scale down the internal grid to the minimum
manufacturing grid size specified in the cifoutput section, upon
reading the techfile.
2023-01-13 17:21:37 -05:00
Tim Edwards ff608b51f1 Updated version to go along with pull requests #208 from
Alessandro de Laurenzis, and pull requests #209 and #210
from Anton Blanchard.
2023-01-08 13:11:06 -05:00
Anton Blanchard 954418d6d8 Fix clang unsequenced modification warning 2023-01-08 13:10:28 -05:00
Anton Blanchard c276110daa Use offsetof()
Magic has an open coded version of offsetof() which clang complains
about, because it takes the offset of a null pointer. Use offsetof()
instead.
2023-01-08 13:09:00 -05:00
Alessandro De Laurenzis a4e65afae9 Add PlowShowTime prototype when NO_RUSAGE isn't defined
While there, change function's type from (implicit) int to void.
2023-01-08 13:06:12 -05:00
Tim Edwards 6d99e5326e Added a command option "setlabel box" to modify the attachment box
of a label from the command line.  Also fixed a long-standing
irritation that "setlabel" would change the properties of a label
in the edit cell but not in the selection itself, which would
cause the label to be drawn both with the original properties
in the selection and the new properties in the edit cell.  Now
both views will track the same changes.
2023-01-04 14:08:39 -05: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 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 0bbb558b94 Reworked the "port" and "noport" label type designations in the
tech file to correct the underlying problem with the SkyWater
sky130 process in which a different layer/purpose pair is used
for TEXTTYPE and DATATYPE for the same layer.  Previously, all
output from magic writes the same pair for both when writing a
port label.  The new method preserves existing syntax, although
there are some differences based on what order the "port"
statement appears relative to other types for the same layer.
2022-12-21 17:49:43 -05:00
Tim Edwards be40825e9a Corrected the "flatten in place" command to force a redraw after
flattening, since the appearance of the layout will change even
though there are no physical changes.  Finally got around to
debugging and correcting the input mask-hints, which can
preserve vendor GDS by marking areas where the vendor GDS differs
from magic's automatically generated output (the method was
almost correct and only needed an input scale factor change).
2022-12-19 16:05:38 -05:00
Tim Edwards 583aaa1007 Added code to avoid making a call to get a default layer width on
an invalid type.  This prevents magic from generating unneeded
error messages about default layer widths on GDS read-in.
2022-12-19 11:52:38 -05:00
Tim Edwards 3d1cf5aa2e Updated the documenation on the "load" command to include the
"-silent" option and the redefinition of "-quiet".
2022-12-19 11:25:09 -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 3b396d65f0 Reverted the toolkit change from the last commit after realizing
that the feature for implementing callbacks on a selection list
was already implemented via the add_dependency procedure.
Modified the GDS read to remove cell instances that are placed
directly on top of one another in the same cell.  Modified the
GDS read to make a better selection of a default font size for
text that specifies a font but not a size, using the minimum
width for the layer the text is placed on.  Modified the GDS
read to remove text with empty-string placeholders (created when
a pin layer is read but no text exists to go along with it, due
to GDS not having a specific way to make pins, such that pins
have to be split between one record for geometry and another
for text).
2022-12-15 12:25:23 -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 edecd81046 Modified the toolkit add_selection procedure to take an extra
optional argument that is a callback function, so that the act
of selecting something from the drop-down menu can cause things
to happen such as changing the GUI window contents for the item
selected.
2022-12-14 17:38:19 -05:00
Tim Edwards e5813f51fa Added a new option "-doinplace" for the "flatten" command. This
should have been done a long time ago!  Allows an instance to be
flattened in place inside a cell def, which otherwise requires
a complicated set of commands to do.  Also:  Modified the polygon
handling routine from the previous commit so that it correctly
removes the polygon cell defs after flattening them into the
parent cell.
2022-12-14 12:44:30 -05:00
Tim Edwards 13a1bfcc2e Discovered that reading in polygons as subcells and then flattening
can be much, much faster than reading in polygons directly into a
cell from GDS.  Modified the handling of polygons so that they are
*always* read into subcells.  If the "polygon subcell flatten true"
option is not enabled, then the subcells are flattened at the end
of reading the cell, and the polygon cells are deleted.  This method
avoids most of the cases in which "polygon subcell flatten true"
has ever needed to be set.
2022-12-13 21:58:30 -05:00
Tim Edwards 53682af668 Added a new special device model name "Short" which enables the
use of a resistor type as a FET extended drain, allowing the
FET drain node to short across to the other side of the resistor
so that the resistor is absorbed into the FET device.  Used with
the GF180MCU process to describe the salicide-block ESD FET types.
2022-12-13 16:02:49 -05:00
Tim Edwards 86b4ac3e4c Modified the "lef read -annotate" method so that pins are checked
for compatible layout over the area of the pin rectangle in the
entire hierarchy of the cell, not just in the top level.  This
corrects issues where pins are placed in the top level cell with
no metal underneath.  It is written in such a way that it will
work regardless of whether paint is split across the hierarchy,
or the label spans different types (such as crossing a contact).
2022-12-12 14:49:42 -05:00
Tim Edwards 11ddd559b2 Fixed an error with LEF read where duplicate macros are encountered
in the input.  The name of one was being modified but was being
right-justified into the string, resulting in a name starting with
many space characters.  Also:  Fixed an issue with extresist where
a label that ends up with an empty string can become a node with
an empty string name in the .res.ext file output.
2022-12-09 17:31:47 -05:00
Tim Edwards 02bbb1064e Corrected an error in "extresist" that can output an incorrect
number of terminals for devices that don't have the usual gate/
source/drain terminals (e.g., diodes, resistors, capacitors) when
writing the devices with re-mapped terminals into the .res.ext
file.  Also:  Changed the size of the word containing the name
refcount for "equiv" statements, since an accidental shorting
of pins can cause a large number of "equiv" statements in a .ext
file, causing an overrun of the previously 1-byte refcount (this
probably does not make the structure any longer, since it likely
has to fit to a word boundary).
2022-12-06 21:55:01 -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 e5e1e04146 Made a variant of the "directional surround" rule to be able to
implement a GF DRC rule.  This variant allows for a difference
between the minimum allowed surround on one side and the amount
that must be extended on the adjacent side.
2022-11-30 15:33:21 -05:00
Tim Edwards f222004d65 Fixed an error in "lef read" that fails to apply an annotated
pin on a compatible area due to an incorrect type mask.  (Also
note that this routine only works (after correction) for RECT
statements, but there should be a similar check for POLYGON
statements.)
2022-11-29 17:02:36 -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 0f05bb1356 Corrected the LEF technology setup, where LEF layers (routes and
contacts) take default values from the DRC section.  Since both
are in lambda, but the DRC section uses a two-part integer and
modulus representation, if default values are taken before
scaling, the LEF layers may get rounded values.  This has been
solved by marking values with -1 to indicate that they require
defaults, and then set those defaults (from scaled DRC rules)
after scaling all other tech values.
2022-11-20 15:15:04 -05:00
Tim Edwards 18fc328289 Revised the last commit slightly to put the PIN entry as the first
entry of a set of net connections in a DEF file, instead of the
last entry.
2022-11-20 13:32:40 -05:00
Tim Edwards 44af9aaf9f Added pin connection to the list of NET connections in a DEF file
when doing "def write", which was missing.
2022-11-20 13:30:19 -05:00
Tim Edwards 65ef9a1ad3 Final (I hope!) corrections to the "def write" command. 2022-11-19 22:02:44 -05:00
Tim Edwards 6369c44821 One correction to the last commit, to avoid missing output of
port nets in "def write".
2022-11-18 22:28:20 -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 fe89170f5a Small correction to defWrite to cancel a non-default rule when a
wire with default width is encountered.
2022-11-18 21:00:23 -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
Tim Edwards 2519d0a4d8 Corrected an issue with readline that breaks the non-Tcl/Tk flow
due to a missing function prototype.  Modified the GDS output
flow to always output instance IDs as a property, not just in the
non-default case.  The property has been used for many years and
appears to be accepted by all tools reading GDS, so there is no
downside to always generating this output.  This has the upside
that default instance names don't get scrambled by going from
magic to GDS and back to magic.
2022-11-11 11:20:34 -05:00
Tim Edwards 05056d2f1f Left in the new code supporting the "calma contact true" option
for the squares-grid operator and for GDS compression.  But I
reverted the "calma contact" option to be false by default, because
the method does not exactly match the output when not using cell
instance arrays, and so may produce unexpected results.  Will
need a different implementation that uses the same code to generate
the same (effective) layout.
2022-11-10 14:46:26 -05:00
Tim Edwards e37a4f418a Based on output from a large contact array for a pad, modified the
default behavior of magic to make use of the "gds contacts true"
option to output contacts as arrays of subcells instead of
individual boundary entries, as the former is much more efficient
than the latter.  Set the option to be true by default, and set
the "gds flatglob" option to have one entry "$$*$$" corresponding
to the contact subcells created by the "gds contacts" option, so
that GDS reads and writes as it did previously (but using a
different method).  Expanded the method to include "squares-grid"
and "slots" operators (the latter should produce much more
efficient fill pattern arrays).  Implemented for both compressed
and uncompressed GDS.  Tested in all variations.
2022-11-10 14:08:58 -05:00
Tim Edwards 70e15b1d33 Corrected the "def write" output with respect to the "-units"
option.  This is important as the default units of 1nm are not
necessarily able to be converted to integer values if the
minimum manufacturing grid is an odd number of nanometers.
2022-11-09 17:38:09 -05:00
Tim Edwards 31ba6eeba3 Corrected an error introduced with the last push which changes
wire direction on vias during DEF write without changing the
"orient" value, causing Y values to get copied into X positions
in the output.
2022-11-09 15:14:53 -05:00
Tim Edwards f4c5ec3a78 Fixed the DEF write routine, which had an error in identifying
"slivers";  the error tended to produce artifacts (extra metal)
around contacts.  Fixed an issue that caused the DEF write routine
to open the same file twice instead of a new file for the second
part of the DEF data, and then potentially hit a runaway condition
when trying to merge the two files together.
2022-11-09 11:15:06 -05:00
Tim Edwards 2059d6fbb1 Corrected an error in "def write" that starts output on the wrong
layer when the first part of the route is a contact (starts on the
via top instead of the via bottom).
2022-11-08 09:59:43 -05:00
Tim Edwards a9aafebfc4 Corrected the antenna checking routines, which were incorrect with
respect to calculations around diode-connected diffusion regions.
The diffusion area calculation needed to be fixed to avoid double-
counting contacts, and the value for the ratioDiffA coefficient
needed to be scaled, since it is multiplied by the diffusion area
and therefore has dimensioned units of (1/area^2) and should be
treated like all other dimensioned units in magic.
2022-11-06 11:50:05 -05:00
Tim Edwards 3534b79994 Fixed an instance where dbFgets() was used in the "def write"
routine;  that is incorrect, and it should have been fgets().
When dbFgets() is recast to a zlib version, then its use in
"def write" causes magic to crash.
2022-11-03 16:15:36 -04: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
Tim Edwards 0dac37cb46 Changed the behavior of GDS writing to halt with an error if an
attempt is made to write an abstract view to GDS.  This behavior can
be overridded with the new command option "gds abstract [enable|disable]".
Also:  Corrected extraction to allow split tiles to be set as the
reference tile for a node.  Previously this was allowed only if the
tile was the first to be searched, but that can cause different tiles to
be marked as the reference depending on where the search starts,
resulting in different names for the same node in .ext files, which is
bad.  Also:  Modified the LEF annotation to avoid bad entries in the LEF
that would create layers in the layout where none exist.
2022-11-02 09:40:20 -04:00
Tim Edwards 5aee1dcb5a Added "-Werror=implicit-function-declaration" to CFLAGS in the
configure script, now that Alessandro De Laurenzis has cleaned
up the code so that it will compile with the setting (now, just
need to do the same thing for "implicit-int"!).
2022-10-29 10:04:18 -04:00
Tim Edwards d229aefb15 A handful of changes after applying pull request #191 from
Alessandro De Laurenzis.  That pull request cleaned up the vast
majority of compiler warnings.  However, that cleanup exposed a
few additional warnings pointing to errors in the code that needed
fixing.  The code now compiles cleanly except for one warning
about redefined CAD_DIR that I have not looked into.
2022-10-29 09:57:41 -04:00
Alessandro De Laurenzis 70ebfb831b Define Cairo functions prototypes only when support is enabled 2022-10-29 06:07:46 +02:00
Alessandro De Laurenzis 68cecd5382 C99 code compat when configured with no TCL support 2022-10-29 06:07:46 +02:00
Alessandro De Laurenzis 1c343584e9 graphics/grTkCommon.c: remove OGL includes
No references to OpenGL here, so headers not needed.
While there, replace panic() with TxError() + MainExit (+ include
utils/main.h for C99 compat).
2022-10-29 06:07:46 +02: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 9d40fbfecb Corrected an error in parsing the "defaultperimeter" statement in
tech files which incorrectly parses the syntax using five
parameters.  This syntax variant does not get used often, which
is why the error went undetected for a long time.
2022-10-22 22:12:15 -04:00
Tim Edwards 94daf986ab Corrected the GDS write for "boundary" to make sure that the
calculation of the area to check for output and the clip box
does not reduce the size of any layer associated with the
fixed bounding box declared by the FIXED_BBOX property.
2022-10-18 14:14:22 -04:00
Tim Edwards eecdc3c642 Added a "flatten -doproperty" command option that allows selective
flattening based on cells which have a property "flatten".  Also:
Modified the DEF read and write to convert DIEAREA into a
FIXED_BBOX property.  This solves issues with placing of components
from DEF, when those components may not have have come from place &
route and may not have P&R bounding boxes.  Also:  Fixed the
documentation for the "dump" command, which was missing the optional
orientation in the description.
2022-10-15 11:33:59 -04:00
Tim Edwards bc5093502c Corrected a small error in "extract unique" that will attempt to
run free() on a memory location that was never allocated.  This
error has no effect on anything, but correcting it prevents magic
from issuing a mysterious warning.
2022-10-07 08:43:49 -04:00
Tim Edwards 189d62da9b Corrected a really stupid error which prevented the "extract
unique notopports" from working.  Fixes issue #186 reported by
Mitch Bailey.
2022-09-28 17:45:28 -04:00
Tim Edwards bc46a7d469 Corrected the cell search algorithm so that it allocates memory
for BPEnum instead of putting it in the local frame.  The structure
is half a megabyte and will severely limit the hierarchy depth
because it is used in the recursive cell search.
2022-09-27 10:58:49 -04:00
Tim Edwards 65b54e0cd5 Corrected a stack corruption error (that I have never seen in
practice but which was detected by AddressSanitizer.  Also
corrected a crash condition in the absence of a window;  also
hard to reproduce.
2022-09-27 10:43:04 -04:00
Tim Edwards f12a155ea7 Found a crash condition reported by Abhinav Uppal where labels
that are unattached (type = space) will cause magic to crash on
the command "lef write -hide"---The lowest level issue was in
SelectChunk(), so for good measure SelectChunk() now checks for
type == TT_SPACE, and "lef write" does also.
2022-09-23 15:44:49 -04:00
Tim Edwards a550d615c0 Made some modifications to the "def write" command: It now handles
non-default rules and so can accurately capture wire widths other
than the technology LEF defaults (also corrected a bug with non-
default rules for "def read").  Corrected via handling in "def
write" to function as claimed (although the algorithm is still
naive and expects all contacts to be rectangular, which is usually
true but doesn't have to be).
2022-09-23 15:02:22 -04:00
Tim Edwards 82c79b36ee Added a check for unfortunate values of a MAG record in a GDS text
record.  Failure to use the right 8-byte real format can produce
bizarre results where a label's bounding box ends up in some random
place and messes up an entire top level circuit's bounding box.
2022-09-19 17:26:42 -04:00
Tim Edwards 7905e15ae3 Enhanced the "def read -annotate" option to correctly annotate pins
with class, use, and shape information from the DEF file PINS record.
This is similar to what is done with LEF file annotation, but less
sophisticated (only erases an existing pin if it is an exact match
for pin name and location).
2022-09-14 13:02:55 -04:00
Tim Edwards 1178db42c6 Modified the "flatten" command so that flattened labels use an
alternative separator "." instead of "/".  This prevents other
routines that expect "/" to indicate a true hierarchy from treating
the label as hierarchical instead of flat, which should be the
correct handling for a flattened cell.
2022-09-08 18:05:44 -04:00
Tim Edwards 1c20abad5b Updated the version with the last commit, which was supposed to be
done yesterday and so shouldn't have needed a version update.
2022-09-08 11:13:25 -04:00
Tim Edwards 84b429792d Modified the cell copy routine so that it does not attempt to
guarantee unique instance names during generation of each new
copy, but only afterward, in bulk.  Otherwise the copy routine
has a runtime that is exponential with the number of cells being
copied.  This and the last commit guarantee that the "flatten
-novendor" option works as advertised.
2022-09-07 17:02:36 -04:00
Tim Edwards 4087ac2dba Added a prototype function for DBDescendSubcell(), without which
the return value is cast to the wrong size and all calls fail.
2022-09-07 15:27:11 -04:00
Tim Edwards 63b9590958 Updated version to go along with the merge of pull request #181
from Brad Smith, for OpenBSD compatibility.
2022-09-04 12:48:42 -04:00
Brad Smith 662a041dba Make use of termios on OpenBSD 2022-09-02 23:52:34 -04:00
Tim Edwards 4afc476d92 Modified the "element" command so that coordinates may be given in
physical units (e.g., um).
2022-09-01 17:58:30 -04:00
Tim Edwards 5d51e10fb9 Corrected an error with perimeter calculation of a device that was
caused by other code that can move the plane of a device to match
the plane of a port.  Solved by retaining the original plane of the
node in the extTransRec structure, and using that to determine the
device plane for purposes of calculating perimeters and not double-
counting contacts.
2022-08-30 10:13:18 -04:00
Tim Edwards 2d4fb51ae6 Corrected a failure to check for an invalid layer in the routine
that queries a default layer width.  Otherwise this can cause a
segfault, especially when a technology file has not been specified
and the minimum tech is in effect.
2022-08-26 20:59:50 -04:00
Tim Edwards eed9882bf2 Modified the handling of GDS library names to avoid creating cells
with slashes in the name (picks up the text after the last slash).
Also allowed the "gds library" command option to modify the
behavior of "gds read" (previously only affected "gds write") to
indicate that the GDS file is a library and that there are no top-
level contents, only subcell definitions.  Also:  Corrected a typo
from yesterday's commit that prevents magic from compiling (oops).
2022-08-26 08:59:25 -04:00
Tim Edwards 2561afd402 Implemented the correction of Anton Blanchard's git pull request #180
"Antenna checker should ignore vias in partial mode".  I changed the
implementation by moving the correction into the antennaAccumFunc()
subroutine so that it skips the area calculations for the contacts,
avoiding unnecessary computation.  Otherwise, it's the same (vias
do not contribute to the surface area of the antenna when calculating
antenna area in "partial" mode).
2022-08-25 11:03:56 -04:00
Anton Blanchard e13e218778 Print cell name for antenna violations with diffusion diodes 2022-08-24 15:08:53 +10:00
Tim Edwards f45f3c96e5 Updated version to go along with the merge of pull requests 175 and 176
(OpenBSD/NetBSD/DragonFly support), and a change to the wrapper to allow
manual override of the number of icon columns (because sometimes some
window managers are clueless about the correct window dimensions).
2022-08-22 12:20:59 -04:00
Brad Smith 0bfb7c80d3 Simplify OpenBSD shared lib handling 2022-08-22 12:19:42 -04:00
Brad Smith e4f6926ac0 Use proper path for more(1) on OpenBSD / NetBSD and DragonFly 2022-08-05 22:44:29 -04:00
Tim Edwards f7df5e7c86 Added an option to "def read" to avoid creating obstructions from
"BLOCKAGES" statements.
2022-06-24 15:22:53 -04:00
Tim Edwards 43d5cc2804 Added a quick check on cell defs when running "antennacheck" to
make sure that the cell def's .ext is not marked "abstract".
Otherwise, "antennacheck" appears to run, but no output is
produced, and no reason is given.
2022-06-20 12:26:23 -04:00
Tim Edwards 2b7b12d34c Added a catch for a node named "(none)" in a merge line. This
prevents magic from crashing but does not do anything about the
fact that a non-existent node ended up in the .ext file, which
will have to be investigated.
2022-06-16 19:54:21 -04:00
Tim Edwards bb9b9660e7 Updated version to go along with the merge of pull request #169 from
Matt Guthaus.
2022-06-14 08:55:43 -04: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 085131b090 Modified the handling of polygon cells when writing GDS; if a
polygon cell has been created with the "gds polygon subcell"
option and the parent cell is read-only (vendor GDS), then the
polygon cell does not actually exist in the original GDS and
should not be output during a "gds write".
2022-06-09 11:44:58 -04:00
Tim Edwards d099562e85 Fixed two issues: (1) Found a backwards-incompatibility with the
fringe capacitance halo where the default halo distance was set to
zero instead of one and caused divide-by-zero issues;  (2) Found
extraction issues where labels picked up from cells flattened
during GDS reading cause the flattened/emptied cells to show up
in the extraction with extra pins that can mess up LVS.  Solved
this by removing labels from flattened/emptied cells.
2022-06-08 16:02:40 -04:00
Tim Edwards 1d570a5b67 Found one more error that was causing issues with the hierarchical
capacitance adjustments, and may have caused issues with basic
hierarchical extraction as well (although I have not checked or
proven the latter).
2022-06-04 21:09:54 -04:00
Tim Edwards bcf35db713 Working through various issues with parasitic capacitance extraction
using the newer methods for nearest-edge searching and fringe area
of effect.  Removed a same-net check in a routine that removes
capacitances that are redundant due to hierarchical overlaps;  these
redundancies must be checked on shapes within the same net.  Corrected
(again) an out-of-clip-bounds check.
2022-06-04 08:16:50 -07:00
Tim Edwards 3d4b3ad914 Found another place where a bounds check on the clip area was not
done (at all), again resulting in negative capacitances.
2022-06-01 04:54:59 +00:00
Tim Edwards 8d985ea766 Corrected an error in the fringe area calculation that was supposed
to be ignoring geometry outside the area of the halo, but wasn't.
2022-05-31 22:45:46 -04:00
Tim Edwards bbcc05c004 Corrected a (very bad) accidental deletion in the last commit that
causes the compile to fail.
2022-05-29 21:20:32 -04:00
Tim Edwards c997f4cccf Modified the configure script and Makefiles so that systems that do
not include zlib by default will pick it up from the compile line.
2022-05-28 17:51:20 -04:00
Tim Edwards c001de3d9d (1) Corrected an error in generating GDS_FILE properties when
reading GDS files, caused by an unneeded change to pass both
the "original" filename and the actual filename when handling
compressed files---The original filename is unneeded.
(2) Implemented several new methods for parasitic extraction.  The
first is an option offset value to apply to sidewall calculations.
This handles issues where actual wire separation is different
from drawn wire separation, which can be significant for the
1/d calculation of sidewall coupling.  The second method is to
use the recently-added fringe halo to compute the coupling of the
fringe capacitance to nearby wires.  Prior to this change, all
fringe capacitance was applied to surfaces directly under a wire
edge as if the fringe capacitance did not extend outward from the
edge.  Now the capacitance is properly pro-rated for the position
of any overlapped shape inside the fringing field.  Finally, the
third method added is a new search algorithm for finding the
nearest shapes along the length of a boundary.  This is used for
sidewall coupling and fringe shielding, where the nearest shape
dominates the coupling, and any shapes behind are shielded and
may (to first order) be ignored.  Previously, the entire halo
was searched without regard to shapes shielding other shapes
behind, and a recent correction added an ad-hoc search for
blocking shapes that was inefficient and not always correct.
The new method is both efficient and accurate.
2022-05-28 10:33:21 -04:00
Tim Edwards 4f5e1aec6b Corrected a typo in the new sidewall coupling shield check that
will cause an infinite loop during extraction.  Fixes issue #166
on the github issue tracker.
2022-05-18 09:26:00 -04:00
Tim Edwards 62ce6cde05 Corrected an error in the call to calmaDumpStructure(), which I added
an extra argument to, briefly, and then failed to remove it from one
call.
2022-05-12 20:43:30 -04:00
Tim Edwards f5382b824c Updated the version because the github mirror was copied earlier
today due to the critical fix for the compressed GDS file code.
2022-05-12 17:36:28 -04:00
Tim Edwards 3dca72d873 Applied the same solution as was just committed for sidewall coupling
to the fringe shielding calculations, which uses very similar code and
suffered the same problem of not being able to recognize when another
shape was between the two edges under consideration.  Fixing this
makes the fringe shielding calculations symmetric, as they should be.
2022-05-12 17:32:17 -04:00
Tim Edwards 8138bc71db Added some code to the sidewall coupling search that will avoid
computing coupling to shapes that are shielded by other
intervening shapes.  This is not a perfect solution but will
properly handle all but a few pathological cases.
2022-05-12 13:51:50 -04:00
Tim Edwards 0c38707542 A number of other corrections around CalmaFullDump, which had
mistakenly recast the input file routines from zlib back to stdio;
only the output file routines should have been changed.
2022-05-12 09:55:38 -04:00
Tim Edwards b643f44659 Modified the configure script to allow zlib compression to be
disabled from the configure command line.  Corrected an error with
the non-zlib-enabled compile.
2022-05-12 09:27:32 -04:00
Tim Edwards 93c96c23a1 Corrected an error in the new zlib GDS reading code that missed
changing the "rewind" function to "gzrewind", causing a crash when
a GDS file has to be re-read due to out-of-order contents.
2022-05-11 12:38:05 -04:00
Tim Edwards 250d811fc5 Removed the unused former checks for system "gzip" and "gunzip" from
the configuration script.
2022-05-10 09:24:46 -04:00
Tim Edwards 371018ae4b Implemented native gzip compression/decompression using zlib routines.
Compression levels of the output can be controlled with the "gds
compress [<value>]" command, where <value> 0 (default) is uncompressed
output, 6 is "normal" gzip compression, and 9 is maximum compression.
2022-05-10 09:19:39 -04:00
Tim Edwards 6e0768ebd4 Removed the "-k" option from "gunzip", which is not only redundant
with "-c" but is unsupported on some OS versions of gunzip.
2022-05-09 15:27:51 -04:00
Tim Edwards da49a50d8e Extended the code from the previous commit to handle automatically
pointing GDS_FILE to a compressed filename when using "gds readonly
true" on a compressed file.  The start and end pointers still point
to data bounds in the uncompressed file.
2022-05-05 18:04:41 -04:00
Tim Edwards 85d8ad6622 Added the capability to handle compressed GDS files through the use
of systems calls to "gzip" and "gunzip".  A compressed GDS file can
be made simply by doing "gds write <name>.gds.gz", and can be read
simply by doing "gds read <name>.gds.gz".  Names of compressed files
can be put in the GDS_FILE property of a cell.
2022-05-05 17:40:56 -04: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 e00633b8a1 Corrected an issue in the extraction where a region could be set to
a split tile type, causing a crash if the node name had to be
discovered by a "hard search".
2022-05-04 12:00:09 -04:00
Tim Edwards 99384a63c7 Still recovering from unintended consequences of setting EditCellUse
to NULL for a read-only view. . .  Changed the command "what" so that
it will not fail on a non-edit cell.  There are likely a few other
commands that should not fail on non-edit cells because they do not
alter anything.
2022-05-03 18:03:27 -04:00
Tim Edwards f760b038d6 Updated VERSION to go along with the merge of pull requests 160
and 161 from Donn, and modified one of the files from PR 161 to
maintain typographic consistency.
2022-05-03 08:32:00 -04:00
Mohamed Gaber e240185298 Disable Mac CI for now: XQuartz breaks on Github Actions 2022-05-03 08:30:40 -04:00
Mohamed Gaber 9bf3d76260 Mac Build Fixes
+ Add "smoke test" build CI to Github Actions
+ Added a configure_mac script (requires brew)
~ caddr_t -> void* (was never a part of any UNIX standard)
2022-05-03 08:30:39 -04:00
Donn 98cd88f12c Update to CentOS 7, Add AppImage CI 2022-05-03 08:28:53 -04:00
Donn b9f1ebd439 Makefile cleanup, dockerignore 2022-05-03 08:28:53 -04:00
Donn 2820aa49e2 Add AppImage Building Capabilities
(Take two)

+ Adds a GitHub Actions flow that builds an AppImage (see AppImages.org) that can produce a monolithic magic binary
~ Fix a portability issue in tcltk/magic.sh.in

This binary should theoretically work on any Linux distro with Glibc 2.3+ and Cairo 1.8+, which is any up to date distro in the last decade.
2022-05-03 08:28:53 -04:00
Tim Edwards e082bf8c77 Corrected a problem with extresist in which node names are not
transferred when doing a node merge, which can cause named
terminals to get lost, because there is no longer a node with
a name corresponding to the terminal.  The node gets a default
name which is not the terminal name, and the netlist is broken.
2022-05-02 17:49:42 -04:00
Tim Edwards 4000dd758f Made a correction to the command option "contact erase" which was
not properly handling stacked contacts, failing to erase a contact
out of the middle of a stack.
2022-05-02 14:38:46 -04:00
Tim Edwards fcc884332b Made some corrections to the "extresist" code to avoid issues with
extracting a port-to-port net that does not touch any devices.
The error happens in a fairly rare set of cases.
2022-05-02 12:27:39 -04: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 fd4f239e2d Additional extensions to allow "extend" to be used for transistor
gates when the gate length minimum may be larger than the gate
width minimum, and to implement an "angles" option on the "width"
rule that can implement rules where a layer width must be wider
as measured from angled edges than from straight edges.
2022-04-20 21:29:32 -04:00
Tim Edwards a1adfaaa09 Corrected an issue with non-Manhattan tiles, caused by the fact that
the "width" rule is assumed to be symmetric, and not checked in all
four directions, as that would be redundant.  But non-Manhattan tiles
are not symmetric and must be checked all four directions.  Implemented
in a way that does not increase the DRC processing time.
2022-04-20 17:12:58 -04:00
Tim Edwards 55128d3437 Updated version. 2022-04-20 16:18:31 -04:00
Tim Edwards 8b2c33d8dd Added new tech DRC rule option "angles 45-only", which handles
rules such as "No 90 degree bends on transistors".
2022-04-20 16:16:20 -04:00
Tim Edwards 30ab57ee79 Found a problem with the calculation for the non-Euclidean grow/
shrink routine that over-computes the diagonal position (the
equation failed to divide the intersecting angle in half).
Rewrote the equation for the correct grow distance, still
accounting for the grid limit (if set).
2022-04-19 18:20:58 -04:00
Tim Edwards 62df377ba8 Made a correction to extHierSubstrate, which was checking for
substrate shielding types in a subcell inside the interaction area
only.  Since the interaction area is clipped by the "cookie cutter"
extraction areas, it could completely miss the shielding.  As
revised, any shielding under a subcell will effectively shield the
entire subcell.  This could be improved by warning if the subcell
has substrate connections outside of the shield area (as that is
not extractable), but that requires additional processing.
2022-04-13 18:01:18 -04:00
Tim Edwards e7de38899d Also fixed the error noted by Ryan Schmidt in Issue #156 (void
function attempts to return a value).
2022-04-13 08:39:05 -04:00
Tim Edwards 7b08d16542 Updated version to go along with pull requests 155, 157, and 158
from Ryan Schmidt.
2022-04-13 08:35:41 -04:00
Ryan Schmidt 874209b884 Fix inadequate quoting in MSED variable
Fixes:

sed: 1: "s/\/\\/
": unescaped newline inside substitute pattern
2022-04-13 08:35:14 -04:00
Ryan Schmidt 4c4b0e301b Resolve -Wcomment warnings
Resolve -Wcomment warnings like:

./cifin-cmos14b.gen:2:1: warning: '/*' within block comment [-Wcomment]
2022-04-13 08:33:45 -04:00
Ryan Schmidt b4d635a3ab Use the python3 that configure found
When running preproc.py, use the python3 that the configure script found
instead of assuming (via preproc.py's #! line) that it is called
"python3" and is located in PATH. This allows the user to specify a
different python3 by running e.g.:

./configure ac_cv_path_PYTHON3=/path/to/python3
2022-04-13 08:32:05 -04:00
Tim Edwards eb1e94f440 Corrected issue with extresist that involves a device with a
terminal connected to a substrate or well type that is not a
FET 4th terminal (e.g., a varactor, or maybe a diode).
2022-04-12 17:41:17 -04:00
Tim Edwards 9402b0dcdd Added a new command option "contact erase". This provides a way to
remove contact cuts from a layout without affecting the surrounding
metals, which is something that the "erase" command does not do.
2022-04-07 11:10:24 -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
Tim Edwards a09fa78d2c Found another issue with the substrate extraction, caused by the
fact that "extract all" does not enumerate cells from bottom up
as I had assumed---The order is roughly bottom-to-top, but cells
re-used in different places in the hierarchy could end up called
before one or more of their own subcells is extracted.  Since
this conflicted with the preparation of the substrate in each
extracted subcircuit, I changed the method to enumerate cells so
that it is properly bottom-to-top.  Also, methods were added to
"extract" (incremental), "extract cell", and "extract parents"
to ensure that the substrate is prepared on all subcells before
extraction.
2022-04-05 21:33:15 -04:00
Tim Edwards ff10aedf69 Added a prototype declaration for LefReadLayerSection (see github
issue tracker issue #154).
2022-04-05 09:50:36 -04:00
Tim Edwards 7199cefddc Found that ExtFindRegions() does not set temp_subsnode to NULL like
extFindNodes() does;  consequently, ExtLabelRegions() when called
after ExtFindRegions() may accidentally chain together a substrate
region with whatever was left in this linked list after the
previous call to extFindNodes(), with unpredictable results.
2022-04-04 21:16:03 -04:00
Tim Edwards a4c5945d60 Corrected parsing of NONDEFAULTRULES in a LEF file. Modified the
DEF reading to use vector fonts on PIN labels, with some ad hoc
rules for size and rotation (may need refinement).  Modified the
DEF annotation (def read -annotate) so that the preferred position
of labels is on a wire leading out from a pin connection, which
is a "safer" place to put it, in case the layout was manually
edited between the DEF read and annotation.  Fixed another two
crash conditions related to read-only views.  Corrected a startup
error caused by an uninitialized variable used by the "wiring"
section of the tech file.
2022-03-31 20:02:12 -04:00
Tim Edwards 37fec8a06a Tentative implementation of parsing NONDEFAULTRULE definitions in
a LEF file (complementary to the implementation recently added to
the DEF file parser).
2022-03-31 10:23:39 -04:00
Tim Edwards 222639e4c4 Corrected the diagnostic output of "configure" to no longer refer
to the "make.log" and "install.log" files, which no longer exist.
2022-03-30 17:38:40 -04:00
Tim Edwards 82695d981d Updated the command reference for the "def" command and the new
"display" command.
2022-03-30 17:32:29 -04:00
Tim Edwards a74f11e3b2 One correction to prevent some unnecessary messages when doing a
label annotation from a DEF file.
2022-03-30 17:17:09 -04:00
Tim Edwards cfb81101ec Added command option "-annotate" for "def read" that allows nets
to be annotated from a DEF file.  This is particularly useful if
"def read" has been used without the "-labels" option, and the
labels are needed at some point.
2022-03-30 13:02:12 -04:00
Tim Edwards e675decfc0 Cleaned up a bunch of stuff around "magicdnull", starting with not
linking it to Tk or X11 graphics.  Added new command "display" which
returns the display type, which is good for finding out if the
display is "NULL".  Added code to allow the wrapper to be defined
for NULL graphics with the Tk console, the main necessities of which
are to remove the "openwrapper" command, and to return immediately
from a number of tag callback functions.
2022-03-30 10:55:08 -04:00
Tim Edwards bfa4272481 Removed some diagnostic messages from "def write", and added code to
prevent "def write" from running on an unnamed cell.
2022-03-29 17:10:50 -04:00
Tim Edwards 0c584f9e77 Modified the configure scripts and makefile per Proppy's comments
in github issue #149.  This causes magic to no longer write log files
for "make" and "make install" but will properly exit with a non-zero
return code on any error during compile.

Also:  Corrected the command "tech drc surround <type1> <type2>" so
that it now returns the correct value when <type1> and <type2> are in
the same plane.  Added new command "tech drc directional <type1> <type2>"
which works the same way as "tech drc surround" except for directional
surround rules.  Used this to generate vias from "def write" with the
correct metal surround amounts included in the via definiton.  The
route analysis then ignores tile slivers that make up the surrounding
material around contacts.  Also implemented a method that handles
routes that are made of multiple thin tiles due to the maximum horizontal
stripes rule.  Now magic handles "def write" well except for not dealing
with non-minimum-width routes unless they're specifically called out as
"special" nets.
2022-03-29 16:52:01 -04:00
Tim Edwards 3bc80a9869 Reran autoconf after merging changes from configure.in. 2022-03-28 22:35:49 -04:00
Johan Euphrosine 6947b8c6d7 scripts/configure: enable building without x 2022-03-28 22:35:19 -04:00
Tim Edwards 3b44dacab5 Corrected a minor issue in "def write" that will ignore a wire
completely if the width does not match the wire minimum width,
rather than attempt to cope with it gracefully.
2022-03-28 22:34:12 -04:00
Tim Edwards 84fbaa4ee1 Updated version with the offset fix. 2022-03-25 21:40:40 -04:00
Tim Edwards 2147d0a882 Corrected the offsets caused in "def write" when writing components
with "FIXED_BBOX" properties, which need to be positioned relative
to the abutment box, not the cell bounds.
2022-03-25 21:38:41 -04:00
Tim Edwards cf39fb102c Fixed some errors in DEF read/write and added behavior to "def write"
to treat unlabeled/unconnected layout as blockage statements in the
output.
2022-03-24 17:58:05 -04:00
Tim Edwards 645a872967 Implemented non-default rules for DEF reads. This is in preparation
for using such non-default rules for "def write" to capture any
layout geometry that is not a "special net" and does not have the
default wire width.
2022-03-23 17:08:39 -04:00
Tim Edwards 59b68606e0 Corrected the equations for fringe shielding, as the equation for
the shielding fraction was inverted---I do not know how the tests
could pass that way.
2022-03-23 10:49:02 -04:00
Tim Edwards a205a0e941 Corrected a potential segfault condition on "extract" if a cellname
contains slashes (which makes it look like a full path).
2022-03-21 09:06:35 -04:00
Tim Edwards d98645afc1 Added an important new method: If the keyword "fringeshieldhalo"
is specified in the extraction section of the techfile, then magic
will compute the effect of a nearby shape partially shielding the
sidewall overlap capacitance, which approaches 100% shielding as
the shapes converge to zero separation.  This method prevents
magic from vastly overestimating the fringe capacitance of closely
spaced wires, which was magic's worst problem with parasitic
accuracy.  The "fringeshieldhalo" value is the distance at which
the fringe shielding becomes negligible.  Typically, it will be
about three times the distance at which half the fringe value is
shielded.  It may be necessary at some point to make both the
fringe shielding halo and the sidewall halo values per-type values
(or per-plane, at least).  For now, it should suffice to bring
Magic's parasitic extraction back in line with other tools.
2022-03-17 17:35:41 -04:00
Tim Edwards 083c0c10e9 Modified the routine that flattens labels so that it does not prepend
the name of the cell use if the cell use is a top level window.  It
was accidentally discovered that using "select top cell ; select flat"
will do this (creating label text with spaces in the process, which is
illegal syntax for netlists).
2022-03-08 13:55:07 -05:00
Tim Edwards 353ca3aff6 Corrected the (recently implemented) "labellayer" GDS/CIF output
function, which was incorrectly multiplying through by two scale
factors, resulting in incorrectly-placed labels in the GDS output.
2022-03-07 11:44:30 -05:00
Tim Edwards 47df9da0d3 Debugged an issue where a label on the default substrate node may
not be seen during hierarchical processing, causing the substrate
to get split into several names that may conflict in the netlist.
At issue is the fact that ExtLabelRegions() will not attach a
default substrate label to a default substrate region.  This may
need further untangling, as extFindNodes() will set the default
substrate node and is sometimes followed by ExtLabelRegions(),
which will label it.  Any place ExtFindRegions() is called, this
could be an issue.
2022-02-26 17:39:36 -05:00
Tim Edwards b1b986cbe4 Added a procedure to esMakePorts() in ext2hier.c which tracks the
EF_SUBS_PORT flags up the hierarchy.  This is a rather lot of code
needed to make substrate connections to circuits where the substrate
connects to devices but not make such connections where the substrate
doesn't.  There may be simpler ways to accomplish the same thing,
depending on whether the order of "merge" statements in a .ext file
is reliable;  this code does not depend on it.
2022-02-25 20:59:59 -05:00
Tim Edwards bae5d9cd06 Added a command-line option "magic --commit" which provides the commit
number from the git repository, which is overall more reliable than
the version number, but mainly to support a common method across the
open source tools for providing information to builds like open_pdks
that may need to know what version of every tool was used for the
build.
2022-02-25 09:56:22 -05:00
Tim Edwards db4fa65bfc Corrected some issues related to the handling of substrate hierarchy.
Most of this had to do with the incorrect use of the parent's substrate
name in extHierSubstrate().  After the correction, there still remains
an issue that is caused when a labeled isolated substrate region overlaps
an extraction tile boundary.  I believe that this particular error has
existed for some time and is not new, so I am committing these changes.
2022-02-24 16:47:11 -05:00
Anton Blanchard 3d41b3e98b Fix a few issues with missing or incorrect prototypes
There are a few places we either don't have a variable or
function prototype and need one, or we have one and they
don't match.
2022-02-23 21:04:19 -05:00
Tim Edwards 16c0a65adc Several important fixes to the handling of coupling capacitance,
which had become fouled up due to the changes in the way that the
substrate is defined and handled.  Worked through a large torture
test until all types of substrate coupling and overlap shielding
were resolved to be extracted as expected.
2022-02-23 20:57:30 -05:00
Tim Edwards 505155497e Resolved an issue with magic crashing during "antennacheck" due to
a routine that should have been called with a NULL argument, but
instead was called with no argument, making the behavior system-
dependent.  Revised the parsing of the "defaultareacap" and
"defaultperimeter" statements in the tech file, such that the short
version of both statements gets automatic handling of the substrate
and isolated substrate areas;  this goes back to the recent change
in extraction behavior to redefine the "substrate type" (e.g., pwell)
during extraction as defining isolated substrate areas, and not the
default substrate.  The earlier code change dealt with problems
related to extracting nodes and regions, but did not consider how
parasitic capacitance was affected.  This commit resolves that issue.
2022-02-23 15:02:40 -05:00
Tim Edwards f8390b78f8 Tackling a section of code with poor performance in extraction.
The extSubtree() routine cuts a layout into squares and extracts
each separately, checking for subcell interactions.  In each
square it parses all labels looking for unconnected ones.  This
section of code not only parses all labels M x N times, but it
then marks interaction areas where there may be none, forcing
additional unnecessary processing.  This commit makes the first
quick optimization, which is to change the return value of
DRCFindInteractions() from boolean to integer, allowing it to
return a value indicating that there are no subcells in the
area.  This prevents the loop through labels from happening in
cases where there can never be interactions.  More to come.
2022-02-20 17:36:49 -05:00
Tim Edwards 7d601628e4 This commit adds an additional function to the substrate generation,
effectively forcing the substrate type (e.g., "pwell") to be defined
as delineating isolated substrate areas only (e.g., pwell in deep nwell
or isosub a.k.a. subcut).  It does so by erasing all of the substrate
type out of a cell prior to extraction before redrawing it in the
isolated areas.  This avoids issues caused by pwell drawn in separate
unconnected areas of a cell, as these are removed and the area treated
as the default substrate everywhere.  Has worked on all layouts tested
so far.
2022-02-17 17:06:25 -05:00
Tim Edwards 2e99d0cff7 Changed the behavior of "extract" routine extFindNodes() to not
check for abstract views to determine how to handle the substrate
node.  Running tests to check if this has any negative impact on
the extraction of abstract views that do not specify substrate
and well types.
2022-02-17 11:27:43 -05:00
Park-Hyung-Joo 31639f61fc fix error in transform part in cmdDumpParseArgs 2022-02-16 13:26:40 -05:00
Tim Edwards f23aec37b9 Corrected the "select flat" command, which failed to recompute the
selection bounding box, causing all following commands to fail to
handle anything in the selection outside of the unit area (0, 0) to
(1, 1).
2022-02-16 11:28:06 -05:00
Tim Edwards 9086773d8c Added "!" as a macro for "drc find ; findbox zoom ; zoom 16" as
suggested by Matt Guthaus in github issue #127.
2022-02-15 14:27:28 -05:00
Tim Edwards 436a70ce65 Reverting the last commit, as the author (Donn) says it is not
ready and needs some work before it should be integrated into
the github workflows.
2022-02-15 14:17:38 -05:00
Donn 4ab32d219e Add AppImage + CI 2022-02-15 14:13:15 -05:00
Johan Euphrosine 4677aae8d6 commands/CmdLQ: fix typo 2022-02-15 14:09:56 -05:00
Tim Edwards 3a758912c4 Corrected a small issue in the "property" command that will attempt
to free memory from location 0 if the cell is not editable.
2022-02-15 12:01:11 -05: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 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 750ad12677 Updated version (after pulling last commit). 2022-01-31 15:33:56 -05:00
Tim Edwards 9bc9435337 Merge branch 'master' of opencircuitdesign.com:/home/tim/gitsrc/magic
Pull before push.
2022-01-31 15:32:42 -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 62c8af719c Modified the "box" command to run a check on the specified box values
and raise an error if the values are outside the range (MINFINITY,
INFINITY) used by magic's layout planes.
2022-01-27 16:57:23 -05:00
Tim Edwards 45bb62de2f Merge branch 'master' of opencircuitdesign.com:/home/tim/gitsrc/magic
Pull me.
2022-01-24 17:20:42 -05:00
Tim Edwards ee1d1ae5b0 Corrected an error in LEF write in which sticky labels that declare
the label to be attached to a non-contact type when the label is
actually over a contact are not handled correctly when checking if
multiple labels should belong to the same port record.
2022-01-24 17:19:13 -05:00
Tim Edwards 019b852d84 Corrected a typo from the previous commit (causes other flags to
be cleared when setting the fixed timestamp flag for LEF reads).
2022-01-22 14:35:33 -05:00
Tim Edwards 8e80644dd7 Could not get the LEF datestamp to work correctly as a pointer,
due to issues of declaring global variables;  rather than track
down the correct use, just reworked it so that the value is just
an integer and takes -1 as the default (fixed timestamping
disabled).
2022-01-22 13:30:11 -05:00
Tim Edwards 81ecdbf209 Added a "lef datestamp" command option which is the equivalent of
"gds datestamp" for LEF reads.  When set to non-default, all cell
definitions created from LEF macros will be given the specified
timestamp, which allows the stamps of abstract views to match the
stamps of full views, preventing issues of updated timestamps
whenever a layout is switched between views.
2022-01-22 13:02:47 -05:00
Tim Edwards 416b604eff Fixed the "copy-up" CIF rule handling, which failed to clear the
CDFLATGDS flags after removing the copied-up planes.
2022-01-22 11:32:43 -05:00
Tim Edwards e1aedc6f41 Decided that a different approach needed to be taken for having
timestamps that are fixed, since the timestamp update routine is
called from too many places, too many times.  Instead created a
new cell definition flag indicating a fixed timestamp, which can
be set by "cellname timestamp" for an individual cell, or with
"gds datestamp" for cells read from a GDS file.
2022-01-22 11:18:32 -05:00
Tim Edwards 3065d4cc4b After much pain and suffering, finally tracked down all the places that
the timestamp is updated after reading in CIF or GDS, and managed to
get the timestamp dirty flag to remain clear after reading when
"gds datestamp" is used.  This includes a modification of the timestamp
update routine that only updates timestamps on a single file if only a
single file is being written.
2022-01-21 22:17:54 -05:00
Tim Edwards 5dd0c97dce Modified the "writeall" command to (1) raise an error message when
"writeall force <cell>" is used but <cell> doesn't exist, and (2)
to add options "writeall modified" and "writeall noupdate" (which
may or may not be useful).
2022-01-21 17:43:04 -05:00
Tim Edwards 93c4503fa8 Refined the new "gds maskhints" command option for GDS input from
yesterday's commit to allow the syntax "gds maskhints <types>", in
which mask hints can be restricted to a specific list of layers
rather than all layers which define mask hints in the cifoutput
rule.
2022-01-21 14:48:59 -05:00
Tim Edwards 97441bc07a Extended the GDS timestamp handling to GDS input. Unlike former
behavior, in which all cells read from GDS are given a zero
timestamp, and the timestamp is set when the file is written to
disk, the default behavior now is to set the layout cell's timestamp
from the timestamp provided in the GDS (the creation date timestamp,
specifically).  The same command "gds datestamp" implemented in the
previous commit for GDS writes now also applies to GDS reads:  If
set to "no", then the timestamp value from the GDS file is
transferred to the layout view (default behavior);  if set to "yes",
then the timestamp is set to zero (legacy behavior).  If set to
a value, then the value is used as the timestamp.
2022-01-21 13:05:24 -05:00
Tim Edwards 09577b5636 Updated all of the documentation by copying back from the website.
The website documentation now points to these contents in a clone
of the repository on opencircuitdesign.com, so all future edits of
the command-line documentation will be made directly to the git
repository.  Also:  Changed the precision of box values printed in
microns from 2 to 3 digits after the decimal place, so that 5 nanometer
grids do not get values clipped in the output.
2022-01-21 10:44:13 -05:00
Tim Edwards 5629c2a6cd Changed the "gds nodatestamp" option to "gds datestamp" and added
"gds datestamp <value>" as an option to force a specific datestamp
on the GDS output.  This is a third option beyond the previous two
which were either to use the current time or to write zero.  The
new option allows an entire library to get a common timestamp, for
example, related to a PDK version number.  The "gds nodatestamp"
option has been retained for backwards compatibility.
2022-01-21 10:26:29 -05:00
Tim Edwards c2755a061f First cut at a method to automatically generate mask hint properties
in a cell to account for the difference between what's in an input
GDS file and what magic would write out itself from the processed
data.  This potentially allows library cells to be read in that
will generate the equivalent mask data as output without resorting
to using GDS file references as properties.  The method is activated
with the new command option "gds maskhints on" and the default is
off.
2022-01-20 21:50:13 -05:00
Tim Edwards 6deb7d4f01 Missed a few calls in CIFsee.c to the routine that was modified
in the previous commit, causing segfaults when using "cif see".
2022-01-19 15:46:15 -05:00
Tim Edwards 10c5ba99c9 Corrected an error in the hierarchical GDS processing of mask hints,
which failed to translate hint coordinates from subcells into the
composite cell, resulting in hierarchical GDS errors.
2022-01-19 15:37:45 -05:00
Tim Edwards c8c8f8b362 Slight change to the criteria for "electrical" types: Removed
device ID layers, and added substrate shield layers.
2022-01-14 17:42:21 -05:00
Tim Edwards 73314e30d7 Added some automatic handling of the "extract" section in the tech
file to generate a mask of all the types called out in the section
as being used for parasitic calculations (resistive and capacitive)
and device terminal types.  This is supplemented with a list of all
types that are specified in the "connect" and "contact" sections as
connecting to something other than themselves.  All remaining types
are considered non-electrical and removed from the list of types
that can be considered electrical nodes.  This works a bit better
than the existing method of using "resist <types> None" to specify
non-electrical types, as it is backwardly-compatible to older tech
files.  The upshot is that in the worst case, if a type needs to be
extracted as an electrical node but does not satisfy any of the
above criteria, then it should be added to the "resist" list, with
a resistance of 0 if necessary.
2022-01-14 17:30:05 -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 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
Jean-Paul Chaput f354920133 Patch for gcc11/RHEL9 2022-01-12 15:33:42 -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 f43bd19e36 Made small modifications to Anton Blanchard's pull request #120 to
use DBTypeLongNameTbl[] instead of DBTypeShortName() to print the
names of the illegally overlapping types.
2022-01-10 22:38:20 -05:00
Anton Blanchard 93dbc77dcf Add more information to illegal overlap warnings
Print the names of the tile types that are illegally overlapping. This
gives us a better idea of what is wrong, eg:

feedback add "Illegal overlap between obsm2 and m2 (types do not connect)" medium
2022-01-10 22:34:56 -05:00
Tim Edwards 940a18efab Updated the version to go along with the merge of several pull
requests (117, 118, and 119) from Anton Blanchard.
2022-01-10 14:05:34 -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
Anton Blanchard 4f79580248 Add missing includes
A number of places are using isspace(), tolower(), toupper() and strcmp()
without including the relevant header.
2022-01-10 14:01:36 -05:00
Anton Blanchard a5614e0d97 Fix typo in MakeLegalLEFSyntax
In MakeLegalLEFSyntax we step through the badLEFchars string
but instead of looking for the NULL terminator, we instead
look for a NULL pointer.
2022-01-07 20:37:00 +11:00
Tim Edwards f89d52dbcc Modified the short selection routine (again) to avoid issues when
tracing the short path back through stacked contacts.  Discovered
a problem with the connectivity search routine (which has been in
the code for a very long time) which will fail to copy contacts
to the selection cell if it has already drawn one of the metal
layers in the same place.  This has now been fixed.
2022-01-06 13:29:43 -05:00
Tim Edwards 2fc0e669b6 Some optimizations on the "select search" function. Mainly this
stops checking for the "best" path during the feed-forward check
and only enumerates the cost function for every tile in the
selection, moving outward from the source.  This keeps the
algorithm efficient.
2022-01-03 17:49:54 -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 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 6a78f4967e Updated the version to go along with pull request #115 from github
user susinxy.  Edited the merged code slightly, without changing
the functionality.
2022-01-01 13:24:18 -05:00
susinxy 620217b860 fix tech file load error with qflow 2022-01-01 13:18:09 -05:00
Tim Edwards 72227b4995 Revised the messaging coming from "gds read" so that it does not
post error messages when a GDS library addendum is read.  It now
assumes that if a cell is called but not defined in the GDS, and
that cell happens to be in memory already, then this is intentional.
2021-12-31 23:11:24 -05:00
Tim Edwards cb27fba5ab Attempted another optimization to speed up the short-finding
algorithm, but it's clear it needs a lot more than that.
2021-12-31 22:57:54 -05:00
Tim Edwards abc4b263a5 One additional optimization to the routine just committed, which
avoids pushing space tiles and processing them just so it can pop
them off the stack and deallocate the memory.
2021-12-31 22:25:22 -05:00
Tim Edwards f81560557b Modified the routines used by "select short" so that they use the
stack routines in utils/stack.c instead of relying on a recursive
routine, which will run out of the computer's stack space pretty
quickly on a large layout.
2021-12-31 22:19:11 -05:00
Tim Edwards 05b1c75455 Missed one use of the word "fatal" in ExtCell.c. 2021-12-31 14:06:04 -05:00
Tim Edwards d65be34f98 Attempt to lighten up on the use of "fatal" referring to errors
that are not fatal to the program, the circuit, and sometimes not
even errors.
2021-12-31 14:02:58 -05:00
Tim Edwards 271449128a Updated the way that the technology file parser handles the
"defaultareacap" and "defaultperimeter" statements in the technology
file.  Now, the parser makes use of the configuration of the
substrate from the "substrate" line to generate a default list of
which types and planes represent the substrate, and which types and
planes represent shielding to the substrate.  This solves an issue
with the use of substrate isolation layers (e.g., "isosub" in
sky130A), because its definition and usage created substrate shields
on two planes (well and dwell), while the syntax for "defaultareacap"
and "defaultperimeter" only allow one shielding plane to be defined.
2021-12-31 11:13:59 -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 be5b6dec0c Updated version to go along with the merge of pull request #113
from Brad Smith.
2021-12-30 09:26:38 -05:00
Brad Smith 10fa302bba Correct & has lower precedence than parentheses warnings.
CmdRS.c:1269:22: warning: & has lower precedence than ==; == will be evaluated first [-Wparentheses]
DRCtech.c:2573:16: warning: & has lower precedence than !=; != will be evaluated first [-Wparentheses]
2021-12-30 04:35:03 -05:00
Tim Edwards cf28ad6cf9 Removed a bogus setting for freeBSD that was pointed out by Brad
Smith and which had escaped my attention.  The commit from 8/3/2019
fixed an obvious fatal error but just replaced it with something
syntactically clean but nonsensical.  This commit just removes the
questionable line altogether.
2021-12-29 21:14:44 -05:00
Tim Edwards 6adcd2dc74 Updated the version to go along with the merge of pull request
112 from Brad Smith.  Also ran autoconf, since change was made
to configure.in and the standard instructions don't call for
autoconf to be run.
2021-12-29 21:06:48 -05:00
Brad Smith 60b2660b39 Eliminate bogus clearing of CPPFLAGS so the contents of CPPFLAGS
is properly passed down throughout the autoconf script.
2021-12-29 19:03:37 -05:00
Tim Edwards 9af44230eb Removed an oddball method put into the extflat code some time ago
that makes a net a global net if there is a Tcl variable of the
same name.  This conflicts with a later use of Tcl variables VDD
and GND to denote power and ground names, which is a completely
different usage.
2021-12-25 16:14:37 -05:00
Tim Edwards 86f7c1f2cf Corrected the return value of extSubsFunc2(), which was returning
value 1 after finding a substrate connecting type shielded (by deep
nwell, in the example) from the substrate, thus preventing the
search from processing any remaining substrate types.  Solved by
changing the return value to zero to keep the search going.
2021-12-23 16:31:34 -05:00
Tim Edwards 716848067e Made a few corrections that stem from the change to add a separate
record to the label structure to hold the port number.  One major
issue stemming from this was reported in github issue #203 by Anton
Blanchard.  This commit fixes that error.
2021-12-22 12:08:34 -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 7297ca079f Found another long-time error in which a hash table created during
ext2spice is not freed.  This may account for the rest of the memory
leak that was partially fixed in the previous commit.
2021-12-13 16:55:02 -05:00
Tim Edwards 82f280e23e Corrected a failure (in the code for many a decade) to properly
clean up memory after running "ext2spice".  There are apparently
still memory leaks somewhere, difficult to diagnose with valgrind,
but this fix removes the most substantial leakage and allows
"ext2spice" to be run continuously, at least for a while.
2021-12-13 16:12:30 -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 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 9f7011333a Fixed the behavior of the "def write" command, which was not
clearing the "subcircuit" flag from the top level cell, causing
only nets connected to ports to be output.
2021-12-06 10:56:59 -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 bfdf1227a7 Modified the "extract unique" behavior so that it treats "soft"
connections through the substrate as the same node, and so will
not force different nodes names on the soft connection to be
unique.  This should probably be selectable behavior.  However, as
written, the "extract" command will always merge soft connections,
so giving them unique names just causes problems with "extract".
2021-12-04 15:04:01 -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 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 6d289d4061 Updated the README.md file to change a broken web link and correct
some other horribly outdated content.
2021-11-29 22:12:26 -05:00
Tim Edwards d43013048d Corrected a recent line change to return "0" instead of void, per
github Issue #104 by lantertronics.
2021-11-29 17:57:18 -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 8957d4b947 Slightly modified various use cases of "cellname" so that they
behave as one would expect;  e.g., "cellname self" returns the name
of the currently edited cell if nothing is selected;  "cellname
rename <name>" renames the currently edited cell to <name>.
Modified the "extract" command so that it will not extract a cell
named "(UNNAMED)" but will insist that the cell must be given a
proper name, much like the "writeall" command does.
2021-11-25 12:40:51 -05:00
Tim Edwards 021e9b5eec Modified the print routines so that TxPrintf and certain uses of
Tcl_SetResult() will backslash-escape "$" characters occurring in
names (e.g., cell and net names) when the "$" does not represent
a Tcl variable.
2021-11-24 12:40:59 -05:00
Tim Edwards e670dd9720 Corrected the error in which "splitpaint" and "spliterase" are
incorrectly applied to locked layers, as reported by Mark Martin
in issue #95 on github.
2021-11-24 12:01:45 -05:00
Tim Edwards c7e59ef461 Corrected issues with loading an invalid tech file. Also corrected
the behavior that extensions other than ".tech*" are not honored in
a tech file name.
2021-11-24 10:56:08 -05:00
Tim Edwards 6b72a51b17 Fixed a segfault condition if doing "splitpaint" on a zero-area
rectangle.  Likewise, this also fixes an unexpected result when
doing "spliterase" on a zero-area rectangle (which does not cause
a segfault, but is not what one would want magic to do).
2021-11-24 10:00:15 -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 f8a45a19bb Corrected the non-Manhattan DRC edge check, which was failing to
account for the fact that non-Manhattan tiles are processed twice
in the search, with the side mask bit 1 and 0 for each call.  The
DRC check, like the Manhattan checks, only needs to check one of
these.
2021-11-17 10:55:50 -05:00
Tim Edwards 73bad08457 Updated the version to go along with the merge of pull request
the existing coding style.
2021-11-17 09:12:47 -05:00
Maximo 7083d1904c Quick fix of 'def write' issue with the nets extending beyond it's original shape in some cases. It would be good to analyze in more detail the use of the extlen variable 2021-11-17 09:10:00 -05:00
Maximo 730746664c Fixed 'def write' warning message about default net widths. It was informing the wrong dimension 2021-11-17 09:10:00 -05:00
Maximo 7c13915205 Corrected 'def write' location of components. It was using the boundaries on the parent without taking into account the internal cell origin point 2021-11-17 09:10:00 -05:00
Tim Edwards cf47772278 Corrected the "grow-euclidean" option for grow/shrink/bloat-or so
that it correctly lands on a grid limit boundary (which the
previous commit did not do).  Note that work is still ongoing to
detect some pathological cases where the shapes end up off-grid
where two non-manhattan shapes intersect at different angles
(such as an inside corner).
2021-11-16 17:33:05 -05:00
Tim Edwards 7ffe8bc866 More or less reverted the last commit, as it was found that the
calculation for "limit" in the CIFgen routines was wrong, not the
interpretation of the "gridlimit" value in the tech file.  The
parsing of "gridlimit" has been put back the way it was before the
last commit, and the "limit" value calculations have been corrected.
2021-11-16 15:15:33 -05:00
Tim Edwards db6128232f Added a new cif/calma layer type "labellayer" that can be used to
tag geometry with a specific label which is the name of the layer.
2021-11-16 10:58:18 -05:00
Tim Edwards e8eb96103d Modified the Euclidean distance "grow" operator so that it honors
the grid limit setting.
2021-11-16 09:59:23 -05:00
Tim Edwards bee0039e43 More updates to prevent magic from crashing when commands are run
on non-edit cells (this time, "erase").
2021-11-12 13:57:26 -05:00
Tim Edwards 898783467c Corrected the "lef write" routine to more correctly handle port
statements, with all "hard" connections being enumerated in the
same PORT entry, and "soft" connections (same label on unconnected
areas;  e.g., through substrate or resistor device) being
enumerated as separate PORT entries, per the LEF spec.  Also
corrected behavior with respect to the "lef write -toplayer"
option, which was treating each port label independently, and so
generating entries for lower layers of a port if there were ports
on those layers, in contravention to the "-toplayer" option.
Also:  Added the PINS section to the "def write" output;  this had
been left as a "to be completed" item but was never done in spite
of being easy to add.
2021-11-12 11:34:16 -05:00
Tim Edwards 3afc462cac Removed the dependence on EXT_DOLABELCHECK when generating node
entries for "floating" labels.  Otherwise it is possible for the
hierarchical checks to find the label in flattened geometry and
reference it, resulting in merge statements in an .ext file that
reference undeclared nodes, ultimately resulting in extflat
failing to perform the merge, and an incorrect netlist.
2021-11-11 10:01:05 -05:00
Tim Edwards f6695cea52 Added an error message when writing GDS if any cell being written
still has the default "(UNNAMED)" cell name;  this is not strictly
an error, but is almost certainly not what the user intended.
2021-11-08 10:25:38 -05:00
Tim Edwards 9af83abfe5 Updated version with the previous commit. 2021-11-05 12:17:10 -04:00
Tim Edwards ea301b53f8 Corrected a case of a missing variable initialization in the case of
reading a bad "bloat-all" statement in a techfile.  This prevents
magic from eventually segfaulting when exercising the recipe in which
the bad statement occurs.
2021-11-05 12:15:57 -04:00
Tim Edwards c0ea133e98 A recent commit caused connections to implicit (unlabeled) substrate
to not get into the subcircuit port list during ext2spice.  The new
fix brings back (unfortunately) the behavior of creating a substrate
node for cells that have no substrate connection to any device;
this will have to be handled separately.
2021-11-03 17:34:38 -04:00
Tim Edwards 3e07197dfa Adjusted LAYERS_PER_CONTACT from 3 to 4. This is not a preferred
solution;  it would be much better to make the value adjustible, but
the array of tiles sized to LAYERS_PER_CONTACT is a Region structure,
and the routine that frees the Region structures does not have a way
to call a routine to take additional measures like free'ing a sub-
structure of the Region.  A proper solution will require some work.
2021-11-01 09:26:21 -04:00
Tim Edwards c82c96cb73 Added checks to prevent magic from crashing when running various
commands on selections in a cell that is not editable.  Moves
and Copies were already handled correctly;  this correction fixes
Delete and transforms (e.g., rotates and flips).
2021-10-28 15:57:17 -04: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 34af2f3309 The "extresist" command was still generating "Couldn't find wire"
messages which was traced to code that changes a drivepoint position
to match a label;  the same drivepoint may be part of the record for
the initial position to search on the net, in which case if the
position is changed, then the tile type needs to be changed to match
the new position.
2021-10-11 10:18:27 -04:00
Tim Edwards bb8f7e6960 Revised the routine ResSortByGate() in ResRex.c so that it sorts
using qsort() instead of its own linked-list-based sorting, which
is horribly inefficient.  This change allows power nets (which
tend to be connected to all transistors) to be extracted in a
reasonable amount of time (hours instead of days).
2021-10-10 19:20:24 -04:00
Tim Edwards 2f7813094b Implemented glob-style matching for label selection. Introduces
an optional extra argument to the "select" command that can be used
to select labels by glob-style matching;  e.g., "select area labels
VSS*" or "select less area labels *_1".  This will help in managing
labels after flattening a standard cell design;  e.g., by using
"select less area labels */VDD".
2021-10-09 13:44:04 -04:00
Tim Edwards 537b1f057d Modified the generation of "equiv" statements in "extract" some more,
to eliminate all redundant names resulting from redundant labels.
Changed the behavior of "goto" so that it will find local names with
slashes, which are the result of using "flatten".  A hierarchical
search is done first, as before, but on failure to find a subcell
component, the local cell is searched for the verbatim name.
2021-10-08 10:58:10 -04:00
Tim Edwards 083ef458a8 Update of version with the fix to the last commit. 2021-10-08 09:36:51 -04:00
Tim Edwards bf89c834f4 Removed a line that should have been removed before the last commit. 2021-10-08 08:43:05 -04:00
Tim Edwards 4fae7a1a2b One more correction to limit, by default, the generation of "equiv"
statements in the .ext file output to those that mark a port as
equivalent to the node name used elsewhere in the file.  This
limits unnecessary output of "equiv" statements that can bog down
ext2spice and other commands that use the .ext file contents.
2021-10-07 21:36:10 -04: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 15f081b4da Made a change to ext2hier.c that should prevent the propagation of
substrate nodes in subcircuits that don't make connections to the
substrate (such as arrays of pFETs).  This is done under the
restriction that ext2spice is being called without generating
parasitics (otherwise the connection to substrate is valid), as it
would be when extracting for LVS.  The ground node must not appear
as a connection to any device.  This is then propagated up the
hierarchy such that if none of a subcell's descendents connect to
the substrate, then neither does the subcell.
2021-10-05 20:34:22 -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 52a424e511 Added another option to the "extresist" command, this one to include
specific nets to extract, rather than excluding them.  That allows
"extresist" to target specific nets like the power supply or a clock
tree for extraction.
2021-10-04 15:32:37 -04:00
Tim Edwards 98a631144c Updated version to go along with the merge of pull request #90 from
Harald Pretl.
2021-10-02 11:07:17 -04:00
Harald Pretl 166e83d715
Update README.md 2021-10-02 11:31:45 +02:00
Harald Pretl e1c519a1aa Added installation instructions for MacOS (Big Sur).
Changes to be committed:
new file:   INSTALL_MacOS.md
2021-10-02 11:29:43 +02:00
Tim Edwards bd59849309 Reverted a line in EFread.c back to the way it had been before
magic version 8.1.154.
2021-09-28 22:07:58 -04:00
Tim Edwards 36864bc79e Reverted a change made in version 8.1.154. The implementation is
wrong, and it needs revisiting.  This is the cause of a number of
negative capacitances appearing in the netlist (even after accounting
for overlap with subcircuits).
2021-09-28 21:26:27 -04:00
Tim Edwards 73929a0bcc One more round of edits on that issue. . . 2021-09-20 20:14:25 -04:00
Tim Edwards 07ed2c13f4 Fix to the last commit, which was in error as pointed out by
Manar Abdelatty.
2021-09-20 19:46:57 -04:00
Tim Edwards c101d98921 Modified EFbuild.c to stop generating an error message when an
"equiv" statement is encountered in a .ext file when using the
"ext2spice short" option.
2021-09-20 15:02:57 -04:00
Tim Edwards 0bb6ac1fa9 Modified the extresist code to handle substrate extraction. Currently
this appears to work correctly but does not yet handle the implicit
substrate (space as substrate) or "virtually" isolated substrate regions
(which need to be removed for full parasitic extraction).
2021-09-15 16:25:46 -04:00
Tim Edwards 35a65a9ba1 Corrected the "def read" command so that when reading PIN blocks,
all geometry will be handled;  the previous behavior expected only
a single rectangle per pin and so would only acknowledge the last
entry in any list of rectangles for the pin.
2021-09-15 14:45:14 -04:00
Tim Edwards bfab888bc9 Cleaned up a few lines related to "equiv" nodes, which are not
actually an issue and probably never relevant.  extresist now works
except for substrate connections and soft connections between substrate
regions.  That will require additional coding, not bugfixing, so I'm
committing the last of this set of bugfixes before starting that.
2021-09-14 13:42:27 -04:00
Tim Edwards ce276d90af Finally got around to removing the hack that ignores power and ground
nets in "extresist" and replaced it by an option "extresist ignore"
in which specific nets can be called out to be ignored by extresist.
2021-09-13 14:12:21 -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 2eb47969c7 Another correction to deal with labels that are on contacts (the
port generation routine comes after contacts are removed, so such
labels must be searched for on the contact residues, not the contact
type itself).
2021-09-12 20:27:51 -04:00
Tim Edwards 02f42e7260 Corrections to the extresist code. Some of the changes are just
text formatting.  Made one critical correction to ResGetDevice() to
pass the device type;  otherwise, devices on different planes (e.g.,
MiM caps) with the same coordinate will always return the device on
the lowest plane, leading to incorrect results and an eventual crash
when the device record is free'd twice.
2021-09-12 17:20:22 -04:00
Tim Edwards 96b7c20c17 Added option "notopports" to "extract unique". The option
behaves like "extract unique all" on all cells below the topmost
level of hierarchy, and "extract unique noports" on the top
level.
2021-09-09 15:47:48 -04:00
Tim Edwards d63a102515 Made various updates and corrections to the "extresist" code in
support of devices with terminals on different plances, such as
capacitors, diodes, and bipolar transistors.  Output now appears
to give meaningful results for flattened layouts, although
numerous issues remain for hierarchical layouts.
2021-09-08 16:41:36 -04:00
Tim Edwards 0ebdf3e513 Updated VERSION to go along with pull request #87 from Ryan Schmidt.
Also using this to test the last update to the continuous integration.
2021-08-28 13:18:33 -04:00
Ryan Schmidt 3fd058d369 Fix typo in comment 2021-08-28 13:18:17 -04:00
Tim Edwards 4cba342ad0 Changed README to README.md to be compatible with github. 2021-08-28 13:15:08 -04:00
Tim Edwards 303c4c45dc Corrected the badge link in the README file to point to my own
repository and not Sai Charan's fork.
2021-08-28 13:04:52 -04:00
Tim Edwards 1ffd1c51ec Updated VERSION to go along with the merge of pull request #88 from
Sai Charan.
2021-08-28 13:00:06 -04:00
Sai Charan Lanka f038cf8c1b Update README 2021-08-28 12:58:58 -04:00
Sai Charan Lanka b099b17178 Create techbuilder.tcl 2021-08-28 12:58:58 -04:00
Sai Charan Lanka b2874d0c1b Update main.yml 2021-08-28 12:58:58 -04:00
Sai Charan Lanka 0835a682d9 Update main.yml 2021-08-28 12:58:58 -04:00
Sai Charan Lanka 5011052176 Update main.yml 2021-08-28 12:58:58 -04:00
Sai Charan Lanka 643c05e6db Update main.yml 2021-08-28 12:58:58 -04:00
Sai Charan Lanka 0e9035fff6 Update main.yml 2021-08-28 12:58:58 -04:00
Sai Charan Lanka 6560545ebb Update main.yml 2021-08-28 12:58:58 -04:00
Sai Charan Lanka e65b16ab8f Update main.yml 2021-08-28 12:58:58 -04:00
Sai Charan Lanka 31a7b4d66d Update main.yml 2021-08-28 12:58:58 -04:00
Sai Charan Lanka 474829e6b5 Update README 2021-08-28 12:58:58 -04:00
Sai Charan Lanka 5d61807126 Update main.yml 2021-08-28 12:58:58 -04:00
Sai Charan Lanka 13b1c94305 Create main.yml
Adding CI to MAGIC
2021-08-28 12:58:58 -04:00
Sai Charan Lanka e7bc994224 Delete techbuilder.tcl 2021-08-28 12:58:58 -04:00
Sai Charan Lanka 6b646fd103 Update techbuilder.tcl 2021-08-28 12:58:58 -04:00
Tim Edwards d711b12311 Updated the version with the last commit. 2021-08-25 21:42:20 -04:00
Tim Edwards 88d672c7a5 Corrected an error that prematurely exists the substrate search
if a shielded type is found, preventing any other substrate types
from being discovered and processed.
2021-08-25 21:40:27 -04:00
Tim Edwards f428b7c792 Corrected a scaling error that causes all extraction dimension values
to be scaled twice when using the "extract style" command and with an
extraction style that uses micron units.  The microns-to-internal
units conversion expects an unscaled result when calling
CIFGetOutputScale(), but except when loading a tech file for the
first time, this value is scaled, and causes the double scaling.
Fixed by unscaling the CIF output before reloading the extraction
style, then scaling it afterward.
2021-08-23 13:46:19 -04:00
Tim Edwards 56d1d9380e Corrected an error caused by the modifications to the DRC engine
to copy up errors from non-interacting subcells.  The routine was
only copying up TT_ERROR_P type errors, but for deep hierarchies,
TT_ERROR_S type errors may have to be propagated up as well.
2021-08-20 21:49:27 -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 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 c776c82445 Fixed an error in the DRC rule optimization ("||" used instead of
"|"), pointed out by Jim Everitt.  The error is pretty major, but
because the section of code it affects is just eliminating
unnecessary DRC rules, I believe that the only effect is that the
DRC ruleset ends up using more memory than it needs to.  But, good
to have fixed.
2021-08-01 12:04:13 -04:00
Tim Edwards 08461c9384 Simple change to "gds read" to print out a diagnostic message for
every 5000 uses read instead of 100;  this significantly cuts down
on the output.
2021-07-30 15:40:39 -04:00
Tim Edwards e553bbb7c3 Modified the "close" function in CIFgen.c so that it uses the
STACKPUSH/STACKPOP functions instead of recursing.  Otherwise it
has a tendency to cause the process to exceed the recursion limit.
2021-07-30 14:54:40 -04:00
Tim Edwards 1d8a59049c Added sanity checks to the GDS dump from GDS_FILE pointers. Since
it is easy to subvert the process by updating GDS without updating
the pointers, it is trivial to end up with bad GDS output.  The
sanity checks confirm that the position pointed to is a complete
structure (check begin and end records), and that it has the same
name as the cell (this is not a requirement, as there are reasons
one might want to point to data from a structure of a different
name, but a warning will be printed).
2021-07-30 13:45:03 -04:00
Tim Edwards 07e366ad8a Extended the "cellname rename" command to add an option "-force"
that can be used to force renaming of a read-only cell.  The
action revokes the read-only status of the cell and removes any
GDS filename and pointers from the cell's properties.  This can be
used to swap out a library cell in a layout for a custom version,
by first forcing a rename of the cell, and then resetting the
filepath of the cell and flushing.
2021-07-29 17:34:39 -04:00
Tim Edwards 55bf0ebd54 Corrected the "bridge" operator, which failed to check for "false"
tile corners in the check area to find areas needing bridges.
This prevents generation of unnecessary bridging geometry;  and
since the error made the check rotation-dependent, this may
resolve some "parent and child disagree on CIF" errors.
2021-07-28 09:40:36 -04:00
Tim Edwards 11c53bb6d5 Modified an ad-hoc rule in CIFgen stating that "squares" and similar
rules do not get hierarchical processing.  I am not sure why I added
that exception, which clearly is not like "bound" or "net" in causing
serious issues when used hierarchically.  The current counterexample
is the use in sky130A.tech for the NPC layer.  Based on that usage,
the exception has been relaxed to consider any "squares" and similar
rule during hierarchical processing if followed by a "grow" operator.
Possibly this is still not relaxed enough to capture all meaningful
use cases, but should suffice for now.
2021-07-27 16:13:54 -04:00
Tim Edwards 25166f2f7c Corrected issue with finding devices in ResMain()---there is not
necessarily a 1:1 correspondence from tile types to extracted
device names, and not necessarily a 1:1 correspondence in the other
direction, either.  So the search for devices at the location given
by the .sim file has been loosened to look for any tile type at that
location.  Matches are restricted to those in which the plane of the
type found is the same as the plane of the device recorded in the .sim
file;  this prevents matching device like MiM caps that may be in the
same location as a device in another plane.
2021-07-27 14:34:01 -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 758a7d72ec Corrected a potential segfault issue in "extresist" if it encounters
a port label that is not connected to a valid layer (e.g., space).
2021-07-23 10:39:59 -04:00
Tim Edwards 7c973ad91a Corrected an error caused by fixing the unterminated comment in
the last commit, which was an undeclared variable in the block
that was being left out accidentally.  So that has now been fixed.
2021-07-13 14:08:35 -04:00
Tim Edwards 648f27dcf0 Corrected an unterminated comment pointed out by Jim Everitt. 2021-07-12 09:52:14 -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 1d24d2869d Updated version with the last commit. 2021-07-10 21:17:12 -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 355399d3ef Modified the startup behavior so that if a ".tcl" script file is
presented on the command line, then all following arguments are
assumed to be arguments of the script and not additional input
to be processed by magic.  This allows arguments to be passed to
scripts passed to magic on the command line.
2021-07-08 16:03:05 -04:00
Tim Edwards 3b70c95013 Updated the version along with the fix to "cif coverage". 2021-07-04 22:34:52 -04:00
Tim Edwards bd787d2a97 Corrected the "cif coverage" command so that the coverage is not
accidentally converted from (long long) back to (int);  otherwise
the coverage is wrong on any large layouts, especially full-chip
sizes.
2021-07-04 22:33:42 -04:00
Tim Edwards 958d6f1670 Updated the version to match pull request #84 from Dan Moore. 2021-06-29 14:25:33 -04:00
Dan Moore 1aab7e5a3a parse USEMINSPACING LEF statement 2021-06-29 10:53:00 -07:00
Tim Edwards b0ed7f09a9 Modified the "flatten" command so that when used with "-dobox", it
is not necessary that the target cell not exist.  That allows a
layout to be flattened into a destination in pieces.  Also found
that the "flatten" command never frees memory for the CellUse it
creates for the copy, so fixed that as well.
2021-06-23 17:41:32 -04:00
Tim Edwards e36560fb90 Added a missing include of ctype.h to a source file that uses the
isalnum() subroutine.  Corrected an assignment in utils/tech.c
which was a syntax error that passes through the compiler.
2021-06-19 10:30:47 -04:00
Tim Edwards f001502a18 One small enhancement to the code of the previous commit: If a
cell is referenced by a GDS "addendum" file but is not in either
the tree of the root def or any other dumped GDS file, then check
the database for those files and output them if they exist.  This
allows one way to get around missing cells in the GDS output if a
cell from a GDS addendum is used but no cells from the library
that the file is an addendum of are used.
2021-06-17 12:55:45 -04:00
Tim Edwards e55c1ecbda Corrected issues with GDS write that come from two features recently
introduced:  The use of substitutions for PDKPATH and home directory
in path names for GDS files referenced in abstract views, and the
"gds addendum" option.  Both were interfering with magic's handling
of writing GDS files from abstract layout views.
2021-06-17 12:40:21 -04:00
Tim Edwards 39630ea710 Added missing function declaration for GeoCanonicalRect in
geometry.h.
2021-06-14 09:45:36 -04:00
Tim Edwards 37c5355b8f A very minor change to the code of the last commit preserves the
behavior of keeping the same first record when merging two nodes.
This does not seem to have any effect on extraction output.  But
since the order of nodes can make a difference and there is no
performance impact in the code change, I will keep it as-is.
2021-06-13 21:47:33 -04:00
Tim Edwards b335dfafff Modified the node merging in ExtHier.c to match the node merging
optimization done in ExtFlat, which is to keep a count of the
number of different node names assigned to the node so that when
merging, the one with fewer nodes can be updated to match the one
with more nodes.  Note:  This change is made on the assumption
that the names for node1 and node2 are equally preferred.
Supposedly the first name in the node list is canonical, so if
node1 is preferred in any case, it may be necessary to move
the first item of the second list to the beginning (a minor code
change).
2021-06-13 20:17:19 -04:00
Tim Edwards 6e09586c54 Changed the property attribute number used for cell instance names
from 98 (arbitrarily selected) to 61 (apparently commonly used by
other tools).  This should help increase compatibility with GDS
files output from other tools.
2021-06-13 12:23:07 -04:00
Tim Edwards df26cf1ace This corrects the issue raised in pull request #75 that breaks the
compile on clang and probably other finicky compilers (as well as
just being wrong).
2021-06-12 20:29:09 -04:00
Tim Edwards 75386e6467 Corrected the GDS read routine so that the "gds noduplicates"
option does not get undermined by GDS files that have cell
instances appear before cell definitions.
2021-06-12 11:40:13 -04:00
Tim Edwards e9f21885b3 Corrected an error in initNodeClient in ext2spice that uses
TTMaskSetMask() like = instead of |=, which doesn't work because
the mask is uninitialized.
2021-06-11 16:53:23 -04:00
Tim Edwards 36f61ca601 Modified the CIF/GDS array processing in CIFhier.c, finding that there
were incorrect assumptions made in the code from 35 years back or so,
for the case where the CIF layer halo is larger than the size/separation
of the cells in the array.  The new code will prevent the array routine
from copying hierarchical additions to the mask layers outside of the
array area.  Whether or not the new code has its own faulty assumptions
remains to be seen through thorough vetting.
2021-06-07 16:38:12 -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 78be76a650 Corrected a potential crash condition if attempting to read a GDS
cell without any edit cell defined.
2021-06-05 17:02:39 -04:00
Tim Edwards 0503ce0ebf Corrected the "surround_ok" spacing rule, which did not prevent
the layers2->layers1 swapped case from being implemented;  the
surround_ok rule type is by definition asymmetric and the two
layer sets cannot just be swapped.
2021-06-04 12:26:11 -04:00
Tim Edwards a8fcca13ee Corrected an error in the implementation of the CIF "mask-hints"
operator that failed to set cifplane to curplane before drawing into
it.  This can cause the "mask-hints" layers to vanish, or worse,
cause a segfault.
2021-06-01 10:25:34 -04:00
Tim Edwards 7d6c7f5797 Updated the version number. 2021-05-27 16:15:56 -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 7f11020ab4 Additional changes, almost all stylistic, to make the resis/ section
style conform to the rest of the database.  It is difficult to work
with code written in a sloppy, random style.
2021-05-26 22:34:36 -04:00
Tim Edwards 9aa39f820f A number of fixes to the extresist code (as well as style cleanup).
Still tracking down a problem with non-FET devices (e.g., capacitors).
So, work in progress.  Nothing should be affected outside of extresist.
2021-05-25 22:41:52 -04:00
Tim Edwards c22d584ac3 Corrected a problem with character array bound overflow when writing
values to a LEF file.
2021-05-25 11:05:33 -04:00
Tim Edwards 8d8fe2fe55 One correction to the last commit, otherwise segfaults are
essentially guaranteed. . .
2021-05-23 21:26:02 -04:00
Tim Edwards 82fada3af6 Corrected two somewhat related errors. When "getcell" finds a
name conflict and renames a cell, the name was not pointing to
the new name and immediately caused a crash condition.  However,
it got to that point by believing that cell "path/x" and "path/x.mag"
were different files.  The name was stripped of the extension but
the full file path was not, causing the confusion.
2021-05-23 20:59:00 -04:00
Tim Edwards e6f17735b8 Modified the "cmdDumpParseArgs()" routine (used, for instance, by
the "getcell" command) so that the "parent" and "child" arguments
will accept the standard syntax for coordinates used by most other
commands (will accept SI units or trailing suffix i/l for internal
or lambda units).
2021-05-23 14:09:50 -04:00
Tim Edwards 5e02726f7f Modified the cell load routine to avoid creating an "undo" record
for loading a cell after displaying an unmodified "(UNNAMED)" cell,
because "(UNNAMED)" will be deleted, leaving the undo record
invalid and causing a crash if it is attempted to be invoked.
2021-05-23 12:07:31 -04:00
Tim Edwards 0809dddbe0 Resolved an outstanding issue with extresist, which is that the
extresist extractor is less sophisticated than the standard extraction
and will not check through the list of device records belonging to a
single device type.  Therefore a device in the .res.ext may have a
different device name.  So name hashing and checks are made against
the tile type, not the device name, as the tile type + device
coordinates is sufficient to uniquely identify the device.  However,
the extresist extractor does need to be sophisticated enough to find
all the terminal types, so that needs to be fixed.
2021-05-21 22:41:51 -04:00
Tim Edwards 123219b5f1 Corrected an error in the extresist code that will cause an infinite
recursive loop and crash magic.  Corrected a number of other issues
along the way, especially one where routines in EFantenna and extresist
make use of array EFDevTypes which was only created by ext2sim and
ext2spice, and freed when done.  Having run extresist through valgrind,
there are still issues in the code.
2021-05-21 16:33:20 -04:00
Tim Edwards 032a2e7221 Merge branch 'master' of 192.168.0.7:/home/tim/gitsrc/magic 2021-05-19 17:24:04 -04:00
Tim Edwards 33edee6b42 Modified the condition under which the (UNNAMED) file is deleted
on loading a layout to avoid doing so with in a suspendall ...
resumeall block.  That avoids weird errors occurring when the
PDK toolkit scripts are run to generate a new device layout if
the top level layout is still (UNNAMED) and empty.
2021-05-19 17:21:59 -04:00
Tim Edwards ff913ddb23 Updated VERSION. 2021-05-17 15:22:27 -04:00
Tim Edwards 1c328dfe15 Corrected an error in the "cifspacing" rule check for non-Manhattan
geometry (which had gone unnoticed due to the lack of use of
"cifspacing" in any rule decks).  The rule was not checking for
all synthetic edges, because the tile type was expected to match
the rule type when the function is called, but with a non-Manhattan
tile, that may or may not be true and needs to be checked.
2021-05-17 15:18:05 -04:00
Tim Edwards 8d647287e2 Implemented a basic DRC check on non-Manhattan edges. Previously
checks on non-Manhattan tiles were made only on the straight edges;
this was sufficient for most checks.  However, it can miss the case
of facing non-Manhattan edges.  This check does not do triggered
rules because there is no non-Manhattan maxwidth algorithm implemented,
and because the triggering clipping area is a triangle and needs an
extension to support it.
2021-05-14 18:02:34 -04:00
Tim Edwards f8b6bd1525 Updated version for the last commit. 2021-05-12 22:50:53 -04:00
Tim Edwards aa9e06e498 Merge branch 'master' of 192.168.0.7:/home/tim/gitsrc/magic
Pull before push.
2021-05-12 22:50:13 -04:00
Tim Edwards d8450cf1d4 Corrected an issue with a conflict between the "gds ordering" and
"gds noduplicates" options (essentially, they were canceling each
other out).
2021-05-12 22:49:25 -04:00
Tim Edwards 693256c373 Corrected an error in extresist that caused it to lose track of any
port that has zero area for the label rectangle.
2021-05-09 16:58:49 -04:00
Tim Edwards 94a6daa9b0 Corrected the array DRC checking, which was clipping to the error
area + halo but then failing to limit overlap checks to that clip
area, resulting in bizarre errors whenever an array is made.  Not
sure why the error didn't show up more often.
2021-05-07 10:42:44 -04:00
Tim Edwards e403e92017 Correction to the previous commit (didn't work as advertised). 2021-04-27 14:53:34 -04:00
Tim Edwards be19fda504 Added a "gds unique" option that behaves like the default CIF behavior,
in which if a cell is read from GDS that has the same name as a cell
in memory, then the cell in memory is renamed to keep all cell names
unique in the database.
2021-04-27 13:07:27 -04:00
Tim Edwards 36f9bfb162 Added exceptions to avoid processing sticky labels in two other
places;  this cuts extraction time by half for the example being
used to test.
2021-04-26 17:00:37 -04:00
Tim Edwards 538d7201e1 Modified the behavior of "extract" so that it does not try to check
for sticky labels making connections through the hierarchy.  This
is only needed for some annoying layouts that put point-size labels
with no connecting geometry in cells, and causes magic to spent
excessive amounts of time searching through labels for any layout
that has lots of labels.
2021-04-26 12:19:33 -04: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 56c0620417 Properly handled the yes/no argument to "cellname writeable" so that
like other commands, it accepts the usual assortment of true/false,
yes/no, 1/0.
2021-04-22 15:39:32 -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 a5248a95d3 Additional correction for properly handling the substrate node
when generating the device outputs in the .res.ext file, which was
one of the main points of this exercise.
2021-04-21 21:04:17 -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 1e08e90b2f Additional modification to the previous commit to make the "-pinonly"
argument to "lef write" take an optional value which is a setback
distance, similar to "-hide", but specifically for limiting the
distance that pins can extend into the center of a macro.
2021-04-20 13:33:25 -04:00
Tim Edwards 5b00ee7b83 Added a "-pinonly" option to "lef write" to restrict the pin area
to what is defined by the label, and no additional surrounding
geometry.
2021-04-20 10:19:12 -04:00
Tim Edwards 521baa91d9 Modified the "gds write" command so that it issues a strongly-
worded warning if an abstract cell view is written to GDS.
Corrected the "cellname ... writeable" command to allow an
overrride of the read-only status of a cell.  That change had
been made before but apparently got reverted by the recent
rollback.
2021-04-19 12:53:32 -04:00
Tim Edwards 04fca92bf0 Finally got around to modifying the "cellname [list] top" command
so that it returns cellnames in "natural sort" alphabetical order
instead of the random order produced by scanning the hash table
of cell names.  Since this command is used by the "cell manager"
window code, which was also not doing any sorting, then this fixes
the same issue in the "cell manager".
2021-04-19 10:08:58 -04:00
Tim Edwards 4aa7e21a64 Merge branch 'master' of 192.168.0.7:/home/tim/gitsrc/magic
Pulling last commit from the server.
2021-04-12 13:32:59 -04:00
Tim Edwards a9fc99174a Revert "Removed the stupid restriction that "cellname readwrite" won't work"
This reverts commit 8b9c47c3ef.

Reverting back to the state before messing with the substrate extraction
code.  All of the substrate extraction code is now in a separate branch.
2021-04-12 13:32:16 -04:00
Tim Edwards a5e0de031c Corrected the "font measure" line in the wrapper Tcl code from
revision 131, as a Tk default font size less than 10 will round the
scaling factor down to zero and result in bad things happening.
2021-04-06 22:04:53 -04:00
Tim Edwards 3703560305 Removed some testing code that was not supposed to be in the last commit. 2021-04-06 10:15:15 -04:00
Tim Edwards 84f4bf82ea Corrected a few errors in the code from yesterday's commit. 2021-04-06 10:13:36 -04:00
Tim Edwards f84de3676a Moved the substrate plane/restore further out so that planes are
not restored until after all cells have been processed through
extraction.  Otherwise, top-down connections can end up with
different generated names for the same node, resulting in a
disconnect in the netlist.
2021-04-05 16:03:54 -04:00
Tim Edwards fca21c8fc0 Corrected an error causing weird and undefined behavior when
extracting substrate regions, due to failure to clean up the tagged
tiles after exiting a search due to finding a substrate type that
was not the global substrate.
2021-04-05 14:16:28 -04:00
Tim Edwards 9aa9fb53c4 Cleaned up some unused code left over from extraction tests. 2021-04-05 10:29:14 -04:00
Tim Edwards 865a4040dd Updated version along with isolated substrate handling in extraction. 2021-04-05 10:23:05 -04:00
Tim Edwards 7be338b44f Committing final verified method for handling isolated substrate. 2021-04-05 10:20:41 -04:00
Tim Edwards 75e4fbe5ad Tests of substrate extraction 2021-04-04 20:43:43 -04:00
Tim Edwards a2f7831b17 First pass at properly handling deep nwell in a parent cell under
subcells that do not have deep nwell.  This commit handles the
case where the pwell region is explicitly marked with a layer
type.  To do:  Handle the case where the pwell region is implicit.
2021-04-01 17:38:00 -04:00
Tim Edwards 8b9c47c3ef Removed the stupid restriction that "cellname readwrite" won't work
on a non-writeable cell.  While technically valid, that just means
that nobody can make temporary edits on the cell in memory, which is
useful in many applications.  A slight quirk of the "cellname" command
is that if applied to the cell currently in the layout window, it is
not possible to make the cell show as edited and editable until leaving
and re-entering the cell.
2021-04-01 13:09:08 -04:00
Tim Edwards 8f8c3f77f2 Got rid of the annoying behavior of "popstack" to not return to the
original view position;  this was due to not setting units to
internal before re-applying the previous view position.  Also wrapped
most of the "popstack" routine into a suspendall...resumeall block so
that the view is refreshed only once;  this is especially important
when popping back into a full chip view.
2021-04-01 12:31:46 -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 9656c86b96 Added a negation capability to the "select intersect" command, so
that the intersection of (A and-not B) can be found.  This and the
(A and B) version give a large amount of capability like the cifoutput
operators available as command-line commands.  Also:  Fixed the new
"drop" command so that it properly redisplays and runs DRC after
executing, and modified the behavior so that the dropped material
is clipped to the area of the selection.
2021-03-25 15:35:37 -04:00
Tim Edwards 2cc557532d Modified the "flatten" command so that ports of the topmost cell
are preserved, which seems like reasonable behavior.
2021-03-25 14:39:29 -04:00
Tim Edwards f3febfae73 Updated VERSION 2021-03-25 11:17:27 -04:00
Tim Edwards 4964b1f789 Created a new command "drop" which can be used to drop a layer
into subcells in a hierarchy.  The intent is to use this in
conjunction with the "select intersect" command option added
yesterday to add deep nwell into the cells containing the devices
that need it.
2021-03-25 11:12:41 -04:00
Tim Edwards 2d1cf8435a Corrected the list produced by "what -listall" to have the intended
nesting.  Corrected the "select visible" command, which got broken
during the modifications.
2021-03-24 20:20:55 -04:00
Tim Edwards f5d8dbc3e5 Corrected an error in the last commit's implementation of the "what"
command.
2021-03-24 19:43:30 -04:00
Tim Edwards e884b5b256 Revised the "select intersect" command from the previous commit so
that the behavior is to pare down any existing selection by removing
any parts of it that do not intersect the layer specified on the
command line.  This is generally more useful than the previous
method, as the intended purpose is to intersect a number of layers
against one (e.g., all transistors intersecting deep nwell).
2021-03-24 16:57:22 -04:00
Tim Edwards dd86ecc454 Extended the "what" command to take the option "-listall" in
addition to "-list", where the list of layers returned is more
like the (recently extended) non-listing method where each type
is followed by a list of cell names in which that type is found
(within the selection area).
2021-03-24 15:30:30 -04:00
Tim Edwards b0f89ea4af Updated VERSION 2021-03-24 14:57:13 -04:00
Tim Edwards 7cb88ffceb Added a new selection command option "select intersect" that selects
the area of intersection between any number of types.
2021-03-24 14:52:17 -04:00
Tim Edwards e152deb97b Corrected typo from the last commit that will cause a crash. . . 2021-03-23 11:14:44 -04:00
Tim Edwards c2aedcebab Applied the same change made yesterday to DBconnect.c to ResConDCS.c
and SimDBstuff.c, which have nearly the same connectivity search
functions.  All three now use the hybrid list + stack method.
2021-03-22 09:49:56 -04:00
Tim Edwards f7820ed960 Corrected an error in the connectivity tables that for contact types
failed to add in any layers from other planes that are marked as
connected in the "connect" section of the techfile but otherwise
unrelated to the contact type and its residues.
2021-03-21 22:26:50 -04:00
Tim Edwards 4ff8d06810 Changed to a hybrid list and stack; the list keeps 65536 entries
at a time, and when it runs out of space, it pushes the stack.
This should speed up the connectivity routine somewhat, as it no
longer has to copy memory when expanding the list size, and it no
longer has limit at the integer boundary for memory allocation.
2021-03-21 20:53:20 -04:00
Tim Edwards fbd1acd60e A few corrections to the network connection selection. The pruning
method does not work and needs debugging, but is otherwise harmless.
2021-03-21 17:21:25 -04:00
Tim Edwards 633f6f558d Modified the connectivity finding search routine so that it does
not crash if too many unprocessed areas get queued up.  Also modified
it to prune entries that match one of the last five entries created
before searching the current tile.  However, it is not clear that
that makes any significant difference to the run time, and it needs
to be analyzed vs. the number of entries to check against.
2021-03-21 15:54:07 -04:00
Tim Edwards 58cdbc5356 Made the "select short" command a bit easier to use (and more in line
with the existing documentation) by not requiring the net containing
the two labels to be selected before running the "select short" command.
The command now first checks if the labels exist in the selection, and
if not, the command effectively executes "goto label1 ; select net" and
then continues as previously implemented.
2021-03-21 12:02:43 -04:00
Tim Edwards b77352849d Corrected the "what" command so that the correct cells are listed
that contain the selected paint.  Previously, all cells inside the
area of the selection box would be printed, which is completely
wrong, and can lead unexpectedly to thousands of cell instance
names being printed out.
2021-03-20 17:04:31 -04:00
Tim Edwards 8384891f3d Removed one diagnostic message after flattening a cell in GDS input
because depending on the GDS file it could be printed millions of
times.
2021-03-18 20:47:59 -04:00
Tim Edwards 08cb75a9b4 Modified the GDS read routine behavior so that if a cell is being
flattened per "gds flatten" or "gds flatglob", and the "gds readonly"
option is not set, then the instances of the flattened cells are
removed from the layout.  They are retained for the "readonly" option
because when writing GDS of such a cell, the full hierarchy needs to
be walked.
2021-03-18 15:16:37 -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 2532a696e4 Correction from a recent commit; complicated sets of "equiv"
statement in a .ext file require that all aliases of a node name be
rehashed after a node merge, or else node loops can occur.  Also
prevented statements of the form "equiv A A" from being output in
the .ext file, as they are useless.
2021-03-18 11:37:44 -04:00
Tim Edwards fd4569081e Added a reference count to the node structure in extflat to account
for the "equiv" statement---equivalent nodes names have to be
registered in the def->def_nodes hash table, and if they point to
the same node, then that node can't be free'd until the last
referenced node is seen when iterating through the hash table to
free the node records during EFDone().  This is handled by the
reference count.
2021-03-17 14:54:36 -04:00
Tim Edwards 8a0b180cde Modified the crash backup script to add options "disable" and "resume".
However, this has not been implemented as it has been observed that
the use of itimer() has a restriction of one timer per process, which
interferes with the three or more uses of the timer within magic.  The
timer method will have to be changed to use the POSIX timer_create()
routine, before this will work properly.
2021-03-17 12:45:35 -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 010c0599bd Encountered a crash condition caused by the "equiv" statement, for
circuits with nets having multiple conflicting labels, depending
on where the "equiv" statement occurs in the .ext file output.
Corrected the error but am still puzzled as to why this has never
shown up before, as it does not appear to be the result of any
recent development work.
2021-03-16 20:31:29 -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 f790ea7589 More enhancements for schematic_to_layout to parse various
non-circuit content in a SPICE netlist (mainly to ignore test-
bench elements and commands).
2021-03-11 13:30:28 -05:00
Tim Edwards 56be41932f Restored the toolkit behavior of spreading out cells that are
read in from a SPICE netlist in a row instead of placing them
on top of each other.
2021-03-11 12:27:14 -05:00
Tim Edwards 3bd9adbaf8 Corrected a set of regexps in the schematic-to-layout script that
prevented normal x=y type parameters from being parsed.
2021-03-11 11:09:37 -05:00
Tim Edwards 5b8a59c4ad Added extensions to the toolkit base to add netlist-to-layout
conversion, largely converted from the python script in open_pdks,
which itself was derived from an efabless script, and none of
which have been particularly well tested.
2021-03-09 22:07:51 -05: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 324721b514 Added some options to the net selection with respect to labels.
The previous behavior was to generate hierarchical names for all
labels when copying contents of subcells.  This is "safe" for
copying selections without accidentally shorting things through
labeling, but it can make a mess of the selection.  Options are
now "select do labels" for the existing behavior, "select no labels"
to not show any labels, and "select simple labels" to show only the
root name of labels in subcells.
2021-03-04 14:00:31 -05:00
Tim Edwards c99e632744 Modification of readspice.tcl script to work around issue if no ports
are found (i.e., "port first" returns nothing, instead of a number).
2021-03-03 11:39:35 -05:00
Tim Edwards e4bebffeb4 Updated VERSION with the previousl commit to fix problems with the
hierarchical SPICE netlist generation.
2021-03-01 11:28:15 -05:00
Tim Edwards 33927740bf Merge branch 'master' of opencircuitdesign.com:/home/tim/gitsrc/magic/
Pull before push.
2021-03-01 11:12:42 -05:00
Tim Edwards 83808dcf79 Corrected an error that was causing disconnects in the hierarchical
SPICE netlist output that appears to have come from flags created
for writing DEF that inappropriately got set during ext2spice.
A redundant call to efAddNodes() was adding confusion by appearing
to handle most cases but actually missing some.  With the corrected
flag, the redundant call is really redundant and can be removed.
It has not been tested whether DEF output is affected by the change
(DEF output from magic is rarely used, anyway).
2021-03-01 11:08:25 -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 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 2bb3580f3e Also modified DEF reads to avoid letting instance names contain
either slash or comma.
2021-02-24 14:51:46 -05:00
Tim Edwards f2af326368 Gave up on attempting to separate out slashes in instance names
from slashes in hierarchical names.  Magic does not allow slashes
in names when using "identify", so the simplest solution is just
to prohibit them in names being read from GDS files, and replace
them with underscores to make them magic-compatible.  Changing
GDS names always has repercussions on things like back-annotating
delays, so it should probably be revisited in the future.
2021-02-24 14:41:35 -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 9a79a1eee2 Fixed a minor error in the plot command that is missing a value
in the print statement on detecting an invalid plot parameter
value name.
2021-02-23 09:58:52 -05:00
Tim Edwards 2e9c554f2c Revised the wrapper script to use the Tk command "font measure"
to get the pixel size of the default font, and scale the window
glyphs and scrollbars to match, so that the display is automatically
adjusted for screen resolution and does not require manual intervention
to correct for high resolution displays.
2021-02-20 13:24:02 -05:00
Tim Edwards 3af205cd66 Altered the way that cells in unknown GDS libraries get prefixed,
to make it more compatible with SPICE by keeping it case-sensitive
and avoiding a number for the first character.
2021-02-19 08:52:56 -05:00
Tim Edwards 2d79e0e0ce Corrected variables that set the PaintPlane routine, which had been
changed from returning void to returning int without changing the
type of the variable, thus causing a compiler warning.
2021-02-18 15:47:40 -05:00
Tim Edwards 5b2042d078 Corrected the "property put" command to handle changes in the
GDS_FILE property in the same way that it handles changes to the
FIXED_BBOX property, by setting or clearing the associated flag
bit in the cell.  Otherwise, it becomes impossible to make a
cell writeable, as it always has some belief that it is still
attached to a specific GDS file.  Corrected an error in the
"gds" ("calma") command parsing that switched the callbacks for
the "noduplicates" and "nodatestamp" options.
2021-02-18 15:36:29 -05:00
Tim Edwards 59b021af73 Corrected an error in which the "select" command returns the name
of an instance with double-escaped brackets if the instance name
contains brackets.  This then undermines the use of the backslash
escape and causes the interpreter to raise an error instead of
printing the name.
2021-02-18 13:05:29 -05:00
Tim Edwards 1f698aa6ee Merged pull request #53 from Dan Moore. 2021-02-17 21:15:54 -05:00
Tim Edwards 15fe4d2d29 Merged pull request #35 from Jan Belohoubek 2021-02-17 21:08:10 -05:00
Tim Edwards aa88c69636 Updated from pull request #49 (required a manual merge due to
change in DRC flags type).
2021-02-17 20:53:17 -05:00
Tim Edwards dca33becd9 Updated VERSION along with pull request #68 from Anton Blanchard 2021-02-17 20:46:26 -05:00
Anton Blanchard bdeb4bab50 Restore terminal if exit is called inside a TCL script at startup
If exit is called in a TCL script that is executed at startup, the libc
exit() function is called directly and we don't get a chance to reset
the terminal. We return to the shell with echo off, and have to run
"reset". A simple example:

echo exit > test.tcl
magic -noconsole -dnull  test.tcl

There are a few ways we could solve this. We could register an exit
handler using atexit(). Here I use Tcl_SetExitProc() to register a
callback with the TCL interpreter.
2021-02-18 11:38:42 +11:00
Tim Edwards 48b04385c3 Corrected an error with the new off-grid DRC check that can cause
a crash condition during GDS read-in.
2021-02-16 10:05:59 -05:00
Tim Edwards f11a718368 Added return values to DBPaintPlaneVert(), which was missing them
and causing compiling under clang-10 to fail.
2021-02-13 20:40:52 -05: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 e53a23de59 Added an "off-grid geometry" check, in two versions. The simple
one is an "off_grid" DRC type, which can be used to check geometry
that is below the manufacturing grid.  Normally magic prevents the
grid from being subdivided below the manufacturing grid, but this
limit can be removed and replaced by DRC checks to check for such
errors in a GDS file of unknown origin.  The second version looks
for interactions between subcells that end up with intersections
of non-manhattan geometry landing on points that are not on the
database internal grid.  Such errors cannot be seen by magic's DRC
engine by definition, and so must be detected while flattening
geometry for the DRC checks.
2021-02-04 17:35:43 -05:00
Tim Edwards 2a1494e4d1 Added "cellname timestamp" option to the "cellname" command to
print or set cell timestamps.  This is intended to be used with a
PDK installer like open_pdks.
2021-02-03 15:53:12 -05:00
Tim Edwards 76295cab86 Added Shift-scroll-wheel scrolling (maps to horizontal scroll) to
the default macros.
2021-02-03 12:04:45 -05:00
Tim Edwards 522171510c Moved the "Generating output" statement for "gds write" after the
calls on subcells, as otherwise the statement is confusing.
2021-02-03 11:09:58 -05:00
Tim Edwards bca4b97b04 Updated VERSION with the latest commit. 2021-02-02 20:02:21 -05:00
Tim Edwards c0867ef71e Reverted about half of pull request #41 because it breaks compatibility
with qflow, which wants to launch applications from symbolic links.
The portability of magic now depends only on setting environment
variable CAD_ROOT, but the portability should still be ensured.
2021-02-02 10:19:04 -05:00
Tim Edwards c66a460053 Updated VERSION. 2021-01-25 15:17:02 -05:00
Tim Edwards fd49cad047 Corrected the CIF input scaling to include the 2nd set of planes used
by GDS reads.
2021-01-25 15:05:05 -05:00
Tim Edwards dfba4601f1 Substantially revised the equations for computing bridges for the
"bridge" GDS output operator;  the previous equations were, under
some situations, failing to meet the width requirement.  Also:
corrected the "cif style" check so that it does not claim that a
style name with an exact match is ambiguous.  Also:  Corrected the
use of "grid limit", so that the limit correctly scales with the
output expander value.
2021-01-24 13:29:20 -05:00
Tim Edwards 171287a131 Corrected the "extract unique" method so that ports which are made
unique will also be assigned a unique port index at the end of the
port list.  That ensures that the unique names are all properly
found in the extracted .subckt for the cell.
2021-01-21 17:08:24 -05:00
Tim Edwards 3c42c5a7f3 Corrected the extraction method for devices with terminals on the
implicit global substrate, as a block of code meant to handle this
case was left unreachable by another recent code fix.
2021-01-21 09:57:03 -05:00
Tim Edwards cf54d146d1 Another change to CalmaWrite to avoid writing subcells of any
cell def that is marked for a "full dump" from a referenced GDS
file.  This change was supposed to have been done a few commits
ago but did not work as advertised.
2021-01-20 15:00:19 -05:00
Tim Edwards 647b7cc6c7 Corrected one small inconsistency in the handling of symmetric vs.
asymmetric MOSFET definitions in the tech file "extract" section.
Corrected the nmos.tech.in file to put the resistance classes in
plane order, as otherwise the interpretation of which resistance
classes belongs to the transistor source and drain can get messed
up by the presence of buried contacts.
2021-01-17 12:52:57 -05:00
Tim Edwards e7e01a635f Modified the behavior of "gds write" to refuse to write out the
magic database derived layout of a cell that declares GDS_FILE
but for which the GDS file referenced cannot be found or read.
This will produce an incomplete GDS file instead of an apparently
good and complete GDS file that actually contains bad data.  Also:
Added new command "random" that allows a random seed to be set,
for use with the GDS output when writing a full dump of a GDS
file.  Otherwise, the output prefixes are always the same, which
defeats the purpose of adding the random prefix.
2021-01-15 12:40:20 -05:00
Tim Edwards 8428dcda1b Added the old (very old!) nmos.tech file from the early days of
magic (version 6.3) and lightly edited it to make it compatible
with version 8.3.  Edited the scmos/Makefile so that it installs
with the rest of the distributed tech files.
2021-01-14 17:01:23 -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 fa5a49ac3d Updated VERSION to go along with the pull request #64 from Dan Moore. 2021-01-14 12:14:55 -05:00
Dan Moore 86c0b7dbbd One last change for issue #50 2021-01-14 12:14:40 -05:00
Tim Edwards 3712aa70a6 Updated VERSION to go along with the merge of pull request #63. 2021-01-13 09:13:59 -05:00
Anton Blanchard e30472d009 Skip over BLOCKAGES section when reading DEF files
I'm seeing warnings when parsing a DEF with BLOCKAGES in it:

DEF read, Line 572201 (Message): Unknown keyword "BLOCKAGES" in DEF file; ignoring.
DEF read, Line 572202 (Message): Unknown keyword "-" in DEF file; ignoring.
DEF read, Line 572205 (Error): END statement out of context.

Skip over the section.
2021-01-13 09:13:04 -05:00
Tim Edwards 71fbcaca6e Added the ability to handle command option "cif list cover ..." to
provide a single decimal value back to the interpreter, without the
additional diagnostic output.
2021-01-12 13:15:29 -05:00
Tim Edwards 3f2210df74 Because the pull update was missed, the version was not updated to
the correct number.
2021-01-12 12:50:18 -05:00
Tim Edwards 4a1752aa61 Merge branch 'master' of 192.168.0.7:/home/tim/gitsrc/magic/
Missed a pull.
2021-01-12 12:49:34 -05:00
Tim Edwards 2462d6f220 I discovered that for large designs, running DBWredisplay will take
significant amounts of time even though there is no display to
receive the result.  However, the "suspendall" command only works
if a window exists.  The obvious solution is to set GrDisplayStatus
to DISPLAY_SUSPEND whenever magic is run with the "-dnull" option.
This should help speed up a lot of scripts, in particular where
designs are large.
2021-01-12 12:46:43 -05:00
Tim Edwards 0e1ca4ba07 A few minor edits to prevent compiler warnings around the changes
made in yesterday's commit (implicit return value, missing string.h
include).
2021-01-08 14:39:32 -05:00
Tim Edwards feeeccecda Corrected error caused by empty string labels in GDS input; when
a cell is flattened, these were getting the hierarchy prepended
and therefore became non-NULL and tending to screw up things
generally.
2021-01-07 21:47:16 -05:00
Tim Edwards 67d0d8c3f0 Corrected the use of the global substrate node name; this has been
restricted to its original intent, which is to replace the long name
formed from the plane short name and the "minfinity" coordinate.
This avoids issues with conflicting substrate names derived from a
real layer such as pwell.  Also, the global substrate node name now
returns the variable name without the "$" in front if the variable
has not been set to anything.  This avoids potential syntax errors
in the netlist.
2021-01-07 15:19:36 -05:00
Tim Edwards 2bbe1be790 Small correction to the mask hints code to correctly handle multiple
rectangles in a single property.
2021-01-06 12:17:19 -05:00
Tim Edwards a35f3b3d14 Additional code to make sure that the database scaling acts on all
values in a mask hints property, and added back the handling of
mask hints in the top level cell, since the hierarchical function
on cells does not apply the function to the top level.
2021-01-06 11:35:03 -05:00
Tim Edwards d4c3939feb Extended the "mask-hints" operator to work correctly through a
hierarchy.
2021-01-06 10:33:43 -05:00
Tim Edwards d6eeb90f6b Made corrections to the extraction based on a pull request by
Dan Moore for preventing integer overflow in the area calculations.
2021-01-05 12:25:25 -05:00
Tim Edwards ebb378da08 One additional correction to yesterday's commit, as the 2nd solution
was compatible with CentOS but not OSX.  This solution appears to be
more universally compatible.
2021-01-05 09:30:05 -05:00
Tim Edwards 22c6eb0f2c Changed "realpath" in the scripts (added from a pull request merge
earlier today) to "readlink -f", because "realpath" does not exist
on some systems (e.g., CentOS).  "readlink" seems to be more
universally available.  Noticed that the ext2spice and ext2sim
scripts use /bin/sh instead of /bin/bash, which would cause problems
with some systems where sh != bash.
2021-01-04 14:53:21 -05:00
Tim Edwards 5005f77d3f A few minor changes to the last commit to prevent compiler warnings. 2021-01-04 10:02:15 -05:00
Tim Edwards 20eb6ce6c1 Made a few modifications to the patch from Keno Fischer (pull request
startup.  I'm not sure that it is even possible to have a Tcl variable
set at this point in the startup procedure, though.
2021-01-04 09:47:03 -05:00
Keno Fischer 5b6692a914 Add configure flag for wish binary
At the moment the build system hardcodes the path
to the wish binary as it was found at compile time.
For relocatability add a configure flag that allows
the build driver to specify how to invoke the wish
binary at runtime.
2021-01-04 09:34:31 -05:00
Keno Fischer 3e6acd43fd Make bash wrapper relocatable
By having the build system put in a relative path rather
than an absolute path. Unfortunately, make does not support
computing relative paths manually, so a small bash script is
needed that will do this for us.
2021-01-04 09:34:31 -05:00
Keno Fischer 80488a8ee9 Have magic.tcl look for the shared library in the script directory
Rather than having the build process embed an absolute path.
The first of a couple of steps to make the magic build relocatable.
2021-01-04 09:34:31 -05:00
Dan Moore d675076254 Ignore derived files when compiling on OSX 2021-01-04 09:01:14 -05:00
Dan Moore 8dba03cebf Set GrClosePtr back to NULL before calling MainExit()
to squash the seg fault. It appears that calling GrTkClose
before graphics are fully initialized causes this.
2021-01-04 08:59:20 -05:00
Ahmed Ghazy 4066d50332 Add dependencies on the VERSION file
- this fixes issue where some of the binary objects would contain an
  outdated MAGIC_VERSION if "make clean" was not done after the VERSION
  file changes. (e.g., the "Magic VERSION revision REVISION" message in
  the wish console and the version requirement checks from a tech file)
2021-01-04 14:11:21 +02:00
Tim Edwards bb453f976e Changed "Writing cell" to "Generating output for cell" from the
"gds write" command, since "Writing cell" is easily confused with
writing a .mag database file.  "Generating output" seems clearer
to me.  Maybe it's just me.
2020-12-30 12:50:07 -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 1426f5921f Added an option "-dobox" to the "flatten" command, which flattens
just the area inside the cursor box.  This is important for certain
methods like stepped fill pattern generation.
2020-12-29 11:51:15 -05:00
Tim Edwards 18b4375790 Correction to yesterday's commit to fix the "bridge" operator for
CIF/GDS output.  Yesterday's commit did not completely solve the
issue.  Today's commit should.
2020-12-29 11:00:04 -05:00
Tim Edwards 44325f81e6 Corrected two errors: (1) Do not write subcircuit calls to subcircuits
that have been removed by flattening into the parent cell due to lack
of devices.  Previously the checks on writing the subcircuit and writing
the call were slightly different, leading to instances in which the
subcircuit call would be written to the netlist output without the
subcircuit being defined.  (2) Corrected an error in the "bridge" CIF/GDS
output operator.  In certain (somewhat rare) geometries, the tile behind
(instead of in front of) the corner being checked may be incorrectly
flagged as a DRC spacing error.  The fix is to ignore tiles that are
behind the corner being checked.
2020-12-28 16:54:20 -05:00
Tim Edwards e12d4c7e17 Updated VERSION along with Sylvain Munaut's fix to the maskhints code. 2020-12-27 10:00:27 -05:00
Sylvain Munaut eb945dc6ef CIFgen: Fix processing of MASKHINTS_* properties
- Don't print error if there is no more data to process
 - Fix error message: `propname` already has the
   MASKHINTS_ prefix

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2020-12-27 10:33:02 +01:00
Tim Edwards 01e86c0d46 Updated VERSION to rev 104 in conjunction with pull request merges
from github.
2020-12-24 22:01:21 -05:00
Anton Blanchard 91f9bc166f Fix a few compiler warnings
We were missing string.h in a few places, and were also creating
a string format of %llld.
2020-12-24 22:00:44 -05:00
Anton Blanchard a31bd9f003 Update config.guess/config.log
The current version doesn't understand ppc64le Linux.
2020-12-24 21:59:14 -05:00
Tim Edwards 3aef946167 Corrected an error that can confuse a source-drain tied device
with another device record for the same magic type.
2020-12-23 13:39:25 -05:00
Tim Edwards b12734bfc2 Made a slight change to the "gds flatglob" command option to allow
cells with subcells to be flattened in this way, as there does not
seem to be any prohibition against it.
2020-12-22 21:53:36 -05:00
Tim Edwards bcc7b3d06d Added an option "gds flatglob [<string>|none]" that allows flattening
of input cells on a per-cellname basis, using glob-style pattern
matching.  This is probably the best way to deal with 3rd-party vendor
GDS with unfortunate practices like dividing devices up among cells in
a hierarchy, even though it comes across as a bit of a hack solution.
2020-12-22 14:44:30 -05:00
Tim Edwards 47f37cc13a Corrected a subtle but very bad compiler-dependent error in the
extflat code;  failure to provide a forward external reference
to EFHNBest() resulted in a failure to correctly evaluate a
boolean expression.  That resulted in a failure to merge
hierarchical nodes during ext2spice, resulting in an incorrect
netlist with single nodes broken up into pieces.
2020-12-21 14:22:24 -05:00
Tim Edwards a660d73d5a Fixed a problem with extraction. If an extraction line specifies
one terminal of a device as the substrate, but also specifies
shielding types for the substrate, then the extraction cannot just
assume that a missing terminal is connected to the substrate without
first checking that there are no substrate shielding types under the
device.
2020-12-21 10:10:18 -05:00
Tim Edwards 5f64c2b3d7 Corrected the "lef" command so that "lef help" works again.
Corrected the "lef write -hide" command option so that obstructions
outside of the boundary are included in the obstruction list, in
addition to the block inside.  This had previously been done
correctly for use with the "setback" option but would fail only
for setback = 0.
2020-12-18 16:38:06 -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 5755e0bcfd Added "gds" command option "gds nodatestamp [true|false]". Set to
true, this will force the "gds write" command to write out creation
date stamps as zero.  This is very useful for avoiding changing the
contents of an otherwise-unchanged layout, especially if it is in
a git repository where it will force the entire file to be replaced.
2020-12-15 14:52:30 -05:00
Tim Edwards 69bd2fe57b Changed the cif output style option "see-vendor" to "see-no-vendor"
and made the default behavior equivalent to "see-vendor".  While it is
true that running "cif see" on a readonly cell shows layers that are
not necessarily representative of what is in the file, the opposite
behavior manifests itself in ways that are confusing.
2020-12-14 16:55:29 -05:00
Tim Edwards ea9d8cc3e5 Implemented first part of "mask hints", a method to allow mask
layers that are normally automatically generated to be supplemented
with additional geometry in the form of properties.  The first
commit implements a CIF operator "mask-hints" that tells CIFGenLayer
that additional geometry may be specified with a property named
"MASKHINTS_" plus the name passed to the operator as its only
argument.  A more extensive commit to be done will allow this
operator to be used on cifinput to use mask hints to retain the
exact geometry of mask layers used in the input file.
2020-12-14 16:16:37 -05:00
Tim Edwards 2b513eb3bb Added command options "flush -dereference" and also "cellname dereference"
to allow a cell to be flushed with dereferencing (i.e., discard any file
path attached to the cell, and use the search paths to find the cell when
it is reloaded).
2020-12-10 12:13:48 -05:00
Tim Edwards 6952e814f6 Added a command option "cellname dereference" to force a dereferencing
flush of a cell, by name.
2020-12-10 11:49:53 -05:00
Tim Edwards f8edb30d4e Removed .gitconfig, which I thought I did yesterday. But apparently
not.
2020-12-09 09:18:06 -05:00
Tim Edwards 0429d94e1c Corrected a scaling error in the post-order reading routine. The
routine attempts to rescale the contents of the top-level cell after
moving forward in the GDS to find a cell that was used before it was
defined, if reading that cell caused the scale to change.  However,
the numerator and denominator were reversed, causing the scaling to
be the inverse of what it should have been.
2020-12-08 20:38:33 -05:00
Tim Edwards a78b459303 Modified the DEF read routine (following a diff script from Ahmed
Ghazy) to read pin uses from a DEF file, including the three types
that are not defined by the LEF format (go figure).  Expanded the
bitmask of label flags to include the additional use types.  Also
shifted the label flag bitmask up to make additional room for more
port number, as there is no point in having unused bits in the
bitmask.
2020-12-07 10:39:39 -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 1b3299ec90 Updated PaOpen() to handle a Tcl variable of the type ${X} as well as
just plain $X (i.e., ignore any brackets around the variable) when
doing variable expansion.
2020-12-04 14:46:48 -05:00
Tim Edwards 414f4a8ccb Modified the DEF and LEF read/write routines to keep the
defMakeInverseLayerMap() from returning complete contact types when used
by the lefWrite command when writing LEF macros, which contain cut layers
but not entire contacts.
2020-12-03 21:37:32 -05:00
Tim Edwards 825ec353b1 Added missing brackets around a phrase in the "close" operator that
was causing false positive errors in DRC checks involving CIF rules
using the "close" operator, such as the minimum hole size in the
sky130A PDK.
2020-12-03 14:22:09 -05:00
Tim Edwards 0d10b7f785 Corrected a crash condition that can occur if a GDS file pointed
to by GDS_FILE does not exist.
2020-12-03 10:35:54 -05:00
Tim Edwards fdf379ef71 Reinstated the search on subcells when doing "drc check". This is
somewhat inefficient, but otherwise subcells do not get re-checked
for errors.
2020-12-02 13:21:37 -05:00
Tim Edwards 83e2fe55ce Corrected an error in the "close" CIF operator, which was checking
for infinities in space tiles by checking tile dimensions against
TiPlaneRect, where in fact TiPlaneRect is slightly smaller than
the plane boundaries, so this check would always fail, causing
unpredictable behavior due to integer overflow.
2020-11-24 15:57:40 -05:00
Tim Edwards 497c13c34e Updated VERSION to 8.3.89. 2020-11-24 15:38:45 -05:00
Tim Edwards bb83b1df89 Merge branch 'master' of 192.168.0.7:/home/tim/gitsrc/magic/
Pull before push
2020-11-24 15:38:02 -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 3a42a1aa58 Corrected the lefRead routine so that LEF annotation works properly
on cells with multiple ports per pin.  As written, the code was
erasing all labels before creating a new port label, which would
erase all previous port labels.  This should have been done only on
the first port.
2020-11-23 14:28:46 -05:00
Tim Edwards 0ad9ac91e3 Updated version to go along with the pull request merge from github. 2020-11-21 17:25:03 -05:00
Tim Edwards b9f9f73c9b "Partly" corrected an issue in GDS read: The cd_client record is
used both for counting cells during GDS write and for saving
geometry data from the "copyup" operator during GDS read.  The write
routine does not clear the client record, and the read routine was
checking if the cd_client value was default.  Corrected the resulting
crash condition by resetting cd_client before GDS reads.  However, the
underlying problem is that the GDS read is reading data into a cell
that already exists in the database, and is not handling it robustly
by renaming the existing cell.  So this should be revisited.
2020-11-20 19:56:41 -05:00
Tim Edwards 0608784a18 Added an option to "findlabel", a 3rd argument which is the
occurrence of the label to place the box on.  This can be used with
"findlabel -glob <name>" to get a list of labels and determine the
length of the list, and then iterate through each occurrance of the
label in the edit cell.
2020-11-20 10:10:32 -05:00
Tim Edwards 960be0e9b0 Rewrote the hierarchical check routine so that it does not report
disagreements between parent and child cells on GDS generation for
templayers, as these layers are not output;  any resulting differences
showing up eventually on an output layer will be reported.
2020-11-18 22:31:19 -05:00
Tim Edwards f934fc3cf5 Updated version in preparation of forcing the github mirror update. 2020-11-17 14:36:02 -05:00
Tim Edwards 4cac448337 Such a little typo, such a big problem. . . Fixed error from last
commit.
2020-11-17 14:29:21 -05:00
Tim Edwards 7a12bf8f60 Corrected a badly-written routine for the CIF generator for operator
bloat-all, that was resetting flags in the entire plane within the
callback for each tile processed.  This would push DRC run-times from
minutes to hours.  Also corrected another, much more minor, efficiency,
in which the connection mask was generated in the callback routine
for each tile, instead of calculating before the plane search and
passing the mask to the callback function in the client data.
2020-11-16 11:29:36 -05:00
Tim Edwards 750d6c0ecf Corrected a bad error (missing braces around a code block of more
than one line) in the "grow-min" function that was affecting GDS
output for any layers using the grow-min operator.
2020-11-13 10:24:31 -05:00
Tim Edwards 6d009682bc Applied a patch by Matt Guthaus to a routine in the readspice
annotation script, that moves a block of code making a list of
all labels outside of an inner loop where it causes a huge slowdown.
2020-11-12 16:46:51 -05:00
Tim Edwards cd3d765f9d Changed the readspice (annotation) script so that it uses the exact
label name with "port make", resolving any issues that might arise
if the label overlaps another.
2020-11-12 13:59:22 -05:00
Tim Edwards b0616e9f0e Fixed two misspellings in comments. 2020-11-12 10:55:20 -05:00
Tim Edwards 75a18053f8 Modified the CIFGenLayer() routine to be aware of when it is called during
hierarchical processing from CIFGenSubcells() and CIFGenArrays(), and to
avoid certain operators that are useless and harmful when applied
hierarchically; namely squares, slots, bbox, boundary, and net.
2020-11-12 10:34:27 -05:00
Tim Edwards 73629467ed Added a forward reference to prevent a compiler warning. 2020-11-11 14:12:51 -05:00
Tim Edwards ad2857dfab Corrected the "grow-min" CIF operator to grow more than the minimum
amount as needed to land on the specified minimum manufacturing grid.
2020-11-11 14:06:12 -05:00
Tim Edwards 114982fc72 Corrected the handling of DRC in cell instance arrays so that it matches
the handling of subcell instances generally.  Previously it would check
the interaction between neighboring cells in an array without regard to
any material in the parent cell which might remove those errors;
consequently, the array would have to be DRC clean by itself in order for
the parent cell to show as DRC clean.  The array check has been moved
inside the DRCInteractionCheck() routine, so that it runs only where
arrayed instances do not interact with anything else.  Within interaction
areas, the area is flattened and checked, so the array check is not
needed.
2020-11-11 11:50:16 -05:00
Tim Edwards 6b84efa86e Additional correction for the CIF "close" operator. 2020-11-10 13:28:40 -05:00
Tim Edwards 4f7567b864 Problem apparently stems from the routine not being in the header
file, so corrected that, too.
2020-11-10 11:11:41 -05:00
Tim Edwards d2fc99c433 Corrected an error that makes the "drc listall why" command segfault. 2020-11-10 10:52:32 -05:00
Tim Edwards 904a60423e Corrected the CIF "close" function to accommodate non-manhattan
geometry.
2020-11-10 10:26:01 -05:00
Tim Edwards 61188031cb Corrected the LEF read routine so that it preserves the sticky flag
on labels while annotating other properties (this error was a simple
typo).
2020-11-07 17:00:17 -05:00
Tim Edwards 6d463a20fe Corrected the "suspendall" and "resumeall" Tcl scripts so that they
do not fail when using "magicexec -dnull" (because there are no
layout windows, there is nothing to suspend and resume).
2020-11-06 14:39:10 -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 f7eb54fac7 Corrected the paint table from "compose", which was improperly
handling compose lines that override contact behavior.
2020-10-30 20:19:29 -04: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 1fe032a79b Changed the readspice script to avoid changing pin direction from
a CDL file unless the existing pin direction is set to "default".
This is consistent with the way the LEF annotation works, as well.
2020-10-27 15:39:12 -04:00
Tim Edwards d50fd1c42c Corrected a wayward cut-and-paste error from the last commit. 2020-10-26 13:23:52 -04:00
Tim Edwards 1891abe348 Also added code to not put parameters for a device marked "Ignore"
into the .ext file, in case such devices were assigned parameters.
2020-10-26 13:12:18 -04:00
Tim Edwards 3755661196 Changed the behavior of searches for labels in the basic extraction
such that it looks for material connecting to the label at the
center point of the label and not the lower left corner.  This keeps
the behavior of looking for tiles on the corners of a degenerate
label line or point between layers, but avoids problems with sticky
labels that are not quite aligned with the rectangle (due to certain
commercial EDA tools that have a sloppier notion of labeling).
2020-10-26 13:01:04 -04:00
Tim Edwards 0a1cb9ca99 Added a method to ignore a specific device extraction combination
by setting the model name to "Ignore" in the tech file.
2020-10-26 11:41:36 -04:00
Tim Edwards be17067e13 Corrected a problem with argument passing in the DRC subcell
copying up of DRC errors into the parent cell.
2020-10-22 10:44:59 -04:00
Tim Edwards d1793ce19f Updated version to go along with the last commit. 2020-10-20 12:25:10 -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 503a6bc190 Corrected the (minor) problem caused by the slightly different handling
of an alias that defines only one type (which is treated like it
would be if it were declared on the same line as the original type
declaration), such that the alias name does not become the default
name for the layer (which is the one that ends up showing in the
title bar when hovering over the layer toolbar icon).  Mainly the
problem showed up as "nwell" for the sky130A process appearing in the
toolbar as "allwellplane".
2020-10-18 14:28:23 -04:00
Tim Edwards a67b8cc395 Corrected an error in the "bloat-all" operator of the CIF generation,
which was failing to clear tiles in the layout of the "processed" state,
leading to unpredicatable results if the same layout layer is used in
a subsequent CIF operation.
2020-10-18 14:03:15 -04:00
Tim Edwards a015b7f8eb Corrected a problem in which extraction of MOS caps (or any device
with two or more terminals other than the device identifier type
tied together) would fail if there were not a device record
specifically matching a one-S/D-terminal device.  This is
inconsistent with past behavior, and so has been fixed.
2020-10-17 12:43:22 -04:00
fabian-l-c c872db78b3 Added new cif operator bridge-lim
The new CIF operator BRIDGE-LIM is similar to the BRIDGE operator with the difference that the material created to meet the minimum spacing/width rules do not overlap the limiting layers. Syntax of the new operator is:

bridge-lim spacing width layers

where "layers" are the limiting layers.
2020-10-17 12:23:16 -04:00
Tim Edwards 6b633be797 Corrected the algorithm created yesterday for copying up DRC errors
from child cells, which was incorrectly descending all the way down
into the hierarchy;  not only can this produce the incorrect result
but it also wastes time searching cells that don't need to be
searched.
2020-10-17 11:26:01 -04:00
Tim Edwards 65b7ca8dac Corrected a few wayward commas in the "lef" command that prevented
correct operation of "lef write".
2020-10-16 21:14:10 -04:00
Tim Edwards d99d84c533 Removed the scalefactor from the DRC-CIF rule parsing, so that rules
are interpreted in the dimensions used in the cifoutput section rather
than always in centimicrons (otherwise, rules at, say, 5nm cannot be
represented in the DRC section).
2020-10-16 09:37:24 -04:00
Tim Edwards 4b0652ecc9 Additional change: The switch to propagating DRC errors up from
the bottom in non-interacting areas means that any change in DRC
to a subcell must be handled before checking DRC in the parent.
Previously the order of checks was reversed, moving parent cells
to the beginning of the check list.  This prevents the error cited
in the previous commit which was showing up as a delayed DRC check
when creating parameterized cells.
2020-10-15 20:59:08 -04:00
Tim Edwards 2a4baa82c3 Substantially overhauled the way that the DRC checker finds and
processes "interaction areas".  This should eliminate weirdnesses
where errors will fail to show up in a subcell that does not
interact with paint or other subcells in the top level edit cell.
These errors cannot be reported directly in the top level cell,
but a new error message has been created to direct the user to
check the subcell for errors.  Also:  Modified the toolkit procedures
to force DRC to be run on newly created or modified parameterized
cell layouts.  There is some oddity about the process that causes
DRC errors to be delayed unless a print statement is put before the
DRC check;  I would like to investigate this further.
2020-10-15 17:31:20 -04:00
Tim Edwards 5cb645e2d5 Fixed a missing requirement of a reverse direction check on spacing
rules with "surround_ok" on different planes.
2020-10-15 12:18:14 -04:00
Tim Edwards 4bbe4ef74e Added another fix from a pull request by Dan Moore, which apparently
fixes a problem with substrate nodes not being flagged as such when
reading .ext files.
2020-10-14 22:53:03 -04:00
Tim Edwards 9f49ad97da Added a fix from Dan Moore to remove the Depend files on "make clean"
(these are automatically removed and regenerated on "make" anyway).
2020-10-14 22:39:48 -04:00
Tim Edwards 4c5b40bcd9 Added the correct header to DRCmain.c to see the prototype for
CIFGetScale().
2020-10-14 22:04:47 -04:00
Tim Edwards 9a5cc08d41 Made a small change to add a flag to the DRC rules to denote whether
the rule is a normal database rule or a CIF-DRC rule.  For the latter,
the flag is used when substituting for escape strings in the "why"
rule explanation to produce the correct value in microns.
2020-10-14 21:41:50 -04:00
Tim Edwards e7074e5723 Added two small features: (1) Added the "-annotate" option to "lef
read".  While "lef read" normally annotates existing layout, this
option ensures that no additional cells are created from macros in
the input LEF file.  (2) Added a check on the "Input off lambda grid"
warning during CIF/GDS input such that it is not repeated once issued,
as it tends to be output many times when it occurs.
2020-10-14 17:20:45 -04:00
Tim Edwards c0015efbe0 Added experimental "calma addendum" option to output only references
to readonly cells but not the readonly cells themselves when writing
a GDS library.
2020-10-13 09:47:54 -04:00
Tim Edwards a066f01bb2 Upon reflection, decided to just omit the cursor box when generating
an SVG plot.
2020-10-08 14:04:28 -04:00
Tim Edwards 581ad6041b Added new command option "box remove" that removes the cursor box
from the layout window.  The main reason for this is to keep the
box out of the image when doing "plot svg".  The "plot" command was
also modified to always do a plot of the entire cell in the active
layout window if the box is not present.
2020-10-08 13:50:14 -04:00
Tim Edwards dc99e382dd Corrected a simple error from the last commit. 2020-10-07 16:34:49 -04:00
Tim Edwards 4e5f7251b7 Modified the "lef write -toplayer" option so that masterslice layers
are considered an exception to the "-toplayer" restriction;  this is
because masterslice well/substrate layers will affect the electrical
connectivity between port and sustrate or well.
2020-10-07 16:26:56 -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 52d9639011 Added a "-nomaster" option to "lef write", and made writing masterslice
layers in the output a default option.  Use "-nomaster" to prevent the
output of masterslice layers.
2020-10-06 15:41:35 -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 b846c45056 Changed the behavior of the "compose" paint and erase rules to allow
multiple types to be painted;  for example, to paint over both planes
of a contact when a paint type causes the contact to disappear.
2020-09-22 15:25:26 -04:00
Tim Edwards 5308c35268 Corrected one final case of extracting an extended-drain pFET
because the opposite type (pwell) is not directly underneath the
gate, but touches it on the plane below.  Because the pwell may
be represented by space tiles on the well plane, it was also
necessary to deal with the space type in the bitmask.
2020-09-21 20:23:37 -04:00
Tim Edwards ec3ac4863f Also corrected an error where the bounds search uses the device
type in the device record, which was not updated at the end of
checking terminals for matching device extraction types.  so the
boundary survey might see the wrong device type and generate an
incorrect boundary survey as a result.
2020-09-21 16:52:49 -04:00
Tim Edwards 380b287aa9 Modified the extraction code to properly handle length and width
of devices that have a terminal underneath the device.  Code not
yet tested.
2020-09-21 16:03:37 -04:00
Tim Edwards 813bc223ac Updated version to force the overnight github mirror. 2020-09-15 21:57:20 -04:00
Tim Edwards 6e4046607d Found an apparent error in the continuous DRC that tends to erase
errors in the periphery of where a change has been made.  For some
reason this was not apparent before, but seems to be from a change
dating back to 2008---which seems unlikely.  The fact that it has
not been seen before may have something to do with the size of the
DRC halo compared to the DRC step size in the SkyWater PDK, where
it has suddenly become apparent.  Jury is still out on this one.
2020-09-15 21:46:38 -04:00
Tim Edwards c3e8ed545d Implemented an additional setback value for "lef write -hide <value>"
that produces a result that looks like "lef write -hide" in the middle
but "lef write" around the edge.  Can be useful for catching all the
detail around the edges but obscuring/simplifying the bulk of the cell
interior.
2020-09-14 15:54:38 -04:00
Tim Edwards a52590a10e Updated the version number to trigger the git mirror. 2020-09-11 17:40:46 -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 ebe12fecfe Corrected an extraction error that prevented the use of the same
device layer type to describe the extraction for both a regular FET
and an extended-drain device.  Note that the current code still
requires that the extended-drain device be declared first, and does
not check for this or attempt to reorder if incorrect.
2020-09-10 21:44:02 -04:00
Tim Edwards 6cf5f65b51 Corrected a tiny but bad error in the extract section reading of the
tech file that completely undermined the ability to describe an
asymmetric device (different materials for terminals).
2020-09-09 12:18:09 -04: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 5148049ffc Modified version to make sure the github repo and tarball gets updated. 2020-09-03 19:31:46 -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 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 0df5f6d073 Provisionally switched the memory allocation definitions away from
Tcl_Alloc() and Tcl_Free() because Tcl_Alloc() uses (unsigned int)
for the argument type and therefore limits memory allocations to
what can fit in 32 bits.  Using the system malloc(size_t) should not
cause any issues.
2020-08-11 16:50:26 -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 1ee9309d15 Fixed a long-standing but unnoticed (or unreported) error in which
using the "-rcfile" switch fails if running magic from a user home
directory.
2020-08-08 15:27:01 -04:00
Tim Edwards 0a532f5721 Applied a patch from Ahmed Ghazy that corrects an error reading PINS
from a DEF file that have the PLACED or FIXED property declared before
LAYER.
2020-08-08 14:02:29 -04:00
Tim Edwards 8b05346409 Added an assertion in ExtCell.c to force a fault if the technology
is NULL when writing a .ext file;  this should help with tracking
down an obscure bug.
2020-08-03 08:18:58 -04:00
Tim Edwards 0598f4edf7 Corrected a potential segfaulting error in which (apparently)
port labels that are unnattached ("attached" to space), or possibly
sticky labels without any geometry underneath, end up with a NULL
node during EFBuild().
2020-08-02 09:37:45 -04:00
Tim Edwards e00a9a293f Corrected one more uninitialized variable, in ExtHard.c. 2020-07-31 21:56:01 -04:00
Tim Edwards 78fbbfa032 Corrected some uninitialized variables in the "lef write" function. 2020-07-31 21:45:42 -04:00
Tim Edwards 5fb41a68c8 Modified the routine that determines contact size from the CIF rules
to accomodate a method used for processes that require additional
spacing between contacts for large via arrays;  this requires
distinguishing between large and small areas to output vias, and
so requires use of "and" and "and-not" before "squares".  This
highlights the arbitrary nature of this routine, which probably
works better getting data from cifinput, or not at all (i.e., it is
used when reading LEF, but it is known that the LEF read routines
would be better implemented by running input through CIFGen().  If
that were done, then this problem would not come up).
2020-07-31 14:11:24 -04:00
Tim Edwards 2e0e7af3f3 Corrected an error with the "slots" function that prevents slots
from being generated in areas of negative coordinates when a
grid limit is defined for the output style.
2020-07-30 21:01:24 -04:00
Tim Edwards 313112329c Updated version to force new tarball and github mirror. 2020-07-29 14:16:05 -04: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
Tim Edwards 917d7590d3 Implemented a string truncation with ellipsis for the output to the
caption line in the GUI window, which was causing problems with
long filenames overrunning the string array dedicated to the caption
line.  Thanks to Sylvain Munaut for the patch.
2020-07-27 12:10:08 -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 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 19dd5638d6 Removed "UNITS \n DATABASE MICRONS" entry from all LEF file output
other than the technology LEF (when given the option to dump the
technology LEF information).
2020-07-25 12:00:18 -04:00
Tim Edwards 850df529b9 Removed "NAMESCASESENSITIVE" from "lef write", since this has been
deprecated since LEF version 5.6.
2020-07-22 12:18:47 -04:00
Tim Edwards ae1743e5ad Removed handling of LEF macro "SOURCE", which is only valid pre-
version 5.6, and Magic now officially writes version 5.7.
2020-07-21 08:40:25 -04:00
Tim Edwards e453f130ee Also corrected the "lef write" output to always put "END LIBRARY"
at the end of a macro output, even if it is not part of a library.
According to some commercial tools, this is what is expected, even
though the use of "END LIBRARY" is never explained in the LEF/DEF
spec.
2020-07-19 22:10:19 -04:00
Tim Edwards 9c4fb65a58 Corrected a problem with "lef read" that prevents it from working
with non-standard extensions such as ".tlef".
2020-07-19 21:56:00 -04:00
Tim Edwards f7b5f38461 Corrected an error in the last commit in which I expanded the body of
a "for" loop in extract/ExtHier.c from one line to two but failed to
then put braces around the whole loop.
2020-07-19 17:08:51 -04:00
Tim Edwards d755e4400a Corrected an error in the the extSubtreeFunc() routine, that is
supposed to pull "sticky labels" into the cumulative flattened
layout.  Because it failed to check for the "sticky" flag, it
would copy all labels, causing extraction time to go exponential
as the number of labels in the design increases.  Based on this
correction, the extHierConnectFunc1() routine should be able to
be optimized by stopping the search for sticky labels on the first
non-sticky label, since extSubtreeFunc() ensures that all sticky
labels come first in the label list.
2020-07-18 15:49:20 -04:00
Tim Edwards 1a774e92d1 Corrected an error pointed out by Sylvain Munaut in which the "plow"
command fails for the tutorial tut3d cell due to a missing
initialization of the cd_cellPlane record in DBCellCopyDefBody().
This was missed in the implementation of "bplane", and was not
checked because the routine is only called from the "plow" command
routines.
2020-07-17 12:38:21 -04:00
Tim Edwards 838c9b840d Added a "calma library" command option, to generate a GDS library
from the subcircuits of a top-level layout without also writing the
top level.
2020-07-16 08:55:46 -04:00
Tim Edwards 7a8e6352a3 Two changes to "lef write": (1) Added support for generating output
for geometry on MASTERSLICE layers (which was inadvertantly broken),
and (2) Added option "lef write -toplayer", which outputs pin geometry
only for the topmost layer belonging to a pin, with connected layers
underneath being designated as obstructions.
2020-07-15 17:29:56 -04:00
Tim Edwards 72b4053774 Updated VERSION to force an update on the system; no changes were
made.
2020-07-05 21:38:28 -04:00
Tim Edwards d577439be9 Test again. 2020-07-05 17:39:24 -04:00
Tim Edwards 2be23d886d Test. 2020-07-05 17:39:00 -04:00
Tim Edwards 14251b797f Corrected readspice.tcl script to ignore CDL parameters in the
subcircuit I/O list, and to not fail with an error if something
in the PININFO line cannot be found in the layout (just prints
an error message instead).
2020-06-30 18:05:12 -04:00
Tim Edwards 52dadcff08 Modified the "plot svg" command to remove the window trimmings
(scrollbar, title bar, etc.) from the output if the command is
called from the non-GUI-wrapper environment (where the border area
is part of the rendered output).  This was required due to an
unsolved bug in which calling magic to write SVG output from the
wrapper in some pathological case exposed a Tk bug that caused
the Tk grid manager to infinite loop, filling memory without
limit.
2020-06-30 16:07:31 -04:00
Tim Edwards 6812e7cd10 Modified readspice to support the CDL "*.PININFO" line for annotating
layouts with pin class (direction) from CDL files.
2020-06-29 21:13:57 -04:00
Tim Edwards f6de28c760 Corrected defs.mak.in to use @LD@ passed from the configure script
instead of hard-coding "ld" for the LINK variable.
2020-06-29 11:07:43 -04:00
Tim Edwards 0b17c4d168 Not sure why the temporary copy of DRCtech.c was not removed in
previous commits, but am now doing 'git rm' on it to make sure it
stays banished.
2020-06-29 08:25:55 -04:00
Tim Edwards eab0fe770d Corrected the readspice script to treat the input line as a string
and not a character list when checking the first character of a
SPICE netlist for a comment or continuation character.
2020-06-27 21:46:53 -04:00
Tim Edwards b36d5cce3c Updated VERSION along with the pull request merge for changing the
in-line comment character recognized by ngspice (which has changed
since the version of the documentation I had, which supported the
use of the character ';', which was what magic was using).
2020-06-27 19:50:43 -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 8519d2f13c Corrected the "macro" command so that if no help text has been given
for the key bindings, then the key bindings themselves will be
printed when "macro help" is run, and not just empty strings.
2020-06-25 20:59:44 -04:00
Tim Edwards 28fbb34845 Updated VERSION to trigger the github mirror and tarball generation. 2020-06-17 12:17:44 -04:00
Tim Edwards b39a45a700 Further refined the layers used in hierarchical GDS generation to
exclude layers created using the "boundary" or "bbox" operators,
since they only exist in specific levels of the hierarchy.  Pretty
much by definition they should not be used in a way that requires
additional geometry to be added to the parent cell.  This greatly
reduces parent-vs.-child disagreements (and the corresponding error
messages), but does not entirely eliminate them.
2020-06-17 12:14:41 -04:00
Tim Edwards bf4364da44 Corrected an error in the GDS output hierarchical adjustments code
caused by the new bloat-all with templayers, which used the distance
record in the bloat structure differently than the other bloat
functions, and therefore was messing up the enumeration of layers
needing to be handled by the hierarchical output.  This was probably
also wrong for the existing bloat-all function, which might explain
some problems recently with the GDS output.
2020-06-16 22:54:48 -04:00
Tim Edwards 8297386a6c Corrected error in the new expansion of the cifoutput "bloat-all"
rule to include CIF templayers;  the connection mask was not
correctly generated for the CIF templayer, leading to bad GDS
output.
2020-06-15 15:41:27 -04:00
Tim Edwards f1c432585a Applied a patch from Ahmed Ghazy to correct the last change to
"lef write", which had one typo in the formatting, plus was using
a static string method for generating the formatted output that was
implementation-dependent on fprintf().  These have been fixed.
2020-06-15 09:35:21 -04:00
Tim Edwards d0febe7614 Corrected an error in the global substrate name method added recently;
the extractor was not checking temp_subsname as well as glob_subsname,
and so was failing to apply the substrate name to child cells in
"merge" statements in the extract file, causing the substrate to get
disconnected between parent and child.
2020-06-13 16:31:37 -04:00
Tim Edwards bdf684dafe An additional change to remove the formatting for the antenna area
output values, which were set to format according to database
distance precision (which is not the same as area).
2020-06-13 11:15:33 -04:00
Tim Edwards 95d1dfddc3 Changed the behavior of "lef write" (again) to set the UNITS to the
minimum manufacturing grid (normally 1000 but can be altered by the
"angstroms" flag in the cifoutput section, and by "gridlimit").
The output values then are truncated such that the floating-point
output value, when multiplied by the UNITS value, is always an
integer.  e.g., "gridlimit 5" will change UNITS to 200, and values
will be minimum precision 0.005, or 5 nanometers.
2020-06-13 11:05:53 -04:00
Tim Edwards 56250c907d Added a "bridge" operator to the set of operators used for CIF layer
generation in the "cifoutput" section of the techfile.  This operator
solves the problems with the catecorner position of geometry when
attempting to automatically close up gaps between islands of a layer.
2020-06-11 16:40:01 -04:00
Tim Edwards 7540854184 Corrected the handling of the "defaultsideoverlap" statement so that it
works for the first pair of types/plane being below the second pair of
types/plane (upward fringing from the top of a wire to an overlapping
wire above it), which was not being handled due to an implicit assumption
that plane1 < plane2, which does not have to be the case.
2020-06-10 10:52:54 -04:00
Tim Edwards 035195bb47 Updated DRCtech with fix by Fabian Cabrera to make the "surround ...
directional" rule work correctly for types not on the same plane.
2020-06-10 09:22:58 -04:00
fabian-l-c a263a5a5a5
Update directed case for drcSurround in DRCtech.c
Before this modification "directed" surround rule only worked for layers1 and layers2 belonging to the same plane.
After this modification the "directed" rule works also for different planes, even if layer1 is a contact type.
2020-06-09 16:11:22 -03:00
Tim Edwards f6c6e2c29c Reverted a change from a prior commit that removed backslashes in
front of brackets in LEF names.  These have a special meaning
that is not yet handled correctly, but removing them is the wrong
approach.
2020-06-05 14:55:45 -04:00
Tim Edwards fc9ecd2c9b Corrected a problem with an uninitialized entry in ExtCurStyle that
could cause serious errors on systems that do not auto-zero allocated
memory.  Also:  Fixed an error introduced by a recent commit to allocate
character memory for efReadLine() which frees the memory before reading
a .res.ext file, causing a crash when using "ext2spice" with the
"extresist on" option.
2020-06-05 12:46:46 -04:00
Tim Edwards ac244109bc Modified the efReadLine() routine so that it dynamically allocates
memory for the input line instead of using a fixed 1024-character
buffer.  That avoids the issue of rare but possible overflow when
reading a .ext file with unknown line lengths.
2020-06-03 21:57:56 -04:00
Tim Edwards efe6af8465 Modified the EFread routine so that it will not infinite loop on
a truncated line.  There is still a question as to why an example
occurred that caused a line to be truncated, and whether a buffer
size needs to be made larger or made dynamically allocated.
2020-06-03 20:36: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 15f1c82bc9 Added two new features: (1) Default substrate name: Added an
optional name field to the "substrate" line in the extract section
of the techfile.  This is the default name of the substrate if not
connected to anything labeled.  It may use a Tcl variable (preferred).
(2) Added command option "instance orientation [-def]" that returns
the orientation of the named or selected instance.  The -def option
returns the orientation using DEF naming convention;  otherwise, the
naming used with "getcell" is generated.
2020-06-01 16:49:59 -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 643bd096ea One more fix. . . 2020-05-29 16:51:20 -04:00
Tim Edwards 09e85dedab And the corresponding pointer. 2020-05-29 16:39:40 -04:00
Tim Edwards 112e58e371 And one more hash key type needed to be changed in the other call
to HashInit().
2020-05-29 16:36:07 -04:00
Tim Edwards 82106387a6 Corrected the type of hash key on the property definitions hash
table in lefWrite.
2020-05-29 16:26:37 -04:00
Tim Edwards 44ca5d996b Added handling of PROPERTYDEFINITIONS block in LEF output based on
properties in the cells.
2020-05-29 16:12:09 -04:00
Tim Edwards 4ad7ce3cf4 Modified LEF read and write to preserve macro PROPERTY lines. This
probably needs revisiting, because "lef write" and "lef writeall"
need handling to generate the PROPERTYDEFINITIONS block for the
PROPERTY entries to be correct.
2020-05-29 14:31:48 -04:00
Tim Edwards bad4842707 Corrected a improperly placed call to freeMagic() from the last
commit.
2020-05-29 13:10:03 -04:00
Tim Edwards 9372a9e0e8 Added more behavior to "lef read" annotation to include handling
bracket characters in the LEF file that are escaped with backslashes.
2020-05-29 12:51:21 -04:00
Tim Edwards a57f024587 Making the "lef read" usage for annotation of an existing layout
somewhat flexible with regard to pin name translations between
the LEF and the layout.
2020-05-29 12:37:10 -04:00
Tim Edwards bf061f0012 Additional change to readspice script to handle various issues with
pins not matching between netlist and layout due to delimiter changes
or case sensitivity.
2020-05-29 11:55:30 -04:00
Tim Edwards 0b17bcdb86 Try again without confusing Tcl and python syntax. . . 2020-05-29 11:27:16 -04:00
Tim Edwards c16ae32e70 Correct readspice script to close the file after reading. 2020-05-29 11:25:13 -04:00
Tim Edwards 9522e0e9dd Added CDL to the types of file extensions checked by the readspice script. 2020-05-29 11:23:39 -04:00
Tim Edwards 0eada90eab Corrected the readspice.tcl routine to correctly handle input
without filename extensions.
2020-05-29 11:19:37 -04:00
Tim Edwards 36f2d0cca9 Corrected an out-of-order code block that can cause the USE statement
to be printed twice for a pin during "lef write".
2020-05-29 09:35:54 -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 53a488989f Moved the read-in of the readspice script from the wrapper to the
startup file, since the script is not (and should not be) wrapper-
dependent.
2020-05-28 12:40:28 -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 'mithro' Ansell b47d4c5642 Removing extra `$Header$` 2020-05-27 20:35:27 -04:00
Tim Edwards e63e8f5761 Corrected the expected position of top and bottom layers in a
DEF VIA ENCLOSURE when doing "def read".  Thanks to Ahmed Ghazy
for finding the error and providing the patch.
2020-05-27 18:02:36 -04:00
Tim Edwards b6f4553cef One additional place where the port number needed to be taken from
the existing label on "lef read", where the port record is never
read.
2020-05-26 20:40:41 -04:00
Tim Edwards 8b159a07cd Corrected LEF annotation so that it does not try to change or any
port indexes, or create duplicated port indexes.
2020-05-26 17:58:05 -04:00
Tim Edwards 582539e95d Modified LEF and DEF writes to set VERSION to 5.7, as nothing in
the output is known to be incompatible with LEF/DEF version 5.7.
2020-05-26 17:25:44 -04:00
Tim Edwards da9c180670 Modified lefWrite with the odd trick of adding a zero to prevent
fprint from printing "negative zeros", which routinely happens in
the ORIGIN output of LEF files with "lef write".
2020-05-26 17:19:57 -04:00
Tim Edwards 3203eec28c Modified the "bloat-all" cifoutput operator to allow operations on
templayers.  This permits some useful interactions like growing to
the size of a bounding box, or abutment box, as well as many other
possibilities.  Also:  Corrected the use of "cif see" for the boundary
(abutment box) layer, which was not working because the "cif see"
command uses a flattened CellDef that does not have the boundary
property of the cell it was flattened from.
2020-05-26 14:29:36 -04:00
Tim Edwards a908893ae3 Updated revision. 2020-05-25 16:14:24 -04:00
Tim Edwards 84f63ad545 Corrected segfault condition when running "lef write" on a cell
with split tiles (error caused by previous commit).
2020-05-25 16:13:42 -04:00
Tim Edwards 994c6aaf57 Modified the LEF write routine so that it correctly handles contact
layers (apart from the fact that contacts are output as magic's
contact layer representation, and not as cuts;  this still needs to
be handled properly).
2020-05-25 12:26:01 -04:00
Tim Edwards df9a52de6c Corrected potential crash condition that can happen if there is one
or more repeated "equiv" lines in a .ext file.  This implies two
ports with different names are connected, indicating probably a bad
layout, but that's not a reason to have magic crash.
2020-05-23 21:33:42 -04:00
Tim Edwards 9382cc622c Changed the "feedback count" command to return the feedback count
as a Tcl int object instead of printing out a text message, per
the suggestion from Dan Moore.
2020-05-23 17:26:32 -04:00
Tim Edwards 2af38a4191 Updates from running the fix-ending-whitespace script. 2020-05-23 17:13:14 -04:00
Tim 'mithro' Ansell c81d9add00 LEF writer: Fix indenting.
I missed the LAYER value and the geometry was one level to high.

Previous;
```
    PORT
         LAYER li1 ;
      RECT 1.145000 1.075000 1.690000 1.275000 ;
      RECT 3.720000 1.075000 4.490000 1.275000 ;
         LAYER met1 ;
      RECT 1.105000 1.260000 1.395000 1.305000 ;
      RECT 3.765000 1.260000 4.055000 1.305000 ;
```

After;
```
    PORT
      LAYER li1 ;
        RECT 1.145000 1.075000 1.690000 1.275000 ;
        RECT 3.720000 1.075000 4.490000 1.275000 ;
      LAYER met1 ;
        RECT 1.105000 1.260000 1.395000 1.305000 ;
        RECT 3.765000 1.260000 4.055000 1.305000 ;
```
2020-05-23 17:03:03 -04:00
Tim Edwards 55e7abf396 Committing changes 2020-05-23 17:01:30 -04:00
Tim 'mithro' Ansell 516ae506d7 Remove all the $XXX: YYY$ 2020-05-23 17:00:38 -04:00
Tim 'mithro' Ansell b28d10f80d Convert $Id$ placeholders to $Header$ placeholders. 2020-05-23 17:00:38 -04:00
Tim 'mithro' Ansell a5f050ce21 Convert expanded $Id:XXXXX$ values back to placeholder $Id$ 2020-05-23 17:00:38 -04:00
Tim 'mithro' Ansell 83c9288e13 Add Makefile target which strips all trailing whitespace. 2020-05-23 16:57:24 -04:00
Tim 'mithro' Ansell 2c066c8df0 Remove trailing whitespace. 2020-05-22 20:14:13 -04:00
Tim 'mithro' Ansell e2f0832cdf LEF writer: Move formatting properties to #defines 2020-05-22 20:14:13 -04:00
Tim 'mithro' Ansell c04a33cbf1 LEF writer: Use 6 decimal places of accuracy in output. 2020-05-22 20:14:13 -04:00
Tim Edwards 89c9335727 Modified area accumulation routines to avoid double-counting contacts
during "lef write".
2020-05-22 20:13:33 -04:00
Tim Edwards 77d17a4fa7 One correction to yesterday's commit for "lef write" enhancements:
If the last pin to be parsed generated no output, then the
obstructions would generate no output as well.
2020-05-22 16:14:27 -04:00
Tim Edwards 1e9334664c Modified the LEF write routine so that it will not output ports
that have no geometry (that do not exist on planes defined in
LEF).
2020-05-21 21:53:23 -04:00
Tim Edwards 6adb5dbacf Enhanced the "lef write" routine: (1) Calculates gate and diff
areas and writes ANTENNAGATEAREA and ANTENNADIFFAREA values.
(2) Determines "USE POWER" or "USE GROUND" from label names
matching Tcl variables $VDD and $GND, if the USE has not been
registered as a cell property (knowning the use allows magic
to avoid writing an ANTENNADIFFAREA for power rails, although
doing so should not be an issue).
2020-05-21 16:26:24 -04:00
Tim Edwards 6635817383 Modified LEF read to give all labels the sticky flag so that they
cannot be moved from the layer on which they are defined in the
LEF file.
2020-05-21 13:47:14 -04:00
Tim Edwards 4066c6821b Corrected error introduced a while ago, probably with the addition
of cell name dereferencing on file loads, where the cell load
subroutine call ended up with the wrong number of arguments,
resulting in an invalid pointer and a crash condition.
2020-05-20 10:09:02 -04:00
Tim Edwards 45d0faaee5 Updated revision so that new tarball will be posted with fix and
commit from Saturday.
2020-05-18 10:06:48 -04:00
Tim Edwards fa60cbaaf0 Corrected the cell delete routine to include removing any elements
related to that cell (since elements are usually temporary and so
kept in a separate list, not in the cell).  Corrected a major error
in the bplane implementation that failed to remove a cell use from
the child def's parent list when deleting the use.  Can cause magic
to go into an infinite loop, especially after selecting and unselecting
cells.
2020-05-15 20:49:51 -04:00
Tim Edwards 028612b70a Added extension to "gds flatten" command option to change the limit
of geometry primitives that triggers flattening (default 10).
2020-05-14 15:59:39 -04:00
Tim Edwards 38c6ce3b07 Changed the handling of GDS reads so that if the cifinput option
"ignore-unknown-layer-labels" is set, then error messages will not
be displayed when labels in the GDS input are on unknown layers
(this option is and has been otherwise handled correctly;  the only
issue is the generation of an error message on the output).
2020-05-14 15:41:46 -04:00
Tim Edwards 682a559455 Added code to fail on the "cellname rename" command if the cell in
question is a read-only cell.
2020-05-12 12:31:39 -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 838591bdf2 Corrected unfortunate typo from today's previous commit, and
corrected a wrong typecasting that results in a compile warning.
2020-05-10 20:01:05 -04:00
Tim Edwards f0d2c8db0f Corrected the LEF read routine so that it parses an ORIGIN line in
a LEF macro that has parentheses around the coordinates.  Weirdly,
this is requires by the LEF/DEF spec, but is rarely if ever seen
in actual LEF files.  Go figure.
2020-05-10 12:21:04 -04:00
Tim Edwards 35175882bc Corrected another similar bit of code causing a segfault. It is
not known, though, why the flag is set indicating valid planes
in the clientdata record when there in fact is none.  That seems
to be the underlying bug.
2020-05-08 17:02:36 -04:00
Tim Edwards 6737741902 Corrected CalmaRdpt() routine to avoid crashing if the cd_client
record is uninitialized when calling the rescale routine.
2020-05-08 16:44:29 -04:00
Tim Edwards 669ae1dfcc Added a way to subvert the adding of a prefix to subcells of a dumped
GDS library from an abstract view, by defining the property LEFview
in the cell as "no_prefix" instead of "TRUE".
2020-04-23 16:03:29 -04:00
Tim Edwards 0f16b7da6c One modification to the last commit, such that if the cell is not
marked as abstract yet has GDS_START but not GDS_END defined,
magic will not crash by attempting to use the nonexistant value
of GDS_END.
2020-04-23 15:08:56 -04:00
Tim Edwards 88e23a114e Corrected CalmaWrite behavior to be as was intended for handling vendor
GDS of abstract views, such that if the cellname being dumped is the
same as the library name, then no prefix is added to subcells.  This
behavior may be changed in the future.
2020-04-23 14:41:29 -04:00
Tim Edwards bcb8e9a081 Corrected typo in CmdCD.c for "count_total" when compiled without Tcl/Tk. 2020-04-18 15:49:23 -04:00
Tim Edwards 0a78dc0ab5 Updated revision to 3. 2020-04-14 11:08:29 -04:00
Tim Edwards 4b31af66b1 Corrected error in the bplane implementation that accidentally
called the undo record generation twice when transforming (move,
copy, etc.) cell instances.  This would cause the "undo" command
to regenerate the old instance position in the bplane records,
generally causing trouble down the road (did not encounter any
fatal errors, but it can't be good).
2020-04-14 11:00:51 -04:00
Tim Edwards 97df4e8dd1 Removed a diagnostic debugging message from the antennacheck routine. 2020-04-09 19:37:23 -04:00
Tim Edwards 116feec2df Found and added another unused but missing subroutine from the bplane
implementation.
2020-04-08 12:28:26 -04:00
Tim Edwards 2d35bb52b3 Updated VERSION to trigger overnight tarball and mirror. 2020-04-08 12:12:36 -04:00
Tim Edwards 99ac84d590 Corrected bpDump to remove UnitsS2I(), replacing with scalefactor
determined by CIFGetOutputScale().
2020-04-08 12:11:32 -04:00
Tim Edwards 7e1fcc8ef6 Fixed lefWrite, which was not including drc.h and so was messing up
one of the arguments to the DRC technology query.  Also, drc/drc.h
itself did not export that particular function, so it was added.
2020-04-07 20:08:42 -04:00
Tim Edwards 937e848d03 Modified DBTreeCopyConnect() so that it can take an argument to
not copy labels;  not copying labels speeds up the antenna checks
(which don't need labels) greatly.  Also fixed several numerical
overflow problems in the antenna checks, which resulted in false
positive errors, as well as nonsensical results.
2020-04-03 16:22:56 -04:00
Tim Edwards 08fabeedd5 Merge branch 'master' into bplane
Merging fix to "lef write" to preserve SITE, from master branch.
2020-04-01 11:02:08 -04:00
Tim Edwards e98b768c45 Corrected "lef write" to add the SITE definition that it may have
been preserving in the cell properties (which was inadvertently
omitted).
2020-04-01 11:01:13 -04:00
Tim Edwards 706e342171 Merge branch 'master' into bplane
Conflicts:
	lef/lefWrite.c

Merged change to "lef write -hide" method from the master branch.
2020-04-01 10:46:06 -04:00
Tim Edwards d6cadeb0cd Decided that "lef write -hide" should always use widespacing rules,
because otherwise all pins will flag metal-to-obstruction spacing
within the cell if the cell is wide enough that the obstruction
layer satisfies the width requirement for the rule.  It is too
complicated to try to find specific places where the wide spacing
might not be needed.  Potentially this could be a problem for
technologies that define a number of graded wide-spacing rules,
as the largest-width rule is always used now by "lef write -hide",
and the largest-width rule could theoretically allow enough space
to route through, which would cause a short that cannot be
detected.  That would be a pathological case that may not show up
in practice.
2020-04-01 10:39:43 -04:00
Tim Edwards daf93e5bad Merge branch 'master' into bplane
Conflicts:
	VERSION

Merged from master correction that should prevent "lef write" from
creating pins with no geometry in them.
2020-04-01 09:01:33 -04:00
Tim Edwards e296fc5ba0 Corrected an error in lefWrite that should have avoided degenerate
labels by expanding a zero area label rectangle, but then if "select
chunk" returns nothing, it sets the area to the zero area label
rectangle instead of the expanded one that it just created.  This
is the reason that "lef write" is producing pins with no geometry
in the LEF file output.
2020-04-01 08:59:19 -04:00
Tim Edwards 195bb301ff Merge branch 'master' into bplane
Conflicts:
	VERSION

Changed mallocMagic() argument to size_t to match change in master
branch (essentially an ineffectual change).
2020-03-31 09:35:55 -04:00
Tim Edwards f689366553 Updated VERSION with commit. 2020-03-31 09:35:25 -04:00
Tim Edwards 688f07d302 Changed mallocMagic() argument to size_t. However, this is probably
not useful so long as Tcl_Alloc() has (unsigned int) for an argument.
The more important investigation is probably to determine if there is
a way to keep csa2_list from growing to absurdly large sizes on
connectivity checks.
2020-03-31 09:31:49 -04:00
Tim Edwards d742550edc Merge branch 'master' into bplane
Conflicts:
	VERSION

Merge from master (LEF read:  Read all tokens for LEF CLASS record)
2020-03-30 09:37:42 -04:00
Tim Edwards b5e06455c5 Corrected LEF read routine so as not to truncate LEF "CLASS" to a
single token (LEF CLASS records may have a subclass, such as "PAD
INPUT").
2020-03-30 09:36:24 -04:00
Tim Edwards 42917e80cc Merge branch 'master' into bplane
Conflicts:
	VERSION

Merged master (fix to dbcConnectFunc for integer size overflow in
call to mallocMagic()).
2020-03-28 20:15:17 -04:00
Tim Edwards 70613a3778 Modified line in DBconnect.c to cast csa2_size to type (size_t), as
magic crashed when the conSrArea array exceeded the size of a 32-bit
int during the antenna rule check.  Should be good for another four
orders of magnitude.
2020-03-28 20:11:22 -04:00
Tim Edwards d77cec8bf6 Merge branch 'master' into bplane
Conflicts:
	VERSION

Merged from master
2020-03-27 17:16:44 -04:00
Tim Edwards 2a7e2ab110 Updated version with the last fix. 2020-03-27 17:14:20 -04:00
Tim Edwards f28d2c5989 Merge branch 'master' into bplane
Merging correction to CalmaWrite.c for reference to property string
GDS_FILE that may not exist.
2020-03-27 16:52:21 -04:00
Tim Edwards d6b4b014d6 Corrected bad reference to GDS_FILE property when it may not exist. 2020-03-27 16:51:23 -04:00
Tim Edwards 4b2bf7b61d Merge branch 'master' into bplane
Merging master change to resis/ResBasic.c (correction for non-Manhattan
geometry).
2020-03-26 10:41:04 -04:00
Tim Edwards 74ea0a29b4 Corrected problem with ResSimple where extresist was not handling
non-manhattan geometry in device types.
2020-03-26 10:39:37 -04:00
Tim Edwards 7084ffe455 Merge branch 'master' into bplane
Merge master
2020-03-25 15:21:35 -04:00
Tim Edwards 521efeb929 Corrected uninitialized variable problem in lefWrite. 2020-03-25 15:21:05 -04:00
Tim Edwards aab318176b Corrected lefWrite, which was not initializing the count of items
written, so that a LEF output with no ports would fail to write
the OBS ... END around the obstruction geometry.
2020-03-25 15:19:28 -04:00
Tim Edwards 76411004b5 Merge branch 'master' into bplane
Merge quick fix from master
2020-03-25 12:07:33 -04:00
Tim Edwards 151f1fb470 Quick fix to last commit. 2020-03-25 12:07:14 -04:00
Tim Edwards 6a3c8c2fb6 Merge branch 'master' into bplane
Pulled change to GDS read from master branch.
2020-03-25 12:01:46 -04:00
Tim Edwards c433534f4c Modified GDS read to assign the same port index to incoming port
labels with the same text.
2020-03-25 12:01:06 -04:00
Tim Edwards 79ada35815 Merge branch 'master' into bplane
Conflicts:
	VERSION
	extract/ExtMain.c
	lef/lefWrite.c

Pulled master branch changes to lefWrite into the bplane branch.
2020-03-25 11:23:16 -04:00
Tim Edwards 195e096d64 Modified lefWrite to ensure maximum spacing per all widespacing rules
for any gap between a pin touching the cell boundary and the internal
obstruction layer.
2020-03-25 11:07:54 -04:00
Tim Edwards 6bae7c25c4 Enhanced the "lef write -hide" command option to check for metal
wide spacing rules; should result in LEF views that can import
back into magic without DRC errors.
2020-03-25 09:29:16 -04:00
Tim Edwards 007806521c Updated the "lef write -hide" to understand and use widespacing rules
(may still need additional enhancements, as it does not specifically
look for layer-to-obstruction rules).
2020-03-25 09:25:32 -04:00
Tim Edwards 5bf2a6ec69 Updated VERSION to revision 202. 2020-03-24 13:59:03 -04:00
Tim Edwards 00e1c01d8d Missed one instance of extFileOpen() in the implementation of the
"extract do local" command option.
2020-03-24 13:57:46 -04:00
Tim Edwards 54c6ccc8cd Corrected ExtMain() in the bplane branch (need to do this in master) 2020-03-24 13:55:44 -04:00
Tim Edwards 5df9ede961 Merge branch 'master' into bplane
Merged the change to run *bypass on the "crash save" command in tools.tcl.
2020-03-23 11:53:34 -04:00
Tim Edwards fe727cc6f2 Found that the "crash save" command in tools.tcl also disrupts
redirected command-line entry from the layout window;  fixed.
2020-03-23 11:52:31 -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 4777ced813 Corrected the bplane branch implementation of DRCFindInteractions,
where the function drcFindOtherCells() was missing, which causes
interaction areas to be missed and messes up the DRC checks between
parent and child cells.
2020-03-22 17:08:21 -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 c2bf9a8fb4 Added new command option "extract do local" to force all .ext files
to be written to the local directory instead of the directory where
the .mag file is located.
2020-03-21 20:57:11 -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
Tim Edwards a1ee1720f1 Corrected the "lef write -hide" method to keep a list of the areas
of the pin port geometry and using those areas to create the
spacing between them and the obstruction layer.  Otherwise, the
existing method used different databases (source vs. flattened) to
find the pin area, and they did not always agree on the exact
dimensions, leading to spacing errors within the LEF view.
2020-03-20 21:29:29 -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 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 43506e62ae Updated revision. 2020-03-19 09:23:50 -04:00
Tim Edwards 1e4c020b1e Corrected an error in which the "save" command attempts to overwrite
an allocated Tcl argument, and can cause a crash for a filename of
sufficient length.
2020-03-19 09:20:50 -04:00
Tim Edwards 311c223114 Merge branch 'master' into bplane
Conflicts:
	VERSION

Merged changes from master into the bplane branch.
2020-03-18 10:43:45 -04:00
Tim Edwards f4174d3670 Fixed a recent addition to the extraction method that prevents
generating duplicate devices that may have parts overlaid in
different subcells;  this failed to filter the check by plane of
the device, and so if any two devices exist at the same point in
two different planes (e.g., metal resistor and a transistor), one
of them would get eliminated.
2020-03-17 21:26:46 -04:00
Tim Edwards be1c0d1368 Merge branch 'master' into bplane
Conflicts:
	VERSION
	calma/Depend
	cif/Depend
	cmwind/Depend
	commands/Depend
	database/Depend
	dbwind/Depend
	debug/Depend
	drc/Depend
	ext2sim/Depend
	ext2spice/Depend
	extflat/Depend
	extract/Depend
	garouter/Depend
	gcr/Depend
	graphics/Depend
	grouter/Depend
	irouter/Depend
	lef/Depend
	lisp/Depend
	mzrouter/Depend
	netmenu/Depend
	plot/Depend
	plow/Depend
	resis/Depend
	router/Depend
	select/Depend
	sim/Depend
	tcltk/Depend
	textio/Depend
	tiles/Depend
	utils/Depend
	windows/Depend
	wiring/Depend

Merged recent changes from master branch into bplane branch.  Testing the
bplane implementation which has about a 5x improvement in extraction times
for large layouts, which is significant enough to move ahead with the bplane
implementation;  however, the bplane implementation has not been thoroughly
vetted yet, so it will remain a branch until such time that it has been
validated.
2020-03-15 13:23:24 -04:00
Tim Edwards 4f8ac38b27 Substantially enhanced the "lef write" methods. This now preserves
multiple ports;  also, when using the "-hide" option, the obstruction
area is computed from layer geometry, not from the bounding box.
Still left to do:  Ensure minimum width on pins, and remove slivers
of obstruction that are below minimum width.
2020-03-14 13:00:03 -04:00
Tim Edwards ea339ba367 Updated version so critical fix will get into a new tarball. 2020-03-14 09:51:34 -04:00
Tim Edwards 1a882bf2d7 Corrected careless error from yesterday's commit that causes "gds read"
to crash.
2020-03-14 09:50:36 -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 49c5e215c4 Updated revision to 195. 2020-03-13 12:22:26 -04:00
Tim Edwards f1624a2394 Merge branch 'master' into bplane
Merging fix from master.
2020-03-13 12:19:21 -04:00
Tim Edwards 2fee1a8c9a Missed one place to flag the substrate extraction; fixed now. 2020-03-13 12:18:56 -04:00
Tim Edwards 431b73c860 Corrected ExtInter.c after git merge screwed it up. 2020-03-13 11:45:53 -04:00
Tim Edwards bb1c9a6c0e Merge branch 'master' into bplane
Conflicts:
	extract/ExtSubtree.c
	utils/Depend

Updated bplane branch from master branch.
2020-03-13 11:39:56 -04:00
Tim Edwards 2788fd70ab One more change to the extraction method to avoid extracting the
substrate more than once for the same subcell, since the substrate
extraction method scans the entire plane area;  this was making
large standard cell layouts extract very slowly, as every component
cell was causing the substrate search to be repeated.
2020-03-13 11:36:42 -04:00
Tim Edwards 2569a06c1f Substantial improvements on several fronts, mostly to do with
extraction:  Fixed a problem causing long extraction times, at
least some of which had to do with a poor string hash function
implementation.  Fixed a huge problem in ext2spice, where the
node merge function was particularly poorly implemented, causing
exponentially increasing processing times with layout size.
Corrected a minor issue with ext2spice where arguments were
improperly specified, causing unnecessary error messages to be
issued.  Fixed an error in the "load -dereference" command option,
which again caused unnecessary error messages to be issued.
Changed .gitignore to ignore Depend files, which are now regenerated
on every build.
2020-03-13 10:33:44 -04:00
Tim Edwards cd87b08b21 Merge branch 'master' into bplane
Conflicts:
	VERSION
	database/DBcellsrch.c
	database/DBconnect.c
	extract/ExtInter.c
	lef/Depend
	utils/Depend

Updated bplane branch with all changes to master since the bplane branch
was last modified.
2020-03-12 08:29:33 -04:00
Tim Edwards aa738bb350 Corrected an obscure error in GDS generation caused by an
uninitialized variable, with the result that writing GDS would
claim that it cannot scale down enough and that the output units
are either wrong or the output style must have "units angstroms".
Using angstrom units would solve the problem but did not treat
the root of the problem.
2020-03-09 20:44:03 -04:00
Tim Edwards 1283317084 Corrected the improper use of the variable DRCErrorTable twice,
which results in conflicting hash tables and a crash, if a DRC
section is reloaded when doing an error count.
2020-03-06 13:46:40 -05:00
Tim Edwards 5a7eb37d6e Updated VERSION along with the LEF/DEF input correction. 2020-03-06 09:19:50 -05:00
Tim Edwards 86cad629ec Modified the LEF read routine to use the via geometry manipulations
from the cifoutput section, NOT the cifinput section.  This change
underscores the point that LEF and DEF formats define mask data,
and therefore all LEF and DEF routines should be using the CIF
input/output methods and layers.  That is a major code change;
meanwhile, getting via layer values from the cifoutput parameters
is slightly more reliable than using cifinput, since there is good
reason to use templayers to read vias, and that sort of indirection
makes it difficult to determine a simple relationship between a
LEF cut layer and a magic contact.
2020-03-06 09:15:22 -05:00
Tim Edwards a37fc1e242 Implemented the "def read ... -labels" option, which labels each net
with the name given to the net in the DEF file.  Especially useful
for LVS.
2020-03-05 14:29:54 -05:00
Tim Edwards 7413d89da1 Corrected the "lef writeall" command to add the "-hide" option, as
is available for "lef write".  This was inadvertently omitted.
2020-03-05 13:14:47 -05: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 cb7926ab0d Corrected lefTech.c not to issue a warning if defining a contact
type as an obstruction;  that should be perfectly acceptible.
2020-02-28 14:25:57 -05:00
Tim Edwards 612251b2b0 Changed the PNG bitmaps to GIF, because PNG is not supported in
Tcl/Tk 8.5, which is still installed and considered current/stable
on a lot of systems.
2020-02-26 10:10:55 -05:00
Tim Edwards 2beb5ee0e9 Modified the handling of "why" strings in the DRC mechanism, so that
DRC records contain an index into a string array instead of containing
a copy of a string.  This is preliminary to changing the way the DRC
error plane is painted, so that the types painted will mark the error
type.  This will (1) allow "drc why" to simply scan the DRC error
plane rather than running the DRC engine, (2) allow DRC errors to be
counted by area rather than by tile, and (3) let the DRC count be the
same whether done by "drc listall why" or "drc count".
2020-02-25 13:57:41 -05:00
Tim Edwards b62efea43d Corrected the last commit for fixing the "drc count" command option,
which had been changed a few months back to remove the individual
cell count and only list the top level cell.  The behavior has been
changed a bit so that "list" returns values for the top level cell
only, but "listall" returns a complete list.  "drc list count total"
gives the DRC count for the top cell, but "drc listall count total"
gives the DRC count for everything (probably not very useful).
Also:  Implemented a behavior by request to automatically removed
the (UNNAMED) cell whenever a new cell is loaded and the (UNNAMED)
cell has not been modified.
2020-02-25 09:52:06 -05:00
Tim Edwards 458631df41 updated VERSION for the night (to be checked tomorrow---versioning,
git, and the update script should all be working smoothly now).
2020-02-24 21:50:15 -05:00
Tim Edwards fba66b7dff Reverted the "drc count" command to the way it was. There is more
to be investigated here.  I am no longer sure why I removed the
cell search from DRC count, but it appears that the cell search is
non-functional, and it should be determined why.  There is no
particular reason not to have a DRC count search.  It could be
implemented such that "list" vs. "listall" counts the top cell vs.
all cells.  First it must be determined why there are no subcell
counts.
2020-02-24 21:47:44 -05:00
Tim Edwards b2c6193589 Manual VERSION update, checking regeneration of tarball build. 2020-02-24 17:34:02 -05:00
Tim Edwards 75292d1d1f Corrected Makefile to use -include instead of include on defs.mak
so that "make distclean" works.
2020-02-24 17:30:18 -05:00
Tim Edwards 509e936edb One more version update, checking fixes. . . 2020-02-24 17:26:20 -05:00
Tim Edwards 4c67d2dbe5 Forcing a version update. 2020-02-24 17:21:26 -05:00
Tim Edwards 592776098e Removed VERSION from gitignore; will rewrite scripts to handle
it properly without causing perpetual updates.
2020-02-24 10:06:39 -05:00
Tim Edwards fd6de6391f Modified the TODO list, partly becuase it's outdated, and partly to
force an update of the repository, which caused the script handling
the tarball generation and mirror to github to be hosed, which I did
not notice for three weeks.
2020-02-21 16:17:57 -05:00
Tim Edwards 421ff1fa0d Removed a temporary diagnostic output file that ended up in the
last commit by mistake.
2020-02-19 14:49:55 -05:00
Tim Edwards 2db6a6849a Finally rid myself of the C preprocessor. Took a moderately-developed
preproc.py script from another project.  Had to further develop it to
get around the amazingly complicated preprocessor usage in the scmos
subdirectory.  Needed to add handling of parameterized definitions;
could not figure out how to align the syntax used in scmos/extract_template
with any consistent syntax.  Gave up and rewrote some of the contents of
extract_template to avoid the more ambiguous usage.  All of this is to
support a completely deprecated scmos.tech.  However, it does avoid both
the M4 and cpp preprocessors altogether.  Also did auto-detection of
python3 in the configure script for use of the preproc.py preprocessor,
and applied the same preprocessor to the macro definitions.
2020-02-19 14:25:58 -05:00
Tim Edwards 6049b7e00e Further dealing with retinal displays: The scrollbars and related glyphs
now scale with Opts(scale), which is a zoom scalefactor (default 1), and
Opts(toolscale) sets an independent sizing for the toolbar icons, which is
multiplied by the Opts(scale) scalefactor.  Also:  Added GR_LIBS to the
link options for magicexec and magicdnull, to avoid compile-time problems
on some systems (thank you to Charlene of OpenBSD for the patch!).
2020-02-17 16:51:30 -05:00
Tim Edwards 2572421162 Added new option setting Opts(toolsize) that makes the toolbar icons
scale with the given size (default 16).  This can be put in the site.def
or .magicrc file as, e.g., "set Opts(toolsize) 32".  This is the first
part of an attempt to get everything to scale properly on ultra-high-
resolution monitors.
2020-02-17 15:13:54 -05:00
Tim Edwards 715843ca2a Changed the script drc.tcl into two routines for DRC load and save,
and merged the contents into drcmgr.tcl, with a new button in the
DRC manager for saving the DRC contents.  Loading is somewhat less
useful since the DRC error tiles are interactive.  The DRC manager
still has the issue that every checked edge becomes a separate
entry;  this is an artifact of the way the DRC checker works, but
it creates large numbers of error areas, many of which are redundant.
2020-02-17 10:25:45 -05:00
Tim Edwards ed8117784e Corrected three annoying errors: (1) Select net method had been
changed to ignore labels below the top level of hierarchy.  This
turned out to be a bad idea.  However, the original behavior was
problematic due to confusion over what part of the hierarchy the
labels were in.  The new behavior prefixes each label with the
cell hierarchy, eliminating both problems.  (2) Corrected the
problem where the attachment box for rendered labels is not
displayed if the label name is not in the viewing area.  (3)
Corrected the problem where redirection of input from the layout
window to the console window with the ":" command gets inadvertently
canceled;  this turned out to be due to a missing "*bypass" in
front of the command that finds the output scale to display the
pointer coordinates, and this was happening whenever the mouse was
moved while typing in a command.
2020-02-14 09:36:30 -05:00
Tim Edwards 897a8064ba Restored the behavior of selecting and displaying labels that are
down in the hierarchy when selecting a region or net, but with a
(hopefully very useful) twist:  To avoid the problem of ambiguous
labels in subcells, the subcell name hierarchy is generated in
the same way as is done when flattening a cell, with the instance
name prepended.  For example, when selecting a net in a standard
cell design, a terminal would highlight the name "OR2X1_1/B"
instead of just "B".
2020-02-14 08:48:47 -05:00
Tim Edwards f2dc4b37f0 Corrected the connectivity search function so that it does not attempt
to copy and search on a label that already exists in the flattened,
copied database.  Otherwise multiple labels on a single net can cause
the search to go into an infinite loop, repeatedly copying and erasing
the same label over and over again.
2020-02-13 10:04:55 -05: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
Tim Edwards 2ca9511152 Added fix for SVG output. This brings back the original behavior
of generating scalable output.  Some libcairo update had caused
the output to use the wrong version of SVG by default, which
generates an SVG-wrapped PNG data block, which is not scalable,
and not what was intended with the "plot svg" command.
2020-02-07 11:38:00 -05:00
Tim 'mithro' Ansell 4f30e76688 Make SVG output actually SVG again.
Currently the SVG output is a SVG file with an embedded `image/png`
file. Restricting to `CAIRO_SVG_VERSION_1_2` means the file goes back to
being a vector.

Signed-off-by: Tim 'mithro' Ansell <me@mith.ro>
2020-02-07 17:31:05 +01:00
Tim 'mithro' Ansell 6077907f77 Adding generated files to .gitignore. 2020-02-04 14:50:46 +01:00
Tim 'mithro' Ansell 3af3eeffff Change the file used to store the LICENSE. 2020-02-04 14:48:27 +01:00
Tim Edwards da7cc2096d Missed a number of Makefiles in directories two levels down. 2020-01-28 13:10:31 -05:00
Tim Edwards 4c5f027104 Correction to the configuration for distributed install. 2020-01-28 12:29:44 -05:00
Tim Edwards 323ce95981 Corrected missing references to the dist_dir install location in
the top-level Makefile.
2020-01-28 12:17:22 -05:00
Tim Edwards bc00b5578b Implemented a new configuration variable "dist_prefix" for
distributed installations, where the immediate installation location
is different from the final installation location, but in the case
where it is not desirable to put the entire install hierarchy as a
subdirectory of DESTDIR.
2020-01-28 10:40:01 -05:00
Tim Edwards 20a661e1ec Corrected problem in "extresist" if a port is a label with the
sticky flag set, and the type of the label does not correspond
exactly to the type under the label (e.g., label defined on m1
but is on top of a contact).
2020-01-24 17:13:59 -05:00
Tim Edwards 61859d152d Corrected a missing argument from the call to DBFlagMismatches()
that causes the recovery option (magic -r) to fail with a segfault
(which is definitely not helpful for recovering lost work).
2020-01-18 15:55:05 -05:00
Tim Edwards fc4638634a Corrected the ifdef MAGIC_WRAPPER placement in the EFantenna.c file,
which should have been only around the tclmagic.h include.
2020-01-17 12:54:58 -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
Alex Coffin 8e6f770afa
Fixed typo 2020-01-13 05:29:20 -08:00
Tim Edwards ff2f2de046 Corrected the dereferencing code from the last commit, where the
flag definition had been put in database.h instead of database.h.in,
and so was deleted on "make clean".  Also, corrected a problem that
causes the cif output style to be lost when running DRC-CIF checks
if the first output style is the DRC style.
2020-01-03 12:21:39 -05:00
Tim Edwards 82e33248f2 Corrected dereferencing of cell dependencies, which was being applied
only at the time of running the command "load".  But cells are generally
loaded only on an as-needed basis, so the dereferencing option must be
saved as a flag in the cell and honored whenever its subcells are expanded
or otherwise read at a later time.
2020-01-02 10:13:04 -05:00
Tim Edwards 67866c7991 Apparently GDS format does not enforce the original string character
limit of the Calma definition, and probably has not done so for ages.
Nobody informed me of this.  The restriction has been lifted from
GDS input and output in Magic.  It can be reinstated if necessary by
setting a flag in the cifoutput section of the techfile, but it is
likely that this will not be necessary unless there are other tools
that enforce the limit and will not read a GDS file that exceeds it.
2019-12-19 17:28:06 -05:00
Tim Edwards f15ea2a135 Modified "lef writeall" to only generate output for the set of subcells
that are direct children of the top level cell.  The "-all" option was
added to enable the previous behavior, although its usefulness is
doubtful.
2019-12-19 10:33:22 -05:00
Tim Edwards d0f3aaeb59 Corrected ext2hier.c so that resistance output from extresist takes
the right argument type (float, not int).  Otherwise all resistances
from extresist come out zero when doing "ext2spice extresist on"
and "ext2spice hierarchy on".  Also changed the format of the resistance
in the SPICE output to type float, since values are in standard units of
ohms, and rounding to the nearest ohm seems excessively coarse-grained.
2019-12-16 09:55:11 -05:00
Tim Edwards be38dac9fb Corrected .mag file read-in so that it will not complain about
a layout being redefined if one records the full path name and
the other records the home directory tilde expression.
2019-12-14 18:30:48 -05:00
Tim Edwards fd737dbf80 Overhauled the extresist code (again), this time to (1) correct for
a long-standing error (introduced with the "extresist geometry"
option) that can cause nets not to be extracted (due to the first
record not having extraction data, which was itself a long-standing
error in the code but which was not fixed correctly);  (2) handle
"device mosfet" type transistors (previously only handled the old
"fet" type extraction devices);  and (3) correct for the res.ext
file having a different scalefactor relative to the .ext file.  The
latter item was solved by forcing all input to scale like
ExtCurStyle->exts_unitsPerLambda, locally correcting all input as
needed.  Note that extresist still needs to handle other extraction
devices (e.g., resistors and capacitors) but those will require
additional handling in the routines which analyze the current path
to determine how to break up wires into paths.
2019-12-08 17:37:48 -05:00
Tim Edwards 31612b593f Added new CIF generation op "grow-min" that ensures a minimum width
for a layer.
2019-12-02 10:18:37 -05:00
Tim Edwards cfaccd973f Expanded the antenna rule violation setup and calculations to
include (1) specification of sidewall or surface to use for
each type individually, rather than a single method for all
types, and (2) specification of a linear model R = Ax + B for
the ratio limit when diodes are attached to the wire, where x
is the diode surface area (unitless, as this is a ratio).
2019-11-27 10:38:47 -05:00
Tim Edwards a374230d88 Modified the behavior of the LEF read routine when used to annotate
an existing cell.  If the existing cell has labels but the labels
are defined as point labels (no rectangle defined using specific
layer-purpose pairs), then the LEF macro's port geometry will be
used for the labels.  Because the GDS file can define label sizes
and fonts, which the LEF file cannot, but because the LEF file may
define multiple rectangles per port, the original point label is
given the first port rectangle from the LEF file, while the
remainder of the labels in the LEF file generate new non-rendered
labels in the cell.
2019-11-26 10:57:42 -05:00
Tim Edwards 46eefe8c33 Small correction on the last commit to avoid an integer overflow
error on large areas (need type dlong to encode areas in internal
units).
2019-11-25 16:37:03 -05:00
Tim Edwards 1fe128a405 Implemented new CIF operator "close", in the syntax "close <area>",
which takes the existing generated CIF plane, finds all enclosed
areas that have an area less than <area>, and fills them in.  This
satisfies a minimum hole area rule in a way that is not possible
with any of the existing CIF operators.
2019-11-25 15:14:41 -05:00
Tim Edwards b90166985d Corrected an error in the dual CIF style (output & drc) method where
the output style is not set back to what it was before if there are
no cif rules in the default DRC style.
2019-11-25 11:07:59 -05:00
Tim Edwards 7373d55c55 Corrected a problem from the last commit that causes error messages
in the toolkit Tk window when any parameter is modified, due do the
use of a variable before its being defined in the dialog update.
2019-11-22 11:37:04 -05:00
Tim Edwards 27ed2bf975 Modified the toolkit to take a selectlist with the special variable
name "gencell" and use that to create a selection that can change
between (compatible or somewhat compatible) device types.
2019-11-21 15:48:24 -05:00
Tim Edwards be8ba09373 Created an additional argument "start" to the "slots" operator,
which adds an offset value of "start" to both X and Y from the
lower left corner of the fill area.  This allows the use of the
"offset" (from the previous git commit) to be declared on different
layers without creating an exact overlap, as is often required by
foundries for fill patterns.
2019-11-20 13:36:03 -05:00
Tim Edwards adb4d2613d Added indexed selection to the PDK toolkit script (returns an index
from a selection, which can then be used to index into other lists.
This lets one selection be made on a list of arbitrary names, and
then additional parameters can be linked together with the same
index).  Also, implemented (finally!) the "offset" parameters of
the "slots" function (as advertised in the documentation).
2019-11-20 13:01:14 -05:00
Tim Edwards 3aa09725cb Changed extraction to avoid generating an error message for devices
like resistors where a tile other than space may border the resistor
device on its non-terminal sides (which is handled correctly, and
should not be considered an error).
2019-11-19 11:39:59 -05:00
Tim Edwards d3eb03d19a Additional correction to extraction, still part of the effort to
remove redundant ports.  A comment that I left in the code at the
last commit asked if it was necessary to call efAddNodes and
efAddConns recursively.  An example came up in which the answer
is apparently "yes".  These routines have been replaced by
efFlatNodes(), which appears to solve the problem.  There is now
a question of whether efFlatNodesDeviceless() does anything, and
should its main behavior (to flag deviceless subcircuits) be
folded into efFlatNodes.
2019-11-17 19:08:47 -05:00
Tim Edwards e1783a42a9 Added a "DRC manager" window option. This allows DRC errors to be
categorized by error type and scrolled through conveniently.  However,
it needs work dealing with finding the actual error bounds.  The
"DRC count" counts tiles, which is tile-plane-geometry-specific, and
"DRC listall why" fractures errors both over tiles and over the square
areas that the interactive DRC splits the layout into, for performance.
The DRC error plane needs to be changed to hold different types for
each error class, so that errors can be scanned by boundary instead of
by tile (work to be done).
2019-11-15 10:26:04 -05: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 5007f3f602 Modified "lef write" so that if a cell has a bounding box declared
by FIXED_BBOX derived from GDS and the new "boundary" cif input
rule, then the bbox property values take precedence over the
extent-of-geometry bounding box.
2019-11-13 15:10:01 -05:00
Tim Edwards 8e22b1504e Corrected an error introduced with the extension of extraction methods
to multiple entries per device;  the resistor length and width calculating
routine lost a break statement and would go into an infinite loop for
resistors with bends in them.
2019-11-13 14:29:19 -05:00
Tim Edwards 3a6f868efc Corrected an error in ext2spice caused by recent changes, that can
generate an extra node in the extract output that comes out as a
"(none)" node in the SPICE netlist from ext2spice.
2019-11-13 13:05:03 -05:00
Tim Edwards e3624d3e5f Added code to avoid a problem with "lef write" when a sticky label
is placed over multiple types.  This causes SelectChunk() to fail
and the pin will have no geometry output in the LEF file.  To avoid
this, the area of the label is always painted into the select cell
so that if SelectChunk() fails, the label area still exists with
the label tile type.
2019-11-12 21:46:52 -05:00
Tim Edwards 855e4ca134 Corrected an apparently long-standing error with the triggered rules
(such as widespacing or directional surround) that will cause the
rule to be triggered without a cause due to a failure to reset the
error count from a previous triggered rule (the condition of failure
is much more rare than this explanation makes it sound, which is why
it went undiscovered for so long).
2019-11-11 15:56:17 -05:00
Tim Edwards 0aca80dbc2 Corrected problem that can cause magic to crash on a "lef read"
command due to an uninitialized variable.
2019-11-01 13:23:31 -04:00
Tim Edwards 8e85c3a96e Corrected a long-standing error in the "widespacing" rule implementation
that was intended to avoid computing maxwidth more than necessary, but
ended up causing the widespacing rule to not be checked in certain
situations.
2019-11-01 12:01:07 -04:00
Tim Edwards 0f45014d18 Corrected an erroneous scalefactor used when reading geometry
attached to a label in a GDS input file;  the scalefactor that was
being used is reset at the beginning of a GDS read, and so becomes
invalid after a database rescaling, resulting in improperly scaled
label geometry if "gds read" is used more than once.
2019-11-01 10:16:43 -04: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 a4ea827d1e More corrections to extresist, which now appears to work if used
with ext2spice without the hierarchy option.  More work needed to
produce correct hierarchical output and to support extraction
devices other than the old "fet" record.
2019-10-28 13:10:16 -04:00
Tim Edwards 0e966af926 Modified the check for redundant label indexes in lefWrite so that
it only complains about (i.e., issues an error message) ports with
the same index but different text, indicating a read port number
collision and a true error.
2019-10-25 12:21:19 -04:00
Tim Edwards 2046318942 Corrected routine lefFileOpen() so that it will read files with
extensions other than specifically ".lef" or ".def" (such as
".tlef" for technology LEF, recently encountered).
2019-10-24 16:57:46 -04:00
Tim Edwards d9ccd711d9 Realizing that the "no such node" messages were directly related to
the below-threshold coupling caps being removed from the hierarchy,
added code to suppress the error message when it is clearly related
to a below-threshold cap that has been removed.
2019-10-23 11:59:59 -04: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 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 77e8ff437b Finished first cut at an implementation of antenna rule violation
checks.  Added new command "antennacheck" and a routine that
adds feedback entries where violations are found.  Extended the
syntax of the extraction section of the techfile to support the
antenna ratios and antenna calculation methods.
2019-10-20 22:12:02 -04:00
Tim Edwards b8c34cb10b Fixed an additional call to HashFind() that should have been
HashLookOnly() and can potentially cause a crash.
2019-10-18 14:25:28 -04:00
Tim Edwards 39ab59e7ec Corrected error causing a crash when parasitic extraction is
invoked on a layout with an array of instances.  Also, continued
implementation of antenna violation checking (not done yet).
2019-10-18 14:12:52 -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
Tim Edwards b41c86980b Corrected a mistake with the extension of the bloat-all CIF operator
that broke the operator for the usual case of all types in the same
plane.
2019-10-16 20:53:03 -04:00
Tim Edwards 745afa900d Corrected missing NULL initializer for device substrate name, which
can result in a segfault when reloading a techfile.
2019-10-16 11:38:31 -04:00
Tim Edwards 0386752abb Removed an error message from DRCcif.c; otherwise it raises an
error whenever there are no DRC-CIF rules in the techfile.  The
same error will be raised anyway when reading the techfile if
DRC-CIF rules are declared without a style being specified.
2019-10-16 10:14:44 -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 8b0a9275a8 Fixed the value of property FIXED_BBOX when saving a file; it needs
to be scaled down by "reducer" like all other values in the cell.
Suggests a need to have property types other than string, so that
a property type "rect" or "box" can be declared that is saved as a
Rect and always scales without special hack handling of the specific
string FIXED_BBOX. . .
2019-10-15 20:40:59 -04:00
Tim Edwards 3d7a56ac3a Finally got around to undoing an annoyance caused by the wholesale
reduction of memory and startup time, which was to maintain only
one CIF style in memory.  The new method is just to read in and
keep the DRC CIF style separately from the output CIF style.
Because the CIF sections of the techfile are read before the DRC
sections, and the CIF DRC style is declared in the DRC section,
the CIF DRC style is read in on the fly during the first DRC
checking.
2019-10-15 16:24:49 -04:00
Tim Edwards e969097f84 Another correction to fix the tile type for port drivers in
extresist, as the tile type was being set to a transistor gate
type and not the type of the port.
2019-10-15 09:51:25 -04:00
Tim Edwards 097f4fb28c Corrected node reading from extresist because the ".nodes" file
does not have any scaling in the dimensions and so values should not
be divided by the factor lambda from the .sim file "units" line.
2019-10-15 09:16:07 -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 57a5ff6094 Corrected errors preventing extresist from working properly with
hierarchical cells (namely a scaling issue with .sim file units).
More can be done to make the extresist command more user friendly,
but at least port connections as drivers appears to work.
2019-10-14 17:17:08 -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 1933c5d4a5 Corrected another problem where the device source/drain area and
perimeter were not output because of recent code that broke the
routine that assigns the resistance classes to devices.  This is
now fixed.  Thanks to Dan Moore for bringing this to my attention,
and debugging investigations.
2019-10-14 11:56:39 -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 000dab40e3 Made a correction to the last commit as the wrong hash search
function was used (HashFind, which never returns NULL, vs.
HashLookOnly, which does) resulting in a failure to solve the
problem which was being patched, which was ext2spice crashing
when cell arrays are present, which itself was due to allowing
brackets in base cell use names.
2019-10-02 12:59:10 -04:00
Tim Edwards 798e87deaf Corrected method relating to use of array notation in the base
use name (not part of an array in magic).  This was failing in
ext2spice due to code in extflat dealing incorrectly with the
array delimiters.  The correction fixes the problem but leaves
the possibility that there could be a conflict between a use
name that is an array and a use name that has the array index
as part of the name.
2019-10-01 19:32:52 -04:00
Tim Edwards 091d7ba2ae Corrected drcAssign for use with CIF drc rules, where the check for
plane is not relevant and can generate false-positive error messages
(although no actual errors occur).
2019-09-19 14:33:30 -04:00
Tim Edwards 0c24c33451 Corrected a bad error from a previous commit (5 days ago, for fixing
the forward-referenced GDS cell problem) in which when writing cells
from 3rd-party GDS, the structure names are written to GDS with the
indicator flag in front, making the structure names and the referenced
names different, so that the GDS file is no longer valid.  This has
been fixed.
2019-09-19 08:22:11 -04:00
Tim Edwards 4b5566af3e Corrected an error that causes alias names for layers to become the
principle layer name, which should not happen (especially in the
case of space, where layers may be aliased to "space" to make them
ignored on input).  Also:  Implemented a "-<types>" option to the
"substrate" record in the techfile to declare types which shield
layers from the substrate.  This allows types like pwell to be used
in different contexts, e.g., as part of the substrate, or as a P-well
in deep N-well, without requiring a different type.  This works in
conjunction with the recently-implemented "+<types>" ID types for
devices.  All of this may seem unnecessary but helps to reduce the
number of layers needing to be defined, and the subsequent complexity
of the DRC rulesets.
2019-09-18 20:48:33 -04:00
Tim Edwards 9b0905ad01 Corrected an error in the GDS compositing that fails to handle GDS
files that have forward references (cells that are instanced before
they are defined), resulting in those cells being given an undefined
string for a prefix, which will result in corrupted GDS output.
Also added a method to prevent forward-referenced cells from triggering
a "redundantly defined" error message when the structure is output.
2019-09-13 09:52:45 -04:00
Tim Edwards 643c39a2d5 Corrected error where modification to allow use of brackets inside
a cell instance name not related to an array moved a variable that
was used later in the routine to the inside of an if block,
effectively making that variable undefined in most cases.
2019-09-03 14:02:27 -04:00
Tim Edwards 63829cbbaa Hopefully final correction to new extraction method. Now correctly
handles diodes or other devices with source/drain on planes other
than the plane of the device type.  This no longer requires that
the non-connecting type be in any given terminal position.  The
device type boundary is surveyed for all types, connecting or
overlapping, and at least one of each required type must be present.
2019-08-24 14:18:03 -04:00
Tim Edwards 9f973fa9fc Minor correction to device extraction using the new device structure
format with multiple devices per magic tile type.  The code was left
incompatible with diodes defined with one terminal as substrate
(and therefore no source/drain-like types connecting to the device
type).  This has been fixed.
2019-08-23 14:01:28 -04:00
Tim Edwards a75aec4d7c Finally realized the problem came from a quick addition of a TO-DO
item that was never properly validated.  Corrected the root of the
problem, which was an attempt to deallocate memory that had never
been allocated in the first place.
2019-08-20 15:10:45 -04:00
Tim Edwards d5b695fea0 Corrected one other instance of checking for NULL when it should
have checked for CLIENTDEFAULT.
2019-08-20 15:05:30 -04:00
Tim Edwards c360fb9d5a Corrected check on cd_client in CalmaRdcl; if not set for holding
GDS plane data, it is initialized to CLIENTDEFAULT, not NULL.
2019-08-20 14:44:20 -04:00
Tim Edwards aa4bb4b19c Since allowing brackets to be part of cell names in a previous
commit, found that DBTreeFindUse fails to find such uses because
it strips the array delimiters off the name.  Fixed the routine
although the routine really should be checking if the use is a
1- or 2- dimensional array and stripping off only the components
expected.  The current code will probably fail for cell uses
that have brackets in the name AND are arrayed.  Fortunately
this search routine does not appear to be used frequently or in
any critical database functions like netlisting.
2019-08-20 10:37:12 -04:00
Tim Edwards 942eaf8113 Revised the substrate extraction method: Instead of searching on
all types specified in the "substrate" statement, split such types
into those on the declared well plane, and everything else.  Any
types on the well plane are searched as before.  Types not on the
well plane (e.g., psd on active) are searched and added to the
substrate node *only* if overlapping nothing on the well plane.
This allows a type such as "psd" to be used on, e.g., both space
(substrate) and deep pwell, but only be extracted as part of the
substrate when found over space.  Note that if there is NO
implicit substrate, the substrate connections will always be
found through the usual connection rules.
2019-08-20 08:42:07 -04:00
Tim Edwards 8c75f81cc4 Revised the method for multiple extraction models per device type
to be more robust and not depend on the ordering of the devices in
the techfile.  The extraction method now keeps a mask of which
properties of the device (source/drain types, substrate type,
identifier type) have been found, and will look only for device
records that match what is known about the device.  Added a device
identifier record which is the last record before parameters if the
record begins with "+".  This allows marker layers to be placed
over a device such that it will extract with a different type.
This helps reduce the complexity of the techfile and allows
certain specialized devices like RF or ESD to be identified without
a separate layer type for the device.
2019-08-19 14:11:02 -04:00
Tim Edwards f429e4eca4 Copied the text of the BSD copyright in the C source code into its
own file, to be consistent with most other software these days.
2019-08-09 16:52:20 -04:00
Roman-Parise 1edccafb2c Removed files in .gitignore from repo 2019-08-03 12:19:38 -04:00
Roman-Parise 46e0ec7a24 Updated outdated files in utils/magsgtty.h 2019-08-03 12:19:38 -04:00
Roman-Parise d235e01b2d Edited configure scripts for FreeBSD installation 2019-08-03 12:19:38 -04:00
Roman-Parise 05c069783a Added FreeBSD detail to INSTALL 2019-08-03 12:19:38 -04:00
Tim Edwards 381fc0cca4 Removed diagnostic print from last commit. 2019-08-02 14:53:22 -04:00
Tim Edwards 9635f10c5a Removed a badly implemented double-loop from the timestamp mismatch
code.
2019-08-02 14:50:32 -04:00
Tim Edwards df77f7853c Corrected the handling of UNPLACED components in a DEF file, which
was previously (and erroneously) lumped with PLACED and FIXED which
take a position argument afterward.  Note that this fix allows the
DEF file to be read without error but does not have the (presumably
desired) behavior of parsing SITE information from the LEF file and
ROWS information from the DEF file and giving each unplaced component
an arbitrary but legal position.  That would require a significant
amount of additional coding work.
2019-07-29 09:51:48 -04:00
Tim Edwards 8562812fff Corrected CalmaError() to CalmaReadError() in cif/CIFrdcl.c. Thanks
to Toby Schaffer for the bug report and patch!
2019-07-25 16:29:12 -04:00
Tim Edwards 982bb8aa63 Changed a recent commit which removed brackets from instance names
while reading DEF.  To preserve names as much as possible, such
names are now kept.  To avoid problems, EFbuild.c and ext2hier
behavior has been changed to only parse entries in a .ext file as
instance arrays if the array notation follows the specific syntax
of [ax:bx:cx][ay:by:cy], letting all other uses of brackets pass
through unaffected.
2019-07-25 10:20:24 -04:00
Tim Edwards 197c3f3448 Merge branch 'master' into bplane
Conflicts:
	commands/CmdCD.c
	database/DBcellsrch.c
	database/DBconnect.c
	database/DBio.c
	lef/lefRead.c
	select/selDisplay.c

Updated the bplane implementation with all recent updates (merged master).
2019-07-24 20:36:55 -04:00
Tim Edwards 93d25e7cf7 Removed the rule for building database.h from rules.mak and
instead created a dependency on database.h for compiling any
source file.  This should (I hope) avoid conflicts when running
"make" with the "-j" option for parallel compilation.
2019-07-24 12:30:03 -04:00
Tim Edwards d08593997a Cleaned up an inconsistency with GDS read-in that generates
informational output that references a (non-existing) CIF file.
2019-07-23 08:45:42 -04:00
Tim Edwards c229139150 Changed two output lines in the LEF read subroutine to conform to
the standard message/warning/error method.
2019-07-23 08:06:41 -04:00
Tim Edwards 9ec5e8e747 Modified DEF reads to avoid instance names with brackets. Not
sure if this is the best policy.  The brackets should be okay
but interfere with ext2spice when it reads them from the .ext
file and decides that they refer to arrays.  May be a better
way to handle this.
2019-07-19 22:58:45 -04:00
Tim Edwards 8183f72b00 Added a missing include for utils/utils.h which has the function
prototype for StrDup().  Otherwise, use of StrDup() in the LEF
read routine can cause an inscrutible crash.
2019-07-17 10:20:52 -04:00
Tim Edwards cd32e39d58 Modified the GDS read routine to account for use of WIDTH in a text
record without a MAG in the PRESENTATION record to override it.
2019-07-16 16:26:56 -04:00
Tim Edwards 70927709c7 Added the capability to read a value from a WIDTH entry for text.
Still not sure how it is supposed to be used, exactly.  Used it
to set a default text size in case a MAG value is missing.
2019-07-16 11:45:10 -04:00
Tim Edwards feac3d94dd Added missing handling of text in GDS input with PRESENTATION
followed by WIDTH (previously it assumed that PRESENTATION and
WIDTH were mutually exclusive).
2019-07-16 10:32:36 -04:00
Tim Edwards c31b305848 Corrected the dependency list in the Makefile for "modules", which
should depend on database/database.h;  otherwise running distributed
make can start compiling modules before the database.h file is
created.
2019-07-14 12:07:38 -04:00
Tim Edwards d95d8ba2ef Corrected the generation of bounding box positions from a GDS
boundary layer, which was being saved in GDS coordinates, not
magic database coordinates.
2019-07-08 20:36:48 -04:00
Tim Edwards d839cc26e2 One last problem fixed, as RECT entries in nets are relative, not
absolute.
2019-07-03 15:36:21 -04:00
Tim Edwards 0141ca8c95 Corrected error in generated vias (set top layer type on bottom,
so bottom layer went missing).
2019-07-03 14:52:22 -04:00
Tim Edwards 5ba84b068a Was missing needed expansion of via cut sizes to match magic's
internal definition of via areas, when reading parameterized vias
from a DEF file.
2019-07-03 14:24:52 -04:00
Tim Edwards 38fa141db5 One minor correction to the creation of generated vias in defRead.c. 2019-07-03 14:05:01 -04:00
Tim Edwards 49d98115bb Added a number of enhancements to the DEF reading to handle various
forms of syntax found in the LEF/DEF spec up to version 5.8.  Handles
vias formed by parameter and a number of syntax variations that mess
up the usual parsing.  Corrected an error in the calculation of wire
extensions when wires are given with three coordinates.
2019-07-03 13:58:13 -04:00
Tim Edwards 95ca3d93cc Added the handling of SHAPE statements in NET records in the DEF
file read routine.
2019-07-02 10:48:34 -04:00
Tim Edwards 5bd3fb91c9 Corrected the argument passing from the top-level wrapper for
configure script to the actual configure script.
2019-06-15 12:50:32 -04:00
Tim Edwards e296246c92 One last correction, as I accidentally dropped two calls to
getCurDevMult() inside spcHierWriteParams(), where it was being
passed as an argument, therefore making a redundant call and
wasting compute cycles.
2019-06-07 21:39:37 -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 51b70f6577 Corrected an error in the LEF/DEF geometry reading, because I
discovered that not all LEF/DEF rectangle coordinates are in
canonical order.  Took the opportunity to update the LefError()
routine with an additional argument so that it can separate
errors, warnings, and informational messages, and will correctly
state whether the output is for a LEF or DEF read operation.
2019-06-06 09:59:56 -04:00
Tim Edwards 87c07451d1 Corrected the LEF read routine so that when LEF is read to annotate
an existing GDS file, the "LEFview" property is not set (i.e., it
should not be marked as an abstract view because it is still a GDS
view).
2019-06-05 17:02:20 -04:00
Tim Edwards 0cd45ae6f7 Modified the cell clear routine so that it removes properties in
addition to subcells, paint, and labels.  Otherwise problems arise
if a cell is read from LEF followed by GDS;  the GDS view overwrites
the LEF but the property "LEFview" remains and causes problems when
writing GDS output subsequently.
2019-06-05 16:48:45 -04:00
Tim Edwards bbf6008363 Enhancements to cifinput and cifoutput in the tech file: Added
option "labels ... cellid" to handle some vendor files where
apparently to get around the 30-character cell name limit, the
actual cellname is encoded on a text layer.  Added new cifop
"boundary" (no arguments) for cases where a cell abutment box
is encoded on a GDS layer;  this now translates the bounding
box to the FIXED_BBOX property, as is done with the LEF bounding
box.  Also corrected the property set function to free existing
property value allocated memory when overwriting a property with
a new value.
2019-06-05 15:03:51 -04:00
Tim Edwards 8f7db3942c Fixed the "writeall force" command, which was behaving exactly the
same as "writeall", meaning that "force" was not being honored and
only cells that were modified were being written, in either case.
2019-06-04 16:17:17 -04:00
Tim Edwards 8170dbe01f Additional corrections to the wiring for some code changes that
were made where contacts are placed when shifting up on metal
layer but not made for the reverse case.  Also corrected one
inconsistency with non-minimum width wires.
2019-06-04 12:13:47 -04:00
Tim Edwards e4bfe864ba Modified the techfile "wiring" section to allow a scalefactor with
the same interpretation as the scalefactor for the DRC section:
Values in the section are interpreted as lambda divided by the
scalefactor.  That allows the wiring values to be real units such
as nanometers and avoid problems with fractional lambda values.
2019-06-04 09:15:56 -04:00
Tim Edwards b098fbbfbb Modified the "def write" routine to strip any path component off of
a cell name (although cell names are not supposed to have path
components, so need to find out where they came from. . .).
2019-05-28 17:14:24 -04:00
Tim Edwards a56309fdb6 Additional change to CalmaWrite: when handling cellnames with
lengths exceeding the maximum GDS name length (32 characters),
truncate by removing all but the last 32 characters, instead of
the previous behavior which was to remove all but the first 32
characters.  The last 32 characters are far more likely to be
unique than the first 32, given that the usual reason for extra-
long names is the concatentation of hierarchical names.
2019-05-22 17:03:52 -04:00
Tim Edwards 30a2226dbb Corrected a problem in CalmaWrite where a cell that was defined
redundantly was flagged, and output anyway, but the cellname was
not being written to the output, resulting in a bad GDS file.
2019-05-22 16:52:34 -04:00
Tim Edwards 243e9652e5 Added information to the GDS read routine error output to indicate
the byte position of the error.
2019-05-22 16:12:13 -04:00
Tim Edwards ec8ffe7333 Corrected an error in the GDS read routine which attempts to kill
a hash table that was never initialized, if the GDS file input
reader encounters an error in the GDS data.
2019-05-22 14:24:44 -04:00
Tim Edwards 24786b208a Corrected a badly-implemented search for electrical connectivity
through labels with the same text (particularly necessary for
abstract views, since the real connectivity may not be represented).
The original implementation could generate very deep subroutine call
stacks and lead to stack overflow.  The new implementation performs
the same check but without the deep nesting.
2019-05-22 10:38:00 -04:00
Tim Edwards 704f1dc69f Corrected an error that has been in the magic code forever, in which
if a GDS (CIF) layer is dependent on, and only on, a templayer or
layers that get hierarchically processed, it will not get added to
the list of layers needing hierarchical processing, and therefore
end up not being generated in the output.
2019-05-16 17:41:42 -04:00
Tim Edwards e2dd5f5157 Corrected the wiring command (adjustment to recent change for
centering wires on grid lines when using a snap grid) so that
the wire width is maintained when switching from one layer to
another, when the wire width is larger than the minimum for the
route layer.
2019-05-16 09:52:59 -04:00
Tim Edwards f7d57c913c Modified "def write" to prevent out-of-bounds array access when
writing vias.  However, the underlying problem, which is that
stacked vias are not decomposed into their constituent parts, has
not been addressed.  A "-units" option was added to the "def write"
command to force the units of the output file to be different than
the default of 1000 (nanometers).  No checks are made for whether
values can be accurately represented at the specified scale.
2019-05-11 15:09:01 -04:00
Tim Edwards 770a6f4a17 Updated the handling of fixed bounding boxes for abstract views
(once corrected in an experimental branch but never merged).  This
avoids changing the actual bounding box of the cell to match the
LEF bounding box, but defines a property instead and uses that
property for certain functions such as displaying the bounding box
outline or selecting the cell.  This avoids certain related errors
such as the failure to extract connections to areas outside of the
fixed bounding box.
2019-05-06 16:30:29 -04:00
Tim Edwards fc7249b04c Extended the "port" command to operate on labels in non-edit cells
as long as the command is not attempting to modify the port.
Attempts to modify ports in non-edit cells result in an error
message that is more helpful than the previous "Exactly one label
must be present..." text.
2019-05-03 10:13:06 -04:00
Tim Edwards b8bfaa5066 Corrected command option "select [more|less] cell <cellname>", which
was not recognizing the more|less option and therefore failing to
search for the instance <cellname>, rendering the command non-functional.
2019-05-03 09:14:25 -04:00
Tim Edwards 9ec23203fb Extended the wiring section definition to add wire extensions in
addition to wire overlaps, and added a method when painting
contacts to draw the necessary wire extension past the contact.
Since the wiring method draws single contacts by default, this
wiring method assumes a change in direction between layers.  But
the main point is to generate wire contacts without DRC errors.
2019-04-24 10:48:45 -04:00
Tim Edwards 5e9f274f65 Modified the way magic does wiring so that when working on a grid,
the wires stay centered on a centerline with respect to each other.
Also corrected the long-standing minor issue that the outline
drawing of the wire does not update when using the mouse scroll
wheel, making it unclear that the wire size has changed until the
wire position changes.
2019-04-23 14:32:11 -04:00
Tim Edwards 7e738576bc Corrected errors in LEF output syntax (missing semicolons at
statement ends on properties imported from a LEF file).  Never
noticed before because writing LEF after reading LEF was unusual.
2019-04-01 12:23:48 -04:00
Tim Edwards f6d4da56ce Extended the "lef read" command when used to annotate existing cells
so that PIN information including USE and CLASS are added to port
labels (previously only the bounding box was annotated).
2019-04-01 11:26:00 -04:00
Tim Edwards 1d04f20f5d Moved new work on magic-8.4 (experimental merging of micromagic bplane structure
into magic-8.2) into the newly-reorganized git repo as branch "bplane".
2019-03-22 19:58:47 -04:00
Tim Edwards 465a46c1c6 Merge branch 'master' into work 2019-03-20 10:09:07 -04:00
Tim Edwards 9e364111fb Update at Wed Mar 20 10:09:07 EDT 2019 by tim 2019-03-20 10:09:07 -04:00
Tim Edwards 92bf587a46 Fixed an error in the previous commit handling pin labels in GDS
input, which failed to update the "lastLabel" record of the cell
in the case that the placeholder label being deleted was the last
label, leading to labels being lost during GDS input.
2019-03-20 10:07:25 -04:00
Tim Edwards 5c36296acf Merge branch 'master' into work 2019-03-19 22:29:31 -04:00
Tim Edwards b7884f7917 Update at Tue Mar 19 22:29:29 EDT 2019 by tim 2019-03-19 22:29:29 -04:00
Tim Edwards 1533424590 Corrected scaling of label rectangles in GDS (that is, GDS layer
types that have been specified as being ports or text), since the
labels are in the magic database and at a different scale.  Added
code to cope with the fact that the labels may come after the
definition of the rectangle, so a rectangle identified as a port
or text label will generate an empty placeholder label, and all
new labels are checked against any empty labels in the database to
see if they are bounded by them.  If so, then the empty label is
removed and the label point is replaced by the rectangle.  This is
a ridiculously round-about way to deal with an under-specified
file format. . .
2019-03-19 22:25:25 -04:00
Tim Edwards ca408a8f22 Merge branch 'master' into work 2019-03-12 13:31:35 -04:00
Tim Edwards e183a5bd5c Update at Tue Mar 12 13:31:32 EDT 2019 by tim 2019-03-12 13:31:32 -04:00
Tim Edwards 1f3a512909 Added a "plot svg" command that, when used in conjuction with the
Cairo graphics package (magic -d XR), will map the display onto
an SVG surface and save it to a file using the Cairo SVG backend.
Due to the simplicity of the mapping, there are no options to this
plot command;  it just creates a file that is a (scalable!)
replica of the layout window.
2019-03-12 13:29:24 -04:00
Tim Edwards c08ddd355f Merge branch 'master' into work 2019-02-18 10:02:00 -05:00
Tim Edwards 6c69c67e17 Update at Mon Feb 18 10:01:58 EST 2019 by tim 2019-02-18 10:01:58 -05:00
Tim Edwards 677692e59f Corrected a potential problem with the substrate finding search,
which can be given an invalid area for the search.
2019-02-18 10:01:17 -05:00
Tim Edwards 834a4504de Merge branch 'master' into work 2019-02-14 12:21:59 -05:00
Tim Edwards d6cffb09f5 Update at Thu Feb 14 12:21:56 EST 2019 by tim 2019-02-14 12:21:56 -05:00
Tim Edwards 5693729ad5 Added code to avoid mishandling negative layer numbers when a
label in a DEF file is on a layer that has not been properly
mapped to a magic layer.  This would apply a negative index to
a TileType bitmask and crash the program.  Also:  Changed the
style and colormap slightly to make the via2 and via4 styles
more visible.
2019-02-14 12:19:50 -05:00
Tim Edwards 4348c11f10 Merge branch 'master' into work 2019-02-09 17:05:50 -05:00
Tim Edwards 8e1d57e234 Update at Sat Feb 9 17:05:48 EST 2019 by tim 2019-02-09 17:05:48 -05:00
Tim Edwards 7f1fa3a4c5 Modified the label connect function so that it only copies connected
labels if they are in the top-level cell of the connection search.
Otherwise, this slows the connection search way down for nets with
lots of internal labels, and can also have potentially bad consequences
if, for example, the connected network is copied to another position,
and carries all the flattened and non-hierarchically-named labels with
it.
2019-02-09 17:02:23 -05:00
Tim Edwards dfa95351cb Merge branch 'master' into work 2019-02-07 10:56:35 -05:00
Tim Edwards 2dba7e7c5e Update at Thu Feb 7 10:56:32 EST 2019 by tim 2019-02-07 10:56:32 -05:00
Tim Edwards 9f5936c7cb Found an additional scaling-up problem in ext2spice (previously handled
a scaling issue in extract) which was caused by the addition of
hierarchical netlist generation.  Finding hierarchical connections
requires finding instances by name, so it is vastly better to create a
hash table of instances instead of a linked list.
2019-02-07 10:54:07 -05:00
Tim Edwards c669d83dc6 Merge branch 'master' into work 2019-02-06 11:09:55 -05:00
Tim Edwards 512f5a7419 Update at Wed Feb 6 11:09:52 EST 2019 by tim 2019-02-06 11:09:52 -05:00
Tim Edwards 1beb7cd741 Corrected error that potentially causes a segfault in "lef write"
when accessing the inverse layer map array beyond its defined
allocated limit of DBNumUserLayers.
2019-02-06 11:09:46 -05:00
Tim Edwards af3ac0dde4 Merge branch 'master' into work 2019-01-31 11:00:26 -05:00
Tim Edwards 5eed0da098 Update at Thu Jan 31 11:00:23 EST 2019 by tim 2019-01-31 11:00:24 -05:00
Tim Edwards 78666d57e0 Modified the behavior of label handling in GDS input so that a
label specified as having type "space" automatically overrides
the "no-reconnect-labels" flag.  Modified the behavior of the
label reconnect algorithm so that it searches by plane order so
that material on the highest plane that matches the reconnection
criteria is chosen over similar materials on lower planes.
2019-01-31 10:56:38 -05:00
Tim Edwards dc6b0c5776 Merge branch 'master' into work 2019-01-30 17:18:51 -05:00
Tim Edwards ae76d92426 Update at Wed Jan 30 17:18:49 EST 2019 by tim 2019-01-30 17:18:49 -05:00
Tim Edwards 25304924b7 Corrected an apparently long-standing (but relatively obscure) error
where devices extracted as "device resistor" or "device capacitor"
and defining parameters (e.g., area, perimeter) will generate the
device arguments in the wrong order in the .ext file, resulting in
incorrect readback when attempting to do ext2spice, resulting in the
device being omitted from the resulting netlist.
2019-01-30 17:16:50 -05:00
Tim Edwards e87d413475 Merge branch 'master' into work 2019-01-29 16:46:41 -05:00
Tim Edwards 83d70924f2 Update at Tue Jan 29 16:46:38 EST 2019 by tim 2019-01-29 16:46:38 -05:00
Tim Edwards 57cded900f Found an error that causes the worst of the problem in long
extraction times, which is an incorrect units conversion of the
"step" parameter in the extract section.  It was converting based
on the "lambda" parameter in the same section, which has to do with
the scaling of values in the output file, not the scale factor of
the database to be extracted, which is set by the current CIF output
scale.  Once fixed, extraction times are minimized using the rule of
thumb mentioned in the techfile reference, which is 50 times the
minimum feature size.  Also:  Give the lengthy nature of extraction
on large designs no matter how well optimized, added a feature to
mark the progress of the extraction in increments of 5%.  Does not
output progress for small cells that extract quickly.
2019-01-29 16:41:48 -05:00
Tim Edwards 39695aecb0 Merge branch 'master' into work 2019-01-28 22:39:06 -05:00
Tim Edwards c3f3c5e4f9 Update at Mon Jan 28 22:39:04 EST 2019 by tim 2019-01-28 22:39:04 -05:00
Tim Edwards 61beaeaf83 Corrected a problem that can cause super-long run times for
extraction.  The plane mask array that denotes for each type which
planes should be searched for connecting types is supposed to be
a rare case that covers situations where planes connect by types
that are not contacts.  Instead, many planes were in this array,
causing the worst-case extraction methods to be run constantly.
2019-01-28 22:36:20 -05:00
Tim Edwards 90b413b582 Merge branch 'master' into work 2019-01-01 20:40:49 -05:00
Tim Edwards 0045ab261c Update at Tue Jan 1 20:40:47 EST 2019 by tim 2019-01-01 20:40:47 -05:00
Tim Edwards 8c35898902 Added same correction as made to version 8.1 to prevent leaving
the undo mechanism in the wrong state when writing a LEF header
with no route track information.  Also added code to the DEF write
routine to handle subcell arrays.  Thanks to Martin Devera for
both patches.
2019-01-01 20:39:16 -05:00
Tim Edwards 44bdb2a80b Merge branch 'master' into work 2018-12-28 10:29:31 -05:00
Tim Edwards 4201980923 Update at Fri Dec 28 10:29:29 EST 2018 by tim 2018-12-28 10:29:29 -05:00
Tim Edwards ded7dcb93f Corrected an error that causes run-time issues with compiling the
non-Tcl/Tk version, as the routine DRCBreak() is called but never
defined.
2018-12-28 10:29:18 -05:00
Tim Edwards 34ae6ea9cc Corrected error in technology file reloading that causes the plow
module to fill up its rules table and start printing errors about
the table overflow.  Tables are now properly reset on tech reload.
2018-12-14 16:33:34 -05:00
Tim Edwards 53fd26d1bc Corrected DRC "why" message subsitution sequence "%a" so that it
corresponds to drcc_cdist, which encodes the area (not drcc_dist).
2018-12-14 14:02:54 -05:00
Tim Edwards 880ebde614 Merge branch 'work' into tomerge 2018-12-14 11:58:25 -05:00
Tim Edwards 213749d009 Update at Fri Dec 14 11:58:22 EST 2018 by tim 2018-12-14 11:58:22 -05:00
Tim Edwards 6aa0895e6f Created a method for distance substitutions in DRC "why" strings in
DRC rules.  The substitutions are specified by "%d" for the main
rule distance, "%c" for the corner rule distance (sometimes
interpreted differently;  e.g., as width in the widespacing rule),
and "%a" for rule area (e.g., maxarea rule).  In addition to
simplifying the process of writing rule violation strings, the
benefits are twofold:  (1) The output is in meaningful physical
units, but in the case of SCMOS technology, will scale properly
depending on the selected GDS output style, and in the case of
all technologies, will scale properly with internal grid division;
and (2) when using lambda, but where rules are given in vendor
minimum dimensions, the rules will be based on the lambda rule
approximation (that is, distances will be rounded to the nearest
lambda but reported in microns).  Behavior is unchanged from
previous versions for "why" strings not using the defined
substitution sequences.
2018-12-14 11:51:27 -05:00
Tim Edwards 533017c8c7 Merge branch 'work' into tomerge 2018-12-13 12:05:18 -05:00
Tim Edwards bd583f476b Update at Thu Dec 13 12:05:16 EST 2018 by tim 2018-12-13 12:05:16 -05:00
Tim Edwards f3d191981d Corrected a few aspects of LEF write: (1) Put BUSBITCHARS in the
header, (2) Use CLASS BLOCK in the macro if no class is defined,
and (3) Add END LIBRARY to the end of the file.
2018-12-13 12:04:10 -05:00
Tim Edwards 3bfc2bd620 Merge branch 'work' into tomerge 2018-12-12 17:25:17 -05:00
Tim Edwards 3fa8a88a79 Update at Wed Dec 12 17:25:15 EST 2018 by tim 2018-12-12 17:25:15 -05: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 fc0645a88e Merge branch 'work' into tomerge 2018-12-07 10:12:31 -05:00
Tim Edwards a746acea5c Update at Fri Dec 7 10:12:29 EST 2018 by tim 2018-12-07 10:12:29 -05:00
Tim Edwards 4da51bc42a Modified the "makedbh" script to avoid intermixing "printf" and
"echo", because there is at least one OS variant out there where
the two buffer independently and cause the output to have lines
out of order.  The script had previously used "printf" because
"echo -n" is not POSIX-compliant and so not necessarily universally
compatible.  The script was changed to use "printf" throughout.
2018-12-07 10:10:22 -05:00
Tim Edwards ba9dfb7765 Merge branch 'work' into tomerge 2018-11-20 13:07:56 -05:00
Tim Edwards 5802fab980 Update at Tue Nov 20 13:07:54 EST 2018 by tim 2018-11-20 13:07:54 -05:00
Tim Edwards 5804bd3326 Minor typo correction. 2018-11-20 13:04:44 -05:00
Tim Edwards 5e28e84336 Merge branch 'work' into tomerge 2018-11-19 15:04:32 -05:00
Tim Edwards f30f976bc7 Update at Mon Nov 19 15:04:29 EST 2018 by tim 2018-11-19 15:04:29 -05:00
Tim Edwards 17227ee427 Added new option "-hide" to the "lef write" command, which causes
the output to have an obstruction area over the entire cell except
for a keep-out area around each pin.  Instead of marking every
part of the pin geometry, only the "chunk" (largest immediate
rectangle) surrounding the port label is output as part of port
LEF geometry.  This avoids making unnecessarily complicated
abstract views, and makes it easier for other tools to read and
manage the same abstract views.
2018-11-19 15:01:20 -05:00
Tim Edwards f756825828 Removed a few diagnostic output statements from the last commit. 2018-11-16 14:43:41 -05:00
Tim Edwards ee6834abde Merge branch 'work' into tomerge 2018-11-16 14:04:00 -05:00
Tim Edwards 852dabeee1 Update at Fri Nov 16 14:03:58 EST 2018 by tim 2018-11-16 14:03:58 -05:00
Tim Edwards dd3a92762c Update for writing files from abstract views. Previous behavior was
to prefix all library components read from GDS files pointed to by
an abstract view (other than the cell itself) with a prefix.  But
this does not account for the fact that the same library may be read
by other cells.  The solution is for every cell in the library, check
if there is a cell in magic with the same name which is also an abstract
view that points to the same GDS library.  Those cells do not get
prefixes.  At the same time, however, it was discovered that the GDS
cellname character limit is set at 32, and so prefixes must be kept
short.  To keep the prefixes unique, the prefix was changed to a 4
character random alphanumeric sequence, and a warning is issued if
any GDS cell exceeds the 32 character limit.
2018-11-16 13:59:17 -05:00
Tim Edwards eca3ba25b3 Merge branch 'work' into tomerge 2018-11-15 15:57:58 -05:00
Tim Edwards a2ef591c8d Update at Thu Nov 15 15:57:56 EST 2018 by tim 2018-11-15 15:57:56 -05:00
Tim Edwards 395fb1a8d6 Corrected node merging, which failed to copy the EF_TOP_PORT flag
bit into the merged node.  Corrected reference to efNodeHashTable
to the more proper call to EFHNLook().
2018-11-15 15:55:41 -05:00
Tim Edwards cf9f9784ed Merge branch 'work' into tomerge 2018-11-12 13:27:15 -05:00
Tim Edwards 131ac3156f Update at Mon Nov 12 13:27:12 EST 2018 by tim 2018-11-12 13:27:12 -05:00
Tim Edwards 66603cdb53 Corrected invalid logic in the interpetation of (cif/gds) label
options "text", "port", and "noport" in the techfile.  The
incorrect interpretation was preventing backwards compatibility,
such that ports would not be output on GDS layers if the "port"
option was not used.
2018-11-12 13:25:05 -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 56e838ebb6 Merge branch 'work' into tomerge 2018-10-31 14:36:02 -04:00
Tim Edwards 27697d36cc Update at Wed Oct 31 14:36:01 EDT 2018 by tim 2018-10-31 14:36:01 -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
985 changed files with 85290 additions and 43156 deletions

1
.dockerignore Normal file
View File

@ -0,0 +1 @@
./appimage

14
.git-expand-header Executable file
View File

@ -0,0 +1,14 @@
#! /usr/bin/env bash
FILE="$(basename $1)"
GIT_DATE="$(git log -n1 --pretty=%ai -- $1)"
GIT_AUTHOR="$(git log -n1 --pretty=%ae -- $1)"
GIT_HASH="$(git log -n1 --pretty=%h -- $1)"
GIT_REV="$(git describe --long --always ${GIT_HASH})"
sed \
-e"s@\\\$Date\\\$@\\\$Date: ${GIT_DATE}\\\$@" \
-e"s|\\\$Author\\\$|\\\$Author: ${GIT_AUTHOR}\\\$|" \
-e"s@\\\$Id\\\$@\\\$Id: ${GIT_REV}\\\$@" \
-e"s@\\\$Revision\\\$@\\\$Revision: ${GIT_REV}\\\$@" \
-e"s|\\\$Header\\\$|\\\$Header: ${FILE} ${GIT_REV} ${GIT_DATE} ${GIT_AUTHOR} \\\$|"

8
.gitattributes vendored Normal file
View File

@ -0,0 +1,8 @@
*.c filter=header
*.h filter=header
*.cpp filter=header
*.tcl filter=header
*.scm filter=header
Makefile filter=header
*.gds diff=gds

170
.github/workflows/appimage10.yml vendored Normal file
View File

@ -0,0 +1,170 @@
on:
push:
tags:
- "*"
workflow_dispatch:
name: CI-appimage10
env:
APPIMAGETOOL_DOWNLOAD_URL: https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage
jobs:
build_appimage10:
name: Build AppImage EL10
runs-on: ubuntu-latest
permissions:
contents: write # action-gh-release
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 149 # enough to cover between tags
#fetch-tags: true # this should work see actions/checkout~issue#1471
- name: Get the version
id: get_version
run: |
git show -s
version=$(cat VERSION) # 8.9.999
version_tstamp=$(git show -s "--format=%cs" | tr -d '-') # YYYYMMDD
version_hash=$(git show -s "--format=%h") # abcdefg
version_num=$(ruby -e "print '$GITHUB_REF'.split('/')[2]") # legacy version method: master
echo "version=${version}"
echo "version_tstamp=${version_tstamp}"
echo "version_hash=${version_hash}"
echo "version_num=${version_num}"
VERSION_NUM="${version}~${version_tstamp}~${version_hash}"
echo "VERSION_NUM=${VERSION_NUM}" >> $GITHUB_ENV
echo "MAGIC_APPIMAGE_OUTPUT_FILENAME=Magic-${VERSION_NUM}-x86_64-EL10.AppImage" >> $GITHUB_ENV
# Is this GHA being run due to a push-on-tag ? if so we make a GitHub release, otherwise we just publish artifact
github_tag=$(echo -n "$GITHUB_REF" | sed -e 's#refs/tags/##') # 8.9.999
echo "github_tag=$github_tag"
if echo -n "$GITHUB_REF" | egrep -q "^refs/tags/" # check prefix
then
if [ -n "$github_tag" ]
then
echo "MY_GITHUB_TAG=${github_tag}" >> $GITHUB_ENV
fi
fi
- name: Build project
run: |
cd appimage/10
make
ln -v Magic-x86_64.AppImage "${MAGIC_APPIMAGE_OUTPUT_FILENAME}"
ls -l *.AppImage
sha256sum *.AppImage
pwd
- name: Create RELEASE-NOTES.txt
run: |
cd appimage/10
# Find the last tag (that does not match the current GITHUB_REF)
echo GITHUB_REF=$GITHUB_REF
echo GITHUB_SHA=$GITHUB_SHA
# GitHub CI is a shallow checkout by default (just the files needed to build)
# but we also want history back to next tag, see fetch-tags/fetch-depth actions/checkout~issue#1471
if [[ "$GITHUB_REF" =~ ^refs/tags/ ]]
then
# remove only if ref of tag (to avoid conflict during fetch)
git update-ref -d $GITHUB_REF
echo git_update_ref_exitstatus=$?
fi
set +e
git fetch --tags --prune --no-recurse-submodules --depth=149 origin +$GITHUB_SHA # fetch-tags: true # is broken
echo git_fetch_exitstatus=$?
git_show_ref=$(git show-ref --hash $GITHUB_REF) # get tagcommit hash
git_show_ref_exitstatus=$?
echo git_show_ref_exitstatus=$git_show_ref_exitstatus
echo git_show_ref=$git_show_ref
git_rev_list=$(git rev-list -n1 $GITHUB_REF) # get commit hash
git_rev_list_exitstatus=$?
echo git_rev_list_exitstatus=$git_rev_list_exitstatus
echo git_rev_list=$git_rev_list
set -e
test "$git_show_ref" = "$GITHUB_SHA" || test "$git_rev_list" = "$GITHUB_SHA" # check we got the ref back (or fail CI)
git_describe=$(git describe --tags $GITHUB_SHA | sed -e 's#\-\([0-9]\+\-g\)#\+\1#') # /-\d+-g/
echo git_describe=$git_describe
# RELEASE-NOTES-EL10.txt
echo "### ${MAGIC_APPIMAGE_OUTPUT_FILENAME} commit ${git_describe}" | sed -e 's#~#\\~#g' > RELEASE-NOTES-EL10.txt
echo "" >> RELEASE-NOTES-EL10.txt
echo "This release is based on EL10 (AlmaLinux10), the AppImage format is designed to run on a wide range of Linux distributions." >> RELEASE-NOTES-EL10.txt
echo "" >> RELEASE-NOTES-EL10.txt
echo "See documentation at https://github.com/${GITHUB_REPOSITORY}/blob/${GITHUB_SHA:0:8}/appimage/10/README.md" >> RELEASE-NOTES-EL10.txt
echo "" >> RELEASE-NOTES-EL10.txt
length_info=$(stat "--format=%s bytes" "${MAGIC_APPIMAGE_OUTPUT_FILENAME}")
sha256_info=$(sha256sum "${MAGIC_APPIMAGE_OUTPUT_FILENAME}" | cut -d ' ' -f1)
echo "| | |" >> RELEASE-NOTES-EL10.txt
echo "| :-------- | :------ |" >> RELEASE-NOTES-EL10.txt
echo "| File Name | ${MAGIC_APPIMAGE_OUTPUT_FILENAME} |" | sed -e 's#~#\\~#g' >> RELEASE-NOTES-EL10.txt
echo "| File Length | ${length_info} |" >> RELEASE-NOTES-EL10.txt
echo "| File SHA256 | ${sha256_info} |" >> RELEASE-NOTES-EL10.txt
echo "" >> RELEASE-NOTES-EL10.txt
# RELEASE-NOTES-CL.txt
set +e # allow this to fail to empty string
git_previous_tag=$(git describe --tags --abbrev=0 $(git rev-list --tags --skip=1 --max-count=1))
echo git_previous_tag=$git_previous_tag
set -e
if [ -n "${git_previous_tag}" ]
then
echo "### Change Log (since previous tag):" > RELEASE-NOTES-CL.txt
echo "\`\`\`" >> RELEASE-NOTES-CL.txt
git log --oneline --no-color --no-decorate "refs/tags/${git_previous_tag}..${GITHUB_REF}" >> RELEASE-NOTES-CL.txt
echo "\`\`\`" >> RELEASE-NOTES-CL.txt
else
echo "### Change Log (last commit only):" > RELEASE-NOTES-CL.txt
echo "\`\`\`" >> RELEASE-NOTES-CL.txt
git log --oneline -n1 --no-color --no-decorate "${GITHUB_REF}" >> RELEASE-NOTES-CL.txt
echo "\`\`\`" >> RELEASE-NOTES-CL.txt
fi
echo "" >> RELEASE-NOTES-CL.txt
#echo "### Build Info:" > RELEASE-NOTES-BI.txt
# FIXME extract package version info and DSO symvers into RELEASE-NOTES.txt
#echo "" >> RELEASE-NOTES-BI.txt
cat RELEASE-NOTES-CL.txt >> RELEASE-NOTES-EL10.txt
cat RELEASE-NOTES-EL10.txt
# RELEASE-NOTES-DOCS.txt
echo "See documentation at https://github.com/${GITHUB_REPOSITORY}/blob/${GITHUB_SHA:0:8}/appimage/7/README.md" >> RELEASE-NOTES-DOCS.txt
echo "See documentation at https://github.com/${GITHUB_REPOSITORY}/blob/${GITHUB_SHA:0:8}/appimage/8/README.md" >> RELEASE-NOTES-DOCS.txt
echo "See documentation at https://github.com/${GITHUB_REPOSITORY}/blob/${GITHUB_SHA:0:8}/appimage/9/README.md" >> RELEASE-NOTES-DOCS.txt
echo "See documentation at https://github.com/${GITHUB_REPOSITORY}/blob/${GITHUB_SHA:0:8}/appimage/10/README.md" >> RELEASE-NOTES-DOCS.txt
# RELEASE-NOTES-GH.txt (this is shared for all AppImage for one tag)
echo "### commit ${git_describe}" | sed -e 's#~#\\~#g' > RELEASE-NOTES-GH.txt
if [[ "$GITHUB_REF" =~ ^refs/tags/ ]]
then
# show tag annotation with tags like before
git tag --cleanup=strip "--format=%(contents)" -n "${GITHUB_REF:10}" | sed -e 's#\([~|]\)#\\\1#g' >> RELEASE-NOTES-GH.txt
fi
echo "" >> RELEASE-NOTES-GH.txt
cat RELEASE-NOTES-DOCS.txt >> RELEASE-NOTES-GH.txt
cat RELEASE-NOTES-CL.txt >> RELEASE-NOTES-GH.txt
# Show in action/artifact output
echo "## RELEASE NOTES" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
cat RELEASE-NOTES-EL10.txt >> $GITHUB_STEP_SUMMARY
- name: Upload Release Asset
if: ${{ env.MY_GITHUB_TAG != '' }} # if: ${{ github.ref_type == 'tag' }}
uses: softprops/action-gh-release@v2
with:
body_path: ${{ github.workspace }}/appimage/10/RELEASE-NOTES-GH.txt
files: |
${{ github.workspace }}/appimage/10/${{env.MAGIC_APPIMAGE_OUTPUT_FILENAME}}
${{ github.workspace }}/appimage/10/RELEASE-NOTES-EL10.txt
- name: Upload Artifact
#if: ${{ env.MY_GITHUB_TAG == '' }} # commented out to always upload
uses: actions/upload-artifact@v4
with:
name: ${{env.MAGIC_APPIMAGE_OUTPUT_FILENAME}}
path: |
${{ github.workspace }}/appimage/10/${{env.MAGIC_APPIMAGE_OUTPUT_FILENAME}}

170
.github/workflows/appimage7.yml vendored Normal file
View File

@ -0,0 +1,170 @@
on:
push:
tags:
- "*"
workflow_dispatch:
name: CI-appimage7
env:
APPIMAGETOOL_DOWNLOAD_URL: https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage
jobs:
build_appimage7:
name: Build AppImage EL7
runs-on: ubuntu-latest
permissions:
contents: write # action-gh-release
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 149 # enough to cover between tags
#fetch-tags: true # this should work see actions/checkout~issue#1471
- name: Get the version
id: get_version
run: |
git show -s
version=$(cat VERSION) # 8.9.999
version_tstamp=$(git show -s "--format=%cs" | tr -d '-') # YYYYMMDD
version_hash=$(git show -s "--format=%h") # abcdefg
version_num=$(ruby -e "print '$GITHUB_REF'.split('/')[2]") # legacy version method: master
echo "version=${version}"
echo "version_tstamp=${version_tstamp}"
echo "version_hash=${version_hash}"
echo "version_num=${version_num}"
VERSION_NUM="${version}~${version_tstamp}~${version_hash}"
echo "VERSION_NUM=${VERSION_NUM}" >> $GITHUB_ENV
echo "MAGIC_APPIMAGE_OUTPUT_FILENAME=Magic-${VERSION_NUM}-x86_64-EL7.AppImage" >> $GITHUB_ENV
# Is this GHA being run due to a push-on-tag ? if so we make a GitHub release, otherwise we just publish artifact
github_tag=$(echo -n "$GITHUB_REF" | sed -e 's#refs/tags/##') # 8.9.999
echo "github_tag=$github_tag"
if echo -n "$GITHUB_REF" | egrep -q "^refs/tags/" # check prefix
then
if [ -n "$github_tag" ]
then
echo "MY_GITHUB_TAG=${github_tag}" >> $GITHUB_ENV
fi
fi
- name: Build project
run: |
cd appimage/7
make
ln -v Magic-x86_64.AppImage "${MAGIC_APPIMAGE_OUTPUT_FILENAME}"
ls -l *.AppImage
sha256sum *.AppImage
pwd
- name: Create RELEASE-NOTES.txt
run: |
cd appimage/7
# Find the last tag (that does not match the current GITHUB_REF)
echo GITHUB_REF=$GITHUB_REF
echo GITHUB_SHA=$GITHUB_SHA
# GitHub CI is a shallow checkout by default (just the files needed to build)
# but we also want history back to next tag, see fetch-tags/fetch-depth actions/checkout~issue#1471
if [[ "$GITHUB_REF" =~ ^refs/tags/ ]]
then
# remove only if ref of tag (to avoid conflict during fetch)
git update-ref -d $GITHUB_REF
echo git_update_ref_exitstatus=$?
fi
set +e
git fetch --tags --prune --no-recurse-submodules --depth=149 origin +$GITHUB_SHA # fetch-tags: true # is broken
echo git_fetch_exitstatus=$?
git_show_ref=$(git show-ref --hash $GITHUB_REF) # get tagcommit hash
git_show_ref_exitstatus=$?
echo git_show_ref_exitstatus=$git_show_ref_exitstatus
echo git_show_ref=$git_show_ref
git_rev_list=$(git rev-list -n1 $GITHUB_REF) # get commit hash
git_rev_list_exitstatus=$?
echo git_rev_list_exitstatus=$git_rev_list_exitstatus
echo git_rev_list=$git_rev_list
set -e
test "$git_show_ref" = "$GITHUB_SHA" || test "$git_rev_list" = "$GITHUB_SHA" # check we got the ref back (or fail CI)
git_describe=$(git describe --tags $GITHUB_SHA | sed -e 's#\-\([0-9]\+\-g\)#\+\1#') # /-\d+-g/
echo git_describe=$git_describe
# RELEASE-NOTES-EL7.txt
echo "### ${MAGIC_APPIMAGE_OUTPUT_FILENAME} commit ${git_describe}" | sed -e 's#~#\\~#g' > RELEASE-NOTES-EL7.txt
echo "" >> RELEASE-NOTES-EL7.txt
echo "This release is based on EL7 (CentOS7), the AppImage format is designed to run on a wide range of Linux distributions." >> RELEASE-NOTES-EL7.txt
echo "" >> RELEASE-NOTES-EL7.txt
echo "See documentation at https://github.com/${GITHUB_REPOSITORY}/blob/${GITHUB_SHA:0:8}/appimage/7/README.md" >> RELEASE-NOTES-EL7.txt
echo "" >> RELEASE-NOTES-EL7.txt
length_info=$(stat "--format=%s bytes" "${MAGIC_APPIMAGE_OUTPUT_FILENAME}")
sha256_info=$(sha256sum "${MAGIC_APPIMAGE_OUTPUT_FILENAME}" | cut -d ' ' -f1)
echo "| | |" >> RELEASE-NOTES-EL7.txt
echo "| :-------- | :------ |" >> RELEASE-NOTES-EL7.txt
echo "| File Name | ${MAGIC_APPIMAGE_OUTPUT_FILENAME} |" | sed -e 's#~#\\~#g' >> RELEASE-NOTES-EL7.txt
echo "| File Length | ${length_info} |" >> RELEASE-NOTES-EL7.txt
echo "| File SHA256 | ${sha256_info} |" >> RELEASE-NOTES-EL7.txt
echo "" >> RELEASE-NOTES-EL7.txt
# RELEASE-NOTES-CL.txt
set +e # allow this to fail to empty string
git_previous_tag=$(git describe --tags --abbrev=0 $(git rev-list --tags --skip=1 --max-count=1))
echo git_previous_tag=$git_previous_tag
set -e
if [ -n "${git_previous_tag}" ]
then
echo "### Change Log (since previous tag):" > RELEASE-NOTES-CL.txt
echo "\`\`\`" >> RELEASE-NOTES-CL.txt
git log --oneline --no-color --no-decorate "refs/tags/${git_previous_tag}..${GITHUB_REF}" >> RELEASE-NOTES-CL.txt
echo "\`\`\`" >> RELEASE-NOTES-CL.txt
else
echo "### Change Log (last commit only):" > RELEASE-NOTES-CL.txt
echo "\`\`\`" >> RELEASE-NOTES-CL.txt
git log --oneline -n1 --no-color --no-decorate "${GITHUB_REF}" >> RELEASE-NOTES-CL.txt
echo "\`\`\`" >> RELEASE-NOTES-CL.txt
fi
echo "" >> RELEASE-NOTES-CL.txt
#echo "### Build Info:" > RELEASE-NOTES-BI.txt
# FIXME extract package version info and DSO symvers into RELEASE-NOTES.txt
#echo "" >> RELEASE-NOTES-BI.txt
cat RELEASE-NOTES-CL.txt >> RELEASE-NOTES-EL7.txt
cat RELEASE-NOTES-EL7.txt
# RELEASE-NOTES-DOCS.txt
echo "See documentation at https://github.com/${GITHUB_REPOSITORY}/blob/${GITHUB_SHA:0:8}/appimage/7/README.md" >> RELEASE-NOTES-DOCS.txt
echo "See documentation at https://github.com/${GITHUB_REPOSITORY}/blob/${GITHUB_SHA:0:8}/appimage/8/README.md" >> RELEASE-NOTES-DOCS.txt
echo "See documentation at https://github.com/${GITHUB_REPOSITORY}/blob/${GITHUB_SHA:0:8}/appimage/9/README.md" >> RELEASE-NOTES-DOCS.txt
echo "See documentation at https://github.com/${GITHUB_REPOSITORY}/blob/${GITHUB_SHA:0:8}/appimage/10/README.md" >> RELEASE-NOTES-DOCS.txt
# RELEASE-NOTES-GH.txt (this is shared for all AppImage for one tag)
echo "### commit ${git_describe}" | sed -e 's#~#\\~#g' > RELEASE-NOTES-GH.txt
if [[ "$GITHUB_REF" =~ ^refs/tags/ ]]
then
# show tag annotation with tags like before
git tag --cleanup=strip "--format=%(contents)" -n "${GITHUB_REF:10}" | sed -e 's#\([~|]\)#\\\1#g' >> RELEASE-NOTES-GH.txt
fi
echo "" >> RELEASE-NOTES-GH.txt
cat RELEASE-NOTES-DOCS.txt >> RELEASE-NOTES-GH.txt
cat RELEASE-NOTES-CL.txt >> RELEASE-NOTES-GH.txt
# Show in action/artifact output
echo "## RELEASE NOTES" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
cat RELEASE-NOTES-EL7.txt >> $GITHUB_STEP_SUMMARY
- name: Upload Release Asset
if: ${{ env.MY_GITHUB_TAG != '' }} # if: ${{ github.ref_type == 'tag' }}
uses: softprops/action-gh-release@v2
with:
body_path: ${{ github.workspace }}/appimage/7/RELEASE-NOTES-GH.txt
files: |
${{ github.workspace }}/appimage/7/${{env.MAGIC_APPIMAGE_OUTPUT_FILENAME}}
${{ github.workspace }}/appimage/7/RELEASE-NOTES-EL7.txt
- name: Upload Artifact
#if: ${{ env.MY_GITHUB_TAG == '' }} # commented out to always upload
uses: actions/upload-artifact@v4
with:
name: ${{env.MAGIC_APPIMAGE_OUTPUT_FILENAME}}
path: |
${{ github.workspace }}/appimage/7/${{env.MAGIC_APPIMAGE_OUTPUT_FILENAME}}

170
.github/workflows/appimage8.yml vendored Normal file
View File

@ -0,0 +1,170 @@
on:
push:
tags:
- "*"
workflow_dispatch:
name: CI-appimage8
env:
APPIMAGETOOL_DOWNLOAD_URL: https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage
jobs:
build_appimage8:
name: Build AppImage EL8
runs-on: ubuntu-latest
permissions:
contents: write # action-gh-release
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 149 # enough to cover between tags
#fetch-tags: true # this should work see actions/checkout~issue#1471
- name: Get the version
id: get_version
run: |
git show -s
version=$(cat VERSION) # 8.9.999
version_tstamp=$(git show -s "--format=%cs" | tr -d '-') # YYYYMMDD
version_hash=$(git show -s "--format=%h") # abcdefg
version_num=$(ruby -e "print '$GITHUB_REF'.split('/')[2]") # legacy version method: master
echo "version=${version}"
echo "version_tstamp=${version_tstamp}"
echo "version_hash=${version_hash}"
echo "version_num=${version_num}"
VERSION_NUM="${version}~${version_tstamp}~${version_hash}"
echo "VERSION_NUM=${VERSION_NUM}" >> $GITHUB_ENV
echo "MAGIC_APPIMAGE_OUTPUT_FILENAME=Magic-${VERSION_NUM}-x86_64-EL8.AppImage" >> $GITHUB_ENV
# Is this GHA being run due to a push-on-tag ? if so we make a GitHub release, otherwise we just publish artifact
github_tag=$(echo -n "$GITHUB_REF" | sed -e 's#refs/tags/##') # 8.9.999
echo "github_tag=$github_tag"
if echo -n "$GITHUB_REF" | egrep -q "^refs/tags/" # check prefix
then
if [ -n "$github_tag" ]
then
echo "MY_GITHUB_TAG=${github_tag}" >> $GITHUB_ENV
fi
fi
- name: Build project
run: |
cd appimage/8
make
ln -v Magic-x86_64.AppImage "${MAGIC_APPIMAGE_OUTPUT_FILENAME}"
ls -l *.AppImage
sha256sum *.AppImage
pwd
- name: Create RELEASE-NOTES.txt
run: |
cd appimage/8
# Find the last tag (that does not match the current GITHUB_REF)
echo GITHUB_REF=$GITHUB_REF
echo GITHUB_SHA=$GITHUB_SHA
# GitHub CI is a shallow checkout by default (just the files needed to build)
# but we also want history back to next tag, see fetch-tags/fetch-depth actions/checkout~issue#1471
if [[ "$GITHUB_REF" =~ ^refs/tags/ ]]
then
# remove only if ref of tag (to avoid conflict during fetch)
git update-ref -d $GITHUB_REF
echo git_update_ref_exitstatus=$?
fi
set +e
git fetch --tags --prune --no-recurse-submodules --depth=149 origin +$GITHUB_SHA # fetch-tags: true # is broken
echo git_fetch_exitstatus=$?
git_show_ref=$(git show-ref --hash $GITHUB_REF) # get tagcommit hash
git_show_ref_exitstatus=$?
echo git_show_ref_exitstatus=$git_show_ref_exitstatus
echo git_show_ref=$git_show_ref
git_rev_list=$(git rev-list -n1 $GITHUB_REF) # get commit hash
git_rev_list_exitstatus=$?
echo git_rev_list_exitstatus=$git_rev_list_exitstatus
echo git_rev_list=$git_rev_list
set -e
test "$git_show_ref" = "$GITHUB_SHA" || test "$git_rev_list" = "$GITHUB_SHA" # check we got the ref back (or fail CI)
git_describe=$(git describe --tags $GITHUB_SHA | sed -e 's#\-\([0-9]\+\-g\)#\+\1#') # /-\d+-g/
echo git_describe=$git_describe
# RELEASE-NOTES-EL8.txt
echo "### ${MAGIC_APPIMAGE_OUTPUT_FILENAME} commit ${git_describe}" | sed -e 's#~#\\~#g' > RELEASE-NOTES-EL8.txt
echo "" >> RELEASE-NOTES-EL8.txt
echo "This release is based on EL8 (AlmaLinux8), the AppImage format is designed to run on a wide range of Linux distributions." >> RELEASE-NOTES-EL8.txt
echo "" >> RELEASE-NOTES-EL8.txt
echo "See documentation at https://github.com/${GITHUB_REPOSITORY}/blob/${GITHUB_SHA:0:8}/appimage/8/README.md" >> RELEASE-NOTES-EL8.txt
echo "" >> RELEASE-NOTES-EL8.txt
length_info=$(stat "--format=%s bytes" "${MAGIC_APPIMAGE_OUTPUT_FILENAME}")
sha256_info=$(sha256sum "${MAGIC_APPIMAGE_OUTPUT_FILENAME}" | cut -d ' ' -f1)
echo "| | |" >> RELEASE-NOTES-EL8.txt
echo "| :-------- | :------ |" >> RELEASE-NOTES-EL8.txt
echo "| File Name | ${MAGIC_APPIMAGE_OUTPUT_FILENAME} |" | sed -e 's#~#\\~#g' >> RELEASE-NOTES-EL8.txt
echo "| File Length | ${length_info} |" >> RELEASE-NOTES-EL8.txt
echo "| File SHA256 | ${sha256_info} |" >> RELEASE-NOTES-EL8.txt
echo "" >> RELEASE-NOTES-EL8.txt
# RELEASE-NOTES-CL.txt
set +e # allow this to fail to empty string
git_previous_tag=$(git describe --tags --abbrev=0 $(git rev-list --tags --skip=1 --max-count=1))
echo git_previous_tag=$git_previous_tag
set -e
if [ -n "${git_previous_tag}" ]
then
echo "### Change Log (since previous tag):" > RELEASE-NOTES-CL.txt
echo "\`\`\`" >> RELEASE-NOTES-CL.txt
git log --oneline --no-color --no-decorate "refs/tags/${git_previous_tag}..${GITHUB_REF}" >> RELEASE-NOTES-CL.txt
echo "\`\`\`" >> RELEASE-NOTES-CL.txt
else
echo "### Change Log (last commit only):" > RELEASE-NOTES-CL.txt
echo "\`\`\`" >> RELEASE-NOTES-CL.txt
git log --oneline -n1 --no-color --no-decorate "${GITHUB_REF}" >> RELEASE-NOTES-CL.txt
echo "\`\`\`" >> RELEASE-NOTES-CL.txt
fi
echo "" >> RELEASE-NOTES-CL.txt
#echo "### Build Info:" > RELEASE-NOTES-BI.txt
# FIXME extract package version info and DSO symvers into RELEASE-NOTES.txt
#echo "" >> RELEASE-NOTES-BI.txt
cat RELEASE-NOTES-CL.txt >> RELEASE-NOTES-EL8.txt
cat RELEASE-NOTES-EL8.txt
# RELEASE-NOTES-DOCS.txt
echo "See documentation at https://github.com/${GITHUB_REPOSITORY}/blob/${GITHUB_SHA:0:8}/appimage/7/README.md" >> RELEASE-NOTES-DOCS.txt
echo "See documentation at https://github.com/${GITHUB_REPOSITORY}/blob/${GITHUB_SHA:0:8}/appimage/8/README.md" >> RELEASE-NOTES-DOCS.txt
echo "See documentation at https://github.com/${GITHUB_REPOSITORY}/blob/${GITHUB_SHA:0:8}/appimage/9/README.md" >> RELEASE-NOTES-DOCS.txt
echo "See documentation at https://github.com/${GITHUB_REPOSITORY}/blob/${GITHUB_SHA:0:8}/appimage/10/README.md" >> RELEASE-NOTES-DOCS.txt
# RELEASE-NOTES-GH.txt (this is shared for all AppImage for one tag)
echo "### commit ${git_describe}" | sed -e 's#~#\\~#g' > RELEASE-NOTES-GH.txt
if [[ "$GITHUB_REF" =~ ^refs/tags/ ]]
then
# show tag annotation with tags like before
git tag --cleanup=strip "--format=%(contents)" -n "${GITHUB_REF:10}" | sed -e 's#\([~|]\)#\\\1#g' >> RELEASE-NOTES-GH.txt
fi
echo "" >> RELEASE-NOTES-GH.txt
cat RELEASE-NOTES-DOCS.txt >> RELEASE-NOTES-GH.txt
cat RELEASE-NOTES-CL.txt >> RELEASE-NOTES-GH.txt
# Show in action/artifact output
echo "## RELEASE NOTES" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
cat RELEASE-NOTES-EL8.txt >> $GITHUB_STEP_SUMMARY
- name: Upload Release Asset
if: ${{ env.MY_GITHUB_TAG != '' }} # if: ${{ github.ref_type == 'tag' }}
uses: softprops/action-gh-release@v2
with:
body_path: ${{ github.workspace }}/appimage/8/RELEASE-NOTES-GH.txt
files: |
${{ github.workspace }}/appimage/8/${{env.MAGIC_APPIMAGE_OUTPUT_FILENAME}}
${{ github.workspace }}/appimage/8/RELEASE-NOTES-EL8.txt
- name: Upload Artifact
#if: ${{ env.MY_GITHUB_TAG == '' }} # commented out to always upload
uses: actions/upload-artifact@v4
with:
name: ${{env.MAGIC_APPIMAGE_OUTPUT_FILENAME}}
path: |
${{ github.workspace }}/appimage/8/${{env.MAGIC_APPIMAGE_OUTPUT_FILENAME}}

170
.github/workflows/appimage9.yml vendored Normal file
View File

@ -0,0 +1,170 @@
on:
push:
tags:
- "*"
workflow_dispatch:
name: CI-appimage9
env:
APPIMAGETOOL_DOWNLOAD_URL: https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage
jobs:
build_appimage9:
name: Build AppImage EL9
runs-on: ubuntu-latest
permissions:
contents: write # action-gh-release
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 149 # enough to cover between tags
#fetch-tags: true # this should work see actions/checkout~issue#1471
- name: Get the version
id: get_version
run: |
git show -s
version=$(cat VERSION) # 8.9.999
version_tstamp=$(git show -s "--format=%cs" | tr -d '-') # YYYYMMDD
version_hash=$(git show -s "--format=%h") # abcdefg
version_num=$(ruby -e "print '$GITHUB_REF'.split('/')[2]") # legacy version method: master
echo "version=${version}"
echo "version_tstamp=${version_tstamp}"
echo "version_hash=${version_hash}"
echo "version_num=${version_num}"
VERSION_NUM="${version}~${version_tstamp}~${version_hash}"
echo "VERSION_NUM=${VERSION_NUM}" >> $GITHUB_ENV
echo "MAGIC_APPIMAGE_OUTPUT_FILENAME=Magic-${VERSION_NUM}-x86_64-EL9.AppImage" >> $GITHUB_ENV
# Is this GHA being run due to a push-on-tag ? if so we make a GitHub release, otherwise we just publish artifact
github_tag=$(echo -n "$GITHUB_REF" | sed -e 's#refs/tags/##') # 8.9.999
echo "github_tag=$github_tag"
if echo -n "$GITHUB_REF" | egrep -q "^refs/tags/" # check prefix
then
if [ -n "$github_tag" ]
then
echo "MY_GITHUB_TAG=${github_tag}" >> $GITHUB_ENV
fi
fi
- name: Build project
run: |
cd appimage/9
make
ln -v Magic-x86_64.AppImage "${MAGIC_APPIMAGE_OUTPUT_FILENAME}"
ls -l *.AppImage
sha256sum *.AppImage
pwd
- name: Create RELEASE-NOTES.txt
run: |
cd appimage/9
# Find the last tag (that does not match the current GITHUB_REF)
echo GITHUB_REF=$GITHUB_REF
echo GITHUB_SHA=$GITHUB_SHA
# GitHub CI is a shallow checkout by default (just the files needed to build)
# but we also want history back to next tag, see fetch-tags/fetch-depth actions/checkout~issue#1471
if [[ "$GITHUB_REF" =~ ^refs/tags/ ]]
then
# remove only if ref of tag (to avoid conflict during fetch)
git update-ref -d $GITHUB_REF
echo git_update_ref_exitstatus=$?
fi
set +e
git fetch --tags --prune --no-recurse-submodules --depth=149 origin +$GITHUB_SHA # fetch-tags: true # is broken
echo git_fetch_exitstatus=$?
git_show_ref=$(git show-ref --hash $GITHUB_REF) # get tagcommit hash
git_show_ref_exitstatus=$?
echo git_show_ref_exitstatus=$git_show_ref_exitstatus
echo git_show_ref=$git_show_ref
git_rev_list=$(git rev-list -n1 $GITHUB_REF) # get commit hash
git_rev_list_exitstatus=$?
echo git_rev_list_exitstatus=$git_rev_list_exitstatus
echo git_rev_list=$git_rev_list
set -e
test "$git_show_ref" = "$GITHUB_SHA" || test "$git_rev_list" = "$GITHUB_SHA" # check we got the ref back (or fail CI)
git_describe=$(git describe --tags $GITHUB_SHA | sed -e 's#\-\([0-9]\+\-g\)#\+\1#') # /-\d+-g/
echo git_describe=$git_describe
# RELEASE-NOTES-EL9.txt
echo "### ${MAGIC_APPIMAGE_OUTPUT_FILENAME} commit ${git_describe}" | sed -e 's#~#\\~#g' > RELEASE-NOTES-EL9.txt
echo "" >> RELEASE-NOTES-EL9.txt
echo "This release is based on EL9 (AlmaLinux9), the AppImage format is designed to run on a wide range of Linux distributions." >> RELEASE-NOTES-EL9.txt
echo "" >> RELEASE-NOTES-EL9.txt
echo "See documentation at https://github.com/${GITHUB_REPOSITORY}/blob/${GITHUB_SHA:0:8}/appimage/9/README.md" >> RELEASE-NOTES-EL9.txt
echo "" >> RELEASE-NOTES-EL9.txt
length_info=$(stat "--format=%s bytes" "${MAGIC_APPIMAGE_OUTPUT_FILENAME}")
sha256_info=$(sha256sum "${MAGIC_APPIMAGE_OUTPUT_FILENAME}" | cut -d ' ' -f1)
echo "| | |" >> RELEASE-NOTES-EL9.txt
echo "| :-------- | :------ |" >> RELEASE-NOTES-EL9.txt
echo "| File Name | ${MAGIC_APPIMAGE_OUTPUT_FILENAME} |" | sed -e 's#~#\\~#g' >> RELEASE-NOTES-EL9.txt
echo "| File Length | ${length_info} |" >> RELEASE-NOTES-EL9.txt
echo "| File SHA256 | ${sha256_info} |" >> RELEASE-NOTES-EL9.txt
echo "" >> RELEASE-NOTES-EL9.txt
# RELEASE-NOTES-CL.txt
set +e # allow this to fail to empty string
git_previous_tag=$(git describe --tags --abbrev=0 $(git rev-list --tags --skip=1 --max-count=1))
echo git_previous_tag=$git_previous_tag
set -e
if [ -n "${git_previous_tag}" ]
then
echo "### Change Log (since previous tag):" > RELEASE-NOTES-CL.txt
echo "\`\`\`" >> RELEASE-NOTES-CL.txt
git log --oneline --no-color --no-decorate "refs/tags/${git_previous_tag}..${GITHUB_REF}" >> RELEASE-NOTES-CL.txt
echo "\`\`\`" >> RELEASE-NOTES-CL.txt
else
echo "### Change Log (last commit only):" > RELEASE-NOTES-CL.txt
echo "\`\`\`" >> RELEASE-NOTES-CL.txt
git log --oneline -n1 --no-color --no-decorate "${GITHUB_REF}" >> RELEASE-NOTES-CL.txt
echo "\`\`\`" >> RELEASE-NOTES-CL.txt
fi
echo "" >> RELEASE-NOTES-CL.txt
#echo "### Build Info:" > RELEASE-NOTES-BI.txt
# FIXME extract package version info and DSO symvers into RELEASE-NOTES.txt
#echo "" >> RELEASE-NOTES-BI.txt
cat RELEASE-NOTES-CL.txt >> RELEASE-NOTES-EL9.txt
cat RELEASE-NOTES-EL9.txt
# RELEASE-NOTES-DOCS.txt
echo "See documentation at https://github.com/${GITHUB_REPOSITORY}/blob/${GITHUB_SHA:0:8}/appimage/7/README.md" >> RELEASE-NOTES-DOCS.txt
echo "See documentation at https://github.com/${GITHUB_REPOSITORY}/blob/${GITHUB_SHA:0:8}/appimage/8/README.md" >> RELEASE-NOTES-DOCS.txt
echo "See documentation at https://github.com/${GITHUB_REPOSITORY}/blob/${GITHUB_SHA:0:8}/appimage/9/README.md" >> RELEASE-NOTES-DOCS.txt
echo "See documentation at https://github.com/${GITHUB_REPOSITORY}/blob/${GITHUB_SHA:0:8}/appimage/10/README.md" >> RELEASE-NOTES-DOCS.txt
# RELEASE-NOTES-GH.txt (this is shared for all AppImage for one tag)
echo "### commit ${git_describe}" | sed -e 's#~#\\~#g' > RELEASE-NOTES-GH.txt
if [[ "$GITHUB_REF" =~ ^refs/tags/ ]]
then
# show tag annotation with tags like before
git tag --cleanup=strip "--format=%(contents)" -n "${GITHUB_REF:10}" | sed -e 's#\([~|]\)#\\\1#g' >> RELEASE-NOTES-GH.txt
fi
echo "" >> RELEASE-NOTES-GH.txt
cat RELEASE-NOTES-DOCS.txt >> RELEASE-NOTES-GH.txt
cat RELEASE-NOTES-CL.txt >> RELEASE-NOTES-GH.txt
# Show in action/artifact output
echo "## RELEASE NOTES" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
cat RELEASE-NOTES-EL9.txt >> $GITHUB_STEP_SUMMARY
- name: Upload Release Asset
if: ${{ env.MY_GITHUB_TAG != '' }} # if: ${{ github.ref_type == 'tag' }}
uses: softprops/action-gh-release@v2
with:
body_path: ${{ github.workspace }}/appimage/9/RELEASE-NOTES-GH.txt
files: |
${{ github.workspace }}/appimage/9/${{env.MAGIC_APPIMAGE_OUTPUT_FILENAME}}
${{ github.workspace }}/appimage/9/RELEASE-NOTES-EL9.txt
- name: Upload Artifact
#if: ${{ env.MY_GITHUB_TAG == '' }} # commented out to always upload
uses: actions/upload-artifact@v4
with:
name: ${{env.MAGIC_APPIMAGE_OUTPUT_FILENAME}}
path: |
${{ github.workspace }}/appimage/9/${{env.MAGIC_APPIMAGE_OUTPUT_FILENAME}}

289
.github/workflows/canary-matrix.yml vendored Normal file
View File

@ -0,0 +1,289 @@
name: CI-canary-matrix
on:
push:
tags:
- "*"
workflow_dispatch:
jobs:
canary:
strategy:
max-parallel: 3
matrix:
os: [ubuntu-24.04, ubuntu-22.04]
# Configure Options
# X11 OGL CAIRO
pkgs: [all, none, no_tk_tcl_rl, no_tk_tcl_brl, no_zlib, no_gc_gl_gu, no_gc, no_gl_gu]
# Toolchain
# ubuntu-20.04 [gcc-9, clang-10]
# ubuntu-22.04 [gcc-11, clang-14]
# ubuntu-24.04 [gcc-13, clang-18]
tc: [default, gcc-10, gcc-11, gcc-12, gcc-13, gcc-14, clang-14, clang-15, clang-17, clang-18, clang-19]
exclude:
- os: ubuntu-22.04
tc: gcc-13
- os: ubuntu-22.04
tc: gcc-14
- os: ubuntu-22.04
tc: clang-17
- os: ubuntu-22.04 # some sources show this as present but not found
tc: clang-18
- os: ubuntu-22.04
tc: clang-19
- os: ubuntu-24.04
tc: gcc-10
- os: ubuntu-24.04
tc: gcc-11
- os: ubuntu-24.04
tc: clang-14
- os: ubuntu-24.04
tc: clang-15
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Matrix Check
env:
MATRIX_OS: ${{ matrix.os }}
MATRIX_PKGS: ${{ matrix.pkgs }}
MATRIX_TC: ${{ matrix.tc }}
run: |
# This takes the macros params ENV and processes into options list
if [ "${MATRIX_PKGS}" = "none" ]
then
pkgs=""
cfgs=""
else
pkgs="kcnrzCLUX"
cfgs=""
fi
# z no.*_zl zlib1g-dev
# n no.*_nc libncurses-dev
# r no.*_rl libreadline-dev
# R no.*_brl --enable-readline-bundled
# c no.*_tcl tcl-dev
# k no.*_tk tk-dev
# C no.*_gc libcairo-dev
# L no.*_gl libgl-dev
# U no.*_gu libglu1-mesa-dev # GLU requires GL
# X no.*_gx libx11-dev
if echo -n "$MATRIX_PKGS" | grep -q "^no.*_zl"; then
pkgs=$(echo -n "$pkgs" | sed -e 's#z##'); fi
if echo -n "$MATRIX_PKGS" | grep -q "^no.*_nc"; then
pkgs=$(echo -n "$pkgs" | sed -e 's#n##'); fi
if echo -n "$MATRIX_PKGS" | grep -q "^no.*_brl"; then
pkgs=$(echo -n "$pkgs" | sed -e 's#r#R#'); fi # replace
if echo -n "$MATRIX_PKGS" | grep -q "^no.*_rl"; then
pkgs=$(echo -n "$pkgs" | sed -e 's#r##'); fi
if echo -n "$MATRIX_PKGS" | grep -q "^no.*_tcl"; then
pkgs=$(echo -n "$pkgs" | sed -e 's#c##'); fi
if echo -n "$MATRIX_PKGS" | grep -q "^no.*_tk"; then
pkgs=$(echo -n "$pkgs" | sed -e 's#k##'); fi
if echo -n "$MATRIX_PKGS" | grep -q "^no.*_gc"; then
pkgs=$(echo -n "$pkgs" | sed -e 's#C##'); fi
if echo -n "$MATRIX_PKGS" | grep -q "^no.*_gl"; then
pkgs=$(echo -n "$pkgs" | sed -e 's#L##'); fi
if echo -n "$MATRIX_PKGS" | grep -q "^no.*_gu"; then
pkgs=$(echo -n "$pkgs" | sed -e 's#U##'); fi
if echo -n "$MATRIX_PKGS" | grep -q "^no.*_gx"; then
pkgs=$(echo -n "$pkgs" | sed -e 's#X##'); fi
_package_list=()
echo -n $pkgs | grep -q "z" && _package_list+=(zlib1g-dev)
echo -n $pkgs | grep -q "n" && _package_list+=(libncurses-dev)
echo -n $pkgs | grep -q "r" && _package_list+=(libreadline-dev)
echo -n $pkgs | grep -q "c" && _package_list+=(tcl-dev)
echo -n $pkgs | grep -q "k" && _package_list+=(tk-dev)
echo -n $pkgs | grep -q "C" && _package_list+=(libcairo-dev)
echo -n $pkgs | grep -q "L" && _package_list+=(libgl-dev)
echo -n $pkgs | grep -q "U" && _package_list+=(libglu1-mesa-dev)
echo -n $pkgs | grep -q "X" && _package_list+=(libx11-dev)
echo "PACKAGE_LIST=${_package_list[*]}" >> $GITHUB_ENV
#
_configure_args=()
if echo -n "$MATRIX_PKGS" | grep -q "^no.*_zl"; then
_configure_args+=(--disable-compression); fi
if echo -n "$MATRIX_PKGS" | grep -q "^no.*_brl"; then
_configure_args+=(--enable-readline-bundled); fi
if echo -n "$MATRIX_PKGS" | grep -q "^no.*_rl"; then
_configure_args+=(--disable-readline); fi
if echo -n "$MATRIX_PKGS" | grep -q "^no.*_tcl"; then
_configure_args+=(--without-tcl); fi
if echo -n "$MATRIX_PKGS" | grep -q "^no.*_tk"; then
_configure_args+=(--without-tk); fi
if echo -n "$MATRIX_PKGS" | grep -q "^no.*_gc"; then
_configure_args+=(--without-cairo); fi
if echo -n "$MATRIX_PKGS" | grep -q "^no.*_gl"; then
_configure_args+=(--without-opengl); fi
echo "CONFIGURE_ARGS=${_configure_args[*]}" >> $GITHUB_ENV
- name: Setup Toolchain
env:
MATRIX_TC: ${{ matrix.tc }}
run: |
# decode settings
BUILD_GCC_VERSION=$( echo -n "$MATRIX_TC" | grep -i "^gcc" | sed -e 's#^gcc\-\?##i')
BUILD_CLANG_VERSION=$(echo -n "$MATRIX_TC" | grep -i "^clang" | sed -e 's#^clang\-\?##i')
echo "BUILD_GCC_VERSION=$BUILD_GCC_VERSION" >> $GITHUB_ENV
echo "BUILD_CLANG_VERSION=$BUILD_CLANG_VERSION" >> $GITHUB_ENV
if [ -n "$BUILD_GCC_VERSION" ]
then
GCCV=$BUILD_GCC_VERSION
# https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2404-Readme.md
sudo apt-get install gcc-${GCCV} g++-${GCCV} cpp-${GCCV}
gcc-${GCCV} -v
g++-${GCCV} -v
cpp-${GCCV} -v < /dev/null
ls -l /usr/bin/g++ /usr/bin/g++-[0-9]* /usr/bin/gcc /usr/bin/gcc-[0-9]* /usr/bin/cpp-* /usr/bin/*-gnu-cpp* || true
update-alternatives --list gcc || true
update-alternatives --list g++ || true
update-alternatives --list cpp || true
update-alternatives --query gcc || true
update-alternatives --query g++ || true
update-alternatives --query cpp || true
ls -l /usr/bin/g++ /usr/bin/g++-[0-9]* /usr/bin/gcc /usr/bin/gcc-[0-9]* /usr/bin/cpp-* /usr/bin/*-gnu-cpp* || true
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${GCCV} 50
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-${GCCV} 50
sudo update-alternatives --install "/usr/bin/$(uname -m)-linux-gnu-cpp" cpp "/usr/bin/$(uname -m)-linux-gnu-cpp-${GCCV}" 50
ls -l /usr/bin/g++ /usr/bin/g++-[0-9]* /usr/bin/gcc /usr/bin/gcc-[0-9]* /usr/bin/cpp-* /usr/bin/*-gnu-cpp* || true
update-alternatives --list gcc || true
update-alternatives --list g++ || true
update-alternatives --list cpp || true
hash -r
gcc -v
elif [ -n "$BUILD_CLANG_VERSION" ]
then
CLANGV=$BUILD_CLANG_VERSION
# https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2404-Readme.md
sudo apt-get install clang-${CLANGV} clang++-${CLANGV} #clang-cpp-${CLANGV}
clang-${CLANGV} -v
clang++-${CLANGV} -v
clang-cpp-${CLANGV} -v < /dev/null
ls -l /usr/bin/clang++ /usr/bin/clang++-[0-9]* /usr/bin/clang /usr/bin/clang-[0-9]* /usr/bin/clang-cpp-* /usr/bin/clang-cpp* || true
update-alternatives --list clang || true
update-alternatives --list clang++ || true
update-alternatives --list clang-cpp || true
update-alternatives --query clang || true
update-alternatives --query clang++ || true
update-alternatives --query clang-cpp || true
ls -l /usr/bin/clang++ /usr/bin/clang++-[0-9]* /usr/bin/clang /usr/bin/clang-[0-9]* /usr/bin/clang-cpp-* /usr/bin/clang-cpp* || true
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-${CLANGV} 50
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-${CLANGV} 50
sudo update-alternatives --install "/usr/bin/clang-cpp" clang-cpp "/usr/bin/clang-cpp-${CLANGV}" 50
ls -l /usr/bin/clang++ /usr/bin/clang++-[0-9]* /usr/bin/clang /usr/bin/clang-[0-9]* /usr/bin/clang-cpp-* /usr/bin/clang-cpp* || true
update-alternatives --list clang || true
update-alternatives --list clang++ || true
update-alternatives --list clang-cpp || true
hash -r
clang -v
fi
- name: Get Dependencies
run: |
if [ -n "$PACKAGE_LIST" ]
then
sudo apt-get install -y ${PACKAGE_LIST}
fi
- name: Build
run: |
if [ -n "$BUILD_CLANG_VERSION" ]
then
export CC="clang-${BUILD_CLANG_VERSION}"
export CXX="clang++-${BUILD_CLANG_VERSION}"
export CPP="clang-cpp-${BUILD_CLANG_VERSION}"
fi
set -o pipefail # due to pipe inside CI
./configure $CONFIGURE_ARGS 2>&1 | tee CONFIGURE.LOG
egrep "^(CPP|CXX|CC)\s" defs.mak
# Add -Wall for CI loggings
sed -e 's# -Werror=# -Wall -Werror=#' -i defs.mak
# Non security/reliability related warnings
#sed -e 's# -Werror=# -Wno-unused-variable -Werror=#' -i defs.mak
#sed -e 's# -Werror=# -Wno-unused-local-typedefs -Werror=#' -i defs.mak
#sed -e 's# -Werror=# -Wno-unused-label -Werror=#' -i defs.mak
#sed -e 's# -Werror=# -Wno-unused-but-set-variable -Werror=#' -i defs.mak
make database/database.h
make -j$(nproc) 2>&1 | tee MAKE.LOG
- name: Summary
env:
MATRIX_OS: ${{ matrix.os }}
MATRIX_PKGS: ${{ matrix.pkgs }}
run: |
set +e
grep "error:" MAKE.LOG > MAKE_error.LOG
grep "warning:" MAKE.LOG > MAKE_warning.LOG
# Less important warnings relating to codesmell more than security (filter out of headline)
grep -v "Wunused-variable" MAKE_warning.LOG |
grep -v "Wunused-local-typedefs" |
grep -v "Wunused-label" |
grep -v "Wunused-but-set-variable" > MAKE_warning_filtered.LOG
ls -l
wc -l *.LOG
error_count=$( grep -c "error:" MAKE_error.LOG)
filtered_warning_count=$(grep -c "warning:" MAKE_warning_filtered.LOG)
title="### $(cat VERSION) ${MATRIX_OS} ${MATRIX_TC} ${MATRIX_PKGS} :: "
if [ "$error_count" -gt 0 ]
then
title="$title $error_count error(s)"
fi
if [ "$filtered_warning_count" -gt 0 ]
then
title="$title $filtered_warning_count warning(s)"
fi
(
total_error_count=$( wc -l MAKE_error.LOG | cut -d' ' -f1)
total_warning_count=$(wc -l MAKE_warning.LOG | cut -d' ' -f1)
echo "$title"
echo ""
echo "PACKAGE_LIST=$PACKAGE_LIST"
echo "CONFIGURE_ARGS=$CONFIGURE_ARGS"
echo ""
if [ "$BUILD_CLANG_VERSION" ]
then
"clang-${BUILD_CLANG_VERSION}" --version | head -n1
if ! update-alternatives --list clang
then
update-alternatives --list "clang-${BUILD_CLANG_VERSION}"
fi
else
gcc --version | head -n1
if ! update-alternatives --list gcc
then
update-alternatives --list "gcc-${BUILD_GCC_VERSION}"
fi
fi
echo ""
echo "total ${total_error_count} error(s) ${total_warning_count} warning(s) :"
echo "|Count|Warning Group (-j build log inaccuracies)|"
echo "|--:|:--|"
# due to -j build the log lines might get corrupted, so missing/incorrect/bogus entries might be seen
# so we add extra: egrep "\[\-W.*\]" (to try to remove that)
sed -e 's#.*\(\[\-W\)#\1#' -e 's#\(\]\).*$#\1#' MAKE_warning.LOG | egrep "\[\-W.*\]" | sort | uniq -c | sort -n | tr -s ' ' | tr ' ' '|' | awk '{print $0"|"}'
echo ""
sed -e '0,/Configuration Summary/d' -e '/\---/,//d' CONFIGURE.LOG | egrep "^.*:"
echo ""
grep DCAD_DIR MAKE.LOG | tail -n1
) >> $GITHUB_STEP_SUMMARY

49
.github/workflows/main-aarch64.yml vendored Normal file
View File

@ -0,0 +1,49 @@
# This is a basic workflow to help you get started with Actions
name: CI-aarch64
# Controls when the workflow will run
on:
push:
pull_request:
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
simple_build_linux_arm:
runs-on: ubuntu-24.04-arm
steps:
- uses: actions/checkout@v4
- name: Get Dependencies
run: |
sudo apt-get update
sudo apt-get install -y tcl-dev tk-dev libcairo-dev
- name: Build
run: |
./configure
make database/database.h
make -j$(nproc)
simple_build_wasm_arm:
runs-on: ubuntu-24.04-arm
steps:
- uses: actions/checkout@v4
- name: Get Dependencies
run: |
git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
./emsdk install latest
./emsdk activate latest
- name: Build
run: |
source ./emsdk/emsdk_env.sh
emconfigure ./configure --without-cairo --without-opengl --without-x --disable-readline --disable-compression --target=asmjs-unknown-emscripten
echo "===== defs.mak ====="
cat defs.mak
echo "===== defs.mak ====="
emmake make
- name: archive wasm bundle
uses: actions/upload-artifact@v4
with:
name: magic-wasm-bundle-arm
path: |
${{ github.workspace }}/magic/magic.wasm

475
.github/workflows/main-macos.yml vendored Normal file
View File

@ -0,0 +1,475 @@
# This is a basic workflow to help you get started with Actions
name: CI-macos
# Controls when the workflow will run
on:
push:
pull_request:
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
simple_build_macos15:
runs-on: macos-15-intel # only and last supported intel MacOS
timeout-minutes: 45 # x86_64 seems non-SSD based (slower)
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get Dependencies
shell: bash # default shell has unwanted broken pipe indication
run: |
brew install --cask xquartz
PACKAGE_LIST="xquartz"
brew install cairo tcl-tk@8 tcsh gnu-sed
_package_list="cairo tcl-tk@8 tcsh gnu-sed"
# These seem needed maybe they are being provided from somewhere else GHA runner
# or brew transitive depend either way doesn't hurt to confirm they are installed.
_package_list="$_package_list libglu freeglut"
if [ -n "$PACKAGE_LIST" ]
then
brew install $PACKAGE_LIST
fi
PACKAGE_LIST="$PACKAGE_LIST $_package_list"
echo "PACKAGE_LIST=$PACKAGE_LIST" >> $GITHUB_ENV
echo "UNAME_M=$(uname -m)" >> $GITHUB_ENV
set +e
set +o pipefail # macosx this is on by default (turn it off)
(
echo "### $(uname -s) $(uname -m) $(uname -r)"
echo ""
set +e
set +o pipefail # macosx this is on by default (turn it off)
export HOMEBREW_NO_COLOR=true
export HOMEBREW_NO_EMOKI=true
# output to $TMPFILE first, then head, instead of using pipeline directly
# this removes unwanted GHA SIGPIPE error/warning indicators from GHA logs
# brew maybe a nodejs command which has a known issue in this area on macosx
TMPFILE=/tmp/shell0$$.tmp
brew info xquartz > $TMPFILE && head -n1 $TMPFILE
brew info cairo > $TMPFILE && head -n1 $TMPFILE
brew info libglu > $TMPFILE && head -n1 $TMPFILE
brew info freeglut > $TMPFILE && head -n1 $TMPFILE
brew info tcl-tk > $TMPFILE && head -n1 $TMPFILE
brew info tcl-tk@8 > $TMPFILE && head -n1 $TMPFILE
brew info tcsh > $TMPFILE && head -n1 $TMPFILE
brew info gnu-sed > $TMPFILE && head -n1 $TMPFILE
echo ""
cc -v 2>&1
echo ""
xcodebuild -version
echo ""
xcodebuild -showsdks | grep macOS
) >> $GITHUB_STEP_SUMMARY
- name: Search
run: |
set +e
( # designed to speed up this process in a single scan
echo "#!/bin/sh"
echo "echo \$*"
echo "ls -ld -- \$*"
echo "shasum -a 1 \$* </dev/null"
echo "echo \"\""
echo "exit 0"
) > search.sh
echo "=== search.sh"
cat search.sh
chmod a+x search.sh
find /opt /usr $HOME \( -iname "libX11.*dylib" -or -iname "Xlib.h" -or -iname "libtcl*dylib" -or -iname "tcl.h" \) -exec ./search.sh {} \; 2>/dev/null
#
# Example symbols that were found missing from the tcl-tk X11 implementation
#find /opt /usr $HOME -iname "x*.h" -exec grep -Hn "XCreateGC" {} \; 2>/dev/null || true
#find /opt /usr $HOME -iname "x*.h" -exec grep -Hn "XGetVisualInfo" {} \; 2>/dev/null || true
#for i in /usr/X11/include/X11/Xlib.h /opt/X11/include/X11/Xlib.h /usr/local/include/X11/Xlib.h;
#do
# echo "====== $i"
# head -n 50 "$i"
# echo "==="
# tail -n 50 "$i"
# echo "======"
#done
# Different GHA platforms have different layouts (x86_64/arm64)
echo "=== /opt"
ls -l /opt
if [ -d /opt/homebrew ]
then
echo "=== /opt/homebrew"
ls -l /opt/homebrew
fi
echo "=== /usr/local/opt"
ls -l /usr/local/opt
echo "=== /usr/local/opt/runner"
ls -l /usr/local/opt/runner
echo "Done"
- name: Build
run: |
export PATH="/opt/X11/bin:$PATH"
./scripts/configure_mac 2>&1 | tee CONFIGURE.LOG
config_log=""
if [ -f scripts/config.log ]
then
config_log="scripts/config.log"
elif [ -f build-magic/config.log ]
then
config_log="build-magic/config.log"
fi
if [ -n "$config_log" ]
then
CONFIGURE_ARGS=$(head -n 10 $config_log | egrep "./configure" | sed -e 's#^ *\$ ##' -e 's#./configure ##')
echo "CONFIGURE_ARGS=$CONFIGURE_ARGS" >> $GITHUB_ENV
fi
echo "===== defs.mak ====="
cat defs.mak
echo "===== defs.mak ====="
make database/database.h
make -j$(sysctl -n hw.ncpu) 2>&1 | tee MAKE.LOG
- name: Install
run: |
sudo make install
- name: Kick The Tyres
run: |
set +e
echo "=== ls -l"
ls -l
find . -type f \( -name "*.dylib" -or -name "magic" -or -name "magicexec" -or -name "magicdnull" \)
echo "=== find /usr/local/bin"
find /usr/local/bin -mtime 0
echo "=== find /usr/local/share"
find /usr/local/share -mtime 0
echo "=== find /usr/local/lib/magic"
find /usr/local/lib/magic -mtime 0
echo "=== otool -L magic/tclmagic.dylib"
otool -L magic/tclmagic.dylib
echo "=== otool -L tcltk/magicexec"
otool -L tcltk/magicexec
echo "=== otool -L tcltk/magicdnull"
otool -L tcltk/magicdnull
set +o pipefail # macosx this is on by default (turn it off)
echo "=== magic --version"
magic --version
echo "=== magic -d help -noconsole"
magic -d help -noconsole
echo "=== magic -d null -noconsole -nowindow -T scmos"
echo "version ; quit" | magic -d null -noconsole -nowindow -T scmos
echo "=== magic -d null -noconsole -T scmos"
echo "version ; quit" | magic -d null -noconsole -T scmos
- name: Summary
if: always()
run: |
set +e
ls -l
touch MAKE.LOG # just in case it did not even build
grep "error:" MAKE.LOG > MAKE_error.LOG
grep "warning:" MAKE.LOG > MAKE_warning.LOG
# Less important warnings relating to codesmell more than security (filter out of headline)
grep -v "Wunused-variable" MAKE_warning.LOG |
grep -v "Wunused-local-typedefs" |
grep -v "Wunused-label" |
grep -v "Wunused-but-set-variable" > MAKE_warning_filtered.LOG
wc -l *.LOG
error_count=$( grep -c "error:" MAKE_error.LOG)
filtered_warning_count=$(grep -c "warning:" MAKE_warning_filtered.LOG)
title="### $(cat VERSION) ${MATRIX_OS} ${MATRIX_TC} ${MATRIX_PKGS} :: "
if [ "$error_count" -gt 0 ]
then
title="$title $error_count error(s)"
fi
if [ "$filtered_warning_count" -gt 0 ]
then
title="$title $filtered_warning_count warning(s)"
fi
(
total_error_count=$( wc -l MAKE_error.LOG | cut -d' ' -f1)
total_warning_count=$(wc -l MAKE_warning.LOG | cut -d' ' -f1)
echo "---"
echo "$title"
echo ""
[ -f scripts/config.log ] && grep "./configure" scripts/config.log | head -n1
echo ""
echo "PACKAGE_LIST=$PACKAGE_LIST"
echo "CONFIGURE_ARGS=$CONFIGURE_ARGS"
echo ""
if [ -s MAKE.LOG ]
then
echo "total ${total_error_count} error(s) ${total_warning_count} warning(s) :"
echo "|Count|Warning Group (-j build log inaccuracies)|"
echo "|--:|:--|"
# due to -j build the log lines might get corrupted, so missing/incorrect/bogus entries might be seen
# so we add extra: egrep "\[\-W.*\]" (to try to remove that)
sed -e 's#.*\(\[\-W\)#\1#' -e 's#\(\]\).*$#\1#' MAKE_warning.LOG | egrep "\[\-W.*\]" | sort | uniq -c | sort -n | tr -s ' ' | tr ' ' '|' | awk '{print $0"|"}'
echo ""
fi
grep -A100 "Configuration Summary" CONFIGURE.LOG | grep -v "Configuration Summary" | egrep "^.*:" | sed -e '/\---/,//d'
echo ""
grep DCAD_DIR MAKE.LOG | tail -n1
) >> $GITHUB_STEP_SUMMARY
- name: Prepare archive
run: |
mkdir -p dist
make install "DESTDIR=$(pwd)/dist"
# Diagnostic details about this build
mkdir -p dist/BUILD-INFO
set +e
cp */config.log dist/BUILD-INFO/
cp *.mak dist/BUILD-INFO/
cp *.LOG dist/BUILD-INFO/
- name: Upload archive magic-macos15
uses: actions/upload-artifact@v4
with:
name: magic-macos15
path: |
${{ github.workspace }}/dist
simple_build_macos:
runs-on: macos-latest
timeout-minutes: 30 # arm64 seems SSD based (faster)
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get Dependencies
shell: bash # default shell has unwanted broken pipe indication
run: |
brew install --cask xquartz
PACKAGE_LIST="xquartz"
brew install cairo tcl-tk@8 tcsh gnu-sed
_package_list="cairo tcl-tk@8 tcsh gnu-sed"
# These seem needed maybe they are being provided from somewhere else GHA runner
# or brew transitive depend either way doesn't hurt to confirm they are installed.
_package_list="$_package_list libglu freeglut"
if [ -n "$PACKAGE_LIST" ]
then
brew install $PACKAGE_LIST
fi
PACKAGE_LIST="$PACKAGE_LIST $_package_list"
echo "PACKAGE_LIST=$PACKAGE_LIST" >> $GITHUB_ENV
echo "UNAME_M=$(uname -m)" >> $GITHUB_ENV
set +e
set +o pipefail # macosx this is on by default (turn it off)
(
echo "### $(uname -s) $(uname -m) $(uname -r)"
echo ""
set +e
set +o pipefail # macosx this is on by default (turn it off)
export HOMEBREW_NO_COLOR=true
export HOMEBREW_NO_EMOKI=true
# output to $TMPFILE first, then head, instead of using pipeline directly
# this removes unwanted GHA SIGPIPE error/warning indicators from GHA logs
# brew maybe a nodejs command which has a known issue in this area on macosx
TMPFILE=/tmp/shell0$$.tmp
brew info xquartz > $TMPFILE && head -n1 $TMPFILE
brew info cairo > $TMPFILE && head -n1 $TMPFILE
brew info libglu > $TMPFILE && head -n1 $TMPFILE
brew info freeglut > $TMPFILE && head -n1 $TMPFILE
brew info tcl-tk > $TMPFILE && head -n1 $TMPFILE
brew info tcl-tk@8 > $TMPFILE && head -n1 $TMPFILE
brew info tcsh > $TMPFILE && head -n1 $TMPFILE
brew info gnu-sed > $TMPFILE && head -n1 $TMPFILE
echo ""
cc -v 2>&1
echo ""
xcodebuild -version
echo ""
xcodebuild -showsdks | grep macOS
) >> $GITHUB_STEP_SUMMARY
- name: Search
run: |
set +e
( # designed to speed up this process in a single scan
echo "#!/bin/sh"
echo "echo \$*"
echo "ls -ld -- \$*"
echo "shasum -a 1 \$* </dev/null"
echo "echo \"\""
echo "exit 0"
) > search.sh
echo "=== search.sh"
cat search.sh
chmod a+x search.sh
find /opt /usr $HOME \( -iname "libX11.*dylib" -or -iname "Xlib.h" -or -iname "libtcl*dylib" -or -iname "tcl.h" \) -exec ./search.sh {} \; 2>/dev/null
#
# Example symbols that were found missing from the tcl-tk X11 implementation
#find /opt /usr $HOME -iname "x*.h" -exec grep -Hn "XCreateGC" {} \; 2>/dev/null || true
#find /opt /usr $HOME -iname "x*.h" -exec grep -Hn "XGetVisualInfo" {} \; 2>/dev/null || true
#for i in /usr/X11/include/X11/Xlib.h /opt/X11/include/X11/Xlib.h /usr/local/include/X11/Xlib.h;
#do
# echo "====== $i"
# head -n 50 "$i"
# echo "==="
# tail -n 50 "$i"
# echo "======"
#done
# Different GHA platforms have different layouts (x86_64/arm64)
echo "=== /opt"
ls -l /opt
if [ -d /opt/homebrew ]
then
echo "=== /opt/homebrew"
ls -l /opt/homebrew
fi
echo "=== /usr/local/opt"
ls -l /usr/local/opt
echo "=== /usr/local/opt/runner"
ls -l /usr/local/opt/runner
echo "Done"
- name: Build
run: |
export PATH="/opt/X11/bin:$PATH"
./scripts/configure_mac 2>&1 | tee CONFIGURE.LOG
config_log=""
if [ -f scripts/config.log ]
then
config_log="scripts/config.log"
elif [ -f build-magic/config.log ]
then
config_log="build-magic/config.log"
fi
if [ -n "$config_log" ]
then
CONFIGURE_ARGS=$(head -n 10 $config_log | egrep "./configure" | sed -e 's#^ *\$ ##' -e 's#./configure ##')
echo "CONFIGURE_ARGS=$CONFIGURE_ARGS" >> $GITHUB_ENV
fi
echo "===== defs.mak ====="
cat defs.mak
echo "===== defs.mak ====="
make database/database.h
make -j$(sysctl -n hw.ncpu) 2>&1 | tee MAKE.LOG
- name: Install
run: |
sudo make install
- name: Kick The Tyres
run: |
set +e
echo "=== ls -l"
ls -l
find . -type f \( -name "*.dylib" -or -name "magic" -or -name "magicexec" -or -name "magicdnull" \)
echo "=== find /usr/local/bin"
find /usr/local/bin -mtime 0
echo "=== find /usr/local/share"
find /usr/local/share -mtime 0
echo "=== find /usr/local/lib/magic"
find /usr/local/lib/magic -mtime 0
echo "=== otool -L magic/tclmagic.dylib"
otool -L magic/tclmagic.dylib
echo "=== otool -L tcltk/magicexec"
otool -L tcltk/magicexec
echo "=== otool -L tcltk/magicdnull"
otool -L tcltk/magicdnull
set +o pipefail # macosx this is on by default (turn it off)
echo "=== magic --version"
magic --version
echo "=== magic -d help -noconsole"
magic -d help -noconsole
echo "=== magic -d null -noconsole -nowindow -T scmos"
echo "version ; quit" | magic -d null -noconsole -nowindow -T scmos
echo "=== magic -d null -noconsole -T scmos"
echo "version ; quit" | magic -d null -noconsole -T scmos
- name: Summary
if: always()
run: |
set +e
ls -l
touch MAKE.LOG # just in case it did not even build
grep "error:" MAKE.LOG > MAKE_error.LOG
grep "warning:" MAKE.LOG > MAKE_warning.LOG
# Less important warnings relating to codesmell more than security (filter out of headline)
grep -v "Wunused-variable" MAKE_warning.LOG |
grep -v "Wunused-local-typedefs" |
grep -v "Wunused-label" |
grep -v "Wunused-but-set-variable" > MAKE_warning_filtered.LOG
wc -l *.LOG
error_count=$( grep -c "error:" MAKE_error.LOG)
filtered_warning_count=$(grep -c "warning:" MAKE_warning_filtered.LOG)
title="### $(cat VERSION) ${MATRIX_OS} ${MATRIX_TC} ${MATRIX_PKGS} :: "
if [ "$error_count" -gt 0 ]
then
title="$title $error_count error(s)"
fi
if [ "$filtered_warning_count" -gt 0 ]
then
title="$title $filtered_warning_count warning(s)"
fi
(
total_error_count=$( wc -l MAKE_error.LOG | cut -d' ' -f1)
total_warning_count=$(wc -l MAKE_warning.LOG | cut -d' ' -f1)
echo "---"
echo "$title"
echo ""
[ -f scripts/config.log ] && grep "./configure" scripts/config.log | head -n1
echo ""
echo "PACKAGE_LIST=$PACKAGE_LIST"
echo "CONFIGURE_ARGS=$CONFIGURE_ARGS"
echo ""
if [ -s MAKE.LOG ]
then
echo "total ${total_error_count} error(s) ${total_warning_count} warning(s) :"
echo "|Count|Warning Group (-j build log inaccuracies)|"
echo "|--:|:--|"
# due to -j build the log lines might get corrupted, so missing/incorrect/bogus entries might be seen
# so we add extra: egrep "\[\-W.*\]" (to try to remove that)
sed -e 's#.*\(\[\-W\)#\1#' -e 's#\(\]\).*$#\1#' MAKE_warning.LOG | egrep "\[\-W.*\]" | sort | uniq -c | sort -n | tr -s ' ' | tr ' ' '|' | awk '{print $0"|"}'
echo ""
fi
grep -A100 "Configuration Summary" CONFIGURE.LOG | grep -v "Configuration Summary" | egrep "^.*:" | sed -e '/\---/,//d'
echo ""
grep DCAD_DIR MAKE.LOG | tail -n1
) >> $GITHUB_STEP_SUMMARY
- name: Prepare archive
run: |
mkdir -p dist
make install "DESTDIR=$(pwd)/dist"
# Diagnostic details about this build
mkdir -p dist/BUILD-INFO
set +e
cp */config.log dist/BUILD-INFO/
cp *.mak dist/BUILD-INFO/
cp *.LOG dist/BUILD-INFO/
- name: Upload archive magic-macos
uses: actions/upload-artifact@v4
with:
name: magic-macos
path: |
${{ github.workspace }}/dist

61
.github/workflows/main.yml vendored Normal file
View File

@ -0,0 +1,61 @@
# This is a basic workflow to help you get started with Actions
name: CI
# Controls when the workflow will run
on:
push:
pull_request:
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
vezzal:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Pulling the docker image
run: docker pull vezzal/vezzal:v1
- name: Start the container with the docker image
run: docker run -id --name test_magic vezzal/vezzal:v1 bash | exit
- name: Run the testing on the container and send the mail
run: docker exec test_magic /vezzal/test_magic.sh "lankasaicharan123@gmail.com,tim@opencircuitdesign.com" ${{secrets.MAILING_KEY}}
simple_build_linux:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Get Dependencies
run: |
sudo apt-get install -y tcl-dev tk-dev libcairo-dev
- name: Build
run: |
./configure
make database/database.h
make -j$(nproc)
simple_build_wasm:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Get Dependencies
run: |
git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
./emsdk install latest
./emsdk activate latest
- name: Build
run: |
source ./emsdk/emsdk_env.sh
emconfigure ./configure --without-cairo --without-opengl --without-x --disable-readline --disable-compression --target=asmjs-unknown-emscripten
echo "===== defs.mak ====="
cat defs.mak
echo "===== defs.mak ====="
emmake make
- name: archive wasm bundle
uses: actions/upload-artifact@v4
with:
name: magic-wasm-bundle
path: |
${{ github.workspace }}/magic/magic.wasm

26
.gitignore vendored
View File

@ -1,5 +1,5 @@
defs.mak
Depend
*/Depend
config.cache
config.log
scripts/config.log
@ -10,5 +10,25 @@ scripts/defs.mak
*.so
*~
scmos/cif_template/objs/*
UPDATE_ME
VERSION
database/database.h
install.log
magic/proto.magicrc
make.log
scmos/gdsquery.tech
scmos/minimum.tech
scmos/scmos-sub.tech
scmos/scmos-tm.tech
scmos/scmos.tech
scmos/scmosWR.tech
scmos/nmos.tech
tcltk/magic.sh
tcltk/magic.tcl
tcltk/magicdnull
tcltk/magicexec
tcltk/ext2spice.sh
tcltk/ext2sim.sh
magic/tclmagic.dylib
tcltk/magicdnull.dSYM/
tcltk/magicexec.dSYM/
reconfigure.sh
pfx/

View File

@ -7,6 +7,8 @@ Autoconf Capsule Summary:
make
make install
Note: Remember to use 'gmake' on FreeBSD.
Autoconf options (use "./configure --help" for a complete list):
--prefix=DIR Indicates the install directory. Determines the
@ -45,6 +47,12 @@ Autoconf Capsule Summary:
Disable threaded X11 and OpenGL graphics.
Normally enabled.
--disable-compression
Disable reading and writing of compressed
(gzipped) GDS files and reading of compressed
.mag files. Normally enabled, if the zlib
development package is installed.
Notes to Magic maintainers:
--------------------------

79
INSTALL_MacOS.md Normal file
View File

@ -0,0 +1,79 @@
# Installing Magic on macOS (Tested on Big Sur)
## With Brew
Get [Homebrew](https://brew.sh).
```sh
brew install cairo tcl-tk@8 python3 gnu-sed
brew install --cask xquartz
./scripts/configure_mac
# If you have both TCL8 and TCL9 installed you may need to verify which was selected.
make database/database.h
make -j$(sysctl -n hw.ncpu)
make install # may need sudo depending on your setup
```
## Without Brew
Get [XQuartz](https://github.com/XQuartz/XQuartz)
### Build Tcl for X11
We are following the instructions from xschem (https://github.com/StefanSchippers/xschem/blob/master/README_MacOS.md).
* Download Tcl from https://prdownloads.sourceforge.net/tcl/tcl8.6.10-src.tar.gz
We are using not `opt` but `opt2` so that this Tcl does not interfere with `tcl-tk` from HomeBrew.
Extract the Tcl sources and then go to the unix folder and execute the following commands::
```
./configure --prefix=/usr/local/opt2/tcl-tk
make
make install
```
### Build Tk for X11
* Download Tk from https://prdownloads.sourceforge.net/tcl/tk8.6.10-src.tar.gz
Extract Tk source and then go to the unix folder:
NOTE: before running 'make' inspect the Makefile and ensure the LIB_RUNTIME_DIR is set as follows. Make the correction if not:
```
LIB_RUNTIME_DIR = $(libdir)
```
```
./configure --prefix=/usr/local/opt2/tcl-tk \
--with-tcl=/usr/local/opt2/tcl-tk/lib --with-x \
--x-includes=/opt/X11/include --x-libraries=/opt/X11/lib
make
make install
```
### Build magic
We need to provide this `tcl-tk` and suppress compilation errors.
```
./configure --with-tcl=/usr/local/opt2/tcl-tk/lib \
--with-tk=/usr/local/opt2/tcl-tk/lib \
--x-includes=/opt/X11/include \
--x-libraries=/opt/X11/lib \
CFLAGS=-Wno-error=implicit-function-declaration
make
make install
```
## If facing issue with layout window not opening / XQuartz:
Make sure that the output of the following command is ```:0```.
```
echo $DISPLAY
```
if the above command doesn't display ```:0``` then add the following line in ```.zshrc```.
```
export PATH="/opt/X11/bin:$PATH"
```
Close & reopen terminal to load the path. Then set display manually to ```0``` by using the following command.
```
export DISPLAY=:0
```
Now ```echo DISPLAY``` should give ```:0``` as output.

10
LICENSE Normal file
View File

@ -0,0 +1,10 @@
Copyright (C) 1985, 1990 Regents of the University of California.
Permission to use, copy, modify, and distribute this
software and its documentation for any purpose and without
fee is hereby granted, provided that the above copyright
notice appear in all copies. The University of California
makes no representations about the suitability of this
software for any purpose. It is provided "as is" without
express or implied warranty. Export of this software outside
of the United States of America may require an export license.

144
Makefile
View File

@ -4,31 +4,33 @@
MAGICDIR = .
PROGRAMS = magic
TECH = scmos
TECHS = scmos
LIBRARIES = database utils extflat
MODULES = cmwind commands database dbwind debug drc extflat extract \
graphics netmenu plow resis select sim textio tiles utils \
windows wiring
MODULES = bplane cmwind commands database dbwind debug drc extflat \
extract graphics netmenu plow resis select sim textio tiles \
utils windows wiring
# This was `cat VERSION`
VERSION := $(shell cat ${MAGICDIR}/VERSION)
MAKEFLAGS =
INSTALL_CAD_DIRS = windows doc ${TECH}
INSTALL_CAD_DIRS = windows doc ${TECHS}
include defs.mak
-include defs.mak
all: $(ALL_TARGET)
all: $(ALL_TARGET) techs
standard:
@echo --- errors and warnings logged in file make.log
@${MAKE} mains 2>&1 | tee -a make.log | egrep -i "(.c:|Stop.|---)"
standard: mains
tcl:
@echo --- errors and warnings logged in file make.log
@${MAKE} tcllibrary 2>&1 | tee -a make.log | egrep -i "(.c:|Stop.|---)"
tcl: tcllibrary
force: clean all
force:
@${MAKE} clean
@${MAKE} all
defs.mak:
@echo No \"defs.mak\" file found. Run "configure" to make one.
@exit 1
config:
${MAGICDIR}/configure
@ -36,38 +38,70 @@ config:
tcllibrary: database/database.h modules
@echo --- making Tcl shared libraries
for dir in ${PROGRAMS}; do \
(cd $$dir && ${MAKE} tcl-main); done
(cd $$dir && ${MAKE} tcl-main) || exit 1; done
mains: database/database.h modules libs
@echo --- making main programs
for dir in ${PROGRAMS}; do \
(cd $$dir && ${MAKE} main); done
(cd $$dir && ${MAKE} main) || exit 1; done
database/database.h: database/database.h.in
database/database.h: ${MAGICDIR}/database/database.h.in
@echo --- making header file database/database.h
${SCRIPTS}/makedbh database/database.h.in database/database.h
${SCRIPTS}/makedbh ${MAGICDIR}/database/database.h.in database/database.h
modules:
@echo --- making modules
for dir in ${MODULES} ${PROGRAMS}; do \
(cd $$dir && ${MAKE} module); done
# tiles xyz => tiles/libtiles.o xyz/libxyz.o
MODULES_SUBDIR := $(shell for i in ${MODULES}; do echo "$${i}/lib$${i}.o"; done)
# tiles xyz => tiles/libtiles.a xyz/libxyz.a
LIBS_SUBDIR := $(shell for i in ${MODULES}; do echo "$${i}/lib$${i}.a"; done)
libs:
@echo --- making libraries
for dir in ${LIBRARIES}; do \
(cd $$dir && ${MAKE} lib); done
.PHONY: FORCE
${MODULES_SUBDIR}: FORCE
@${MAKE} -C $(dir $@) module
depend: database/database.h
${RM} */Depend
for dir in ${MODULES} ${UNUSED_MODULES} ${PROGRAMS}; do \
(cd $$dir && ${MAKE} depend); done
.PHONY: modules
modules: database/database.h depend ${MODULES_SUBDIR}
${LIBS_SUBDIR}: FORCE
@${MAKE} -C $(dir $@) lib
# Force the tiles/utils modules to exist first for libdatabase.a
.PHONY: libs
libs: database/database.h depend tiles/libtiles.o utils/libutils.o ${LIBS_SUBDIR}
#
# extcheck - utility tool
# net2ir - utility tool
# oa - disabled (needs 'clean' target renaming)
SUBDIRS = bplane cmwind commands database dbwind debug drc extflat extract graphics \
magic netmenu plow resis select sim textio tiles utils windows wiring
BUNDLED_MODULES = readline lisp
# Unique list of all subdir that might have Depend file, we have to deduplicate otherwise
# MAKE will warning loudly. This list is somewhat empty when defs.mak does not exist
SUBDIRS_FILTERED := $(shell echo ${MODULES} ${PROGRAMS} ${SUBDIRS} | tr ' ' '\n' | sort | uniq)
SUBDIRS_DEPEND = $(addsuffix /Depend, ${SUBDIRS_FILTERED})
${SUBDIRS_DEPEND}: database/database.h
@echo --- making dependencies
${MAKE} -C $(dir $@) depend
.PHONY: depend
depend: defs.mak ${SUBDIRS_DEPEND}
.PHONY: techs
techs: depend
@echo --- making techs
for dir in ${TECHS}; do \
(cd $$dir && ${MAKE} all) || exit 1; done
install: $(INSTALL_TARGET)
install-magic:
@echo --- installing executable to $(DESTDIR)${BINDIR}
@echo --- installing runtime files to $(DESTDIR)${LIBDIR}
@${MAKE} install-real 2>&1 >> install.log
@echo --- installing executable to $(DESTDIR)${INSTALL_BINDIR}
@echo --- installing runtime files to $(DESTDIR)${INSTALL_LIBDIR}
@${MAKE} install-real
install-real: install-dirs
for dir in ${INSTALL_CAD_DIRS}; do \
@ -76,24 +110,26 @@ install-real: install-dirs
(cd $$dir && ${MAKE} install); done
install-tcl-dirs:
${MAGICDIR}/scripts/mkdirs $(DESTDIR)${BINDIR} $(DESTDIR)${MANDIR} \
$(DESTDIR)${SYSDIR} $(DESTDIR)${TCLDIR} $(DESTDIR)${TCLDIR}/bitmaps
${MAGICDIR}/scripts/mkdirs $(DESTDIR)${INSTALL_BINDIR} \
$(DESTDIR)${INSTALL_MANDIR} $(DESTDIR)${INSTALL_SYSDIR} \
$(DESTDIR)${INSTALL_TCLDIR} $(DESTDIR)${INSTALL_TCLDIR}/bitmaps
install-dirs:
${MAGICDIR}/scripts/mkdirs $(DESTDIR)${BINDIR} $(DESTDIR)${MANDIR} \
$(DESTDIR)${SYSDIR} $(DESTDIR)${SCMDIR}
${MAGICDIR}/scripts/mkdirs $(DESTDIR)${INSTALL_BINDIR} \
$(DESTDIR)${INSTALL_MANDIR} $(DESTDIR)${INSTALL_SYSDIR} \
$(DESTDIR)${INSTALL_SCMDIR}
install-tcl:
@echo --- installing executable to $(DESTDIR)${BINDIR}
@echo --- installing runtime files to $(DESTDIR)${LIBDIR}
@${MAKE} install-tcl-real 2>&1 >> install.log
@echo --- installing executable to $(DESTDIR)${INSTALL_BINDIR}
@echo --- installing runtime files to $(DESTDIR)${INSTALL_LIBDIR}
@${MAKE} install-tcl-real
install-tcl-real: install-tcl-dirs
for dir in ${INSTALL_CAD_DIRS} ${PROGRAMS}; do \
(cd $$dir && ${MAKE} install-tcl); done
clean:
for dir in ${MODULES} ${PROGRAMS} ${TECH} ${UNUSED_MODULES}; do \
for dir in ${SUBDIRS_FILTERED} ${TECHS} ${BUNDLED_MODULES}; do \
(cd $$dir && ${MAKE} clean); done
${RM} *.tmp */*.tmp *.sav */*.sav *.log TAGS tags
@ -103,18 +139,19 @@ distclean:
${RM} defs.mak old.defs.mak ${MAGICDIR}/scripts/defs.mak
${RM} ${MAGICDIR}/scripts/default.conf
${RM} ${MAGICDIR}/scripts/config.log ${MAGICDIR}/scripts/config.status
${RM} scripts/magic.spec magic-`cat VERSION` magic-`cat VERSION`.tgz
${RM} database/database.h
${RM} scripts/magic.spec magic-${VERSION} magic-${VERSION}.tgz
${RM} *.log
dist:
${RM} scripts/magic.spec magic-`cat VERSION` magic-`cat VERSION`.tgz
sed -e /@VERSION@/s%@VERSION@%`cat VERSION`% \
${RM} scripts/magic.spec magic-${VERSION} magic-${VERSION}.tgz
${SED} -e /@VERSION@/s%@VERSION@%${VERSION}% \
scripts/magic.spec.in > scripts/magic.spec
ln -nsf . magic-`cat VERSION`
tar zchvf magic-`cat VERSION`.tgz --exclude CVS \
--exclude magic-`cat VERSION`/magic-`cat VERSION` \
--exclude magic-`cat VERSION`/magic-`cat VERSION`.tgz \
magic-`cat VERSION`
${LN} -nsf . magic-${VERSION}
tar zchvf magic-${VERSION}.tgz --exclude CVS \
--exclude magic-${VERSION}/magic-${VERSION} \
--exclude magic-${VERSION}/magic-${VERSION}.tgz \
magic-${VERSION}
clean-mains:
for dir in ${PROGRAMS}; do \
@ -124,6 +161,13 @@ tags:
${RM} tags
find . ${MODULES} ${PROGRAMS} -name "*.[ch]" -maxdepth 1 | xargs ctags -o tags
TAGS:
TAGS:
${RM} TAGS
find . ${MODULES} ${PROGRAMS} -name "*.[ch]" -maxdepth 1 | xargs etags -o TAGS
setup-git:
git config --local include.path ../.gitconfig
git stash save
${RM} .git/index
git checkout HEAD -- "$$(git rev-parse --show-toplevel)"
git stash pop

View File

@ -1,25 +1,57 @@
![Continuous Integration](https://github.com/RTimothyEdwards/magic/actions/workflows/main.yml/badge.svg)
# MAGIC
1. General Information:
---------------------------------
Use your World Wide Web browser to read:
http://opencircuitdesign.com/magic/
http://vlsi.csl.cornell.edu/magic/
http://www.research.digital.com/wrl/magic/magic.html
Primary documentation is on the opencircuitdesign.com website under
the "Documentation" link.
various links, including "Download", "Compile", and "Install" for
information on obtaining, compiling, and installing the tool from
source; "Code History" for detailed comments on all code changes;
"Using Magic" for basic usage information including a complete on-line
command reference; "Technology Files" for essential documentation on how
to understand, edit, or write technology files for Magic; "Documentation"
for miscellaneous papers and historical documentation converted to HTML
format.
The current distribution version of magic is maintained by Tim Edwards
<tim@opencircuitdesign.com>. Please let me know of any problems/bugs
you find through the github Issues tracker.
Additional information from developer Rajit Manohar:
https://csl.yale.edu/~rajit/magic/
Of mainly historical interest only, now (available through the WayBack machine):
https://web.archive.org/web/20051217204815/http://www.research.compaq.com:80/wrl/projects/magic/magic.html
The current development versions of magic are maintained by Tim Edwards
<tim@opencircuitdesign.com> and the current distribution version is
maintained by Rajit Manohar <rajit@csl.cornell.edu>. Please let us
know of any problems/bugs you find. Development of versions 7.2 and
newer is generously funded by MultiGiG, Inc.
2. Compilation and Installation:
---------------------------------
See the file "INSTALL" in this directory.
See the file "INSTALL" in this directory, or "INSTALL_MacOS.md" for MacOS.
3. Version 8.2 Release Notes:
3. Version 8.3 Release Notes:
---------------------------------
During the course of version 8.2, magic moved to a git-oriented
development. There are no longer "stable" and "distribution"
versions. There is only the git repo with various development
branches.
First release contains the "bplane" implementation for the cell
plane pulled from the open source code for micromagic. This is
much more efficient than using the corner-stitched tile plane
for cells, and speeds up a number of methods, such as extraction,
by a factor of 3 to 5 or so, depending on the amount of hierarchy
in the design.
4. Version 8.2 Release Notes:
---------------------------------
As of the release of version 8.2, Version 8.1 is now the new stable
@ -40,7 +72,15 @@
magic extensions since version 7, including non-manhattan geometry,
stacked contacts, and DRC rule extensions.
4. Version 8.1 Release Notes:
Extended the extraction method to allow multiple extracted device
types per magic layer, depending on the surrounding context
(connecting layers, substrate, identifier layers, etc.).
Corrected the "extresist" method for non-FET devices, although it
continues to need fundamental work to remove its dependence on the
".sim" format files.
5. Version 8.1 Release Notes:
---------------------------------
As of the release of version 8.1, Version 8.0 is now the new stable
@ -54,7 +94,7 @@
name without any understanding of a substrate node and
connectivity.
5. Version 8.0 Release Notes:
6. Version 8.0 Release Notes:
---------------------------------
As of the release of version 8.0, Version 7.5 is now the new stable
@ -82,7 +122,7 @@
7) New extraction method "msubcircuit" with methods for specifying
parameter names for source/drain area and perimeter.
6. Version 7.5 Release Notes:
7. Version 7.5 Release Notes:
---------------------------------
Version 7.5 is the development branch. Version 7.5.0 is the same as
@ -137,7 +177,7 @@
See the online release notes for a more thorough list of features.
7. Version 7.4 Release Notes:
8. Version 7.4 Release Notes:
---------------------------------
Version 7.4 is the new stable distribution version of magic.
@ -149,7 +189,7 @@
not be a "What's new in 7.4" section, as there is not supposed
to be anything new in version 7.4.
8. Version 7.3 Release Notes:
9. Version 7.3 Release Notes:
---------------------------------
Magic release 7.3 incorporates a stacked contact model which is,
@ -197,7 +237,7 @@
28) New method for crash backups, including restore with "magic -r"
29) A number of other technology file additions and enhancements
9. Version 7.2 Release Notes:
10. Version 7.2 Release Notes:
---------------------------------
Magic release 7.2 incorporates the capability to run magic from the Tcl
@ -255,7 +295,7 @@
26) Improved techfile format with asterisk-notation and DRC
"surround", "overhang", and "rect_only" statements.
10. Version 7.1 Release Notes:
11. Version 7.1 Release Notes:
---------------------------------
Magic release 7.1 consolidates all known patches/features
@ -283,7 +323,7 @@
- tons of other small things that hopefully make the build process
nicer.
11. Releases prior to version 7:
12. Releases prior to version 7:
---------------------------------
What's new in 6.5.2:

36
TODO
View File

@ -1,8 +1,32 @@
I. Bugs to fix (also in magic-7.5 [stable]):
I. Bugs to fix
1. The "extresist" code only recognizes original "fet" types, not
the new "device" types in the extract file.
1. The "extresist" code needs to extract substrate networks. Moreover,
the "extresist" code really needs to have the dependence on
ext2sim removed, and instead read directly from .ext files. The
.sim format has no substrate connections, so this cannot be properly
represented. Also, there is nothing that is read from the .sim file
that is not already present in the .ext file.
2. "plow" has been broken for some time. It should derive its rules
from the DRC decks (using the new routines that are meant for just
that sort of thing).
2. "plow" should derive its rules from the DRC decks (using the new
routines that are meant for just that sort of thing).
3. It is possible to trick the net selection into an infinite loop in
unusual geometry situations. That these situations would be DRC
errors does not excuse the infinite loop behavior. The geometry
required is unusual enough that this is not a high priority item.
4. The LEF read/write should operate from the GDS rules and layers, not
the magic database layers. LEF setup should be put in the cifinput
and cifoutput sections in the techfile, not in its own section.
5. Implement a CRC checksum to replace (or complement) timestamps.
Cells are marked as invalid only if the checksum fails to match, not
if the timestamp is outdated. This helps with two problems: (1)
PDKs which are reinstalled but not changed, and (2) libraries which
are copied from one place to another but not changed.
6. Implement tile planes that can be defined as either maximum horizontal
stripes (default) or maximum vertical stripes. The latter, if applied
to vertically oriented route layers, vastly speeds up searches on
those layers. The code for manipulating tile planes with maximum
vertical stripes exists but is used only in by the maze router.

View File

@ -1 +1 @@
8.2.77
8.3.584

4
appimage/.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
*.tar.gz
prefix/
*.AppImage
appimagetool

59
appimage/10/Dockerfile Normal file
View File

@ -0,0 +1,59 @@
FROM almalinux:10
USER root
# Build Dependencies (and dump version to logging)
RUN dnf install -y python3 zlib-devel ncurses-devel readline-devel cairo-devel freeglut-devel \
mesa-libGLU-devel mesa-libGL-devel libX11-devel libstdc++-devel gcc gcc-c++ make git tcsh \
zip \
&& echo "### rpm -qa:" \
&& rpm -qa | sort \
&& echo ""
#RUN dnf group install -y "Development Tools"
# Tcl/Tk
WORKDIR /tcl
RUN curl -L https://prdownloads.sourceforge.net/tcl/tcl9.0.1-src.tar.gz | tar --strip-components=1 -xzC . \
&& cd unix \
&& ./configure --prefix=/prefix \
&& make \
&& make install install-libraries install-msgs install-tzdata
WORKDIR /tk
RUN curl -L https://prdownloads.sourceforge.net/tcl/tk9.0.1-src.tar.gz | tar --strip-components=1 -xzC . \
&& cd unix \
&& ./configure --prefix=/prefix --with-tcl=/prefix/lib \
&& make \
&& make install install-libraries
WORKDIR /prefix/bin
RUN cp ./wish9.0 ./wish
RUN cp ./tclsh9.0 ./tclsh
# Magic
WORKDIR /magic
COPY . .
RUN ./configure \
--prefix=/prefix \
--with-tcl=/prefix/lib \
--with-tk=/prefix/lib \
&& make clean \
&& make database/database.h \
&& make -j$(nproc) \
&& make install
# Produce summary of what was created and confirm their DSOs
RUN echo "### filesystem:" \
find /prefix -printf "%y/%M/%m %i/%n %l %u/%U %g/%G %s/%b %T+/%T@\t%p\n"; \
ls -lR /prefix; \
find /prefix -type f -perm /111 -exec bash -c "echo \#\#\# {}; ldd -v {}" \; 2>/dev/null; \
for name in libgcc_s libstdc++ libpng liblzma libxml2 libz libcairo libGL libGLU; do \
find /lib64 /usr/lib64 -maxdepth 2 -name "*.so" -name "${name}*" -exec bash -c "echo \#\#\# {}; ldd -v {}" \; 2>/dev/null; \
done; \
echo "###"
WORKDIR /
RUN tar -czf /prefix.tar.gz -C ./prefix .
CMD ["/bin/bash"]

46
appimage/10/Makefile Normal file
View File

@ -0,0 +1,46 @@
MAGIC_SRC_ROOT = ../..
RESOURCES := $(shell find ../rsc/ -type f)
ARCH := $(shell uname -m)
APPIMAGE = Magic-$(ARCH).AppImage
VERSION_MAGIC := $(shell cat $(MAGIC_SRC_ROOT)/VERSION)
VERSION_TSTAMP := $(shell git show -s "--format=%cs" | tr -d '-')
VERSION_HASH := $(shell git show -s "--format=%h")
VERSION_NUM ?= $(VERSION_MAGIC)~$(VERSION_TSTAMP)~$(VERSION_HASH)
VERSION := $(VERSION_NUM)
# Allow CI to override
APPIMAGETOOL_DOWNLOAD_URL ?= https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage
all: $(APPIMAGE)
.PHONY: prefix/bin/magic
prefix/bin/magic: Dockerfile Makefile
@echo "APPIMAGE=$(APPIMAGE)"
@echo "VERSION=$(VERSION)"
@echo "ARCH=$(ARCH)"
@echo "RESOURCES=$(RESOURCES)"
rm -rf prefix
docker build -t magic_build -f ./Dockerfile $(MAGIC_SRC_ROOT)
id=$$(docker create magic_build) ; \
docker cp $$id:/prefix ./prefix ; \
docker rm -v $$id
mkdir -p prefix/lib/tcl9.0.1
cp -r prefix/lib/tcl9.0 prefix/lib/tcl9.0.1/library
appimagetool:
curl -L "$(APPIMAGETOOL_DOWNLOAD_URL)" > ./appimagetool
chmod +x ./appimagetool
$(APPIMAGE): prefix/bin/magic appimagetool $(RESOURCES)
cp $(RESOURCES) ./prefix/
./appimagetool prefix
PREFIX ?= /usr/local
install:
install $(APPIMAGE) $(PREFIX)/bin/magic
.PHONY: clean
clean:
rm -f *.AppImage
rm -f prefix.tar.gz
rm -rf prefix

127
appimage/10/README.md Normal file
View File

@ -0,0 +1,127 @@
This is an AppImage that runs on all GNU/Linux platforms with:
* FUSE
* This excludes non-privileged Docker containers unfortunately, unless pre-extracted.
* GLIBC 2.38+
* Cairo 1.18+
* May require runtime CPU matching Linux ABI x86-64-v3 and newer (CPUs with SSE4.2/AVX2/BMI2/FMA via `lscpu`).
This AppImage build is based on EL10 (via AlmaLinux 10).
AlmaLinux 10 was first released on 27 May 2025.
# Version Info
See the AppImage main binary file naming, release tag information and AppInfo metadata
for the exact magic version inside the archive. When starting AppImage by default the
Tcl console banner can also provide version information, also using the `version` Tcl
command.
# Build Info
* Based on AlmaLinux 10 (EL10)
* Tcl/Tk 9.0.1
* and Magic 8.x
* all default modules enabled (including all Display drivers cairo/X11/OpenGL)
# FAQ: How to use
Download the *.AppImage file relevant to your platform and run:
```
chmod +x Magic-x86_64.AppImage
./Magic-x86_64.AppImage
```
Example startup with command line options:
```
./Magic-x86_64.AppImage -d XR -T scmos
```
# FAQ: How to use (inside docker / podman)
```
chmod +x Magic-x86_64.AppImage
### Podman or Docker, use :Z when rootless with selinux enabled
podman run --rm --device /dev/fuse --privileged \
-v "$(pwd):/tmp/work:Z" -v "/tmp/.X11-unix/X0:/tmp/.X11-unix/X0:Z" \
-e DISPLAY -ti almalinux:10
### Inside Docker:
dnf update -y
dnf install -y fuse libX11 cairo libGL libGLU
cd /tmp/work
./Magic-x86_64.AppImage -d XR -T scmos
```
# Building Requirements
* A reasonably recent GNU/Linux host
* GNU make
* Docker 20+
* Git
* curl
The final build is then packaged into an AppImage using AppImageTool on the host machine.
# Build Instructions
`make`
# Installation Instructions
`make install`
# FAQ: Is my CPU supported ?
This is built with the standard x86_64 Linux ABI version for AlmaLinux 10.
Use the command `/lib64/ld-linux-x86-64.so.2 --help` to see which CPUs your
Linux distribtion supports (and your CPU) look for the word "supported".
# FAQ: The DSO versioning link dependencies?
The information here provides an outline of what versions to expect from EL10
of the major dependencies, to assist you in a compatibility check with your
Linux distribution of choice.
The actual versions in our public releases can differ slightly inline with
the EL10 support compatibility and ABI versioning policies for the support
lifecycle of the distribution.
The most important items are the Direct Dependencies and the availabilty
of a suitable graphics DSO as per your '-d' choice.
Direct Runtime Dependencies (from /prefix/**):
| DSO Filename | DSO Symbol Version | Related Packages |
| :--------------------- | :------------------ | :------------------- |
| libc.so.6 | GLIBC_2.38 | glibc-2.39-37 |
| libz.so.1 | ZLIB_1.2.2 | zlib-ng-2.2.3-1 |
| | | zlib-ng-compat-2.2.3-1 |
Optional/Modular Runtime Dependencies (depending on graphics mode):
| DSO Filename | DSO Symbol Version | Related Packages |
| :--------------------- | :------------------ | :------------------- |
| libcairo.so.2 | | |
| libcairo.so.2.11802.0 | | cairo-1.18.2-2 |
| libGL.so.1 | | libglvnd-glx-1:1.7.0-7 |
| | | mesa-libGL-24.2.8-2 |
| libGLU.so.1 | | mesa-libGLU-9.0.3-7 |
Transitive/Third-Party Runtime Dependencies (for information only):
| DSO Filename | DSO Symbol Version | Related Packages |
| :--------------------- | :------------------ | :------------------- |
| libstdc++.so.6 | CXXABI_1.3.9 | gcc-c++-14.2.1-7 |
| libstdc++.so.6 | GLIBCXX_3.4 | gcc-c++-14.2.1-7 |
| libgcc_s.so.1 | GCC_4.2.0 | libgcc_s-14-20250110 |
| libxml2.so.2 | LIBXML2_2.6.0 | libxml2-2.12.5-5 |
| libpng16.so.16 | PNG16_0 | libpng-2:1.6.40-8 |
| liblzma.so.5 | XZ_5.0 | xz-devel-1:5.6.2-4 |
| libz.so.1 | ZLIB_1.2.9 | zlib-ng-2.2.3-1 |
| | | zlib-ng-compat-2.2.3-1 |

68
appimage/7/Dockerfile Normal file
View File

@ -0,0 +1,68 @@
FROM centos/python-38-centos7:20210726-fad62e9
USER root
# CentOS7 went EOL on June 30, 2024 this builds out of vault.centos.org
RUN ls -l /etc/yum.repos.d/ \
&& cp /etc/yum.repos.d/CentOS-Base.repo /tmp/CentOS-Base.repo.old \
&& sed -e 's/mirror.centos.org/vault.centos.org/g' -i /etc/yum.repos.d/*.repo \
&& sed -e 's/^#.*baseurl=http/baseurl=http/g' -i /etc/yum.repos.d/*.repo \
&& sed -e 's/^mirrorlist=http/#mirrorlist=http/g' -i /etc/yum.repos.d/*.repo \
&& diff -u /tmp/CentOS-Base.repo.old /etc/yum.repos.d/CentOS-Base.repo; \
yum clean all \
&& yum -y update \
&& rm -f /tmp/CentOS-Base.repo.old
# Build Dependencies (and dump version to logging)
RUN yum install -y cairo-devel freeglut-devel gcc make tcsh \
&& echo "### rpm -qa:" \
&& rpm -qa | sort \
&& echo ""
# Tcl/Tk
WORKDIR /tcl
RUN curl -L https://prdownloads.sourceforge.net/tcl/tcl8.6.16-src.tar.gz | tar --strip-components=1 -xzC . \
&& cd unix \
&& ./configure --prefix=/prefix \
&& make \
&& make install
WORKDIR /tk
RUN curl -L https://prdownloads.sourceforge.net/tcl/tk8.6.16-src.tar.gz | tar --strip-components=1 -xzC . \
&& cd unix \
&& ./configure --prefix=/prefix --with-tcl=/prefix/lib \
&& make \
&& make install
WORKDIR /prefix/bin
RUN cp ./wish8.6 ./wish
RUN cp ./tclsh8.6 ./tclsh
# Magic
WORKDIR /magic
COPY . .
RUN ./configure \
--prefix=/prefix \
--with-tcl=/prefix/lib \
--with-tk=/prefix/lib \
--without-opengl \
&& make clean \
&& make database/database.h \
&& make -j$(nproc) \
&& make install
# Produce summary of what was created and confirm their DSOs
RUN echo "### filesystem:" \
find /prefix -printf "%y/%M/%m %i/%n %l %u/%U %g/%G %s/%b %T+/%T@\t%p\n"; \
ls -lR /prefix; \
find /prefix -type f -perm /111 -exec bash -c "echo \#\#\# {}; ldd -v {}" \; 2>/dev/null; \
for name in libgcc_s libstdc++ libpng liblzma libxml2 libz libcairo libGL libGLU; do \
find /lib64 /usr/lib64 -maxdepth 2 -name "*.so" -name "${name}*" -exec bash -c "echo \#\#\# {}; ldd -v {}" \; 2>/dev/null; \
done; \
echo "###"
WORKDIR /
RUN tar -czf /prefix.tar.gz -C ./prefix .
CMD ["/bin/bash"]

46
appimage/7/Makefile Normal file
View File

@ -0,0 +1,46 @@
MAGIC_SRC_ROOT = ../..
RESOURCES := $(shell find ../rsc/ -type f)
ARCH := $(shell uname -m)
APPIMAGE = Magic-$(ARCH).AppImage
VERSION_MAGIC := $(shell cat $(MAGIC_SRC_ROOT)/VERSION)
VERSION_TSTAMP := $(shell git show -s "--format=%cs" | tr -d '-')
VERSION_HASH := $(shell git show -s "--format=%h")
VERSION_NUM ?= $(VERSION_MAGIC)~$(VERSION_TSTAMP)~$(VERSION_HASH)
VERSION := $(VERSION_NUM)
# Allow CI to override
APPIMAGETOOL_DOWNLOAD_URL ?= https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage
all: $(APPIMAGE)
.PHONY: prefix/bin/magic
prefix/bin/magic: Dockerfile Makefile
@echo "APPIMAGE=$(APPIMAGE)"
@echo "VERSION=$(VERSION)"
@echo "ARCH=$(ARCH)"
@echo "RESOURCES=$(RESOURCES)"
rm -rf prefix
docker build -t magic_build -f ./Dockerfile $(MAGIC_SRC_ROOT)
id=$$(docker create magic_build) ; \
docker cp $$id:/prefix ./prefix ; \
docker rm -v $$id
mkdir -p prefix/lib/tcl8.6.16
cp -r prefix/lib/tcl8.6 prefix/lib/tcl8.6.16/library
appimagetool:
curl -L "$(APPIMAGETOOL_DOWNLOAD_URL)" > ./appimagetool
chmod +x ./appimagetool
$(APPIMAGE): prefix/bin/magic appimagetool $(RESOURCES)
cp $(RESOURCES) ./prefix/
./appimagetool prefix
PREFIX ?= /usr/local
install:
install $(APPIMAGE) $(PREFIX)/bin/magic
.PHONY: clean
clean:
rm -f *.AppImage
rm -f prefix.tar.gz
rm -rf prefix

137
appimage/7/README.md Normal file
View File

@ -0,0 +1,137 @@
This is an AppImage that runs on all GNU/Linux platforms with:
* FUSE
* This excludes non-privileged Docker containers unfortunately, unless pre-extracted.
* GLIBC 2.17+
* Cairo 1.15+
* Supports all Linux x86_64 CPUs
This AppImage build is based on EL7 (via CentOS 7)
CentOS 7 was first released on 07 July 2014 and went end-of-life on 30 June 2024.
# Version Info
See the AppImage main binary file naming, release tag information and AppInfo metadata
for the exact magic version inside the archive. When starting AppImage by default the
Tcl console banner can also provide version information, also using the `version` Tcl
command.
# Build Info
* Based on CentOS 7 (EL7)
* Tcl/Tk 8.6.16
* and Magic 8.x
* all default modules enabled, but without OpenGL (includes Display drivers cairo/X11)
# FAQ: How to use
Download the *.AppImage file relevant to your platform and run:
```
chmod +x Magic-x86_64.AppImage
./Magic-x86_64.AppImage
```
Example startup with command line options:
```
./Magic-x86_64.AppImage -d XR -T scmos
```
# FAQ: How to use (inside docker / podman)
```
chmod +x Magic-x86_64.AppImage
### Podman or Docker, use :Z when rootless with selinux enabled
podman run --rm --device /dev/fuse --privileged \
-v "$(pwd):/tmp/work:Z" -v "/tmp/.X11-unix/X0:/tmp/.X11-unix/X0:Z" \
-e DISPLAY -ti centos:7
### Inside Docker:
echo "FIXUP yum from vault and update" \
&& ls -l /etc/yum.repos.d/ \
&& cp /etc/yum.repos.d/CentOS-Base.repo /tmp/CentOS-Base.repo.old \
&& sed -e 's/mirror.centos.org/vault.centos.org/g' -i /etc/yum.repos.d/*.repo \
&& sed -e 's/^#.*baseurl=http/baseurl=http/g' -i /etc/yum.repos.d/*.repo \
&& sed -e 's/^mirrorlist=http/#mirrorlist=http/g' -i /etc/yum.repos.d/*.repo \
&& diff -u /tmp/CentOS-Base.repo.old /etc/yum.repos.d/CentOS-Base.repo; \
yum clean all \
&& yum -y update \
&& rm -f /tmp/CentOS-Base.repo.old
yum install -y fuse libX11 cairo
cd /tmp/work
./Magic-x86_64.AppImage -d XR -T scmos
```
# Building Requirements
* A reasonably recent GNU/Linux host
* GNU make
* Docker 20+
* Git
* curl
The final build is then packaged into an AppImage using AppImageTool on the host machine.
# Build Instructions
`make`
# Installation Instructions
`make install`
# FAQ: Is my CPU supported ?
Supports all x86_64 CPUs. The Linux ABI in use is the original x86-64 ABI (v1).
Use the command `/lib64/ld-linux-x86-64.so.2 --help` to see which CPUs your
Linux distribtion supports (and your CPU) look for the word "supported".
# FAQ: The DSO versioning link dependencies?
The information here provides an outline of what versions to expect from EL7
of the major dependencies, to assist you in a compatibility check with your
Linux distribution of choice.
The actual versions in our public releases can differ slightly inline with
the EL7 support compatibility and ABI versioning policies for the support
lifecycle of the distribution.
The most important items are the Direct Dependencies and the availabilty
of a suitable graphics DSO as per your '-d' choice.
Direct Runtime Dependencies (from /prefix/**):
| DSO Filename | DSO Symbol Version | Related Packages |
| :--------------------- | :------------------ | :------------------- |
| libc.so.6 | GLIBC_2.14 | glibc-2.17-326 |
| libz.so.1 | ZLIB_1.2.2 | zlib-1.2.7-21 |
Optional/Modular Runtime Dependencies (depending on graphics mode):
| DSO Filename | DSO Symbol Version | Related Packages |
| :--------------------- | :------------------ | :------------------- |
| libcairo.so.2 | | |
| libcairo.so.2.11512.0 | | cairo-1.15.12-4 |
| libGL.so.1 | | |
| libglvnd-glx-1:1.0.1-0 | | mesa-libGL-18.3.4-12 |
| libGLU.so.1 | | mesa-libGLU-9.0.0-4 |
Transitive/Third-Party Runtime Dependencies (for information only):
| DSO Filename | DSO Symbol Version | Related Packages |
| :--------------------- | :------------------ | :------------------- |
| libc.so.6 | GLIBC_2.35 | glibc-2.17-326 |
| libstdc++.so.6 | GLIBCXX_3.4 | gcc-4.8.5-44 |
| libstdc++.so.6 | CXXABI_1.3.9 | gcc-4.8.5-44 |
| libgcc_s.so.1 | | |
| libgcc_s-4.8.5-20150702.so.1 | GCC_4.2.0 | libgcc-4.8.5-44 |
| libxml2.so.2 | LIBXML2_2.6.0 | libxml2-2.9.1-6 |
| libpng15.so.15 | | |
| libpng15.so.15.13.0 | PNG16_0 | libpng-1:1.5.13-8 |
| liblzma.so.5 | XZ_5.0 | xz-libs-5.2.2-2 |
| libz.so.1 | ZLIB_1.2.9 | zlib-1.2.7-21 |

58
appimage/8/Dockerfile Normal file
View File

@ -0,0 +1,58 @@
FROM almalinux:8
USER root
# Build Dependencies (and dump version to logging)
RUN dnf install -y python311 zlib-devel ncurses-devel readline-devel cairo-devel freeglut-devel \
mesa-libGLU-devel mesa-libGL-devel libX11-devel libstdc++-devel gcc gcc-c++ make git tcsh \
&& echo "### rpm -qa:" \
&& rpm -qa | sort \
&& echo ""
#RUN dnf group install -y "Development Tools"
# Tcl/Tk
WORKDIR /tcl
RUN curl -L https://prdownloads.sourceforge.net/tcl/tcl8.6.16-src.tar.gz | tar --strip-components=1 -xzC . \
&& cd unix \
&& ./configure --prefix=/prefix \
&& make \
&& make install
WORKDIR /tk
RUN curl -L https://prdownloads.sourceforge.net/tcl/tk8.6.16-src.tar.gz | tar --strip-components=1 -xzC . \
&& cd unix \
&& ./configure --prefix=/prefix --with-tcl=/prefix/lib \
&& make \
&& make install
WORKDIR /prefix/bin
RUN cp ./wish8.6 ./wish
RUN cp ./tclsh8.6 ./tclsh
# Magic
WORKDIR /magic
COPY . .
RUN ./configure \
--prefix=/prefix \
--with-tcl=/prefix/lib \
--with-tk=/prefix/lib \
&& make clean \
&& make database/database.h \
&& make -j$(nproc) \
&& make install
# Produce summary of what was created and confirm their DSOs
RUN echo "### filesystem:" \
find /prefix -printf "%y/%M/%m %i/%n %l %u/%U %g/%G %s/%b %T+/%T@\t%p\n"; \
ls -lR /prefix; \
find /prefix -type f -perm /111 -exec bash -c "echo \#\#\# {}; ldd -v {}" \; 2>/dev/null; \
for name in libgcc_s libstdc++ libpng liblzma libxml2 libz libcairo libGL libGLU; do \
find /lib64 /usr/lib64 -maxdepth 2 -name "*.so" -name "${name}*" -exec bash -c "echo \#\#\# {}; ldd -v {}" \; 2>/dev/null; \
done; \
echo "###"
WORKDIR /
RUN tar -czf /prefix.tar.gz -C ./prefix .
CMD ["/bin/bash"]

46
appimage/8/Makefile Normal file
View File

@ -0,0 +1,46 @@
MAGIC_SRC_ROOT = ../..
RESOURCES := $(shell find ../rsc/ -type f)
ARCH := $(shell uname -m)
APPIMAGE = Magic-$(ARCH).AppImage
VERSION_MAGIC := $(shell cat $(MAGIC_SRC_ROOT)/VERSION)
VERSION_TSTAMP := $(shell git show -s "--format=%cs" | tr -d '-')
VERSION_HASH := $(shell git show -s "--format=%h")
VERSION_NUM ?= $(VERSION_MAGIC)~$(VERSION_TSTAMP)~$(VERSION_HASH)
VERSION := $(VERSION_NUM)
# Allow CI to override
APPIMAGETOOL_DOWNLOAD_URL ?= https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage
all: $(APPIMAGE)
.PHONY: prefix/bin/magic
prefix/bin/magic: Dockerfile Makefile
@echo "APPIMAGE=$(APPIMAGE)"
@echo "VERSION=$(VERSION)"
@echo "ARCH=$(ARCH)"
@echo "RESOURCES=$(RESOURCES)"
rm -rf prefix
docker build -t magic_build -f ./Dockerfile $(MAGIC_SRC_ROOT)
id=$$(docker create magic_build) ; \
docker cp $$id:/prefix ./prefix ; \
docker rm -v $$id
mkdir -p prefix/lib/tcl8.6.16
cp -r prefix/lib/tcl8.6 prefix/lib/tcl8.6.16/library
appimagetool:
curl -L "$(APPIMAGETOOL_DOWNLOAD_URL)" > ./appimagetool
chmod +x ./appimagetool
$(APPIMAGE): prefix/bin/magic appimagetool $(RESOURCES)
cp $(RESOURCES) ./prefix/
./appimagetool prefix
PREFIX ?= /usr/local
install:
install $(APPIMAGE) $(PREFIX)/bin/magic
.PHONY: clean
clean:
rm -f *.AppImage
rm -f prefix.tar.gz
rm -rf prefix

126
appimage/8/README.md Normal file
View File

@ -0,0 +1,126 @@
This is an AppImage that runs on all GNU/Linux platforms with:
* FUSE
* This excludes non-privileged Docker containers unfortunately, unless pre-extracted.
* GLIBC 2.28+
* Cairo 1.15+
* Supports all Linux x86_64 CPUs
This AppImage build is based on EL8 (via AlmaLinux 8)
AlmaLinux 8 was first released on 20 March 2021, active support ends 31 May 2024,
security support ends 31 May 2029 (please see AlmaLinux bulletins for
up-to-date information).
# Version Info
See the AppImage main binary file naming, release tag information and AppInfo metadata
for the exact magic version inside the archive. When starting AppImage by default the
Tcl console banner can also provide version information, also using the `version` Tcl
command.
* Based on AlmaLinux 8 (EL8)
* Tcl/Tk 8.6.16
* and Magic 8.x
* all default modules enabled (including all Display drivers cairo/X11/OpenGL)
# FAQ: How to use
Download the *.AppImage file relevant to your platform and run:
```
chmod +x Magic-x86_64.AppImage
./Magic-x86_64.AppImage
```
Example startup with command line options:
```
./Magic-x86_64.AppImage -d XR -T scmos
```
# FAQ: How to use (inside docker / podman)
```
chmod +x Magic-x86_64.AppImage
### Podman or Docker, use :Z when rootless with selinux enabled
podman run --rm --device /dev/fuse --privileged \
-v "$(pwd):/tmp/work:Z" -v "/tmp/.X11-unix/X0:/tmp/.X11-unix/X0:Z" \
-e DISPLAY -ti almalinux:8
### Inside Docker:
dnf update -y
dnf install -y fuse libX11 cairo libGL libGLU
cd /tmp/work
./Magic-x86_64.AppImage -d XR -T scmos
```
# Building Requirements
* A reasonably recent GNU/Linux host
* GNU make
* Docker
* Git
* curl
The final build is then packaged into an AppImage using AppImageTool on the host machine.
# Build Instructions
`make`
# Installation Instructions
`make install`
# FAQ: Is my CPU supported ?
Supports all x86_64 CPUs. The Linux ABI in use is the original x86-64 ABI (v1).
Use the command `/lib64/ld-linux-x86-64.so.2 --help` to see which CPUs your
Linux distribtion supports (and your CPU) look for the word "supported".
# FAQ: The DSO versioning link dependencies?
The information here provides an outline of what versions to expect from EL8
of the major dependencies, to assist you with a compatibility check with your
Linux distribution of choice.
The actual versions in our public releases can differ slightly inline with
the EL8 support compatibility and ABI versioning policies for the support
lifecycle of the distribution.
The most important items are the Direct Dependencies and the availabilty
of a suitable graphics DSO as per your '-d' choice.
Direct Runtime Dependencies (from /prefix/**):
| DSO Filename | DSO Symbol Version | Related Packages |
| :--------------------- | :------------------ | :------------------- |
| libc.so.6 | GLIBC_2.14 | glibc-2.28-251 |
| libz.so.1 | ZLIB_1.2.2 | zlib-1.2.11-25 |
Optional/Modular Runtime Dependencies (depending on graphics mode):
| DSO Filename | DSO Symbol Version | Related Packages |
| :--------------------- | :------------------ | :------------------- |
| libcairo.so.2 | | |
| libcairo.so.2.11512.0 | | cairo-1.15.12-6 |
| libGL.so.1 | | libglvnd-glx-1:1.3.4-2 |
| | | mesa-libGL-23.1.4-4 |
| libGLU.so.1 | | mesa-libGLU-9.0.0-15 |
Transitive/Third-Party Runtime Dependencies (for information only):
| DSO Filename | DSO Symbol Version | Related Packages |
| :--------------------- | :------------------ | :------------------- |
| libc.so.6 | GLIBC_2.35 | glibc-2.28-251 |
| libstdc++.so.6 | GLIBCXX_3.4 | gcc-c++-8.5.0 |
| libstdc++.so.6 | CXXABI_1.3.9 | gcc-c++-8.5.0 |
| libgcc_s.so.1 | GCC_4.2.0 | libgcc-8.5.0-26 |
| libxml2.so.2 | | libxml2-2.9.7-19 |
| libpng16.so.16 | PNG16_0 | libpng-2:1.6.34-5 |
| liblzma.so.5 | | xz-libs-5.2.4-4 |
| libz.so.1 | ZLIB_1.2.9 | zlib-1.2.11-25 |

59
appimage/9/Dockerfile Normal file
View File

@ -0,0 +1,59 @@
FROM almalinux:9
USER root
# Build Dependencies (and dump version to logging)
RUN dnf install -y python311 zlib-devel ncurses-devel readline-devel cairo-devel freeglut-devel \
mesa-libGLU-devel mesa-libGL-devel libX11-devel libstdc++-devel gcc gcc-c++ make git tcsh \
zip \
&& echo "### rpm -qa:" \
&& rpm -qa | sort \
&& echo ""
#RUN dnf group install -y "Development Tools"
# Tcl/Tk
WORKDIR /tcl
RUN curl -L https://prdownloads.sourceforge.net/tcl/tcl9.0.1-src.tar.gz | tar --strip-components=1 -xzC . \
&& cd unix \
&& ./configure --prefix=/prefix \
&& make \
&& make install install-libraries install-msgs install-tzdata
WORKDIR /tk
RUN curl -L https://prdownloads.sourceforge.net/tcl/tk9.0.1-src.tar.gz | tar --strip-components=1 -xzC . \
&& cd unix \
&& ./configure --prefix=/prefix --with-tcl=/prefix/lib \
&& make \
&& make install install-libraries
WORKDIR /prefix/bin
RUN cp ./wish9.0 ./wish
RUN cp ./tclsh9.0 ./tclsh
# Magic
WORKDIR /magic
COPY . .
RUN ./configure \
--prefix=/prefix \
--with-tcl=/prefix/lib \
--with-tk=/prefix/lib \
&& make clean \
&& make database/database.h \
&& make -j$(nproc) \
&& make install
# Produce summary of what was created and confirm their DSOs
RUN echo "### filesystem:" \
find /prefix -printf "%y/%M/%m %i/%n %l %u/%U %g/%G %s/%b %T+/%T@\t%p\n"; \
ls -lR /prefix; \
find /prefix -type f -perm /111 -exec bash -c "echo \#\#\# {}; ldd -v {}" \; 2>/dev/null; \
for name in libgcc_s libstdc++ libpng liblzma libxml2 libz libcairo libGL libGLU; do \
find /lib64 /usr/lib64 -maxdepth 2 -name "*.so" -name "${name}*" -exec bash -c "echo \#\#\# {}; ldd -v {}" \; 2>/dev/null; \
done; \
echo "###"
WORKDIR /
RUN tar -czf /prefix.tar.gz -C ./prefix .
CMD ["/bin/bash"]

46
appimage/9/Makefile Normal file
View File

@ -0,0 +1,46 @@
MAGIC_SRC_ROOT = ../..
RESOURCES := $(shell find ../rsc/ -type f)
ARCH := $(shell uname -m)
APPIMAGE = Magic-$(ARCH).AppImage
VERSION_MAGIC := $(shell cat $(MAGIC_SRC_ROOT)/VERSION)
VERSION_TSTAMP := $(shell git show -s "--format=%cs" | tr -d '-')
VERSION_HASH := $(shell git show -s "--format=%h")
VERSION_NUM ?= $(VERSION_MAGIC)~$(VERSION_TSTAMP)~$(VERSION_HASH)
VERSION := $(VERSION_NUM)
# Allow CI to override
APPIMAGETOOL_DOWNLOAD_URL ?= https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage
all: $(APPIMAGE)
.PHONY: prefix/bin/magic
prefix/bin/magic: Dockerfile Makefile
@echo "APPIMAGE=$(APPIMAGE)"
@echo "VERSION=$(VERSION)"
@echo "ARCH=$(ARCH)"
@echo "RESOURCES=$(RESOURCES)"
rm -rf prefix
docker build -t magic_build -f ./Dockerfile $(MAGIC_SRC_ROOT)
id=$$(docker create magic_build) ; \
docker cp $$id:/prefix ./prefix ; \
docker rm -v $$id
mkdir -p prefix/lib/tcl9.0.1
cp -r prefix/lib/tcl9.0 prefix/lib/tcl9.0.1/library
appimagetool:
curl -L "$(APPIMAGETOOL_DOWNLOAD_URL)" > ./appimagetool
chmod +x ./appimagetool
$(APPIMAGE): prefix/bin/magic appimagetool $(RESOURCES)
cp $(RESOURCES) ./prefix/
./appimagetool prefix
PREFIX ?= /usr/local
install:
install $(APPIMAGE) $(PREFIX)/bin/magic
.PHONY: clean
clean:
rm -f *.AppImage
rm -f prefix.tar.gz
rm -rf prefix

128
appimage/9/README.md Normal file
View File

@ -0,0 +1,128 @@
This is an AppImage that runs on all GNU/Linux platforms with:
* FUSE
* This excludes non-privileged Docker containers unfortunately, unless pre-extracted.
* GLIBC 2.34+
* Cairo 1.17+
* May require runtime CPU matching Linux ABI x86-64-v2 and newer (CPUs with SSE4.2/CX16 via `lscpu`).
This AppImage build is based on EL9 (via AlmaLinux 9)
AlmaLinux 9 was first released on 26 May 2022, full support ends 31 May 2027,
maintenance support ends 31 May 2032 (please see AlmaLinux bulletins for
up-to-date information).
# Version Info
See the AppImage main binary file naming, release tag information and AppInfo metadata
for the exact magic version inside the archive. When starting AppImage by default the
Tcl console banner can also provide version information, also using the `version` Tcl
command.
# Build Info
* Based on AlmaLinux 9 (EL9)
* Tcl/Tk 9.0.1
* and Magic 8.x
* all default modules enabled (including all Display drivers cairo/X11/OpenGL)
# FAQ: How to use
Download the *.AppImage file relevant to your platform and run:
```
chmod +x Magic-x86_64.AppImage
./Magic-x86_64.AppImage
```
Example startup with command line options:
```
./Magic-x86_64.AppImage -d XR -T scmos
```
# FAQ: How to use (inside docker / podman)
```
chmod +x Magic-x86_64.AppImage
### Podman or Docker, use :Z when rootless with selinux enabled
podman run --rm --device /dev/fuse --privileged \
-v "$(pwd):/tmp/work:Z" -v "/tmp/.X11-unix/X0:/tmp/.X11-unix/X0:Z" \
-e DISPLAY -ti almalinux:9
### Inside Docker:
dnf update -y
dnf install -y fuse libX11 cairo libGL libGLU
cd /tmp/work
./Magic-x86_64.AppImage -d XR -T scmos
```
# Building Requirements
* A reasonably recent GNU/Linux host
* GNU make
* Docker
* Git
* curl
The final build is then packaged into an AppImage using AppImageTool on the host machine.
# Build Instructions
`make`
# Installation Instructions
`make install`
# FAQ: Is my CPU supported ?
This is built with the standard x86_64 Linux ABI version for AlmaLinux 9.
Use the command `/lib64/ld-linux-x86-64.so.2 --help` to see which CPUs your
Linux distribtion supports (and your CPU) look for the word "supported".
# FAQ: The DSO versioning link dependencies?
The information here provides an outline of what versions to expect from EL9
of the major dependencies, to assist you in a compatibility check with your
Linux distribution of choice.
The actual versions in our public releases can differ slightly inline with
the EL9 support compatibility and ABI versioning policies for the support
lifecycle of the distribution.
The most important items are the Direct Dependencies and the availabilty
of a suitable graphics DSO as per your '-d' choice.
Direct Runtime Dependencies (from /prefix/**):
| DSO Filename | DSO Symbol Version | Related Packages |
| :--------------------- | :------------------ | :------------------- |
| libc.so.6 | GLIBC_2.34 | glibc-2.34-168 |
| libz.so.1 | ZLIB_1.2.2 | zlib-1.2.11-40 |
Optional/Modular Runtime Dependencies (depending on graphics mode):
| DSO Filename | DSO Symbol Version | Related Packages |
| :--------------------- | :------------------ | :------------------- |
| libcairo.so.2 | | |
| libcairo.so.2.11704.0 | | cairo-1.17.4-7 |
| libGL.so.1 | | libglvnd-glx-1:1.3.4 |
| | | mesa-libGL-24.2.8-2 |
| libGLU.so.1 | | mesa-libGLU-9.0.1 |
Transitive/Third-Party Runtime Dependencies (for information only):
| DSO Filename | DSO Symbol Version | Related Packages |
| :--------------------- | :------------------ | :------------------- |
| libc.so.6 | GLIBC_2.35 | glibc-2.34-168 |
| libstdc++.so.6 | CXXABI_1.3.9 | gcc-c++-11.5.0-5 |
| libstdc++.so.6 | GLIBCXX_3.4 | gcc-c++-11.5.0-5 |
| libgcc_s.so.1 | GCC_4.2.0 | libgcc-11.5.0-2 |
| libxml2.so.2 | LIBXML2_2.6.0 | libxml2-2.9.13-9 |
| libpng16.so.16 | PNG16_0 | ibpng-2:1.6.37-12 |
| liblzma.so.5 | XZ_5.0 | xz-libs-5.2.5-8 |
| libz.so.1 | ZLIB_1.2.9 | zlib-1.2.11-40 |

39
appimage/rsc/AppRun Executable file
View File

@ -0,0 +1,39 @@
#!/usr/bin/env bash
export CURDIR=$(dirname $(readlink -f "${0}"))
export PATH="${CURDIR}/bin":$PATH
export LD_LIBRARY_PATH=${CURDIR}/lib:$LD_LIBRARY_PATH
export CAD_ROOT="${CURDIR}/lib"
export MAGIC_WISH="${CURDIR}/bin/wish"
function my_echo() {
if [ "$MAGIC_VERBOSE" != "0" ]
then
echo -- $@
fi
}
# Attempt to set by default a valid 'ulimit -n' based on TCL version this
# will automatically apply valid limit inside docker running processes.
if [ "X${MAGIC_ULIMIT_NOFILE:+set}" = "X" ] # not set to something
then
if $MAGIC_WISH "${CURDIR}/version_check.tcl" | grep -q "=8\." # only needed for tcl8
then
if [ $(ulimit -Sn) -gt 1024 ] # only reduce >1024 to 1024
then
MAGIC_ULIMIT_NOFILE=1024
my_echo "# ulimit -Sn reduced from $(ulimit -Sn) to $MAGIC_ULIMIT_NOFILE"
fi
fi
fi
if [ "X$MAGIC_ULIMIT_NOFILE" != "X" ] # non empty
then
# Inform user we did this and hint at how to customize
my_echo "ulimit -Sn $MAGIC_ULIMIT_NOFILE # use \$MAGIC_ULIMIT_NOFILE to customize"
ulimit -Sn $MAGIC_ULIMIT_NOFILE
fi
my_echo "# Starting Magic"
exec "${CURDIR}/bin/magic" "$@"

View File

@ -0,0 +1,8 @@
[Desktop Entry]
Type=Application
Name=Magic
Icon=magic
Exec=magic
Comment=Magic - A VLSI Layout System
Categories=Development;
Terminal=true

65
appimage/rsc/magic.svg Normal file
View File

@ -0,0 +1,65 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- Generator: Adobe Illustrator 18.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 464.731 464.731" style="enable-background:new 0 0 464.731 464.731;" xml:space="preserve">
<g id="XMLID_207_">
<path id="XMLID_212_" d="M463.056,441.971l-45.894-43.145l29.759-55.521c0.8-1.508,0.379-3.398-1.029-4.395
c-1.388-1.011-3.305-0.832-4.487,0.424l-43.146,45.895l-55.533-29.746c-1.515-0.803-3.399-0.377-4.395,1.027
c-1.017,1.392-0.815,3.309,0.438,4.488l45.911,43.162l-29.747,55.518c-0.816,1.525-0.378,3.401,1.01,4.412
c1.41,0.996,3.326,0.816,4.502-0.438l43.149-45.912l55.507,29.746c1.506,0.802,3.393,0.378,4.393-1.027
C464.506,445.072,464.308,443.136,463.056,441.971z"/>
<path id="XMLID_211_" d="M369.086,94.641l-20.273,37.826c-1.04,1.918-0.479,4.307,1.285,5.588c1.783,1.271,4.215,1.029,5.71-0.559
l29.417-31.269l37.78,20.26c1.921,1.024,4.323,0.484,5.589-1.285c1.271-1.783,1.048-4.215-0.555-5.709l-31.245-29.385
l20.274-37.814c1.028-1.918,0.466-4.307-1.297-5.59c-1.766-1.268-4.216-1.025-5.713,0.558l-29.381,31.257l-37.814-20.273
c-1.936-1.026-4.325-0.467-5.589,1.301c-1.273,1.766-1.042,4.214,0.544,5.711L369.086,94.641z"/>
<path id="XMLID_210_" d="M123.956,360.06l-44.659,6.239l-17.611-41.484c-0.906-2.113-3.217-3.232-5.423-2.631
c-2.226,0.623-3.626,2.78-3.313,5.051l6.239,44.639L17.69,389.489c-2.1,0.908-3.23,3.217-2.614,5.424
c0.609,2.219,2.767,3.629,5.032,3.31l44.657-6.241l17.611,41.5c0.896,2.118,3.218,3.236,5.425,2.629
c2.206-0.617,3.626-2.765,3.312-5.043l-6.238-44.658l41.5-17.617c2.099-0.904,3.234-3.217,2.612-5.423
C128.383,361.147,126.221,359.745,123.956,360.06z"/>
<path id="XMLID_209_" d="M4.908,45.161l34.646,9.537l-0.23,35.832c-0.012,2.01,1.449,3.704,3.447,3.99
c1.976,0.271,3.851-0.969,4.377-2.901l9.521-34.565l35.923,0.225c2.01,0.016,3.702-1.447,3.992-3.441
c0.271-1.982-0.97-3.853-2.905-4.383l-34.627-9.547l0.213-35.881c0.018-2.01-1.466-3.701-3.441-3.988
c-1.983-0.273-3.856,0.965-4.383,2.901l-9.533,34.608L5.996,37.324c-1.991,0-3.701,1.463-3.974,3.441
C1.751,42.747,2.992,44.633,4.908,45.161z"/>
<path id="XMLID_208_" d="M278.019,234.519l139.775-18.477c1.586-0.21,2.762-1.555,2.762-3.143c0-1.587-1.176-2.928-2.762-3.142
L278.019,191.28l20.476-57.755c0.857-2.446,0.235-5.183-1.603-7.009c-1.828-1.844-4.567-2.445-7.01-1.586l-57.697,20.484
L213.708,5.688c-0.194-1.588-1.554-2.764-3.14-2.764c-1.584,0-2.935,1.176-3.146,2.764l-18.457,139.744l-57.772-20.502
c-2.448-0.875-5.181-0.258-7.014,1.586c-1.84,1.826-2.46,4.563-1.586,7.009l20.489,57.772l-139.73,18.46
c-1.584,0.214-2.762,1.555-2.762,3.142c0,1.588,1.178,2.933,2.762,3.143l139.73,18.461l-20.489,57.742
c-0.874,2.447-0.254,5.182,1.586,7.01c1.833,1.842,4.565,2.462,7.014,1.582l57.772-20.467l18.457,139.743
c0.212,1.583,1.563,2.764,3.146,2.764c1.586,0,2.945-1.181,3.14-2.764l18.477-139.743l57.727,20.486
c2.441,0.876,5.181,0.256,7.009-1.589c1.845-1.825,2.461-4.562,1.584-7.007L278.019,234.519z"/>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

@ -0,0 +1,4 @@
# Usage: wish version_check.tcl
puts "tcl_version=$tcl_version"
puts "tk_version=$tk_version"
exit 0

10
bplane/Makefile Normal file
View File

@ -0,0 +1,10 @@
#
# rcsid "$Header: /usr/cvsroot/magic-8.0/drc/Makefile,v 1.1.1.1 2008/02/03 20:43:50 tim Exp $"
#
MODULE = bplane
MAGICDIR = ..
SRCS = bpDump.c bpUtils.c bpBins.c bpEnum.c bpMain.c bpStat.c
include ${MAGICDIR}/defs.mak
include ${MAGICDIR}/rules.mak

38
bplane/README Normal file
View File

@ -0,0 +1,38 @@
TODO
----
NOTE: nested enums are broken do to dynamic binning.
Don't rebuild entire bplane when bbox grows.
unsubbing sometimes.
Some (remaining) bplane design issues:
groups?
idea: support small number of groups by having
separate bplane for each group. Do selection this
way. Logically layered on top of bplanes - but may
want to integrate.
DECISION: defer for now.
pack/unpack?
Seems incompatible with user alloc/dealloc.
Complicated.
DECISION: Forget it.
coarse/fine with cache.
can be added later. should fit in nicely.
no special support needed.
integrated find/add?
can add later.
don't worry about it now.
May want to add attributes, via external hash.

719
bplane/bpBins.c Normal file
View File

@ -0,0 +1,719 @@
// ************************************************************************
//
// Copyright (c) 1995-2002 Juniper Networks, Inc. All rights reserved.
//
// Permission is hereby granted, without written agreement and without
// license or royalty fees, to use, copy, modify, and distribute this
// software and its documentation for any purpose, provided that the
// above copyright notice and the following three paragraphs appear in
// all copies of this software.
//
// IN NO EVENT SHALL JUNIPER NETWORKS, INC. BE LIABLE TO ANY PARTY FOR
// DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
// JUNIPER NETWORKS, INC. HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
// DAMAGE.
//
// JUNIPER NETWORKS, INC. SPECIFICALLY DISCLAIMS ANY WARRANTIES,
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
// NON-INFRINGEMENT.
//
// THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND JUNIPER
// NETWORKS, INC. HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
//
// ************************************************************************
/* bpBins.c
*
* Routines for creating and manipulating bin arrays.
*
*/
#include <stdio.h>
#include <math.h>
#include "utils/utils.h"
#include "utils/malloc.h"
#include "database/database.h"
#include "utils/geometry.h"
#include "bplane/bplaneInt.h"
/* debug */
#define BPD 0
/* Tcl linked Parameters */
int bpMinBAPop = 10; /* don't sub(bin) when count less than this */
double bpMinAvgBinPop = 1.0; /* try to keep average bin pop at or
* below this
*/
/*
* ----------------------------------------------------------------------------
*
* roundUp -- Round up a number to a grid.
*
* ----------------------------------------------------------------------------
*/
static __inline__ int roundUp(int i, int res)
{
int r = (i % res);
/* Subtract negative number */
if (r > 0) r = r - res;
return i - r;
}
/*
* ----------------------------------------------------------------------------
*
* bpBinArrayNew -- allocate new bin array.
*
* ----------------------------------------------------------------------------
*/
static BinArray *bpBinArrayNew(int dx, /* x diameter of bins */
int dy, /* y diameter of bins */
Rect *bbox) /* area covered */
{
BinArray *new;
Rect abbox;
int w, h, dimX, dimY, numBins;
int size;
/* compute array dimensions */
w = roundUp(GEO_WIDTH(bbox),dx);
h = roundUp(GEO_HEIGHT(bbox),dy);
dimX = w/dx;
dimY = h/dy;
numBins = dimX*dimY;
/* allocate array */
size = sizeof(BinArray) + numBins*(sizeof(void *));
new = (BinArray *)callocMagic(1, size);
/* initial */
new->ba_bbox = *bbox;
new->ba_dx = dx;
new->ba_dy = dy;
new->ba_dimX = dimX;
new->ba_numBins = numBins;
/* pull bbox back one from top-edge, right-edge, to simplify index
* computation in bpEnumPush
*/
new->ba_bbox.r_xtop --;
new->ba_bbox.r_ytop --;
return new;
}
/*
* ----------------------------------------------------------------------------
*
* bpBinAdd -- add element to bin array
*
* ----------------------------------------------------------------------------
*/
void bpBinAdd(BinArray *ba,
Element *e)
{
int i; /* bin index */
/* compute bin index */
if(GEO_WIDTH(&e->e_rect) >= ba->ba_dx ||
GEO_HEIGHT(&e->e_rect) >= ba->ba_dy)
{
/* oversized */
i = ba->ba_numBins;
}
else
{
/* x and y indices */
int xi = (e->e_rect.r_xbot - ba->ba_bbox.r_xbot) / ba->ba_dx;
int yi = (e->e_rect.r_ybot - ba->ba_bbox.r_ybot) / ba->ba_dy;
i = xi + yi*ba->ba_dimX ;
}
/* add element */
if(bpBinType(ba,i) == BT_ARRAY)
{
/* sub-binned */
bpBinAdd(bpSubArray(ba,i), e);
}
else
{
/* simple list */
Element *next = bpBinList(ba,i);
/* link with next */
e->e_link = next;
if(next) next->e_linkp = &e->e_link;
/* link to head */
ba->ba_bins[i] = e;
e->e_linkp = (Element **) &ba->ba_bins[i];
}
}
/*
* ----------------------------------------------------------------------------
*
* bpBinArrayUnbuild - remove elements from bin array and Free the array
*
* Returns: (singly linked) list of elements formerly in the array
*
* ----------------------------------------------------------------------------
*/
static Element *bpBinArrayUnbuild(BinArray *ba)
{
Element *elements = NULL;
int numBins = ba->ba_numBins;
int i;
/* empty the bins */
for(i=0;i<=numBins;i++)
{
Element *l;
if(bpBinType(ba,i) == BT_ARRAY)
{
/* sub-array, unbuild recursively */
l = bpBinArrayUnbuild(bpSubArray(ba,i));
}
else
{
/* Simple list */
l = bpBinList(ba,i);
}
/* collect elements */
while(l)
{
Element *e = l;
l = e->e_link;
e->e_link = elements;
elements = e;
}
}
/* free the array */
freeMagic((char *)ba);
return elements;
}
/*
* ----------------------------------------------------------------------------
* bpListExceedsQ --
*
* check if element list exceeds given length
*
* Returns size of list.
*
* ----------------------------------------------------------------------------
*/
static __inline__ int
bpListExceedsQ(Element *e, /* list */
int n) /* length to check against */
{
n++;
while(e && n)
{
n--;
e = e->e_link;
}
return n==0;
}
/*
* ----------------------------------------------------------------------------
*
* bpBinArraySizeIt -- choose bin sizes for new bin array.
*
* RESULT:
*
* normally returns TRUE,
* returns FALSE on failure: could not come up with binning that
* makes progress.
*
* NOTE: the various 'return' parameters are not set on failure.
*
* ----------------------------------------------------------------------------
*/
static __inline__ bool
bpBinArraySizeIt(Rect *bbox, /* bin array bbox */
Element *elements, /* initial elements */
int *dxp, /* return bin x-diameter here */
int *dyp, /* return bin y-diameter here */
int *maxDXp,
int *maxDYp,
int *numBinsp, /* return number of bins here */
int *countp) /* return number of elements here */
{
BinArray *ba;
int count;
double numBins; /* need double to avoid overflow on tentative calc. */
int h = GEO_HEIGHT(bbox);
int w = GEO_WIDTH(bbox);
int dx,dy; /* individual bin diameter */
int maxEX, maxEY; /* max element dimensions */
int maxDX, maxDY; /* max bin diameter allowed */
int xDim, yDim; /* array dimensions */
int maxBins; /* max number of bins
* (due to bpMinAvgBinPop)
*/
/* compute max element dimensions
* (would like bins coarser than max dimensisons)
*/
{
Element *e;
maxEX = 0;
maxEY = 0;
count = 0;
for(e=elements; e; e=e->e_link)
{
int ew = GEO_WIDTH(&e->e_rect);
int eh = GEO_HEIGHT(&e->e_rect);
maxEX = MAX(maxEX,ew);
maxEY = MAX(maxEY,eh);
count++;
}
}
/* if too few elements, don't bother with binning */
if(count < bpMinBAPop) return FALSE;
/* if too tiny don't subbin,
* avoid nasty corner-cases in code below
*/
if(h<2 || w<2) return FALSE;
/* tentatively choose bin size to fit all elements */
dx = maxEX+1;
dy = maxEY+1;
/* ensure we get at least two bins, so that
* subbining of sparse designs will work.
*/
maxDX = (w+1)/2;
maxDY = (h+1)/2;
/*
fprintf(stderr,"bpBinArraySizeIt, initial "
"maxEX=%d maxEY=%d maxDX=%d maxDY=%d dx=%d dy=%d\n",
maxEX,maxEY,maxDX,maxDY,dx,dy);
*/
if(dx <= maxDX)
{
/* x is cool */
if(dy <= maxDY)
{
/* totally cool */
;
}
else
{
/* y-dim too big for two bins, but x-dim cool,
* just reduce in x this time.
*/
dy = h+1;
}
}
else
{
/* x-dim too big for two bins */
if(dy <= maxDY)
{
/* x-dim too big for two bins but y=dim cool,
* just reduce in y this time
*/
dx = w+1;
}
else
{
/* BOTH x-dim and y-dim too big for two bins.
* We are screwed: will have some oversized.
*
* Choose betwen splitting in two horizontally or
* vertically, by which ever method results in the minimum
* number of oversized elements.
*/
int xOver=0; /* number of oversized if we reduce x-dim. */
int yOver=0; /* number of oversized if we reduce y-dim. */
Element *e;
/* count potential oversized */
for(e=elements; e; e=e->e_link)
{
int ew = GEO_WIDTH(&e->e_rect);
int eh = GEO_HEIGHT(&e->e_rect);
if(ew >= maxDX) xOver++;
if(eh >= maxDY) yOver++;
}
if(xOver<yOver)
{
/* reduce x-dim to minimize oversized */
dx = maxDX;
dy = h+1;
}
else
{
/* are we making progress? */
if(yOver == count) return FALSE;
/* reduce y-dim to minimize oversized */
dx = w+1;
dy = maxDY;
}
}
}
/* tentative number of bins */
xDim = roundUp(w,dx)/dx;
yDim = roundUp(h,dy)/dy;
numBins = xDim*((double)yDim);
/* if too many bins, need to increase at least one dimension */
/* (note this step will NOT reduce dimensions) */
maxBins = MAX(count / bpMinAvgBinPop,1);
/*
fprintf(stderr,"DEBUG numBins = %g count= %d bpMinAvgBinPop=%f maxBins= %d\n",
numBins,count,bpMinAvgBinPop,maxBins);
*/
if(numBins>maxBins)
{
if(dx == w+1)
{
/* can't increase x-dim, so try increasing y-dim */
int yDimTarget = maxBins/xDim;
dy = (h+1) / MAX(yDimTarget,1);
dy = MIN(dy,maxDY);
}
else if (dy == h+1)
{
/* can't increase y-dim, so try increasing x-dim */
int xDimTarget = maxBins/yDim;
dx = (w+1) / MAX(xDimTarget,1);
dx = MIN(dx,maxDX);
}
else
{
/* try for square bins */
double area = h * (w + 0.0);
int d = MAX(sqrt(area/maxBins),1);
if(d<dx)
{
/* target d too small in x-dim
* leave xdim fixed and just increase y-dim
*/
int yDimTarget = maxBins/xDim;
dy = (h+1) / MAX(yDimTarget,1);
dy = MIN(dy,maxDY);
}
else if (d<dy)
{
/* target d too small in y-dim
* leave xdim fixed and just increase y-dim
*/
int xDimTarget = maxBins/yDim;
dx = (w+1) / MAX(xDimTarget,1);
dx = MIN(dx,maxDX);
}
else if(d>maxDX)
{
/* d too big for x-dim
* (this can happen for tall skinny bins)
*
* make x-dim maximal, and adjust y accordingly
*/
dx = w+1;
dy = MAX((h+1)/maxBins,dy);
dy = MIN(dy,maxDY);
}
else if(d>maxDY)
{
/* d too big for y-dim
* (this can happen for long squat bins)
*
* make y-dim maximal, and adjust x-dim accordingly
*/
dy = h+1;
dx = MAX((w+1)/maxBins,dx);
dx = MIN(dx,maxDX);
}
else
{
/* we're cool, create square bins */
dx = d;
dy = d;
}
}
/* update numBins */
xDim = roundUp(w,dx)/dx;
yDim = roundUp(h,dy)/dy;
numBins = xDim*yDim;
}
/* DEBUG */
if(BPD)
{
fprintf(stderr,"\nDEBUG bpBinArraySizeIt DONE, count=%d h=%d w=%d\n"
"\tmaxDX=%d maxDY=%d maxBins=%d\n"
"\tnumBins=%g dx=%d dy=%d\n",
count,h,w,
maxDX,maxDY,maxBins,
numBins,dx,dy);
}
/* set results */
if(dxp) *dxp = dx;
if(dyp) *dyp = dy;
if(maxDXp) *maxDXp = maxDX;
if(maxDYp) *maxDYp = maxDY;
if(numBinsp) *numBinsp = numBins;
if(countp) *countp = count;
/* success */
return TRUE;
}
/*
* ----------------------------------------------------------------------------
*
* bpBinArrayBuild1 -- build and populate bin array of given area and
* bin size.
*
* Returns: pointer to new bin array.
*
* ----------------------------------------------------------------------------
*/
static BinArray *bpBinArrayBuild1(Rect *bbox,
Element *elements, /* initial elements */
int dx, /* bin diameter */
int dy)
{
BinArray *ba;
/* build bin array */
ba = bpBinArrayNew(dx, dy, bbox);
/* transfer elements to bin array */
while(elements)
{
Element *e;
/* pop list */
e = elements;
elements = e->e_link;
bpBinAdd(ba, e);
}
return ba;
}
/*
* ----------------------------------------------------------------------------
*
* bpBinArrayBuild -- build and populate bin array of given area,
*
* NOTE: optimal bin size determined by trial and error.
* oversized subbinned, as indicated.
*
* Returns: pointer to new bin array, NULL on failure.
*
* ----------------------------------------------------------------------------
*/
BinArray *bpBinArrayBuild(Rect bbox,
Element *elements, /* initial elements */
bool subbin) /* subbin as needed */
{
BinArray *ba;
int dx,dy; /* individual bin diameter */
int maxDX, maxDY;
int numBins;
int count;
/* Added by Tim, 2/19/2024 */
/* This line is not supposed to be needed? */
if ((!subbin) && ((pointertype)elements & BT_ARRAY)) return NULL;
if(BPD) DumpRect("#### bpBinArrayBuild, TOP bbox= ", &bbox);
/* figure out good bin dimensions */
if(!bpBinArraySizeIt(&bbox,
elements,
&dx,
&dy,
&maxDX,
&maxDY,
&numBins,
&count)) return NULL;
/* build the bin array */
ba = bpBinArrayBuild1(&bbox, elements, dx, dy);
if(!subbin) return ba;
/* sub-bin normal bins */
{
int dimX = ba->ba_dimX;
int i;
for(i=0;i<numBins;i++)
{
BinArray *sub;
sub = bpBinArrayBuild(bpBinArea(ba,i),
bpBinList(ba, i),
TRUE);
if(sub)
{
ba->ba_bins[i] =
(void *) ((pointertype) sub | BT_ARRAY);
}
}
}
/* sub-bin oversized */
{
BinArray *sub;
sub = bpBinArrayBuild(bbox,
bpBinList(ba, numBins),
TRUE);
if(sub)
{
ba->ba_bins[numBins] =
(void *) ((pointertype) sub | BT_ARRAY);
}
}
if(BPD)
{
DumpRect("\n#### bpBinArrayBuild, DONE bbox= ", &bbox);
fprintf(stderr,"\n");
}
return ba;
}
/*
* ----------------------------------------------------------------------------
*
* bpBinsUpdate -- update bplane bins
*
* Called prior to enumerations.
*
* ----------------------------------------------------------------------------
*/
int bpBinLife = 0;
void bpBinsUpdate(BPlane *bp)
{
Rect bbox;
bool oldBins;
/* rebuild whenever inbox gets big */
if(!bpListExceedsQ(bp->bp_inBox, bpMinBAPop-1)) return;
/* fprintf(stderr,"DEBUG bpBinsUpdate - rebuilding bins.\n"); */
/* do bins already exist ? */
oldBins = (bp->bp_rootNode != 0);
/* if bins exist, dissolve them */
if(oldBins)
{
Element *elist = bpBinArrayUnbuild(bp->bp_rootNode);
/* add inbox to list */
while(bp->bp_inBox)
{
/* pop from inbox */
Element *e = bp->bp_inBox;
bp->bp_inBox = e->e_link;
/* add to elist */
e->e_link = elist;
elist = e;
}
bp->bp_inBox = elist;
}
/* compute accurate bbox */
{
Element *e = bp->bp_inBox;
bbox = e->e_rect;
for(e=bp->bp_inBox; e; e=e->e_link)
{
GeoIncludeRectInBBox(&e->e_rect, &bbox);
}
}
/* if rebuild, double bounding box, to avoid too many rebuilds */
if(oldBins)
{
int dx = GEO_WIDTH(&bbox)/2;
int dy = GEO_HEIGHT(&bbox)/2;
bbox.r_xbot -= dx;
bbox.r_ybot -= dy;
bbox.r_xtop += dx;
bbox.r_ytop += dy;
}
/* build and populate bin array */
bp->bp_rootNode = bpBinArrayBuild(bbox, bp->bp_inBox, TRUE);
if(bp->bp_rootNode) bp->bp_inBox = NULL;
bp->bp_binArea = bbox;
bp->bp_binLife = bpBinLife;
bp->bp_inAdds = 0;
/* if(BPD) bpDump(bp, 0); */
}

328
bplane/bpDump.c Normal file
View File

@ -0,0 +1,328 @@
// ************************************************************************
//
// Copyright (c) 1995-2002 Juniper Networks, Inc. All rights reserved.
//
// Permission is hereby granted, without written agreement and without
// license or royalty fees, to use, copy, modify, and distribute this
// software and its documentation for any purpose, provided that the
// above copyright notice and the following three paragraphs appear in
// all copies of this software.
//
// IN NO EVENT SHALL JUNIPER NETWORKS, INC. BE LIABLE TO ANY PARTY FOR
// DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
// JUNIPER NETWORKS, INC. HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
// DAMAGE.
//
// JUNIPER NETWORKS, INC. SPECIFICALLY DISCLAIMS ANY WARRANTIES,
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
// NON-INFRINGEMENT.
//
// THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND JUNIPER
// NETWORKS, INC. HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
//
// ************************************************************************
/* bpDump.c
*
* routines to dump bin system (for debugging)
*
*/
#include <stdio.h>
#include "utils/utils.h"
#include "database/database.h"
#include "utils/geometry.h"
#include "cif/cif.h"
#include "bplane/bplaneInt.h"
static int bpDumpFlags; /* set by bpDump, used by subroutines */
/*
* ----------------------------------------------------------------------------
* bpIndent --
*
* tab over n spaces on stderr
*
* ----------------------------------------------------------------------------
*/
static void bpIndent(int n)
{
int i;
for(i=0;i<n;i++) fprintf(stderr," ");
}
/*
* ----------------------------------------------------------------------------
* bpDumpRect --
*
* list rects.
*
* ----------------------------------------------------------------------------
*/
void bpDumpRect(Rect *r)
{
if(bpDumpFlags & BPD_INTERNAL_UNITS)
{
fprintf(stderr,"%d ",
r->r_xbot);
fprintf(stderr,"%d ",
r->r_ybot);
fprintf(stderr,"%d ",
r->r_xtop);
fprintf(stderr,"%d",
r->r_ytop);
}
#ifdef CIF_MODULE
else
{
float oscale;
oscale = CIFGetOutputScale(1000);
fprintf(stderr,"%f ",
oscale * (float)r->r_xbot);
fprintf(stderr,"%f ",
oscale * (float)r->r_ybot);
fprintf(stderr,"%f ",
oscale * (float)r->r_xtop);
fprintf(stderr,"%f",
oscale * (float)r->r_ytop);
}
#endif
}
/*
* ----------------------------------------------------------------------------
* bpDumpElements --
*
* list rects.
*
* ----------------------------------------------------------------------------
*/
void bpDumpElements(Element *list, int indent)
{
Element *e;
for(e = list; e; e=e->e_link)
{
bpIndent(indent);
fprintf(stderr,"{element ");
if(bpDumpFlags & BPD_LABELED)
{
LabeledElement *le = (LabeledElement *) e;
fprintf(stderr,"%s ", le->le_text);
}
bpDumpRect(&e->e_rect);
fprintf(stderr,"}\n");
}
}
/*
* ----------------------------------------------------------------------------
* bpDumpEnums --
*
* list active enumerations
*
* ----------------------------------------------------------------------------
*/
void bpDumpEnums(BPEnum *bpe, int indent)
{
for(; bpe; bpe=bpe->bpe_next)
{
bpIndent(indent);
fprintf(stderr,"{enum \"%s\"}",
bpe->bpe_id);
}
}
/*
* ----------------------------------------------------------------------------
* bpBinArrayDump --
*
* recursively dump hierarchical bin system
*
* ----------------------------------------------------------------------------
*/
static void bpBinArrayDump(BinArray *ba, int indent)
{
int numBins = ba->ba_numBins;
int dx = ba->ba_dx;
int dy = ba->ba_dy;
int dimX = ba->ba_dimX;
int dimY = numBins/dimX;
Rect *bbox = &ba->ba_bbox;
int xi,yi;
/* open */
bpIndent(indent);
fprintf(stderr,"{bin-array ");
if(bpDumpFlags & BPD_INTERNAL_UNITS)
{
fprintf(stderr,"{dx %d} {dy %d} ",
dx,dy);
}
#ifdef CIF_MODULE
else
{
float oscale;
oscale = CIFGetOutputScale(1000);
fprintf(stderr,"{dx %f} ",
(float)dx * oscale);
fprintf(stderr,"{dy %f} ",
(float)dy * oscale);
}
#endif
fprintf(stderr,"{dimX %d} {dimY %d} { bbox ",
dimX,
dimY);
bpDumpRect(bbox);
fprintf(stderr," }\n");
/* bins */
for(yi=0; yi<dimY; yi++)
{
for(xi=0; xi<dimX; xi++)
{
Rect area;
int i = xi + yi*dimX;
area.r_xbot = bbox->r_xbot + xi*dx;
area.r_ybot = bbox->r_ybot + yi*dy;
area.r_xtop = area.r_xbot + dx;
area.r_ytop = area.r_ybot + dy;
/* skip empty bins */
if(bpBinEmpty(ba,i)) continue;
/* open bin */
bpIndent(indent+2);
fprintf(stderr,"{bin {number %d} { bbox ",
i);
bpDumpRect(&area);
fprintf(stderr," }\n");
/* list bin contents */
if(bpBinType(ba,i) == BT_ARRAY)
{
/* dump sub array */
bpBinArrayDump( bpSubArray(ba,i),
indent+4);
}
else
{
/* list elements */
bpDumpElements(bpBinList(ba,i),indent+4);
}
/* close bin */
bpIndent(indent+2);
fprintf(stderr,"}\n");
}
}
/* oversized */
if(!bpBinEmpty(ba,numBins))
{
/* open oversized */
bpIndent(indent+2);
fprintf(stderr,"{oversized {bbox ");
bpDumpRect(bbox);
fprintf(stderr,"}\n");
/* list bin contents */
if(bpBinType(ba,numBins) == BT_ARRAY)
{
/* dump sub array */
bpBinArrayDump( bpSubArray(ba,numBins),
indent+4);
}
else
{
/* list elements */
bpDumpElements(bpBinList(ba,numBins),indent+4);
}
/* close oversized */
bpIndent(indent+2);
fprintf(stderr,"}\n");
}
/* close bin array */
bpIndent(indent);
fprintf(stderr,"}\n");
}
/*
* ----------------------------------------------------------------------------
* bpDump --
*
* dump bplane (for debugging)
*
* ----------------------------------------------------------------------------
*/
void bpDump(BPlane *bp, int flags)
{
fprintf(stderr, "======= BPLANE DUMP ======\n");
bpDumpFlags = flags;
/* open bplane */
fprintf(stderr,"{bplane {count %d} {bbox ",
bp->bp_count);
bpDumpRect(&bp->bp_bbox);
fprintf(stderr,"}\n");
/* list in box rects */
bpIndent(2);
fprintf(stderr,"{in_box\n");
bpDumpElements(bp->bp_inBox,4);
bpIndent(2);
fprintf(stderr,"}\n");
/*** bins ***/
bpIndent(2);
fprintf(stderr,"{binned {area ");
bpDumpRect(&bp->bp_binArea);
fprintf(stderr,"}\n");
if(bp->bp_rootNode) bpBinArrayDump(bp->bp_rootNode, 4);
bpIndent(2);
fprintf(stderr,"}\n");
/*** enums ***/
bpIndent(2);
fprintf(stderr,"{enums\n");
bpDumpEnums(bp->bp_enums,4);
bpIndent(2);
fprintf(stderr,"}\n");
/* close bplane */
fprintf(stderr,"}\n");
}

166
bplane/bpEnum.c Normal file
View File

@ -0,0 +1,166 @@
// ************************************************************************
//
// Copyright (c) 1995-2002 Juniper Networks, Inc. All rights reserved.
//
// Permission is hereby granted, without written agreement and without
// license or royalty fees, to use, copy, modify, and distribute this
// software and its documentation for any purpose, provided that the
// above copyright notice and the following three paragraphs appear in
// all copies of this software.
//
// IN NO EVENT SHALL JUNIPER NETWORKS, INC. BE LIABLE TO ANY PARTY FOR
// DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
// JUNIPER NETWORKS, INC. HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
// DAMAGE.
//
// JUNIPER NETWORKS, INC. SPECIFICALLY DISCLAIMS ANY WARRANTIES,
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
// NON-INFRINGEMENT.
//
// THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND JUNIPER
// NETWORKS, INC. HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
//
// ************************************************************************
/* bpEnum.c -
*
* Search routines for bplanes
*
*/
#include <stdio.h>
#include "utils/utils.h"
#include "database/database.h"
#include "utils/geometry.h"
#include "bplane/bplaneInt.h"
/*
* ----------------------------------------------------------------------------
* BPEnumInit --
*
* set up search.
*
* ----------------------------------------------------------------------------
*/
void BPEnumInit(BPEnum *bpe, /* enum to initialize */
BPlane *bp,
const Rect *area, /* search area */
int match,
const char *id) /* for debugging */
{
bool inside = FALSE;
bpe->bpe_plane = bp;
bpe->bpe_id = id;
bpe->bpe_match = match;
bpe->bpe_top = bpe->bpe_stack;
/*
fprintf(stderr,"DEBUG bpEnumInit, match=%d id=%s\n",
match, id);
*/
/* link enum to bplane */
bpe->bpe_next = bp->bp_enums;
bp->bp_enums = bpe;
switch (match)
{
case BPE_EQUAL:
GeoCanonicalRect(area, &bpe->bpe_srchArea);
bpe->bpe_nextElement = IHashLookUp(bp->bp_hashTable, &bpe->bpe_srchArea);
bpe->bpe_top->bps_state = BPS_HASH;
/* don't need to setup stack, just return */
return;
case BPE_ALL:
/* If we start 'INSIDE', no match checks will be done */
bpe->bpe_top->bps_state = BPS_BINS_INSIDE;
inside = TRUE;
break;
case BPE_TOUCH:
GeoCanonicalRect(area, &bpe->bpe_srchArea);
inside = GEO_SURROUND(&bpe->bpe_srchArea, &bp->bp_bbox);
if(inside)
{
bpe->bpe_top->bps_state = BPS_BINS_INSIDE;
}
else
{
bpe->bpe_top->bps_state = BPS_BINS;
bpe->bpe_subBinMinX = GEO_WIDTH(&bpe->bpe_srchArea)/2;
bpe->bpe_subBinMinY = GEO_HEIGHT(&bpe->bpe_srchArea)/2;
bpBinsUpdate(bp);
}
break;
case BPE_OVERLAP:
GeoCanonicalRect(area, &bpe->bpe_srchArea);
GEO_EXPAND(&bpe->bpe_srchArea, -1, &bpe->bpe_srchArea);
inside = GEO_SURROUND(&bpe->bpe_srchArea, &bp->bp_bbox);
if(inside)
{
bpe->bpe_top->bps_state = BPS_BINS_INSIDE;
}
else
{
bpe->bpe_top->bps_state = BPS_BINS;
bpe->bpe_subBinMinX = GEO_WIDTH(&bpe->bpe_srchArea)/2;
bpe->bpe_subBinMinY = GEO_HEIGHT(&bpe->bpe_srchArea)/2;
bpBinsUpdate(bp);
}
break;
default:
ASSERT(FALSE,"BPEnumInit, bad match value");
}
/* push rootnode */
if(bp->bp_rootNode)
{
bpEnumPush(bpe, bp->bp_rootNode, inside);
bpe->bpe_nextElement = NULL;
}
else
{
/* no bins, go straight to inbox */
bpe->bpe_top->bps_state = BPS_INBOX | inside;
bpe->bpe_nextElement = bp->bp_inBox;
}
}
/*
* ----------------------------------------------------------------------------
* BPEnumTerm --
*
* terminate enumeration
*
* ----------------------------------------------------------------------------
*/
void BPEnumTerm(BPEnum *bpe)
{
BPEnum **linkp;
/*
fprintf(stderr,"DEBUG bpEnumTerm, id=%s\n",
bpe->bpe_id);
*/
/* unlink */
linkp = &bpe->bpe_plane->bp_enums;
while(*linkp && *linkp != bpe) linkp = &(*linkp)->bpe_next;
ASSERT(*linkp==bpe,"BPEnumTerm");
*linkp = bpe->bpe_next;
}

537
bplane/bpEnum.h Normal file
View File

@ -0,0 +1,537 @@
// ************************************************************************
//
// Copyright (c) 1995-2002 Juniper Networks, Inc. All rights reserved.
//
// Permission is hereby granted, without written agreement and without
// license or royalty fees, to use, copy, modify, and distribute this
// software and its documentation for any purpose, provided that the
// above copyright notice and the following three paragraphs appear in
// all copies of this software.
//
// IN NO EVENT SHALL JUNIPER NETWORKS, INC. BE LIABLE TO ANY PARTY FOR
// DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
// JUNIPER NETWORKS, INC. HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
// DAMAGE.
//
// JUNIPER NETWORKS, INC. SPECIFICALLY DISCLAIMS ANY WARRANTIES,
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
// NON-INFRINGEMENT.
//
// THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND JUNIPER
// NETWORKS, INC. HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
//
// ************************************************************************
#ifndef _MAGIC__BPLANE__BPENUM_H
#define _MAGIC__BPLANE__BPENUM_H
/* bpEnum.h --
*
* inlined Search routines for bplanes (see also bpEnum.c)
*
*/
#include <stdio.h>
#include "utils/utils.h"
#include "utils/geometry.h"
#include "utils/geofast.h"
#include "bplane/bplane.h"
#include "bplane/bplaneInt.h"
extern void DumpRect(char *msg, Rect *r);
/* state machine states */
#define BPS_BINS 0
#define BPS_BINS_INSIDE 1
#define BPS_INBOX 2
#define BPS_INBOX_INSIDE 3
#define BPS_HASH 4
#define BPS_DONE 5
/* range code */
#define R_LEFT 1
#define R_RIGHT 2
#define R_BOT 4
#define R_TOP 8
/*
* ----------------------------------------------------------------------------
*
* bpBinArea -- compute area covered by given bin.
*
* Returns: bin area.
*
* ----------------------------------------------------------------------------
*/
static __inline__ Rect bpBinArea(BinArray *ba, int i)
{
int dimX = ba->ba_dimX;
int dx = ba->ba_dx;
int dy = ba->ba_dy;
int xi = i % dimX;
int yi = i / dimX;
Rect area;
area.r_xbot = ba->ba_bbox.r_xbot + dx*xi;
area.r_ybot = ba->ba_bbox.r_ybot + dy*yi;
area.r_xtop = area.r_xbot + dx;
area.r_ytop = area.r_ybot + dy;
return area;
}
/*
* ----------------------------------------------------------------------------
* bpEnumRange --
*
* Determine which edges of search area bin overlaps.
*
* (Used to make match checks as efficient as possible, for example if bin
* does not extend past srch area in any direction, no match checking is
* required)
*
* Returns: int encoding 'range'.
*
* ----------------------------------------------------------------------------
*/
static __inline__ int
bpEnumRange(Rect *bin, Rect *srch)
{
int range = 0;
if (bin->r_xbot < srch->r_xbot) range |= R_LEFT;
if (bin->r_xtop > srch->r_xtop) range |= R_RIGHT;
if (bin->r_ybot < srch->r_ybot) range |= R_BOT;
if (bin->r_ytop > srch->r_ytop) range |= R_TOP;
return range;
}
/*
* ----------------------------------------------------------------------------
* bpEnumMatchQ -
*
* Check if element intersects search area
*
* range specifies which search area boundaries the element
* can potentially extend beyond.
*
* We rely on the optimizing compiler to remove unnecessary checks
* based on compile time knowledge of range value.
*
* Returns: TRUE on match, FALSE otherwise.
*
* ----------------------------------------------------------------------------
*/
static __inline__ bool
bpEnumMatchQ(BPEnum *bpe, Element *e)
{
Rect *area = &bpe->bpe_srchArea;
Rect *r = &e->e_rect;
if(r->r_xtop < area->r_xbot) return FALSE;
if(r->r_xbot > area->r_xtop) return FALSE;
if(r->r_ytop < area->r_ybot) return FALSE;
if(r->r_ybot > area->r_ytop) return FALSE;
return TRUE;
}
/*
* ----------------------------------------------------------------------------
* bpEnumPushInside --
*
* called by bpEnumPush when the binarray is entirely inside the search area
*
* push a bin array onto an enum stack.
*
* ----------------------------------------------------------------------------
*/
static __inline__ bool bpEnumPushInside(BPEnum *bpe,
BinArray *ba)
{
BPStack *bps;
/* push stack */
++bpe->bpe_top;
bps = bpe->bpe_top;
bps->bps_node = ba;
bps->bps_state = BPS_BINS_INSIDE;
/* set up indices to scan entire bin array */
bps->bps_i = -1;
bps->bps_max = ba->ba_numBins;
return TRUE;
}
/*
* ----------------------------------------------------------------------------
* bpEnumPush --
*
* push a bin array onto an enum stack.
*
* normally returns TRUE, returns FALSE on (possible) state change.
*
* ----------------------------------------------------------------------------
*/
static __inline__ bool bpEnumPush(BPEnum *bpe,
BinArray *ba,
bool inside)
{
Rect area;
Rect *bbox;
int dx;
int dy;
BPStack *bps;
/*
fprintf(stderr,"DEBUG bpEnumPush, inside=%d\n", inside);
*/
/* special case inside */
if(inside) return bpEnumPushInside(bpe,ba);
bbox = &ba->ba_bbox;
if(GEO_SURROUND(&bpe->bpe_srchArea,bbox))
{
bpEnumPushInside(bpe,ba);
return FALSE; /* state change */
}
/* push stack */
++bpe->bpe_top;
bps = bpe->bpe_top;
bps->bps_node = ba;
bps->bps_state = BPS_BINS;
bps->bps_subbin = FALSE;
bps->bps_rejects = 0;
/* compute search area for this bin array */
dx = ba->ba_dx;
dy = ba->ba_dy;
area.r_xbot = bpe->bpe_srchArea.r_xbot - dx;
area.r_xtop = bpe->bpe_srchArea.r_xtop + 1;
area.r_ybot = bpe->bpe_srchArea.r_ybot - dy;
area.r_ytop = bpe->bpe_srchArea.r_ytop + 1;
GEOCLIP(&area,bbox);
if(GEO_RECTNULL(&area))
{
/* only need to check oversized */
bps->bps_i = 0;
bps->bps_rowMax = 0;
bps->bps_max = 0;
}
else
{
/* setup indices for this array and search area */
int dimX = ba->ba_dimX;
int i;
/* make area relative to bin bbox */
area.r_xbot -= bbox->r_xbot;
area.r_xtop -= bbox->r_xbot;
area.r_ybot -= bbox->r_ybot;
area.r_ytop -= bbox->r_ybot;
/* DumpRect("area relative to bin bbox = ",&area); */
area.r_xbot /= ba->ba_dx;
area.r_xtop /= ba->ba_dx;
area.r_ybot /= ba->ba_dy;
area.r_ytop /= ba->ba_dy;
i = area.r_ybot*dimX + area.r_xbot; /* next index */
bps->bps_i = i-1;
bps->bps_rowMax = i + area.r_xtop - area.r_xbot;
bps->bps_max = area.r_ytop*dimX + area.r_xtop;
bps->bps_rowDelta = dimX + area.r_xbot - area.r_xtop;
bps->bps_dimX = dimX;
/* consider subbinning? */
if(dx >= bpe->bpe_subBinMinX || dy >= bpe->bpe_subBinMinY)
{
bps->bps_subbin = TRUE;
}
}
return TRUE;
}
/*
* ----------------------------------------------------------------------------
* bpEnumNextBin1 --
*
* called by bpEnumNextBin() after indexes for new bin are setup
*
* returns: normally returns TRUE, returns FALSE on state change.
*
* ----------------------------------------------------------------------------
*/
static __inline__ bool
bpEnumNextBin1(BPEnum *bpe, BPStack *bps, bool inside)
{
if(bpBinType(bps->bps_node,bps->bps_i) != BT_ARRAY)
{
bpe->bpe_nextElement = bpBinList(bps->bps_node,bps->bps_i);
return TRUE;
}
/* array, push into it */
return bpEnumPush(bpe, bpSubArray(bps->bps_node,bps->bps_i), inside);
}
/*
* ----------------------------------------------------------------------------
* bpEnumNextBin --
*
* called by bpEnumNextBINS to advance to next bin (bucket).
*
* cycles through normal bins first, then oversized,
* finally, for toplevel, sets INBOX state.
*
* sets bpe->bpe_nextElement to first element in next bin.
*
* returns: normally returns TRUE, returns FALSE on state change.
*
* ----------------------------------------------------------------------------
*/
static __inline__ bool
bpEnumNextBin(BPEnum *bpe, bool inside)
{
BPStack *bps = bpe->bpe_top;
#ifdef BPARANOID
ASSERT(bps,"bpEnumNextBin");
ASSERT(!bpe->bpe_nextElement,"bpEnumNextBin");
#endif
/*
fprintf(stderr,"DEBUG bpEnumNextBin TOP inside=%d nextElement=%x\n",
inside, bpe->bpe_nextElement);
*/
/* consider subbining this bin before advancing to next */
if(!inside)
{
if(bps->bps_rejects >= bpMinBAPop
&& (bps->bps_subbin || bps->bps_i == bps->bps_node->ba_numBins))
{
int i = bps->bps_i;
BinArray *ba = bps->bps_node;
BinArray *sub;
/* fprintf(stderr,"DEBUG, subbining!\n"); */
sub = bpBinArrayBuild(bpBinArea(ba,i),
bpBinList(ba,i),
FALSE); /* don't recursively subbin! */
if(sub)
{
ba->ba_bins[i] =
(void *) ((pointertype) sub | BT_ARRAY);
}
}
bps->bps_rejects = 0;
}
/* handle inside case first */
if(inside)
{
/* Inside case, cycle through all bins */
/* next bin */
if(bps->bps_i<bps->bps_max)
{
bps->bps_i += 1;
return bpEnumNextBin1(bpe,bps,inside);
}
}
else
{
/* cycle only through relevant bins */
/* next in row */
if(bps->bps_i<bps->bps_rowMax)
{
bps->bps_i += 1;
goto bin;
}
/* next row */
if(bps->bps_i<bps->bps_max)
{
bps->bps_i += bps->bps_rowDelta;
bps->bps_rowMax += bps->bps_dimX;
goto bin;
}
/* oversized */
if(bps->bps_i == bps->bps_max)
{
bps->bps_i = bps->bps_node->ba_numBins;
goto bin;
}
}
/* pop stack */
/* fprintf(stderr,"DEBUG BPEnumNextBin Pop.\n"); */
bpe->bpe_top--;
if(bpe->bpe_top>bpe->bpe_stack) return FALSE; /* state may have changed */
/* inbox */
/* fprintf(stderr,"DEBUG BPEnumNextBin INBOX.\n"); */
bpe->bpe_nextElement = bpe->bpe_plane->bp_inBox;
bpe->bpe_top->bps_state = BPS_INBOX | inside;
return FALSE; /* state change */
/* dive into indexed bin */
bin:
return bpEnumNextBin1(bpe,bps,inside);
}
/*
* ----------------------------------------------------------------------------
* bpEnumNextBINS --
*
* Handle BINS state for BPEnumNext()
*
* (bin enumeration.)
*
* ----------------------------------------------------------------------------
*/
static __inline__ Element* bpEnumNextBINS(BPEnum *bpe, bool inside)
{
/* bin by bin */
do
{
/* search this bin */
Element *e = bpe->bpe_nextElement;
while(e && !inside && !bpEnumMatchQ(bpe,e))
{
bpe->bpe_top->bps_rejects++;
e = e->e_link;
}
if(e)
{
bpe->bpe_nextElement = e->e_link;
/* DumpRect("DEBUG e_rect= ",&e->e_rect); */
return e;
}
bpe->bpe_nextElement = NULL;
}
while(bpEnumNextBin(bpe,inside));
/* next state */
return NULL;
}
/*
* ----------------------------------------------------------------------------
* bpEnumNextINBOX --
*
* Handle INBOX states for BPEnumNext()
*
* unbinned enumeration.
*
* ----------------------------------------------------------------------------
*/
static __inline__ Element *bpEnumNextINBOX(BPEnum *bpe,
bool inside)
{
Element *e = bpe->bpe_nextElement;
while(e && !inside && !bpEnumMatchQ(bpe,e)) e = e->e_link;
if(e)
{
bpe->bpe_nextElement = e->e_link;
return e;
}
/* done */
bpe->bpe_top->bps_state = BPS_DONE;
return NULL;
}
/*
* ----------------------------------------------------------------------------
* bpEnumNextHASH --
*
* Handle HASH state for BPEnumNext()
*
* (hash based (EQUALS) enumerations.)
*
* ----------------------------------------------------------------------------
*/
static __inline__ Element *bpEnumNextHASH(BPEnum *bpe)
{
Element *e = bpe->bpe_nextElement;
if(e)
{
bpe->bpe_nextElement =
IHashLookUpNext(bpe->bpe_plane->bp_hashTable, e);
}
else
{
bpe->bpe_top->bps_state = BPS_DONE;
}
return e;
}
/*
* ----------------------------------------------------------------------------
* BPEnumNext --
*
* get next element in enumeration.
*
* ----------------------------------------------------------------------------
*/
static __inline__ void *BPEnumNext(BPEnum *bpe)
{
Element *e;
while(TRUE)
{
/*
fprintf(stderr,"DEBUG state=%d\n",bpe->bpe_top->bps_state);
*/
switch (bpe->bpe_top->bps_state)
{
case BPS_BINS:
if((e=bpEnumNextBINS(bpe, 0))) return e;
break;
case BPS_BINS_INSIDE:
if((e=bpEnumNextBINS(bpe, 1))) return e;
break;
case BPS_INBOX:
if((e=bpEnumNextINBOX(bpe, 0))) return e;
break;
case BPS_INBOX_INSIDE:
if((e=bpEnumNextINBOX(bpe, 1))) return e;
break;
case BPS_HASH:
if((e=bpEnumNextHASH(bpe))) return e;
break;
case BPS_DONE:
return NULL;
default:
ASSERT(FALSE,"BPEnumNext, bad state");
}
}
}
#endif /* _MAGIC__BPLANE__BPENUM_H */

280
bplane/bpMain.c Normal file
View File

@ -0,0 +1,280 @@
// ************************************************************************
//
// Copyright (c) 1995-2002 Juniper Networks, Inc. All rights reserved.
//
// Permission is hereby granted, without written agreement and without
// license or royalty fees, to use, copy, modify, and distribute this
// software and its documentation for any purpose, provided that the
// above copyright notice and the following three paragraphs appear in
// all copies of this software.
//
// IN NO EVENT SHALL JUNIPER NETWORKS, INC. BE LIABLE TO ANY PARTY FOR
// DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
// JUNIPER NETWORKS, INC. HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
// DAMAGE.
//
// JUNIPER NETWORKS, INC. SPECIFICALLY DISCLAIMS ANY WARRANTIES,
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
// NON-INFRINGEMENT.
//
// THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND JUNIPER
// NETWORKS, INC. HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
//
// ************************************************************************
/* bpMain.c
*
* Top-level routines for BPlanes
* (interface to other modules)
*
* See bpEnum.c for enum routines.
* See bpTcl.c for tcl-level interface.
*/
#include <stdio.h>
#include <stddef.h>
#include "utils/utils.h"
#include "utils/malloc.h"
#include "database/database.h"
#include "textio/textio.h"
#include "utils/geometry.h"
#include "bplane/bplaneInt.h"
/*
* ----------------------------------------------------------------------------
* BPNew --
*
* Return newly created BPlane.
*
* ----------------------------------------------------------------------------
*/
BPlane *BPNew(void)
{
BPlane *new;
new = (BPlane *)mallocMagic(sizeof(BPlane));
new->bp_bbox = GeoNullRect;
new->bp_bbox_exact = TRUE;
new->bp_count = 0;
/* ENUMS */
new->bp_enums = NULL;
/* HASH TABLE */
new->bp_hashTable = IHashInit(4, /* initial buckets */
offsetof(Element, e_rect), /* key */
offsetof(Element, e_hashLink),
IHash4WordKeyHash,
IHash4WordKeyEq);
/* IN BOX */
new->bp_inBox = NULL;
/* BINS */
new->bp_binLife = 0;
new->bp_inAdds = 0;
new->bp_binArea = GeoNullRect;
new->bp_rootNode = NULL;
return new;
}
/*
* ----------------------------------------------------------------------------
* BPFree --
*
* free (empty) BPlane
*
* ----------------------------------------------------------------------------
*/
void BPFree(BPlane *bp)
{
ASSERT(bp->bp_count == 0,"BPFree");
IHashFree(bp->bp_hashTable);
freeMagic((char *)bp);
}
/*
* ----------------------------------------------------------------------------
* BPAdd --
*
* Add element to the given bplane
*
* NOTE: e_rect better be canonical!
*
* ----------------------------------------------------------------------------
*/
void BPAdd(BPlane *bp, void *element)
{
int size;
int binDim;
Element * e = element;
Rect *r = &e->e_rect;
/* Don't allow adds during active enumerations.
* This is confusing, since newly added elements may or may not
* be enumerated in on going enumerations, is not particularly
* useful, since elements to add can just be stored up on a local
* list and added after the enumeration completes.
*/
ASSERT(!bp->bp_enums,
"BPAdd, attempted during active enumerations");
/* element rect must be canonical! */
#ifdef BPARANOID
ASSERT(GeoIsCanonicalRect(r),"BPAdd, rect must be canonical.");
#endif
bp->bp_count++;
/* update hash table */
IHashAdd(bp->bp_hashTable, element);
/* update bbox */
if(bp->bp_count == 1)
{
bp->bp_bbox = *r;
}
else
{
GeoIncludeRectInBBox(r,&bp->bp_bbox);
}
/* no bins? */
if(!bp->bp_rootNode) goto inBox;
/* doesn't fit inside bins ? */
if(!GEO_SURROUND(&bp->bp_binArea,r)) goto inBox;
/* bin element */
bpBinAdd(bp->bp_rootNode, e);
return;
/* add to in box */
inBox:
bp->bp_inAdds++;
e->e_link = bp->bp_inBox;
bp->bp_inBox = e;
/* maintain back pointers */
e->e_linkp = &bp->bp_inBox;
if(e->e_link) e->e_link->e_linkp = &e->e_link;
}
/*
* ----------------------------------------------------------------------------
* BPDelete --
*
* remove element from bplane
*
* ----------------------------------------------------------------------------
*/
void BPDelete(BPlane *bp, void *element)
{
Element *e = element;
ASSERT(e,"BPDelete");
if (bp->bp_count == 0)
{
TxError("Error: Attempt to delete instance from empty cell!\n");
return;
}
bp->bp_count--;
/* if element was on edge of bbox, bbox may no longer
* be exact.
*/
if(bp->bp_bbox_exact &&
(bp->bp_bbox.r_xbot == e->e_rect.r_xbot ||
bp->bp_bbox.r_xtop == e->e_rect.r_xtop ||
bp->bp_bbox.r_ybot == e->e_rect.r_ybot ||
bp->bp_bbox.r_ytop == e->e_rect.r_ytop))
{
bp->bp_bbox_exact = FALSE;
}
/* advance any nextElement pointers at e */
{
BPEnum *bpe;
for(bpe=bp->bp_enums; bpe; bpe=bpe->bpe_next)
{
if(bpe->bpe_nextElement != e) continue;
if(bpe->bpe_match == BPE_EQUAL)
{
bpe->bpe_nextElement = IHashLookUpNext(bp->bp_hashTable, e);
}
else
{
bpe->bpe_nextElement = e->e_link;
}
}
}
IHashDelete(bp->bp_hashTable, e);
/* next pointer of prev element */
*e->e_linkp = e->e_link;
/* back pointer of next element */
if(e->e_link) e->e_link->e_linkp = e->e_linkp;
}
/*
* ----------------------------------------------------------------------------
* BPBBox --
*
* Get current bplane bbox.
*
* returns: current bplane bbox
* (returns an inverted rect, if bplane is empty)
*
* ----------------------------------------------------------------------------
*/
Rect BPBBox(BPlane *bp)
{
if(bp->bp_count == 0) return GeoInvertedRect;
/* if bbox is not up-to-date, recompute */
if(!bp->bp_bbox_exact)
{
BPEnum bpe;
Element *e;
bp->bp_bbox_exact = TRUE;
BPEnumInit(&bpe,
bp,
NULL,
BPE_ALL,
"BPBBox");
e = BPEnumNext(&bpe);
bp->bp_bbox = e->e_rect;
while((e = BPEnumNext(&bpe)))
{
GeoIncludeRectInBBox(&e->e_rect, &bp->bp_bbox);
}
}
return bp->bp_bbox;
}

195
bplane/bpOpaque.h Normal file
View File

@ -0,0 +1,195 @@
// ************************************************************************
//
// Copyright (c) 1995-2002 Juniper Networks, Inc. All rights reserved.
//
// Permission is hereby granted, without written agreement and without
// license or royalty fees, to use, copy, modify, and distribute this
// software and its documentation for any purpose, provided that the
// above copyright notice and the following three paragraphs appear in
// all copies of this software.
//
// IN NO EVENT SHALL JUNIPER NETWORKS, INC. BE LIABLE TO ANY PARTY FOR
// DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
// JUNIPER NETWORKS, INC. HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
// DAMAGE.
//
// JUNIPER NETWORKS, INC. SPECIFICALLY DISCLAIMS ANY WARRANTIES,
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
// NON-INFRINGEMENT.
//
// THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND JUNIPER
// NETWORKS, INC. HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
//
// ************************************************************************
#ifndef _MAGIC__BPLANE__BPOPAQUE_H
#define _MAGIC__BPLANE__BPOPAQUE_H
#ifndef _MAGIC__UTILS__IHASH_H
#include "utils/ihash.h"
#endif
/*
* bpOpaque.h --
*
* This file contains strucs directly or indirectly referenced by
* clients of bplane module, whose internals should be treated
* as opaque by clients.
*
* It is included by bplane.h
*
*/
/* data element, stored in BPlane
*
* Storage managed by caller.
* Inital part must correspond to below.
*/
typedef struct element
{
struct element *e_hashLink;
struct element *e_link;
struct element **e_linkp; /* back pointer for quick deletes */
Rect e_rect;
/* client data goes here */
} Element;
/* number of link fields in element
*
* user code should not depend on more than 1 link.
* (and should only use/ref that link when element is not in a bplane)
*/
#define BP_NUM_LINKS 3
/* bin array */
typedef struct binarray
{
Rect ba_bbox; /* area covered by array */
int ba_dx; /* dimensions of a single bin */
int ba_dy;
int ba_dimX; /* number of bins in a row */
int ba_numBins; /* number of regular bins (size of array - 1) */
void *ba_bins[1]; /* low order bit(s) used to encode type info.
* DON'T ACCESS DIRECTLY, USE MACROS BELOW
*
* (last bin is for oversized)
*/
} BinArray;
/* bin types
*
* NOTE: its important that simple lists have type 0, i.e. are
* just standard pointers. This is so that the list head
* 'link' can be treated just as any other link, during
* deletion etc.
*/
#define BT_TYPE_MASK 1
#define BT_LIST 0
#define BT_ARRAY 1
static __inline__ bool bpBinEmpty(BinArray *ba, int i)
{
return ba->ba_bins[i] == NULL;
}
static __inline__ bool bpBinType(BinArray *ba, int i)
{
return (bool) (((pointertype) ba->ba_bins[i]) & BT_TYPE_MASK);
}
static __inline__ Element *bpBinList(BinArray *ba, int i)
{
#ifdef BPARANOID
ASSERT(bpBinType(ba,i)==BT_LIST,"bpBinList");
#endif
return (Element *) ba->ba_bins[i];
}
static __inline__ Element **bpBinListHead(BinArray *ba, int i)
{
#ifdef BPARANOID
ASSERT(bpBinType(ba,i)==BT_LIST,"bpBinList");
#endif
return (Element **) &ba->ba_bins[i];
}
static __inline__ BinArray *bpSubArray(BinArray *ba, int i)
{
#ifdef BPARANOID
ASSERT(bpBinType(ba,i)==BT_ARRAY,"bpSubArray");
#endif
return (BinArray *) ((pointertype) ba->ba_bins[i] & ~BT_TYPE_MASK);
}
/* BPlane - toplevel struc */
typedef struct bplane
{
Rect bp_bbox; /* bbox (bin + in) */
bool bp_bbox_exact; /* if set bp_bbox, is exact,
* if reset bp_bbox may be over-sized.
*/
int bp_count; /* total number of elements in bplane */
struct bpenum *bp_enums; /* list of active enums */
/* HASH TABLE */
IHashTable *bp_hashTable; /* hash table
* (for expediting BP_EQUAL searches) */
/* IN BOX */
Element *bp_inBox; /* elements not yet added to bin system */
/* BINS */
int bp_binLife; /* set to binCount when bin system
* built, decremented on add/delete ops.
* bin system rebuilt when zero reached.
*/
int bp_inAdds; /* additions to inBox since last rebuild */
Rect bp_binArea; /* area covered by bin arrays */
BinArray *bp_rootNode; /* top bin node */
} BPlane;
/* context for BPlane enumeration */
typedef struct bpStack
{
int bps_state; /* where we are at rolled in one convenient
* number (see BPS_* defs in bpEnum.h)
*/
BinArray *bps_node; /* current bin array */
int bps_i; /* current index */
int bps_rowMax; /* max index for this row */
int bps_rowDelta; /* increment from end of one row to beginning
* of next.
*/
int bps_max; /* max index */
int bps_dimX; /* row length */
bool bps_subbin; /* if set consider subbinning */
int bps_rejects; /* number of unmatching elements in current
* bin, used to decide when to subbin.
*/
} BPStack;
/* enumeration 'handle' */
typedef struct bpenum
{
struct bpenum *bpe_next; /* all enums for bplane linked together */
BPlane *bpe_plane; /* plane being searched */
Rect bpe_srchArea; /* area being searched */
int bpe_match; /* match criteria */
const char *bpe_id; /* for debug */
int bpe_subBinMinX;
int bpe_subBinMinY; /* consider subbinning
* for bins bigger than this.
*/
Element *bpe_nextElement; /* next element in current list */
BPStack *bpe_top; /* top of stack */
BPStack bpe_stack[10000]; /* stack for tree traversal during enum */
} BPEnum;
#endif /* _MAGIC__BPLANE__BPOPAQUE_H */

304
bplane/bpStat.c Normal file
View File

@ -0,0 +1,304 @@
// ************************************************************************
//
// Copyright (c) 1995-2002 Juniper Networks, Inc. All rights reserved.
//
// Permission is hereby granted, without written agreement and without
// license or royalty fees, to use, copy, modify, and distribute this
// software and its documentation for any purpose, provided that the
// above copyright notice and the following three paragraphs appear in
// all copies of this software.
//
// IN NO EVENT SHALL JUNIPER NETWORKS, INC. BE LIABLE TO ANY PARTY FOR
// DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
// JUNIPER NETWORKS, INC. HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
// DAMAGE.
//
// JUNIPER NETWORKS, INC. SPECIFICALLY DISCLAIMS ANY WARRANTIES,
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
// NON-INFRINGEMENT.
//
// THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND JUNIPER
// NETWORKS, INC. HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
//
// ************************************************************************
/* bpStat.c
*
* routines to get bplane statistics.
*
*/
#include <stdio.h>
#include <limits.h>
#include "utils/utils.h"
#include "database/database.h"
#include "utils/geometry.h"
#include "bplane/bplaneInt.h"
/*
* ----------------------------------------------------------------------------
* bpCount --
*
* count list of elements.
*
* Returns size of list.
*
* ----------------------------------------------------------------------------
*/
int bpCount(Element *e)
{
int i = 0;
while(e)
{
i++;
e = e->e_link;
}
return i;
}
/*
* ----------------------------------------------------------------------------
* bpStatBA --
*
* compute bin array statistics.
* (includes sub-arrays)
*
*
* Returns memory used by bplane (excluding elements)
*
* ----------------------------------------------------------------------------
*/
unsigned int bpStatBA(BinArray *ba,
int *totCount, /* total number of elements */
int *totBins, /* ret tot num of bins */
int *emptyBins, /* ret num of empty bins */
int *binArraysp, /* ret num of bin arrays */
int *maxEffp, /* ret max effective list length */
int *maxBinCount, /* ret max count for regular bin */
int *totUnbinned, /* ret tot num of e's not binned */
int *maxDepth) /* ret max bin array depth */
{
Rect *bbox = &ba->ba_bbox;
int dx = ba->ba_dx;
int dy = ba->ba_dy;
int numBins = ba->ba_numBins;
int dimX = ba->ba_dimX;
int dimY = numBins/dimX;
int w = GEO_WIDTH(bbox);
int h = GEO_HEIGHT(bbox);
/* initial statistics */
unsigned int mem = 0;
int tot = 0;
int bins = 0;
int emptys = 0;
int binArrays = 1;
int maxCount = 0;
int maxEff = 0;
int maxEffSub = 0;
int maxSubCount = 0;
int unbinned = 0;
int depth = 1;
int maxDepthSub = 0;
int i;
/* add bins in this array */
bins += numBins;
/* add memory usage for this array (sub arrays already tabulated) */
if(ba) mem += sizeof(BinArray) + numBins*sizeof(void*);
/* gather stats bin by bin */
for(i=0;i<numBins;i++)
{
if(bpBinType(ba,i) != BT_ARRAY)
{
/* simple bin */
int count = bpCount(bpBinList(ba,i));
tot += count;
if(count>maxCount) maxCount = count;
if(count==0) emptys++;
}
else
{
/* arrayed, recurse */
int sMem, sTot, sBins, sEmptys, sBinArrays;
int sMaxEff, sMaxCount, sUnbinned, sDepth;
sMem = bpStatBA(bpSubArray(ba,i),
&sTot, /* total number of elements */
&sBins, /* ret tot num of bins */
&sEmptys, /* ret num of empty bins */
&sBinArrays, /* ret num bin arrays */
&sMaxEff, /* ret max effective list length */
&sMaxCount, /* ret max count for regular bin */
&sUnbinned, /* ret tot num of e's not binned */
&sDepth); /* ret max bin array depth */
mem += sMem;
tot += sTot;
bins += sBins;
emptys += sEmptys;
binArrays += sBinArrays;
if(sMaxEff > maxEffSub) maxEffSub = sMaxEff;
if(sMaxCount > maxCount) maxCount = sMaxCount;
if(sUnbinned > maxCount) maxCount = sUnbinned;
if(sDepth > maxDepthSub) maxDepthSub = sDepth;
}
}
maxEff += MAX(maxCount,maxEffSub);
depth += maxDepthSub;
/* oversized */
if(bpBinType(ba,numBins) != BT_ARRAY)
{
/* oversized unbinned */
int over = bpCount(bpBinList(ba,numBins));
tot += over;
unbinned += over;
maxEff += over;
}
else
{
/* oversized is arrayed, recurse */
int sMem, sTot, sBins, sEmptys, sBinArrays;
int sMaxEff, sMaxCount, sUnbinned, sDepth;
sMem = bpStatBA(bpSubArray(ba,numBins),
&sTot, /* total number of elements */
&sBins, /* ret tot num of bins */
&sEmptys, /* ret num of empty bins */
&sBinArrays, /* ret num bin arrays */
&sMaxEff, /* ret max effective list length */
&sMaxCount, /* ret max count for regular bin */
&sUnbinned, /* ret tot num of e's not binned */
&sDepth); /* ret max bin array depth */
mem += sMem;
tot += sTot;
bins += sBins;
emptys += sEmptys;
binArrays += sBinArrays;
maxEff += sMaxEff;
if(sMaxCount > maxCount) maxCount = sMaxCount;
unbinned += sUnbinned;
depth += sDepth;
}
/* set results */
if(totCount) *totCount = tot;
if(totBins) *totBins = bins;
if(emptyBins) *emptyBins = emptys;
if(binArraysp) *binArraysp = binArrays;
if(maxEffp) *maxEffp = maxEff;
if(maxBinCount) *maxBinCount = maxCount;
if(totUnbinned) *totUnbinned = unbinned;
if(maxDepth) *maxDepth = depth;
return mem;
}
/*
* ----------------------------------------------------------------------------
* BPStat --
*
* compute bplane statistics.
*
* Returns memory used by bplane (excluding elements)
*
* ----------------------------------------------------------------------------
*/
unsigned int BPStat(BPlane *bp,
int *totCount, /* total number of elements */
int *inBox, /* ret num of elements in inBox */
int *totBins, /* ret tot num of bins */
int *emptyBins, /* ret num of empty bins */
int *binArraysp, /* ret tot num of bin arrays */
int *maxEffp, /* ret max effective list length */
int *maxBinCount, /* ret max count for regular bin */
int *totUnbinned, /* ret tot num of e's not binned */
int *maxDepth) /* ret max bin array depth */
{
BinArray *ba = bp->bp_rootNode;
int numBins;
unsigned int mem = 0;
int tot = 0;
int bins = 0;
int emptys = 0;
int binArrays = 0;
int maxEff = 0;
int maxCount = 0;
int unbinned = 0;
int depth = 0;
int in;
/* bin arrays */
if(ba)
{
mem += bpStatBA(bp->bp_rootNode,
&tot, /* total number of elements */
&bins, /* ret tot num of bins */
&emptys, /* ret tot num of empty bins */
&binArrays, /* ret tot num of bin arrays */
&maxEff, /* ret max effective list length */
&maxCount, /* ret max count for regular bin */
&unbinned, /* ret tot num of e's not binned */
&depth); /* ret max bin array depth */
}
/* inbox */
in = bpCount(bp->bp_inBox);
tot += in;
maxEff += in;
unbinned += in;
/* add in memory usage for bplane */
mem += sizeof(BPlane);
mem += IHashStats2(bp->bp_hashTable,NULL,NULL);
/* set results */
if(totCount) *totCount = tot;
if(inBox) *inBox = in;
if(totBins) *totBins = bins;
if(emptyBins) *emptyBins = emptys;
if(binArraysp) *binArraysp = binArrays;
if(maxEffp) *maxEffp = maxEff;
if(maxBinCount) *maxBinCount = maxCount;
if(totUnbinned) *totUnbinned = unbinned;
if(maxDepth) *maxDepth = depth;
return mem;
}
/*
* ----------------------------------------------------------------------------
* BPStatMemory --
*
* returns memory usage of BPlane in bytes
* (exclusive of elements contained by the BPlane)
*
* ----------------------------------------------------------------------------
*/
unsigned int BPStatMemory(BPlane *bp)
{
return BPStat(bp,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL);
}

361
bplane/bpTest.c Normal file
View File

@ -0,0 +1,361 @@
// ************************************************************************
//
// Copyright (c) 1995-2002 Juniper Networks, Inc. All rights reserved.
//
// Permission is hereby granted, without written agreement and without
// license or royalty fees, to use, copy, modify, and distribute this
// software and its documentation for any purpose, provided that the
// above copyright notice and the following three paragraphs appear in
// all copies of this software.
//
// IN NO EVENT SHALL JUNIPER NETWORKS, INC. BE LIABLE TO ANY PARTY FOR
// DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
// JUNIPER NETWORKS, INC. HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
// DAMAGE.
//
// JUNIPER NETWORKS, INC. SPECIFICALLY DISCLAIMS ANY WARRANTIES,
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
// NON-INFRINGEMENT.
//
// THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND JUNIPER
// NETWORKS, INC. HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
//
// ************************************************************************
/* bpTest.c
*
* (regression) tests of bplane code
*
*/
#include <stdio.h>
#include <stdlib.h>
#include "utils.h"
#include "message.h"
#include "database.h"
#include "geometry.h"
#include "bplane.h"
#include "bplaneInt.h"
#include "debug.h"
#include "cifInt.h"
/*
* elements used by test code.
*/
typedef struct rectc
{
struct rectc *rc_links[BP_NUM_LINKS];
Rect rc_rect;
} RectC;
/*
* ----------------------------------------------------------------------------
* bpRand --
* generate a random int in given range.
*
* side effects: sets coords of input rect.
* ----------------------------------------------------------------------------
*/
int bpRand(int min, int max)
{
double f = rand()/ (double) RAND_MAX; /* random number in unit interval */
return min + (int) ((max-min+1)*f);
}
/*
* ----------------------------------------------------------------------------
* bpTestRandRect --
* generate a random unit rectangle inside bbox
*
* side effects: sets coords of input rect.
* ----------------------------------------------------------------------------
*/
static void bpTestRandRect(Rect *r, Rect *bbox)
{
r->r_xbot = bpRand(bbox->r_xbot,bbox->r_xtop-1);
r->r_ybot = bpRand(bbox->r_ybot,bbox->r_ytop-1);
r->r_xtop = r->r_xbot+1;
r->r_ytop = r->r_ybot+1;
}
/* ====== GOLD snow test.
* ====== linked list implementation (to determine 'right' answer)
*/
/*
* ----------------------------------------------------------------------------
* bpTestIntersectGold --
*
* check whether rc intersects list
* ----------------------------------------------------------------------------
*/
static bool bpTestIntersectGold(RectC *rc, RectC *list)
{
while(list)
{
if(GEO_TOUCH(&rc->rc_rect,&list->rc_rect)) return TRUE;
list=list->rc_links[0];
}
return FALSE;
}
/*
* ----------------------------------------------------------------------------
* bpTestSnowGold --
* populate square of dimension 'size' with non-overlapping random unit
* rectangles. Keep adding rectangles until failures exceed successes.
* (stop when maxFailures reached.)
*
* coded with simple linked list.
*
* ---------------------------------------------------------------------------- */
void bpTestSnowGold(int size, bool trace)
{
int failures = 0;
int successes = 0;
int i = 0;
int crc = 0;
RectC *result = NULL;
RectC *rc = NULL;
Rect area;
fprintf(stderr,"BEGIN Snow GOLD, size=%d\n", size);
/* set up area */
area.r_xbot = 0;
area.r_ybot = 0;
area.r_xtop = size;
area.r_ytop = size;
while(failures<=successes)
{
i++;
if(!rc) rc = MALLOC_TAG(RectC *,rc, sizeof(RectC), "RectC");
bpTestRandRect(&rc->rc_rect, &area);
if(!bpTestIntersectGold(rc,result))
{
if(trace) DumpRect("success ",&rc->rc_rect);
crc ^= i+ 3*rc->rc_rect.r_xbot+ 5*rc->rc_rect.r_ybot;
rc->rc_links[0] = result;
result = rc;
rc = NULL;
successes++;
}
else
{
if(trace) DumpRect("failure ",&rc->rc_rect);
failures++;
}
}
/* clean up */
while(result)
{
/* pop */
rc=result;
result=rc->rc_links[0];
/* free */
FREE(rc);
}
fprintf(stderr,"END Snow GOLD, size=%d failures=%d successes=%d crc=%d\n",
size,
failures,
successes,
crc);
}
/* ====== bplane snow test.
*/
/*
* ----------------------------------------------------------------------------
* bpTestIntersect --
*
* check whether rc intersects list
* ----------------------------------------------------------------------------
*/
static bool bpTestIntersect(RectC *rc, BPlane *bp)
{
BPEnum bpe;
int result;
BPEnumInit(&bpe,bp, &rc->rc_rect, BPE_TOUCH,"bpTestIntersect");
result = (BPEnumNext(&bpe)!=NULL);
BPEnumTerm(&bpe);
return result;
}
/*
* ----------------------------------------------------------------------------
* bpTestSnow --
* populate area with non-overlapping random unit rectangles.
*
* using bplane.
*
* ----------------------------------------------------------------------------
*/
BPlane *bpTestSnow(int size, bool trace)
{
int failures = 0;
int successes = 0;
int i = 0;
int crc = 0;
RectC *result = NULL;
RectC *rc = NULL;
BPlane *bp = BPNew();
Rect area;
fprintf(stderr,"BEGIN Snow, size=%d\n", size);
/* set up area */
area.r_xbot = 0;
area.r_ybot = 0;
area.r_xtop = size;
area.r_ytop = size;
while(failures<=successes)
{
i++;
if(!rc) rc = MALLOC_TAG(RectC *,rc, sizeof(RectC), "RectC");
bpTestRandRect(&rc->rc_rect, &area);
if(!bpTestIntersect(rc,bp))
{
if(trace) DumpRect("success ",&rc->rc_rect);
crc ^= i+ 3*rc->rc_rect.r_xbot+ 5*rc->rc_rect.r_ybot;
BPAdd(bp,rc);
rc = NULL;
successes++;
}
else
{
if(trace) DumpRect("failure ",&rc->rc_rect);
failures++;
}
}
fprintf(stderr,"END Snow, size=%d failures=%d success=%d crc=%d\n",
size,
failures,
successes,
crc);
return bp;
}
/* ====== Tile Plane based snow test.
*/
/*
* ----------------------------------------------------------------------------
* bpTestIntersectTile --
*
* check whether r intersects existing tiles
*
* ----------------------------------------------------------------------------
*/
int bpTestIntersectTileFunc(Tile *tile, ClientData cd)
{
return 1;
}
static bool bpTestIntersectTile(Rect *r, Plane *plane)
{
Rect area;
/* catch touching tiles */
area = *r;
area.r_xbot -= 1;
area.r_ybot -= 1;
area.r_xtop += 1;
area.r_ytop += 1;
return DBPlaneEnumAreaPaint((Tile *) NULL,
plane,
&area,
&DBAllButSpaceBits,
bpTestIntersectTileFunc,
NULL);
}
/*
* ----------------------------------------------------------------------------
* bpTestSnowTile --
* populate area with non-overlapping random unit rectangles.
*
* using tile plane
*
* ----------------------------------------------------------------------------
*/
Plane *bpTestSnowTile(int size, bool trace)
{
int failures = 0;
int successes = 0;
int i = 0;
int crc = 0;
RectC *result = NULL;
RectC *rc = NULL;
Plane *plane = DBPlaneNew((ClientData) TT_SPACE);
Rect area;
fprintf(stderr,"BEGIN Snow Tile, size=%d\n", size);
/* set up area */
area.r_xbot = 0;
area.r_ybot = 0;
area.r_xtop = size;
area.r_ytop = size;
while(failures<=successes)
{
Rect r;
i++;
bpTestRandRect(&r, &area);
if(!bpTestIntersectTile(&r,plane))
{
if(trace) DumpRect("success ",&r);
crc ^= i+ 3*r.r_xbot + 5*r.r_ybot;
DBPaintPlane(plane, &r, CIFPaintTable, (PaintUndoInfo *) NULL);
rc = NULL;
successes++;
}
else
{
if(trace) DumpRect("failure ",&r);
failures++;
}
}
fprintf(stderr,"END Snow Tile, size=%d failures=%d success=%d crc=%d\n",
size,
failures,
successes,
crc);
return plane;
}

77
bplane/bpUtils.c Normal file
View File

@ -0,0 +1,77 @@
// ************************************************************************
//
// Copyright (c) 1995-2002 Juniper Networks, Inc. All rights reserved.
//
// Permission is hereby granted, without written agreement and without
// license or royalty fees, to use, copy, modify, and distribute this
// software and its documentation for any purpose, provided that the
// above copyright notice and the following three paragraphs appear in
// all copies of this software.
//
// IN NO EVENT SHALL JUNIPER NETWORKS, INC. BE LIABLE TO ANY PARTY FOR
// DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
// JUNIPER NETWORKS, INC. HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
// DAMAGE.
//
// JUNIPER NETWORKS, INC. SPECIFICALLY DISCLAIMS ANY WARRANTIES,
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
// NON-INFRINGEMENT.
//
// THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND JUNIPER
// NETWORKS, INC. HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
//
// ************************************************************************
/* bpUtils.c --
*
* shared low-level routines for this module.
*
*/
#include <stdio.h>
#include "utils/utils.h"
#include "database/database.h"
#include "utils/geometry.h"
#include "bplane/bplaneInt.h"
/*
* ----------------------------------------------------------------------------
* bpRectDim --
*
* return dimension of rectangle in xDir
*
* ----------------------------------------------------------------------------
*/
int bpRectDim(Rect *r, bool xDir)
{
return xDir ? r->r_xtop - r->r_xbot : r->r_ytop - r->r_ybot;
}
/*
* ----------------------------------------------------------------------------
* bpBinIndices --
*
* compute bin indices corresponding to area.
*
* ----------------------------------------------------------------------------
*/
static __inline__ void
bpBinIndices(Rect area, /* area */
Rect binArea, /* lower left corner of bin system */
int indexBits,
int dim,
bool xDir, /* TRUE for x bin, FALSE for y bin */
int *min, /* results go here */
int *max)
{
int ref, coord;
int index;
}

235
bplane/bplane.h Normal file
View File

@ -0,0 +1,235 @@
// ************************************************************************
//
// Copyright (c) 1995-2002 Juniper Networks, Inc. All rights reserved.
//
// Permission is hereby granted, without written agreement and without
// license or royalty fees, to use, copy, modify, and distribute this
// software and its documentation for any purpose, provided that the
// above copyright notice and the following three paragraphs appear in
// all copies of this software.
//
// IN NO EVENT SHALL JUNIPER NETWORKS, INC. BE LIABLE TO ANY PARTY FOR
// DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
// JUNIPER NETWORKS, INC. HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
// DAMAGE.
//
// JUNIPER NETWORKS, INC. SPECIFICALLY DISCLAIMS ANY WARRANTIES,
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
// NON-INFRINGEMENT.
//
// THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND JUNIPER
// NETWORKS, INC. HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
//
// ************************************************************************
#ifndef _MAGIC__BPLANE__BPLANE_H
#define _MAGIC__BPLANE__BPLANE_H
/*
* bplane.h --
*
* This file defines the interface between the bplane
* module and the rest of max.
*
* BUGS
* ====
*
* NOTE nested enums are currently broken do to dynamic binning.
*
* OVERVIEW OF BPLANES
* ===================
*
* BPlanes ('Binned' Planes) are a data-structure for storing, sorting,
* and accessing two dimensional geometric objects.
*
* BPlanes are an alternative to Planes, i.e. corner-stitched tile planes,
* defined in the tile module.
*
* Differences between Planes and BPlanes:
* --------------------------------------
*
* 1. BPlanes are more memory efficient.
* Three pointers (+ a modest amount of binning overhead)
* replaces approximately 8 pointers (4/tile, approx. 1 space
* tile for each data tile).
*
* 2. BPlanes use a 'next' procedure for enumeration, instead of
* function call-backs. This allows client code to be simpler
* and more readable, partcularly with regard to passing state info.
* In addition gprof results are easier to interpet, since
* there is not confusion about which client procedures belong to
* a given "loop".
*
* 3. Planes fundamentally assume objects don't overlap, while BPlanes
* make no such assumption. This makes BPlanes more generally useful.
* In particular they are a natural choice for instance uses,
* labels, and non-manhattan polygons (sorted on bounding boxes).
*
* 4. Planes are optimized for merging (merging recangles
* into maximal horizontal strips) and neighbor access
* (finding nearest elements to current element). BPlanes are less
* efficient for these operations.
*
* 5. Planes generally cannot be safely modified during an enumeration,
* but BPlanes can. This makes operations such as delete, copy, and
* move simpler in BPlanes.
*
* Interface
* ---------
*
* 1. The structure of elements to be stored in BPlanes must be as
* follows:
*
* typedef struct foo
* {
* struct void *foo_bpLinks[BP_NUM_LINKS];
* Rect foo_rect;
* <client fields go here>
* } Foo
*
* 2. It is the clients responsiblity to alloc/free elements.
*
* 3. The client must set foo_rect before adding the element
* to a BPlane. foo_rect must be canonical: not inverted.
*
* 4. The BPlane module does not access or modify any client fields.
*
* 5. The client may access/modify client fields at any time.
*
* 6. As long as an element belongs to a BPlane (i.e. has been
* added via BPAdd() and not removed via BPDelete()):
*
* a. The client should not reference/modify the foo_bpLinks[] fields.
* b. The client may reference but should not modify the foo_rect
* field.
* c. The client should not call BPAdd() for the element
* (an element can only belong to one BPlane at at time).
* d. The client should not free the element!
*
* 7. The client may assume tht BP_NUM_LINKS is at least one, and
* may use foo_bpLinks[0], for his own purposes as long as an
* element does not belong to a bplane.
*
* 8. Concurrent (nested) enumerations of a bplane are permitted.
*
* 9. Elements may not be added to a bplane during active enumeration(s)
* on that bplane.
*
* 10. An element may be deleted from a bplane at any time, including
* during active enumeration(s) of that bplane. After an element
* has been deleted from a bplane, it will not be enumerated
* (i.e. returned by BPEnumNext() on that bplane).
*
* Example
* -------
*
* Here is a procedure that takes an array of id'ed rectangles and an
* area as input, and prints the ids of all rectangles impinging on the
* area.
*
* typedef struct rid
* {
* struct rid *rid_bpLinks[BP_NUM_LINKS];
* Rect rid_rect;
* char *rid_id;
* } RId;
*
* void findRects(RId data[], // ided rects
* int n, // number of rects in data
* Rect *area) // area to search
* {
* int i;
* BPEnum bpe;
* BPlane *bp;
* RId *rid;
*
* bp = BPNew();
* for(i=0;i<n;i++) BPAdd(bp,&data[i]);
*
* BPEnumInit(&bpe,bp,area,BPE_OVERLAP,"findRects");
* while(rid = BPEnumNext(&bpe))
* {
* printf("%s\n", rid->rid_id);
* }
* BPEnumTerm(&bpe);
*
*/
/* data-structures opaque to clients */
#include "bplane/bpOpaque.h"
/* create a new BPlane */
extern BPlane *BPNew(void);
/* free storate assoicated with a BPlane
* (The BPlane must be empty.)
*/
extern void BPFree(BPlane *bp);
/* add an element to a BPlane */
extern void BPAdd(BPlane *bp,
void *element);
/* remove an element from a BPlane */
extern void BPDelete(BPlane *bp,
void *element);
/* begin an enumeration */
extern void BPEnumInit(BPEnum *bpe, /* this procedure initializes this
* client supplied 'handle' for the
* enumeration.
*/
BPlane *bp, /* bplane to search */
const Rect *area, /* area to search */
int match, /* see below */
const char *id); /* for debugging */
/* match values */
/* enum all elements in the bplane (area arg must be null) */
#define BPE_ALL 0
/* element need only touch area */
#define BPE_TOUCH 1
/* some part of element must be inside (not just on boundary of) area */
#define BPE_OVERLAP 2
/* elements rect must be identical to area */
#define BPE_EQUAL 3
/* return next element in enumeration (returns NULL if none) */
#include "bplane/bpEnum.h"
/* inlined extern void *BPEnumNext(BPEnum *bpe); */
/* terminate enumeration
*
* (unterminated enumerations can cause great inefficiency since
* all active enumerations for a bplane must be considered whenever
* an element is added or deleted.)
*/
extern void BPEnumTerm(BPEnum *bpe);
/* get current bounding box of BPlane */
extern Rect BPBBox(BPlane *bp);
/* compute number of bytes used by BPlane
* (does not count memory of the elements themselves)
*/
extern unsigned int BPStatMemory(BPlane *bp);
/* tabulate statistics on a bplane */
extern unsigned int
BPStat(BPlane *bp,
int *totCount, /* ret total number of elements */
int *inBox, /* ret num of elements in inBox */
int *totBins, /* ret tot num of bins */
int *emptyBins, /* ret num of empty bins */
int *binArraysp, /* ret num of bin arrays */
int *maxEffp, /* ret max effective list length */
int *maxBinCount, /* ret max count for regular bin */
int *totUnbinned, /* ret tot num of e's not binned */
int *maxDepth); /* ret max bin array depth */
#endif /* _MAGIC__BPLANE__BPLANE_H */

82
bplane/bplaneInt.h Normal file
View File

@ -0,0 +1,82 @@
// ************************************************************************
//
// Copyright (c) 1995-2002 Juniper Networks, Inc. All rights reserved.
//
// Permission is hereby granted, without written agreement and without
// license or royalty fees, to use, copy, modify, and distribute this
// software and its documentation for any purpose, provided that the
// above copyright notice and the following three paragraphs appear in
// all copies of this software.
//
// IN NO EVENT SHALL JUNIPER NETWORKS, INC. BE LIABLE TO ANY PARTY FOR
// DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
// JUNIPER NETWORKS, INC. HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
// DAMAGE.
//
// JUNIPER NETWORKS, INC. SPECIFICALLY DISCLAIMS ANY WARRANTIES,
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
// NON-INFRINGEMENT.
//
// THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND JUNIPER
// NETWORKS, INC. HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
//
// ************************************************************************
/*
* bplaneInt.h --
*
* This file defines constants and datastructures used internally by the
* bplane module, but not exported to the rest of the world.
*/
#ifndef _MAGIC__BPLANE__BPLANEINT_H
#define _MAGIC__BPLANE__BPLANEINT_H
/* Tcl linked Parameters */
extern int bpMinBAPop; /* don't sub(bin) when count less than this
*/
extern double bpMinAvgBinPop; /* try to keep average bin pop at or
* below this
*/
/* LabeledElement
*
* Used in this module as elements for test bplanes.
*/
typedef struct labeledelement
{
struct element *le_links[BP_NUM_LINKS];
Rect le_rect;
/* client data goes here */
char * le_text;
} LabeledElement;
/* bins */
extern void bpBinsUpdate(BPlane *bp);
extern void bpBinAdd(BinArray *ba, Element *e);
extern BinArray *bpBinArrayBuild(Rect bbox,
Element *elements, /* initial elements */
bool subbin); /* subbin as needed */
/* dump (for debug) */
extern void bpDumpRect(Rect *r);
extern void bpDump(BPlane *bp, int flags);
/* bpDump flags */
/* labeled elements */
# define BPD_LABELED 1
# define BPD_INTERNAL_UNITS 2
/* test */
void bpTestSnowGold(int size, bool trace);
extern BPlane *bpTestSnow(int size, bool trace);
extern Plane *bpTestSnowTile(int size, bool trace);
extern int bpRand(int min, int max);
#endif /* _MAGIC__BPLANE__BPLANEINT_H */

File diff suppressed because it is too large Load Diff

View File

@ -4,25 +4,26 @@
* Input of Calma GDS-II stream format.
* Low-level input.
*
* *********************************************************************
* * Copyright (C) 1985, 1990 Regents of the University of California. *
* * Permission to use, copy, modify, and distribute this *
* * software and its documentation for any purpose and without *
* * fee is hereby granted, provided that the above copyright *
* * notice appear in all copies. The University of California *
* * makes no representations about the suitability of this *
* * software for any purpose. It is provided "as is" without *
* * express or implied warranty. Export of this software outside *
* * of the United States of America may require an export license. *
* *********************************************************************
* * Copyright (C) 1985, 1990 Regents of the University of California. *
* * Permission to use, copy, modify, and distribute this *
* * software and its documentation for any purpose and without *
* * fee is hereby granted, provided that the above copyright *
* * notice appear in all copies. The University of California *
* * makes no representations about the suitability of this *
* * software for any purpose. It is provided "as is" without *
* * express or implied warranty. Export of this software outside *
* * of the United States of America may require an export license. *
* *********************************************************************
*/
#ifndef lint
static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/calma/CalmaRdio.c,v 1.1.1.1 2008/02/03 20:43:50 tim Exp $";
static const char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/calma/CalmaRdio.c,v 1.1.1.1 2008/02/03 20:43:50 tim Exp $";
#endif /* not lint */
#include <stdio.h>
#include <sys/types.h>
#include <time.h>
#include <netinet/in.h>
@ -45,11 +46,14 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
#include "textio/textio.h"
#include "calma/calmaInt.h"
/* Forward declarations */
bool calmaReadR8();
bool calmaSkipBytes();
/* C99 compat */
#include "calma/calma.h"
/* Forward declarations */
bool calmaReadR8(double *pd);
bool calmaSkipBytes(int nbytes);
/*
* ----------------------------------------------------------------------------
*
@ -69,9 +73,9 @@ bool calmaSkipBytes();
*/
bool
calmaReadTransform(ptrans, name)
Transform *ptrans; /* Fill in this transform */
char *name; /* Name of subcell (for errors) */
calmaReadTransform(
Transform *ptrans, /* Fill in this transform */
char *name) /* Name of subcell (for errors) */
{
int nbytes, rtype, flags, angle;
double dangle;
@ -110,8 +114,8 @@ calmaReadTransform(ptrans, name)
if (dmag != (double)((int)(dmag + 0.5)))
{
calmaReadError("Non-integer magnification (%g) in transform\n", dmag);
calmaReadError("Rounding to %d.\n", (int)(dmag + 0.5));
CalmaReadError("Non-integer magnification (%g) in transform\n", dmag);
CalmaReadError("Rounding to %d.\n", (int)(dmag + 0.5));
}
GeoScaleTrans(ptrans, (int)(dmag + 0.5), &t);
*ptrans = t;
@ -144,13 +148,13 @@ calmaReadTransform(ptrans, name)
case 0: case 90: case 180: case 270:
break;
default:
calmaReadError("Non-Manhattan angle (%d) in transform\n", angle);
CalmaReadError("Non-Manhattan angle (%d) in transform\n", angle);
if (angle < 45) angle = 0;
else if (angle < 135) angle = 90;
else if (angle < 225) angle = 180;
else if (angle < 315) angle = 270;
else angle = 0;
calmaReadError(" Rounding to %d degrees.\n", angle);
CalmaReadError(" Rounding to %d degrees.\n", angle);
}
/*
@ -180,7 +184,7 @@ calmaReadTransform(ptrans, name)
return (TRUE);
}
/*
* ----------------------------------------------------------------------------
*
@ -201,9 +205,9 @@ calmaReadTransform(ptrans, name)
*/
bool
calmaReadI2Record(type, pvalue)
int type; /* Type of record expected */
int *pvalue; /* Store value here */
calmaReadI2Record(
int type, /* Type of record expected */
int *pvalue) /* Store value here */
{
int nbytes, rtype, n;
@ -218,15 +222,15 @@ calmaReadI2Record(type, pvalue)
/* Read the value */
READI2(n);
if (feof(calmaInputFile)) goto eof;
if (FEOF(calmaInputFile)) goto eof;
*pvalue = n;
return (TRUE);
eof:
calmaReadError("Unexpected EOF.\n");
CalmaReadError("Unexpected EOF.\n");
return (FALSE);
}
/*
* ----------------------------------------------------------------------------
*
@ -246,9 +250,9 @@ eof:
*/
bool
calmaReadI4Record(type, pvalue)
int type; /* Type of record expected */
int *pvalue; /* Store value here */
calmaReadI4Record(
int type, /* Type of record expected */
int *pvalue) /* Store value here */
{
int nbytes, rtype, n;
@ -263,15 +267,90 @@ calmaReadI4Record(type, pvalue)
/* Read the value */
READI4(n);
if (feof(calmaInputFile)) goto eof;
if (FEOF(calmaInputFile)) goto eof;
*pvalue = n;
return (TRUE);
eof:
calmaReadError("Unexpected EOF.\n");
CalmaReadError("Unexpected EOF.\n");
return (FALSE);
}
/*
* ----------------------------------------------------------------------------
*
* calmaReadStampRecord --
*
* Read a record that contains a pair of timestamps for creation and
* modification dates.
*
* Results:
* TRUE on success, FALSE if the record type we read is not
* what we're expecting.
*
* Side effects:
* Consumes input.
* Translates the creation timestamp from GDS format to a standard
* UNIX (time.h) timestamp (seconds since the epoch).
* Stores the result in the integer pointed to by 'stampptr'.
*
* ----------------------------------------------------------------------------
*/
bool
calmaReadStampRecord(
int type,
int *stampptr)
{
int nbytes, rtype;
struct tm gds_timestamp;
READRH(nbytes, rtype);
if (nbytes < 0)
goto eof;
if (type != rtype)
{
calmaUnexpected(type, rtype);
return (FALSE);
}
nbytes -= CALMAHEADERLENGTH;
if (nbytes != 24)
{
/* Not dealing with any timestamp that is not in I2 format */
calmaSkipBytes(nbytes);
if (stampptr) *stampptr = 0;
CalmaReadError("Unknown timestamp format; setting timestamp to zero.\n");
return TRUE;
}
gds_timestamp.tm_wday = 0; /* Not used by mktime() */
gds_timestamp.tm_yday = 0; /* Not used by mktime() */
gds_timestamp.tm_isdst = -1;
READI2(gds_timestamp.tm_year);
READI2(gds_timestamp.tm_mon);
READI2(gds_timestamp.tm_mday);
READI2(gds_timestamp.tm_hour);
READI2(gds_timestamp.tm_min);
READI2(gds_timestamp.tm_sec);
/* GDS timestamps differ from UNIX time structure only by a */
/* difference of 1 in the month count. */
gds_timestamp.tm_mon--;
/* Skip the modification date timestamp */
(void) calmaSkipBytes(nbytes - 12);
if (stampptr) *stampptr = (int)mktime(&gds_timestamp);
return (TRUE);
eof:
CalmaReadError("Unexpected EOF.\n");
return (FALSE);
}
/*
* ----------------------------------------------------------------------------
*
@ -292,9 +371,9 @@ eof:
*/
bool
calmaReadStringRecord(type, str)
int type;
char **str;
calmaReadStringRecord(
int type,
char **str)
{
int nbytes, rtype;
@ -310,17 +389,17 @@ calmaReadStringRecord(type, str)
nbytes -= CALMAHEADERLENGTH;
*str = (char *) mallocMagic(nbytes + 1);
if (fread(*str, sizeof (char), nbytes, calmaInputFile) != nbytes)
if (magicFREAD(*str, sizeof (char), nbytes, calmaInputFile) != nbytes)
goto eof;
*(*str + nbytes) = '\0';
return (TRUE);
eof:
calmaReadError("Unexpected EOF.\n");
CalmaReadError("Unexpected EOF.\n");
return (FALSE);
}
/*
* ----------------------------------------------------------------------------
*
@ -341,21 +420,21 @@ eof:
*/
bool
calmaReadR8(pd)
double *pd; /* Store result in *pd */
calmaReadR8(
double *pd) /* Store result in *pd */
{
int i, exponent;
unsigned char dchars[8];
double mantissa, d;
bool isneg;
if (fread((char *) dchars, sizeof (char), sizeof dchars,
if (magicFREAD((char *) dchars, sizeof (char), sizeof dchars,
calmaInputFile) != sizeof dchars)
return (FALSE);
/* Extract the sign and exponent */
exponent = dchars[0];
if (isneg = (exponent & 0x80))
if ((isneg = (exponent & 0x80)))
exponent &= ~0x80;
exponent -= 64;
@ -387,7 +466,7 @@ calmaReadR8(pd)
*pd = d;
return (TRUE);
}
/*
* ----------------------------------------------------------------------------
*
@ -410,10 +489,10 @@ calmaReadR8(pd)
*/
void
calmaSkipSet(skipwhat)
int *skipwhat;
calmaSkipSet(
const int *skipwhat)
{
int *skipp;
const int *skipp;
int nbytes, rtype;
for (;;)
@ -433,7 +512,7 @@ skipit:
(void) calmaSkipBytes(nbytes - CALMAHEADERLENGTH);
}
}
/*
* ----------------------------------------------------------------------------
*
@ -454,8 +533,8 @@ skipit:
*/
bool
calmaSkipExact(type)
int type;
calmaSkipExact(
int type)
{
int nbytes, rtype;
@ -478,10 +557,10 @@ calmaSkipExact(type)
return (TRUE);
eof:
calmaReadError("Unexpected EOF.\n");
CalmaReadError("Unexpected EOF.\n");
return (FALSE);
}
/*
* ----------------------------------------------------------------------------
*
@ -500,8 +579,8 @@ eof:
*/
bool
calmaSkipTo(what)
int what;
calmaSkipTo(
int what)
{
int nbytes, rtype;
@ -515,7 +594,7 @@ calmaSkipTo(what)
return (TRUE);
}
/*
* ----------------------------------------------------------------------------
*
@ -536,11 +615,11 @@ calmaSkipTo(what)
*/
bool
calmaSkipBytes(nbytes)
int nbytes; /* Skip this many bytes */
calmaSkipBytes(
int nbytes) /* Skip this many bytes */
{
while (nbytes-- > 0)
if (getc(calmaInputFile) < 0)
if (FGETC(calmaInputFile) < 0)
return (FALSE);
return (TRUE);

View File

@ -4,21 +4,21 @@
* Input of Calma GDS-II stream format.
* Processing of paint (paths, boxes, and boundaries) and text.
*
* *********************************************************************
* * Copyright (C) 1985, 1990 Regents of the University of California. *
* * Permission to use, copy, modify, and distribute this *
* * software and its documentation for any purpose and without *
* * fee is hereby granted, provided that the above copyright *
* * notice appear in all copies. The University of California *
* * makes no representations about the suitability of this *
* * software for any purpose. It is provided "as is" without *
* * express or implied warranty. Export of this software outside *
* * of the United States of America may require an export license. *
* *********************************************************************
* * Copyright (C) 1985, 1990 Regents of the University of California. *
* * Permission to use, copy, modify, and distribute this *
* * software and its documentation for any purpose and without *
* * fee is hereby granted, provided that the above copyright *
* * notice appear in all copies. The University of California *
* * makes no representations about the suitability of this *
* * software for any purpose. It is provided "as is" without *
* * express or implied warranty. Export of this software outside *
* * of the United States of America may require an export license. *
* *********************************************************************
*/
#ifndef lint
static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/calma/CalmaRdpt.c,v 1.7 2010/08/25 17:33:54 tim Exp $";
static const char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/calma/CalmaRdpt.c,v 1.7 2010/08/25 17:33:54 tim Exp $";
#endif /* not lint */
#include <stdio.h>
@ -48,16 +48,17 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
#include "calma/calmaInt.h"
#include "calma/calma.h"
/* C99 compat */
#include "drc/drc.h"
extern int calmaNonManhattan;
extern int CalmaPolygonCount;
extern int CalmaPathCount;
extern HashTable calmaDefInitHash;
extern void calmaLayerError();
bool calmaReadPath();
typedef enum { LABEL_TYPE_NONE, LABEL_TYPE_TEXT, LABEL_TYPE_PORT } labelType;
extern void calmaLayerError(char *mesg, int layer, int dt);
CIFPath *calmaReadPath(int iscale);
/*
* ----------------------------------------------------------------------------
@ -81,8 +82,9 @@ typedef enum { LABEL_TYPE_NONE, LABEL_TYPE_TEXT, LABEL_TYPE_PORT } labelType;
*/
void
calmaInputRescale(n, d)
int n, d;
calmaInputRescale(
int n,
int d)
{
HashEntry *h;
HashSearch hs;
@ -100,7 +102,9 @@ calmaInputRescale(n, d)
{
/* Scale the GDS planes in this cell's cd_client record */
Plane **gdsplanes = (Plane **)def->cd_client;
CIFScalePlanes(n, d, gdsplanes);
/* Should not happen, but punt if client record is not set; */
if (def->cd_client != (ClientData)0)
CIFScalePlanes(n, d, gdsplanes);
}
}
@ -132,9 +136,9 @@ calmaInputRescale(n, d)
*/
void
calmaReadPoint(p, iscale)
Point *p;
int iscale;
calmaReadPoint(
Point *p,
int iscale)
{
int rescale;
@ -145,7 +149,7 @@ calmaReadPoint(p, iscale)
rescale = calmaReadScale2 / FindGCF(calmaReadScale2, abs(p->p_x));
if ((calmaReadScale1 * rescale) > CIFRescaleLimit)
{
calmaReadError("Warning: calma units at max scale; value rounded\n");
CalmaReadError("Warning: calma units at max scale; value rounded\n");
if (p->p_x < 0)
p->p_x -= ((calmaReadScale2 - 1) >> 1);
else
@ -167,7 +171,7 @@ calmaReadPoint(p, iscale)
rescale = calmaReadScale2 / FindGCF(calmaReadScale2, abs(p->p_y));
if ((calmaReadScale1 * rescale) > CIFRescaleLimit)
{
calmaReadError("Warning: calma units at max scale; value rounded\n");
CalmaReadError("Warning: calma units at max scale; value rounded\n");
if (p->p_y < 0)
p->p_y -= ((calmaReadScale2 - 1) >> 1);
else
@ -184,7 +188,7 @@ calmaReadPoint(p, iscale)
p->p_y /= calmaReadScale2;
}
/*
* ----------------------------------------------------------------------------
*
@ -202,14 +206,14 @@ calmaReadPoint(p, iscale)
*/
void
calmaElementBoundary()
calmaElementBoundary(void)
{
int dt, layer, ciftype;
CIFPath *pathheadp;
LinkedRect *rp;
Plane *plane;
CellUse *use;
CellDef *savedef, *newdef = NULL;
CellDef *savedef = NULL, *newdef = NULL;
/* Skip CALMA_ELFLAGS, CALMA_PLEX */
calmaSkipSet(calmaElementIgnore);
@ -218,7 +222,7 @@ calmaElementBoundary()
if (!calmaReadI2Record(CALMA_LAYER, &layer)
|| !calmaReadI2Record(CALMA_DATATYPE, &dt))
{
calmaReadError("Missing layer or datatype in boundary/box.\n");
CalmaReadError("Missing layer or datatype in boundary/box.\n");
return;
}
@ -233,10 +237,11 @@ calmaElementBoundary()
plane = cifCurReadPlanes[ciftype];
/* Read the path itself, building up a path structure */
if (!calmaReadPath(&pathheadp, (plane == NULL) ? 0 : 1))
pathheadp = calmaReadPath((plane == NULL) ? 0 : 1);
if (pathheadp == NULL)
{
if (plane != NULL)
calmaReadError("Error while reading path for boundary/box; ignored.\n");
CalmaReadError("Error while reading path for boundary/box; ignored.\n");
return;
}
@ -244,23 +249,27 @@ calmaElementBoundary()
/* so we need to set it again. */
if (ciftype >= 0) plane = cifCurReadPlanes[ciftype];
/* Convert the polygon to rectangles. */
/* Save non-Manhattan polygons in their own subcells. */
/* NOTE: CALMA_POLYGON_TEMP and CALMA_POLYGON_KEEP read in polygons much
* faster, but that interferes with boolean processing. This method
* needs to be reworked.
*/
if (CalmaSubcellPolygons && (calmaNonManhattan > 0))
if ((CalmaSubcellPolygons != CALMA_POLYGON_NONE) && (calmaNonManhattan > 0))
{
/* Place the polygon in its own subcell */
char newname[] = "polygonXXXXX";
char newname[20];
HashEntry *he;
savedef = cifReadCellDef;
/* Make up name for cell */
sprintf(newname + 7, "%05d", ++CalmaPolygonCount);
snprintf(newname, sizeof(newname), "polygon%05d", ++CalmaPolygonCount);
he = HashFind(&calmaDefInitHash, newname);
if (!HashGetValue(he))
{
newdef = calmaFindCell(newname, NULL);
newdef = calmaFindCell(newname, NULL, NULL);
cifReadCellDef = newdef;
DBCellClearDef(cifReadCellDef);
DBCellSetAvail(cifReadCellDef);
@ -274,8 +283,9 @@ calmaElementBoundary()
}
}
CIFPropRecordPath(cifReadCellDef, pathheadp, FALSE);
rp = CIFPolyToRects(pathheadp, plane, CIFPaintTable, (PaintUndoInfo *)NULL);
/* Convert the polygon to rectangles. */
rp = CIFPolyToRects(pathheadp, plane, CIFPaintTable, (PaintUndoInfo *)NULL, TRUE);
CIFFreePath(pathheadp);
/* If the input layer is designated for ports by a "label" */
@ -289,8 +299,18 @@ calmaElementBoundary()
if (rp != NULL)
{
Rect rpc;
int savescale;
/* Convert rp to magic database units to compare to label rects */
rpc = rp->r_r;
rpc.r_xbot /= cifCurReadStyle->crs_scaleFactor;
rpc.r_xtop /= cifCurReadStyle->crs_scaleFactor;
rpc.r_ybot /= cifCurReadStyle->crs_scaleFactor;
rpc.r_ytop /= cifCurReadStyle->crs_scaleFactor;
if ((ciftype >= 0) &&
((cifCurReadStyle->crs_labelSticky[ciftype] != LABEL_TYPE_NONE)))
(cifCurReadStyle->crs_labelSticky[ciftype] != LABEL_TYPE_NONE))
{
Label *lab;
TileType type;
@ -298,26 +318,60 @@ calmaElementBoundary()
type = cifCurReadStyle->crs_labelLayer[ciftype];
for (lab = cifReadCellDef->cd_labels; lab; lab = lab->lab_next)
{
if ((GEO_SURROUND(&rp->r_r, &lab->lab_rect)) && (lab->lab_type == type))
if ((GEO_SURROUND(&rpc, &lab->lab_rect)) && (lab->lab_type == type))
{
lab->lab_rect = rp->r_r; /* Replace with larger rectangle */
lab->lab_rect = rpc; /* Replace with larger rectangle */
break;
}
}
if (lab == NULL)
{
/* There was no label in the area. Create a placeholder label */
lab = DBPutLabel(cifReadCellDef, &rpc, GEO_CENTER, "", type, 0, 0);
}
if ((cifCurReadStyle->crs_labelSticky[ciftype] == LABEL_TYPE_PORT)
&& ((lab->lab_flags & PORT_DIR_MASK) == 0))
{
/* Label was read previously as a text type, but the pin layer
* causes it to be recast as a port, or corresponding label has
* not yet been seen.
*/
int i, idx;
Label *sl;
/* Order ports as encountered. */
i = -1;
for (sl = cifReadCellDef->cd_labels; sl != NULL; sl = sl->lab_next)
{
idx = sl->lab_port;
if (idx > i) i = idx;
if ((idx > 0) && (sl != lab) && !strcmp(sl->lab_text, lab->lab_text))
{
i = idx - 1;
break;
}
}
i++;
lab->lab_port = i;
lab->lab_flags |= PORT_DIR_NORTH | PORT_DIR_SOUTH |
PORT_DIR_EAST | PORT_DIR_WEST;
}
}
}
/* Paint the rectangles (if any) */
free_magic1_t mm1 = freeMagic1_init();
for (; rp != NULL ; rp = rp->r_next)
{
if (plane)
DBPaintPlane(plane, &rp->r_r, CIFPaintTable, (PaintUndoInfo *)NULL);
freeMagic((char *) rp);
freeMagic1(&mm1, (char *) rp);
}
freeMagic1_end(&mm1);
if (cifCurReadPlanes == cifEditCellPlanes)
{
CIFPaintCurrent();
CIFPaintCurrent(FILE_CALMA);
DBReComputeBbox(cifReadCellDef);
DRCCheckThis(cifReadCellDef, TT_CHECKPAINT, &cifReadCellDef->cd_bbox);
DBWAreaChanged(cifReadCellDef, &cifReadCellDef->cd_bbox,
@ -333,7 +387,7 @@ calmaElementBoundary()
DBPlaceCell(use, cifReadCellDef);
}
}
/*
* ----------------------------------------------------------------------------
*
@ -356,7 +410,7 @@ calmaElementBoundary()
*/
void
calmaElementBox()
calmaElementBox(void)
{
int nbytes, rtype, npoints, savescale;
int dt, layer, ciftype;
@ -371,7 +425,7 @@ calmaElementBox()
if (!calmaReadI2Record(CALMA_LAYER, &layer)
|| !calmaReadI2Record(CALMA_BOXTYPE, &dt))
{
calmaReadError("Missing layer or datatype in boundary/box.\n");
CalmaReadError("Missing layer or datatype in boundary/box.\n");
return;
}
@ -395,7 +449,7 @@ calmaElementBox()
READRH(nbytes, rtype);
if (nbytes < 0)
{
calmaReadError("EOF when reading box.\n");
CalmaReadError("EOF when reading box.\n");
return;
}
if (rtype != CALMA_XY)
@ -408,7 +462,7 @@ calmaElementBox()
npoints = (nbytes - CALMAHEADERLENGTH) / 8;
if (npoints != 5)
{
calmaReadError("Box doesn't have 5 points.\n");
CalmaReadError("Box doesn't have 5 points.\n");
(void) calmaSkipBytes(nbytes - CALMAHEADERLENGTH);
return;
}
@ -451,9 +505,9 @@ calmaElementBox()
*/
void
calmaElementPath()
calmaElementPath(void)
{
int nbytes, rtype, extend1, extend2;
int nbytes = -1, rtype = 0, extend1, extend2;
int layer, dt, width, pathtype, ciftype, savescale;
int xmin, ymin, xmax, ymax, temp;
CIFPath *pathheadp, *pathp, *previousp;
@ -461,7 +515,7 @@ calmaElementPath()
Plane *plane;
int first,last;
CellUse *use;
CellDef *savedef, *newdef = NULL;
CellDef *savedef = NULL, *newdef = NULL;
/* Skip CALMA_ELFLAGS, CALMA_PLEX */
calmaSkipSet(calmaElementIgnore);
@ -479,7 +533,7 @@ calmaElementPath()
if (pathtype != CALMAPATH_SQUAREFLUSH && pathtype != CALMAPATH_SQUAREPLUS &&
pathtype != CALMAPATH_CUSTOM)
{
calmaReadError("Warning: pathtype %d unsupported (ignored).\n", pathtype);
CalmaReadError("Warning: pathtype %d unsupported (ignored).\n", pathtype);
pathtype = CALMAPATH_SQUAREFLUSH;
}
@ -488,18 +542,18 @@ calmaElementPath()
* Allow zero-width paths; we will ignore them later.
*/
width = 0;
PEEKRH(nbytes, rtype)
PEEKRH(nbytes, rtype)
if (nbytes > 0 && rtype == CALMA_WIDTH)
{
if (!calmaReadI4Record(CALMA_WIDTH, &width))
if (!calmaReadI4Record(CALMA_WIDTH, &width))
{
calmaReadError("Error in reading WIDTH in calmaElementPath()\n") ;
CalmaReadError("Error in reading WIDTH in calmaElementPath()\n") ;
return;
}
}
width *= calmaReadScale1;
if (width % calmaReadScale2 != 0)
calmaReadError("Wire width snapped to nearest integer boundary.\n");
CalmaReadError("Wire width snapped to nearest integer boundary.\n");
width /= calmaReadScale2;
@ -516,12 +570,12 @@ calmaElementPath()
if (nbytes > 0 && rtype == CALMA_BGNEXTN)
{
if (!calmaReadI4Record(CALMA_BGNEXTN, &extend1))
calmaReadError("Error in reading BGNEXTN in path (ignored)\n") ;
CalmaReadError("Error in reading BGNEXTN in path (ignored)\n") ;
else
{
extend1 *= calmaReadScale1;
if (extend1 % calmaReadScale2 != 0)
calmaReadError("Wire extension snapped to nearest integer boundary.\n");
CalmaReadError("Wire extension snapped to nearest integer boundary.\n");
extend1 *= 2;
extend1 /= calmaReadScale2;
}
@ -531,12 +585,12 @@ calmaElementPath()
if (nbytes > 0 && rtype == CALMA_ENDEXTN)
{
if (!calmaReadI4Record(CALMA_ENDEXTN, &extend2))
calmaReadError("Error in reading ENDEXTN in path (ignored)\n") ;
CalmaReadError("Error in reading ENDEXTN in path (ignored)\n") ;
else
{
extend2 *= calmaReadScale1;
if (extend2 % calmaReadScale2 != 0)
calmaReadError("Wire extension snapped to nearest integer boundary.\n");
CalmaReadError("Wire extension snapped to nearest integer boundary.\n");
extend2 *= 2;
extend2 /= calmaReadScale2;
}
@ -544,9 +598,10 @@ calmaElementPath()
/* Read the points in the path */
savescale = calmaReadScale1;
if (!calmaReadPath(&pathheadp, 2))
pathheadp = calmaReadPath(2);
if (pathheadp == NULL)
{
calmaReadError("Improper path; ignored.\n");
CalmaReadError("Improper path; ignored.\n");
return;
}
if (savescale != calmaReadScale1)
@ -612,18 +667,18 @@ calmaElementPath()
if (CalmaSubcellPaths)
{
/* Place the path in its own subcell */
char newname[] = "pathXXXXX";
char newname[16];
HashEntry *he;
savedef = cifReadCellDef;
/* Make up name for cell */
sprintf(newname + 4, "%05d", ++CalmaPathCount);
snprintf(newname, sizeof(newname), "path%05d", ++CalmaPathCount);
he = HashFind(&calmaDefInitHash, newname);
if (!HashGetValue(he))
{
newdef = calmaFindCell(newname, NULL);
newdef = calmaFindCell(newname, NULL, NULL);
cifReadCellDef = newdef;
DBCellClearDef(cifReadCellDef);
DBCellSetAvail(cifReadCellDef);
@ -637,14 +692,14 @@ calmaElementPath()
}
}
CIFPropRecordPath(cifReadCellDef, pathheadp, TRUE);
CIFPropRecordPath(cifReadCellDef, pathheadp, TRUE, "path");
CIFPaintWirePath(pathheadp, width,
(pathtype == CALMAPATH_SQUAREFLUSH || pathtype == CALMAPATH_CUSTOM) ?
FALSE : TRUE, plane, CIFPaintTable, (PaintUndoInfo *)NULL);
if (cifCurReadPlanes == cifEditCellPlanes)
{
CIFPaintCurrent();
CIFPaintCurrent(FILE_CALMA);
DBReComputeBbox(cifReadCellDef);
DRCCheckThis(cifReadCellDef, TT_CHECKPAINT, &cifReadCellDef->cd_bbox);
DBWAreaChanged(cifReadCellDef, &cifReadCellDef->cd_bbox,
@ -679,17 +734,16 @@ calmaElementPath()
*/
void
calmaElementText()
calmaElementText(void)
{
static int ignore[] = { CALMA_PATHTYPE, CALMA_WIDTH, -1 };
static const int ignore[] = { CALMA_PATHTYPE, CALMA_WIDTH, -1 };
char *textbody = NULL;
int nbytes, rtype;
int layer, textt, cifnum;
int nbytes = -1, rtype = 0;
int layer, textt, cifnum, textpres;
TileType type;
Rect r;
unsigned short textpres;
double dval;
int size, angle, font, pos;
int size, micron, angle, font, pos, portnum, idx;
/* Skip CALMA_ELFLAGS, CALMA_PLEX */
calmaSkipSet(calmaElementIgnore);
@ -700,7 +754,7 @@ calmaElementText()
cifnum = CIFCalmaLayerToCifLayer(layer, textt, cifCurReadStyle);
if (cifnum < 0)
{
if(cifCurReadStyle->crs_flags & CRF_IGNORE_UNKNOWNLAYER_LABELS)
if (cifCurReadStyle->crs_flags & CRF_IGNORE_UNKNOWNLAYER_LABELS)
type = -1;
else {
calmaLayerError("Label on unknown layer/datatype", layer, textt);
@ -711,10 +765,29 @@ calmaElementText()
font = -1;
angle = 0;
portnum = 0;
/* Default size is 1um */
size = (int)((800 * cifCurReadStyle->crs_multiplier)
/* Use the minimum width of the layer on which the text is placed
* as the default text size, or 1um, whichever is smaller. Account
* for the 8/10 difference encoded in the rendered font height.
*/
size = 0;
if (type > 0)
{
size = DRCGetDefaultLayerWidth(type);
if (size > 0)
{
size *= (calmaReadScale2 * cifCurReadStyle->crs_multiplier * 8);
size /= (calmaReadScale1 * cifCurReadStyle->crs_scaleFactor * 10);
}
}
/* Default or maximum size is 1um */
micron = (int)((800 * cifCurReadStyle->crs_multiplier)
/ cifCurReadStyle->crs_scaleFactor);
if ((size == 0) || (size > micron))
size = micron;
/* Default position is bottom-right (but what the spec calls "top-left"!) */
pos = GEO_SOUTHEAST;
@ -760,6 +833,31 @@ calmaElementText()
else if (nbytes > 0 && rtype != CALMA_STRANS)
calmaSkipSet(ignore);
/* NOTE: Record may contain both PRESENTATION and WIDTH */
PEEKRH(nbytes, rtype);
if (nbytes > 0 && rtype == CALMA_WIDTH)
{
int width;
/* Use WIDTH value to set the font size */
if (!calmaReadI4Record(CALMA_WIDTH, &width))
{
CalmaReadError("Error in reading WIDTH in calmaElementText()\n") ;
return;
}
width *= calmaReadScale1;
if (width % calmaReadScale2 != 0)
CalmaReadError("Text width snapped to nearest integer boundary.\n");
width /= calmaReadScale2;
/* Convert to database units, because dimension goes to PutLabel */
/* and is not converted through CIFPaintCurrent(). */
size = CIFScaleCoord(width, COORD_ANY);
}
else if (nbytes > 0 && rtype != CALMA_STRANS)
calmaSkipSet(ignore);
READRH(nbytes, rtype);
if (nbytes > 0 && rtype == CALMA_STRANS)
{
@ -770,10 +868,20 @@ calmaElementText()
if (nbytes > 0 && rtype == CALMA_MAG)
{
calmaReadR8(&dval);
/* Assume that MAG is the label size in microns */
/* "size" is the label size in 8 * (database units) */
size = (int)((dval * 800 * cifCurReadStyle->crs_multiplier)
/ cifCurReadStyle->crs_scaleFactor);
/* Sanity check on dval (must be nonzero positive) */
if ((dval <= 0) || (dval > 10000))
{
CalmaReadError("Invalid text magnification %lg.\n", dval);
/* Keep default size */
}
else
/* Assume that MAG is the label size in microns */
/* "size" is the label size in 10 * (database units) */
/* The "calma magscale" option can be used to */
/* reinterpret the size for any specific GDS file. */
size = (int)(0.5 + ((dval * 1000 * CalmaMagScale
* cifCurReadStyle->crs_multiplier)
/ cifCurReadStyle->crs_scaleFactor));
}
else
UNREADRH(nbytes, rtype);
@ -802,7 +910,7 @@ calmaElementText()
nbytes -= CALMAHEADERLENGTH;
if (nbytes < 8)
{
calmaReadError("Not enough bytes in point record.\n");
CalmaReadError("Not enough bytes in point record.\n");
}
else
{
@ -825,7 +933,7 @@ calmaElementText()
* a flag for that in the "cifoutput" section of the techfile.
*/
#if 0
#if 0
{
static bool algmsg = FALSE;
@ -834,7 +942,7 @@ calmaElementText()
char *savstring;
for (cp = textbody; *cp; cp++)
{
if (*cp <= ' ' | *cp > '~')
if (*cp <= ' ' | *cp > '~')
{
if (!changed)
{
@ -843,7 +951,7 @@ calmaElementText()
}
if (*cp == '\r' && *(cp+1) == '\0')
*cp = '\0';
else if (*cp == '\r')
else if (*cp == '\r')
*cp = '_';
else if (*cp == ' ')
*cp = '_';
@ -852,15 +960,15 @@ calmaElementText()
}
}
if (changed) {
calmaReadError("Warning: improper characters fixed in label '%s'\n",
CalmaReadError("Warning: improper characters fixed in label '%s'\n",
savstring);
if (!algmsg) {
algmsg = TRUE;
calmaReadError(" (algorithm used: trailing <CR> dropped, "
CalmaReadError(" (algorithm used: trailing <CR> dropped, "
"<CR> and ' ' changed to '_', \n"
" other non-printables changed to '?')\n");
}
calmaReadError(" modified label is '%s'\n", textbody);
CalmaReadError(" modified label is '%s'\n", textbody);
freeMagic(savstring);
}
}
@ -870,53 +978,110 @@ calmaElementText()
/* Place the label */
if (strlen(textbody) == 0)
{
calmaReadError("Warning: Ignoring empty string label at (%d, %d)\n",
CalmaReadError("Warning: Ignoring empty string label at (%d, %d)\n",
r.r_ll.p_x * cifCurReadStyle->crs_scaleFactor,
r.r_ll.p_y * cifCurReadStyle->crs_scaleFactor);
}
else if (cifCurReadStyle->crs_labelSticky[cifnum] == LABEL_TYPE_CELLID)
{
/* Special handling of label layers marked "cellid" in the techfile. */
/* The actual cellname is the ID string, not the GDS structure name. */
DBCellRenameDef(cifReadCellDef, textbody);
}
else if (type < 0)
{
calmaReadError("Warning: label \"%s\" at (%d, %d) is on unhandled"
" layer:purpose pair %d:%d and will be discarded.\n", textbody,
r.r_ll.p_x * cifCurReadStyle->crs_scaleFactor,
r.r_ll.p_y * cifCurReadStyle->crs_scaleFactor, layer, textt);
if (!(cifCurReadStyle->crs_flags & CRF_IGNORE_UNKNOWNLAYER_LABELS))
CalmaReadError("Warning: label \"%s\" at (%d, %d) is on unhandled"
" layer:purpose pair %d:%d and will be discarded.\n", textbody,
r.r_ll.p_x * cifCurReadStyle->crs_scaleFactor,
r.r_ll.p_y * cifCurReadStyle->crs_scaleFactor, layer, textt);
}
else
{
int flags, i;
Label *lab;
Label *sl;
if (cifnum >= 0 && (cifCurReadStyle->crs_labelSticky[cifnum] != LABEL_TYPE_NONE))
flags = LABEL_STICKY;
else if (cifCurReadStyle->crs_flags & CRF_NO_RECONNECT_LABELS)
if (type == TT_SPACE)
/* Assigning GDS layer to space prevents making the label sticky */
flags = 0;
else if (cifnum >= 0 && (cifCurReadStyle->crs_labelSticky[cifnum] != LABEL_TYPE_NONE))
flags = LABEL_STICKY;
else
flags = 0;
/* If there is an empty-string label surrounding the label position */
/* then replace the position with the larger one and remove the */
/* empty label. */
sl = NULL;
for (lab = cifReadCellDef->cd_labels; lab != NULL; lab = lab->lab_next)
{
if (lab->lab_text[0] == '\0')
{
if ((GEO_SURROUND(&lab->lab_rect, &r)) && (lab->lab_type == type))
{
r = lab->lab_rect;
if (sl == NULL)
cifReadCellDef->cd_labels = lab->lab_next;
else
sl->lab_next = lab->lab_next;
if (cifReadCellDef->cd_lastLabel == lab)
cifReadCellDef->cd_lastLabel = sl;
/* Port number from the placeholder is ignored; find
* a new valid port number for the new label name.
*/
i = -1;
for (sl = cifReadCellDef->cd_labels; sl != NULL; sl = sl->lab_next)
{
idx = sl->lab_port;
if (idx > i) i = idx;
if ((idx > 0) && (sl != lab) && !strcmp(sl->lab_text, textbody))
{
i = idx - 1;
break;
}
}
i++;
portnum = i;
flags |= PORT_DIR_NORTH | PORT_DIR_SOUTH |
PORT_DIR_EAST | PORT_DIR_WEST;
freeMagic((char *)lab);
break;
}
}
sl = lab;
}
if (font < 0)
lab = DBPutLabel(cifReadCellDef, &r, pos, textbody, type, flags);
lab = DBPutLabel(cifReadCellDef, &r, pos, textbody, type, flags, portnum);
else
lab = DBPutFontLabel(cifReadCellDef, &r, font, size, angle,
&GeoOrigin, pos, textbody, type, flags);
&GeoOrigin, pos, textbody, type, flags, portnum);
if ((lab != NULL) && (cifnum >= 0) &&
(cifCurReadStyle->crs_labelSticky[cifnum] == LABEL_TYPE_PORT))
{
Label *sl;
int idx;
/* No port information can be encoded in the GDS file, so */
/* assume defaults, and assume that the port order is the */
/* order in which labels arrive in the GDS stream. */
/* order in which labels arrive in the GDS stream. If */
/* ports have the same text, then give them the same index. */
i = -1;
for (sl = cifReadCellDef->cd_labels; sl != NULL; sl = sl->lab_next)
{
idx = sl->lab_flags & PORT_NUM_MASK;
idx = sl->lab_port;
if (idx > i) i = idx;
if ((idx > 0) && (sl != lab) && !strcmp(sl->lab_text, textbody))
{
i = idx - 1;
break;
}
}
i++;
lab->lab_flags |= (PORT_NUM_MASK & i);
lab->lab_port = i;
lab->lab_flags |= PORT_DIR_NORTH | PORT_DIR_SOUTH |
PORT_DIR_EAST | PORT_DIR_WEST;
}
@ -925,7 +1090,7 @@ calmaElementText()
/* done with textbody */
if (textbody != NULL) freeMagic(textbody);
}
/*
* ----------------------------------------------------------------------------
*
@ -937,26 +1102,24 @@ calmaElementText()
* centerline, to avoid roundoff errors.
*
* Results:
* TRUE is returned if the path was parsed successfully,
* FALSE otherwise.
* non-NULL CIFPath* the caller takes ownership of
* if the path was parsed successfully, otherwise NULL.
*
* Side effects:
* Modifies the parameter pathheadpp to point to the path
* that is constructed.
* None
*
* ----------------------------------------------------------------------------
*/
bool
calmaReadPath(pathheadpp, iscale)
CIFPath **pathheadpp;
int iscale;
CIFPath *
calmaReadPath(
int iscale)
{
CIFPath path, *pathtailp, *newpathp;
CIFPath path, *pathheadp, *pathtailp, *newpathp;
int nbytes, rtype, npoints, savescale;
bool nonManhattan = FALSE;
*pathheadpp = (CIFPath *) NULL;
pathheadp = (CIFPath *) NULL;
pathtailp = (CIFPath *) NULL;
path.cifp_next = (CIFPath *) NULL;
@ -964,13 +1127,13 @@ calmaReadPath(pathheadpp, iscale)
READRH(nbytes, rtype);
if (nbytes < 0)
{
calmaReadError("EOF when reading path.\n");
return (FALSE);
CalmaReadError("EOF when reading path.\n");
return (NULL);
}
if (rtype != CALMA_XY)
{
calmaUnexpected(CALMA_XY, rtype);
return (FALSE);
return (NULL);
}
/* Read this many points (pairs of four-byte integers) */
@ -981,7 +1144,7 @@ calmaReadPath(pathheadpp, iscale)
calmaReadPoint(&path.cifp_point, iscale);
if (savescale != calmaReadScale1)
{
CIFPath *phead = *pathheadpp;
CIFPath *phead = pathheadp;
int newscale = calmaReadScale1 / savescale;
while (phead != NULL)
{
@ -991,13 +1154,13 @@ calmaReadPath(pathheadpp, iscale)
}
}
if (ABS(path.cifp_x) > 0x0fffffff || ABS(path.cifp_y) > 0x0fffffff) {
calmaReadError("Warning: Very large point in path: (%d, %d)\n",
CalmaReadError("Warning: Very large point in path: (%d, %d)\n",
path.cifp_x, path.cifp_y);
}
if (feof(calmaInputFile))
if (FEOF(calmaInputFile))
{
CIFFreePath(*pathheadpp);
return (FALSE);
CIFFreePath(pathheadp);
return (NULL);
}
if (iscale != 0)
@ -1005,7 +1168,7 @@ calmaReadPath(pathheadpp, iscale)
newpathp = (CIFPath *) mallocMagic((unsigned) (sizeof (CIFPath)));
*newpathp = path;
if (*pathheadpp)
if (pathheadp)
{
/*
* Check that this segment is Manhattan. If not, remember the
@ -1026,13 +1189,13 @@ calmaReadPath(pathheadpp, iscale)
}
pathtailp->cifp_next = newpathp;
}
else *pathheadpp = newpathp;
else pathheadp = newpathp;
pathtailp = newpathp;
}
}
return (*pathheadpp != NULL);
return (pathheadp);
}
/*
* ----------------------------------------------------------------------------
*
@ -1055,20 +1218,29 @@ calmaReadPath(pathheadpp, iscale)
*/
void
calmaLayerError(mesg, layer, dt)
char *mesg;
int layer;
int dt;
calmaLayerError(
char *mesg,
int layer,
int dt)
{
CalmaLayerType clt;
HashEntry *he;
/* Ignore errors for cells that are marked as read-only, since */
/* these are normally expected to have unhandled layer types, */
/* since the purpose of read-only cells is to preserve exactly */
/* layout in the cell which may not be represented in the tech */
/* file. */
if ((cifReadCellDef->cd_flags & CDVENDORGDS) == CDVENDORGDS)
return;
clt.clt_layer = layer;
clt.clt_type = dt;
he = HashFind(&calmaLayerHash, (char *) &clt);
if (HashGetValue(he) == NULL)
{
HashSetValue(he, (ClientData) 1);
calmaReadError("%s, layer=%d type=%d\n", mesg, layer, dt);
CalmaReadError("%s, layer=%d type=%d\n", mesg, layer, dt);
}
}

View File

@ -3,23 +3,24 @@
*
* Input of Calma GDS-II stream format.
*
* *********************************************************************
* * Copyright (C) 1985, 1990 Regents of the University of California. *
* * Permission to use, copy, modify, and distribute this *
* * software and its documentation for any purpose and without *
* * fee is hereby granted, provided that the above copyright *
* * notice appear in all copies. The University of California *
* * makes no representations about the suitability of this *
* * software for any purpose. It is provided "as is" without *
* * express or implied warranty. Export of this software outside *
* * of the United States of America may require an export license. *
* *********************************************************************
* * Copyright (C) 1985, 1990 Regents of the University of California. *
* * Permission to use, copy, modify, and distribute this *
* * software and its documentation for any purpose and without *
* * fee is hereby granted, provided that the above copyright *
* * notice appear in all copies. The University of California *
* * makes no representations about the suitability of this *
* * software for any purpose. It is provided "as is" without *
* * express or implied warranty. Export of this software outside *
* * of the United States of America may require an export license. *
* *********************************************************************
*/
#ifndef lint
static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/calma/CalmaRead.c,v 1.3 2010/06/24 12:37:15 tim Exp $";
static const char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/calma/CalmaRead.c,v 1.3 2010/06/24 12:37:15 tim Exp $";
#endif /* not lint */
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
@ -27,6 +28,12 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
#include <netinet/in.h>
/*
* C99 compat
* Mind: tcltk/tclmagic.h must be included prior to all the other headers
*/
#include "tcltk/tclmagic.h"
#include "utils/magic.h"
#include "utils/geometry.h"
#include "tiles/tile.h"
@ -46,14 +53,17 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
#include "textio/textio.h"
#include "calma/calmaInt.h"
#include "commands/commands.h" /* for CmdGetRootPoint */
#include "utils/main.h" /* for EditCellUse */
#include "utils/undo.h"
/* C99 compat */
#include "calma/calma.h"
/* Globals for Calma reading */
FILE *calmaInputFile = NULL; /* Read from this stream */
FILETYPE calmaInputFile = NULL; /* Read from this stream */
FILE *calmaErrorFile = NULL; /* Write error output here */
bool CalmaSubcellPolygons = FALSE; /* Put non-Manhattan polygons
* in their own subcells.
*/
unsigned char CalmaSubcellPolygons = CALMA_POLYGON_NONE;
/* Read non-Manhattan polygons as-is */
int CalmaPolygonCount;
bool CalmaSubcellPaths = FALSE; /* Put paths in their own subcells. */
int CalmaPathCount;
@ -63,10 +73,21 @@ bool CalmaFlattenUses = FALSE; /* If TRUE, small cells in the input
* performance when handling contacts
* saved as subcell arrays.
*/
char **CalmaFlattenUsesByName = NULL; /* NULL-terminated list of strings
* to do glob-style pattern matching
* to determine what cells to flatten
* by cellname.
*/
bool CalmaReadOnly = FALSE; /* Set files to read-only and
* retain file position information
* so cells can be written verbatim.
*/
float CalmaMagScale = 1.0; /* Scale by which to interpret the MAG
* record in GDS text records. The
* default is to treat the value as
* the text height in microns. This
* value reinterprets the scale.
*/
bool CalmaNoDRCCheck = FALSE; /* If TRUE, don't mark cells as needing
* a DRC check; they will be assumed
* DRC clean.
@ -77,9 +98,21 @@ bool CalmaPostOrder = FALSE; /* If TRUE, forces the GDS parser to
* flatten cells that are contact cuts.
* Added by Nishit 8/16/2004
*/
extern void calmaUnexpected();
bool CalmaNoDuplicates = FALSE; /* If TRUE, then if a cell exists in
* memory with the same name as a cell
* in the GDS file, then the cell in
* the GDS file is skipped.
*/
bool CalmaUnique = FALSE; /* If TRUE, then if a cell exists in
* memory with the same name as a cell
* in the GDS file, then the cell in
* memory is renamed to a unique
* identifier with a _N suffix.
*/
extern bool CalmaDoLibrary; /* Also used by GDS write */
bool calmaParseUnits();
extern void calmaUnexpected(int wanted, int got);
extern int calmaWriteInitFunc(CellDef *def);
/*
* Scaling.
@ -114,8 +147,8 @@ HashTable calmaLayerHash;
HashTable calmaDefInitHash;
/* Common stuff to ignore */
int calmaElementIgnore[] = { CALMA_ELFLAGS, CALMA_PLEX, -1 };
const int calmaElementIgnore[] = { CALMA_ELFLAGS, CALMA_PLEX, -1 };
/*
* ----------------------------------------------------------------------------
*
@ -134,18 +167,24 @@ int calmaElementIgnore[] = { CALMA_ELFLAGS, CALMA_PLEX, -1 };
*/
void
CalmaReadFile(file, filename)
FILE *file; /* File from which to read Calma */
char *filename; /* The real name of the file read */
CalmaReadFile(
FILETYPE file, /* File from which to read Calma */
char *filename) /* The real name of the file read */
{
int k, version;
char *libname = NULL;
char *libname = NULL, *libnameptr = NULL;
MagWindow *mw;
static int hdrSkip[] = { CALMA_FORMAT, CALMA_MASK, CALMA_ENDMASKS,
CALMA_REFLIBS, CALMA_FONTS, CALMA_ATTRTABLE,
CALMA_STYPTABLE, CALMA_GENERATIONS, -1 };
static int skipBeforeLib[] = { CALMA_LIBDIRSIZE, CALMA_SRFNAME,
CALMA_LIBSECUR, -1 };
static const int hdrSkip[] = { CALMA_FORMAT, CALMA_MASK, CALMA_ENDMASKS,
CALMA_REFLIBS, CALMA_FONTS, CALMA_ATTRTABLE,
CALMA_STYPTABLE, CALMA_GENERATIONS, -1 };
static const int skipBeforeLib[] = { CALMA_LIBDIRSIZE, CALMA_SRFNAME,
CALMA_LIBSECUR, -1 };
if (EditCellUse == (CellUse *)NULL)
{
TxError("Cannot read GDS: There is no edit cell.\n");
return;
}
/* We will use full cell names as keys in this hash table */
CIFReadCellInit(0);
@ -172,6 +211,12 @@ CalmaReadFile(file, filename)
CalmaPolygonCount = 0;
CalmaPathCount = 0;
/* Reset cd_client pointers (using init function from CalmaWrite.c) */
/* This is in case a cell already in memory is being referenced; */
/* it is probably better to avoid those kinds of naming collisions */
/* though. . . */
(void) DBCellSrDefs(0, calmaWriteInitFunc, (ClientData) NULL);
HashInit(&calmaDefInitHash, 32, 0);
calmaLApresent = FALSE;
calmaInputFile = file;
@ -181,20 +226,48 @@ CalmaReadFile(file, filename)
if (version < 600)
TxPrintf("Library written using GDS-II Release %d.0\n", version);
else
TxPrintf("Library written using GDS-II Release %d.%d\n",
TxPrintf("Library written using GDS-II Release %d.%d\n",
version / 100, version % 100);
if (!calmaSkipExact(CALMA_BGNLIB)) goto done;
calmaSkipSet(skipBeforeLib);
if (!calmaReadStringRecord(CALMA_LIBNAME, &libname)) goto done;
if ((libname != NULL) && (libname[0] != '\0'))
/* Use CalmaDoLibrary similarly for input as for output; if set to */
/* TRUE, the library name is considered meaningless and discarded; */
/* the GDS file contents are read into memory but no view is loaded */
if (CalmaDoLibrary)
libnameptr = NULL;
else
libnameptr = libname;
if ((libnameptr != NULL) && (libname[0] != '\0'))
{
bool modified = FALSE;
char *sptr;
/* Avoid generating a magic name with spaces in it. . . */
/* (added by Mike Godfrey, 7/17/05) */
for (k = 0; k < strlen(libname); k++)
if (libname[k] == ' ')
{
libname[k] = '_';
TxPrintf("Library name: %s\n", libname);
modified = TRUE;
}
/* Avoid generating a magic name with slashes in it. . . */
/* (added by Tim, 8/26/2022) */
if ((sptr = strrchr(libname, '/')) != NULL)
{
libnameptr = sptr + 1;
modified = TRUE;
}
if (modified)
TxPrintf("Library name modified to make legal cell name syntax.\n");
TxPrintf("Library name: %s\n", libnameptr);
}
/* Skip the reflibs, fonts, etc. cruft */
@ -219,24 +292,28 @@ done:
/* top-level cell, so magic-produced GDS can be read back */
/* with the expected cell appearing in the layout window. */
if (libname != NULL)
if (libnameptr != NULL)
{
mw = CmdGetRootPoint((Point *)NULL, (Rect *)NULL);
if (mw == NULL)
windCheckOnlyWindow(&mw, DBWclientID);
if (mw != NULL)
{
if (calmaLookCell(libname, NULL) != (CellDef *)NULL)
DBWloadWindow(mw, libname, FALSE);
if (calmaLookCell(libnameptr) != (CellDef *)NULL)
DBWloadWindow(mw, libnameptr, 0);
}
freeMagic(libname);
}
CIFReadCellCleanup(1);
CIFReadCellCleanup(FILE_CALMA);
HashKill(&calmaDefInitHash);
UndoEnable();
if (calmaErrorFile != NULL) fclose(calmaErrorFile);
if (calmaErrorFile != NULL)
{
fclose(calmaErrorFile);
calmaErrorFile = NULL;
}
}
/*
@ -270,12 +347,13 @@ done:
*/
bool
calmaParseUnits()
calmaParseUnits(void)
{
int nbytes, rtype;
int nbytes, rtype = 0;
double metersPerDBUnit;
double userUnitsPerDBUnit;
double cuPerDBUnit;
bool compatible;
READRH(nbytes, rtype);
#ifdef lint
@ -294,6 +372,39 @@ calmaParseUnits()
/* Read meters per database unit */
if (!calmaReadR8(&metersPerDBUnit)) return (FALSE);
/* Important! When CalmaReadOnly is TRUE, then this file will have its
* contents output verbatim. But if the database units don't match,
* then it will get output at the wrong scale. Setting a magnification
* factor on the instance when generating output might (?) work. For
* now, prohibiting a GDS read in read-only mode when the database units
* don't match. This forces the user either to reconsider the read-only
* status or to rewrite the GDS at a compatible scalefactor.
*/
compatible = TRUE;
if (CalmaReadOnly == TRUE)
{
if (CIFCurStyle->cs_flags & CWF_ANGSTROMS)
{
if ((int)(0.5 + metersPerDBUnit * 1e12) != 100)
{
CalmaReadError("Incompatible scale factor of %g, must be 1e-10.\n",
metersPerDBUnit);
TxError("Cannot read this file in read-only mode.\n");
return FALSE;
}
}
else
{
if ((int)(0.5 + metersPerDBUnit * 1e11) != 100)
{
CalmaReadError("Incompatible scale factor of %g, must be 1e-9.\n",
metersPerDBUnit);
TxError("Cannot read this file in read-only mode.\n");
return FALSE;
}
}
}
#ifdef notdef
TxPrintf("1 database unit equals %e user units\n", userUnitsPerDBUnit);
TxPrintf("1 database unit equals %e meters\n", metersPerDBUnit);
@ -326,11 +437,11 @@ calmaParseUnits()
return (TRUE);
}
/*
* ----------------------------------------------------------------------------
*
* calmaReadError --
* CalmaReadError --
*
* This procedure is called to print out error messages during
* Calma file reading.
@ -348,31 +459,38 @@ calmaParseUnits()
*/
void
/*VARARGS1*/
calmaReadError(format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10)
char *format;
char *a1, *a2, *a3, *a4, *a5, *a6, *a7, *a8, *a9, *a10;
CalmaReadError(const char *format, ...)
{
va_list args;
OFFTYPE filepos;
calmaTotalErrors++;
if (CIFWarningLevel == CIF_WARN_NONE) return;
if ((calmaTotalErrors < 100) || (CIFWarningLevel != CIF_WARN_LIMIT))
{
{
filepos = FTELL(calmaInputFile);
if (CIFWarningLevel == CIF_WARN_REDIRECT)
{
if (calmaErrorFile != NULL)
{
fprintf(calmaErrorFile, "Error while reading cell \"%s\": ",
fprintf(calmaErrorFile, "Error while reading cell \"%s\" ",
cifReadCellDef->cd_name);
fprintf(calmaErrorFile, format, a1, a2, a3, a4, a5, a6, a7,
a8, a9, a10);
fprintf(calmaErrorFile, "(byte position %"DLONG_PREFIX"d): ",
(dlong)filepos);
va_start(args, format);
Vfprintf(calmaErrorFile, format, args);
va_end(args);
}
}
else
{
TxError("Error while reading cell \"%s\": ", cifReadCellDef->cd_name);
TxError(format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
TxError("Error while reading cell \"%s\" ", cifReadCellDef->cd_name);
TxError("(byte position %"DLONG_PREFIX"d): ", (dlong)filepos);
va_start(args, format);
TxErrorV(format, args);
va_end(args);
}
}
else if ((calmaTotalErrors == 100) && (CIFWarningLevel == CIF_WARN_LIMIT))
@ -380,7 +498,7 @@ calmaReadError(format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10)
TxError("Error limit set: Remaining errors will not be reported.\n");
}
}
/*
* ----------------------------------------------------------------------------
*
@ -398,11 +516,11 @@ calmaReadError(format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10)
*/
void
calmaUnexpected(wanted, got)
int wanted; /* Type of record we wanted */
int got; /* Type of record we got */
calmaUnexpected(
int wanted, /* Type of record we wanted */
int got) /* Type of record we got */
{
calmaReadError("Unexpected record type in input: \n");
CalmaReadError("Unexpected record type in input: \n");
if (CIFWarningLevel == CIF_WARN_NONE) return;
if (calmaTotalErrors < 100 || (CIFWarningLevel != CIF_WARN_LIMIT))
@ -423,7 +541,7 @@ calmaUnexpected(wanted, got)
}
}
}
/*
* ----------------------------------------------------------------------------
*
@ -440,12 +558,12 @@ calmaUnexpected(wanted, got)
* ----------------------------------------------------------------------------
*/
char *
calmaRecordName(rtype)
int rtype;
const char *
calmaRecordName(
int rtype)
{
static char numeric[10];
static char *calmaRecordNames[] =
static const char * const calmaRecordNames[] =
{
"HEADER", "BGNLIB", "LIBNAME", "UNITS",
"ENDLIB", "BGNSTR", "STRNAME", "ENDSTR",
@ -472,7 +590,7 @@ calmaRecordName(rtype)
return (calmaRecordNames[rtype]);
}
/*
* ----------------------------------------------------------------------------
*
@ -490,8 +608,28 @@ calmaRecordName(rtype)
*/
void
CalmaTechInit()
CalmaTechInit(void)
{
ASSERT(sizeof(FourByteInt)==4, "definition in calmaInt.h");
ASSERT(sizeof(TwoByteInt)==2, "definition in calmaInt.h");
/* NOTE: Add "$$*$$" to the default "flatglob" value */
/* when CalmaContactArrays behaves like the non-arrayed */
/* function and can be enabled by default. */
/* Initialize CalmaFlattenByName to have one entry for */
/* "*_CDNS_*" to match the name style used by many foundry */
/* cells and which corresponds to pcells that often split */
/* layers between cells in ways that magic can't cope with; */
/* and whose original parameterized functions cannot be */
/* recovered by magic anyway. When necessary, this default */
/* can be overridden by the "gds flatglob none" command */
/* option. */
if (CalmaFlattenUsesByName == (char **)NULL)
{
CalmaFlattenUsesByName = (char **)mallocMagic(2 * sizeof(char *));
*CalmaFlattenUsesByName = StrDup((char **)NULL, "*_CDNS_*");
*(CalmaFlattenUsesByName + 1) = NULL;
}
}

File diff suppressed because it is too large Load Diff

2847
calma/CalmaWriteZ.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,30 +0,0 @@
CalmaRead.o: CalmaRead.c ../utils/magic.h ../utils/geometry.h \
../tiles/tile.h ../utils/utils.h ../utils/hash.h ../database/database.h \
../database/databaseInt.h ../utils/malloc.h ../utils/tech.h ../cif/cif.h \
../cif/CIFint.h ../cif/CIFread.h ../utils/signals.h ../windows/windows.h \
../dbwind/dbwind.h ../utils/styles.h ../textio/textio.h \
../calma/calmaInt.h ../commands/commands.h ../utils/undo.h
CalmaRdcl.o: CalmaRdcl.c ../utils/magic.h ../utils/geometry.h \
../tiles/tile.h ../utils/utils.h ../utils/hash.h ../database/database.h \
../database/databaseInt.h ../utils/malloc.h ../utils/tech.h ../cif/cif.h \
../cif/CIFint.h ../cif/CIFread.h ../utils/signals.h ../windows/windows.h \
../dbwind/dbwind.h ../utils/styles.h ../textio/textio.h \
../calma/calmaInt.h ../calma/calma.h
CalmaRdio.o: CalmaRdio.c ../utils/magic.h ../utils/geometry.h \
../tiles/tile.h ../utils/utils.h ../utils/hash.h ../database/database.h \
../database/databaseInt.h ../utils/malloc.h ../utils/tech.h ../cif/cif.h \
../cif/CIFint.h ../cif/CIFread.h ../utils/signals.h ../windows/windows.h \
../dbwind/dbwind.h ../utils/styles.h ../textio/textio.h \
../calma/calmaInt.h
CalmaRdpt.o: CalmaRdpt.c ../utils/magic.h ../utils/geometry.h \
../tiles/tile.h ../utils/utils.h ../utils/hash.h ../database/database.h \
../database/databaseInt.h ../utils/malloc.h ../utils/tech.h ../cif/cif.h \
../cif/CIFint.h ../cif/CIFread.h ../utils/signals.h ../windows/windows.h \
../dbwind/dbwind.h ../utils/styles.h ../textio/textio.h \
../calma/calmaInt.h ../calma/calma.h
CalmaWrite.o: CalmaWrite.c ../utils/magic.h ../utils/malloc.h \
../utils/geometry.h ../tiles/tile.h ../utils/utils.h ../utils/hash.h \
../database/database.h ../database/databaseInt.h ../utils/tech.h \
../cif/cif.h ../cif/CIFint.h ../utils/signals.h ../windows/windows.h \
../dbwind/dbwind.h ../utils/styles.h ../textio/textio.h \
../calma/calmaInt.h ../utils/main.h ../utils/stack.h

View File

@ -4,7 +4,7 @@
MODULE = calma
MAGICDIR = ..
SRCS = CalmaRead.c CalmaRdcl.c CalmaRdio.c CalmaRdpt.c CalmaWrite.c
SRCS = CalmaRead.c CalmaRdcl.c CalmaRdio.c CalmaRdpt.c CalmaWrite.c CalmaWriteZ.c
include ${MAGICDIR}/defs.mak
include ${MAGICDIR}/rules.mak

View File

@ -4,43 +4,97 @@
* This file defines things that are exported by the
* calma module to the rest of the world.
*
* *********************************************************************
* * Copyright (C) 1985, 1990 Regents of the University of California. *
* * Permission to use, copy, modify, and distribute this *
* * software and its documentation for any purpose and without *
* * fee is hereby granted, provided that the above copyright *
* * notice appear in all copies. The University of California *
* * makes no representations about the suitability of this *
* * software for any purpose. It is provided "as is" without *
* * express or implied warranty. Export of this software outside *
* * of the United States of America may require an export license. *
* *********************************************************************
* * Copyright (C) 1985, 1990 Regents of the University of California. *
* * Permission to use, copy, modify, and distribute this *
* * software and its documentation for any purpose and without *
* * fee is hereby granted, provided that the above copyright *
* * notice appear in all copies. The University of California *
* * makes no representations about the suitability of this *
* * software for any purpose. It is provided "as is" without *
* * express or implied warranty. Export of this software outside *
* * of the United States of America may require an export license. *
* *********************************************************************
*
* rcsid $Header: /usr/cvsroot/magic-8.0/calma/calma.h,v 1.1.1.1 2008/02/03 20:43:50 tim Exp $
*/
#ifndef _CALMA_H
#define _CALMA_H
#ifndef _MAGIC__CALMA__CALMA_H
#define _MAGIC__CALMA__CALMA_H
#include "utils/magic.h"
/* Externally visible variables */
extern bool CalmaSubcellPolygons;
extern unsigned char CalmaSubcellPolygons;
extern bool CalmaSubcellPaths;
extern bool CalmaDoLabels;
extern bool CalmaDoLibrary;
extern bool CalmaDoLower;
extern bool CalmaAddendum;
extern bool CalmaNoDuplicates;
extern time_t *CalmaDateStamp;
extern bool CalmaUnique;
extern TileTypeBitMask *CalmaMaskHints;
extern bool CalmaMergeTiles;
extern bool CalmaFlattenArrays;
extern bool CalmaNoDRCCheck;
extern bool CalmaFlattenUses;
extern int CalmaFlattenLimit;
extern float CalmaMagScale;
extern char **CalmaFlattenUsesByName;
extern bool CalmaReadOnly;
extern bool CalmaContactArrays;
#ifdef HAVE_ZLIB
extern int CalmaCompression;
#endif
extern bool CalmaPostOrder;
extern bool CalmaAllowUndefined;
extern bool CalmaAllowAbstract;
/* Definitions used by the return value for CalmaSubcellPolygons */
/* CALMA_POLYGON_NONE: Process polygons immediately */
/* CALMA_POLYGON_TEMP: Create temporary polygon subcells */
/* CALMA_POLYGON_KEEP: Keep polygons in subcells */
#define CALMA_POLYGON_NONE 0
#define CALMA_POLYGON_TEMP 1
#define CALMA_POLYGON_KEEP 2
/* Externally-visible procedures: */
extern bool CalmaWrite();
extern void CalmaReadFile();
extern void CalmaTechInit();
extern bool CalmaGenerateArray();
extern bool CalmaWrite(CellDef *rootDef, FILE *f);
extern void CalmaReadFile(FILETYPE file, char *filename);
extern void CalmaTechInit(void);
extern bool CalmaGenerateArray(FILE *f, TileType type, int llx, int lly, int pitch, int cols, int rows);
extern void CalmaReadError(const char *format, ...) ATTR_FORMAT_PRINTF_1;
#endif /* _CALMA_H */
/* C99 compat */
extern void calmaDelContacts(void);
extern void calmaElementBoundary(void);
extern void calmaElementBox(void);
extern void calmaElementPath(void);
extern void calmaElementText(void);
extern bool calmaIsUseNameDefault(char *defName, char *useName);
extern bool calmaParseStructure(char *filename);
extern int calmaProcessDef(CellDef *def, FILE *outf, bool do_library);
#ifdef HAVE_ZLIB
extern int calmaProcessDefZ(CellDef *def, gzFile outf, bool do_library);
#endif
extern bool calmaReadI2Record(int type, int *pvalue);
extern bool calmaReadI4Record(int type, int *pvalue);
extern void calmaReadPoint(Point *p, int iscale);
extern bool calmaReadR8(double *pd);
extern bool calmaReadStampRecord(int type, int *stampptr);
extern bool calmaReadStringRecord(int type, char **str);
extern bool calmaReadStringRecord(int type, char **str);
extern bool calmaReadTransform(Transform *ptrans, char *name);
extern bool calmaSkipBytes(int nbytes);
extern bool calmaSkipExact(int type);
extern bool calmaSkipTo(int what);
extern void calmaUnexpected(int wanted, int got);
#ifdef HAVE_ZLIB
extern bool CalmaWriteZ(CellDef *rootDef, gzFile f);
extern bool CalmaGenerateArrayZ(gzFile f, TileType type, int llx, int lly, int pitch, int cols, int rows);
#endif
#endif /* _MAGIC__CALMA__CALMA_H */

View File

@ -4,23 +4,23 @@
* This file defines constants used internally by the calma
* module, but not exported to the rest of the world.
*
* *********************************************************************
* * Copyright (C) 1985, 1990 Regents of the University of California. *
* * Permission to use, copy, modify, and distribute this *
* * software and its documentation for any purpose and without *
* * fee is hereby granted, provided that the above copyright *
* * notice appear in all copies. The University of California *
* * makes no representations about the suitability of this *
* * software for any purpose. It is provided "as is" without *
* * express or implied warranty. Export of this software outside *
* * of the United States of America may require an export license. *
* *********************************************************************
* * Copyright (C) 1985, 1990 Regents of the University of California. *
* * Permission to use, copy, modify, and distribute this *
* * software and its documentation for any purpose and without *
* * fee is hereby granted, provided that the above copyright *
* * notice appear in all copies. The University of California *
* * makes no representations about the suitability of this *
* * software for any purpose. It is provided "as is" without *
* * express or implied warranty. Export of this software outside *
* * of the United States of America may require an export license. *
* *********************************************************************
*
* rcsid $Header: /usr/cvsroot/magic-8.0/calma/calmaInt.h,v 1.2 2010/06/24 12:37:15 tim Exp $
*/
#ifndef _CALMAINT_H
#define _CALMAINT_H
#ifndef _MAGIC__CALMA__CALMAINT_H
#define _MAGIC__CALMA__CALMAINT_H
#include "utils/magic.h"
#include "database/database.h"
@ -99,6 +99,7 @@
#define CALMA_NUMRECORDTYPES 60 /* Number of above types */
/* Property types defined for magic */
#define CALMA_PROP_USENAME_STD 61 /* To record non-default cell use ids */
#define CALMA_PROP_USENAME 98 /* To record non-default cell use ids */
#define CALMA_PROP_ARRAY_LIMITS 99 /* To record non-default array limits */
@ -130,10 +131,17 @@ typedef struct
/* Length of record header */
#define CALMAHEADERLENGTH 4
/* Label types
* The intention is all the values can be stored/converted with unsigned char type,
* C23 allows us to be explicit with the type but C99 does not, so a comment for now.
*/
typedef enum /* : unsigned char */ { LABEL_TYPE_NONE, LABEL_TYPE_TEXT, LABEL_TYPE_PORT, LABEL_TYPE_CELLID } labelType;
/* ------------------------- Input macros ----------------------------- */
/* Globals for Calma reading */
extern FILE *calmaInputFile;
extern FILETYPE calmaInputFile;
extern FILE *calmaInputFileNoCompression;
extern char *calmaFilename;
extern int calmaReadScale1;
extern int calmaReadScale2;
@ -154,7 +162,7 @@ extern int calmaLArtype;
# define ntohs(x) (x)
# define htonl(x) (x)
# define htons(x) (x)
# endif
# endif
#endif
typedef union { char uc[2]; unsigned short us; } TwoByteInt;
@ -164,8 +172,8 @@ typedef union { char uc[4]; unsigned int ul; } FourByteInt;
#define READI2(z) \
{ \
TwoByteInt u; \
u.uc[0] = getc(calmaInputFile); \
u.uc[1] = getc(calmaInputFile); \
u.uc[0] = FGETC(calmaInputFile); \
u.uc[1] = FGETC(calmaInputFile); \
(z) = (int) ntohs(u.us); \
}
@ -173,10 +181,10 @@ typedef union { char uc[4]; unsigned int ul; } FourByteInt;
#define READI4(z) \
{ \
FourByteInt u; \
u.uc[0] = getc(calmaInputFile); \
u.uc[1] = getc(calmaInputFile); \
u.uc[2] = getc(calmaInputFile); \
u.uc[3] = getc(calmaInputFile); \
u.uc[0] = FGETC(calmaInputFile); \
u.uc[1] = FGETC(calmaInputFile); \
u.uc[2] = FGETC(calmaInputFile); \
u.uc[3] = FGETC(calmaInputFile); \
(z) = (int) ntohl(u.ul); \
}
@ -189,10 +197,10 @@ typedef union { char uc[4]; unsigned int ul; } FourByteInt;
calmaLApresent = FALSE; \
} else { \
READI2(nb); \
if (feof(calmaInputFile)) nb = -1; \
if (FEOF(calmaInputFile)) nb = -1; \
else { \
(rt) = getc(calmaInputFile); \
(void) getc(calmaInputFile); \
(rt) = FGETC(calmaInputFile); \
(void) FGETC(calmaInputFile); \
} \
} \
}
@ -211,19 +219,52 @@ typedef union { char uc[4]; unsigned int ul; } FourByteInt;
UNREADRH(nb, rt); \
}
/* Structure used for sorting ports by number */
typedef struct portlabel
{
Label *pl_label;
unsigned int pl_port;
} PortLabel;
/* Other commonly used globals */
extern HashTable calmaLayerHash;
extern int calmaElementIgnore[];
extern CellDef *calmaFindCell();
extern const int calmaElementIgnore[];
extern CellDef *calmaFindCell(const char *name, bool *was_called, bool *predefined);
/* (Added by Nishit, 8/18/2004--8/24/2004) */
extern CellDef *calmaLookCell();
extern void calmaWriteContact();
extern CellDef *calmaGetContactCell();
extern CellDef *calmaLookCell(char *name);
extern void calmaWriteContacts(FILE *f);
extern CellDef *calmaGetContactCell(TileType type, bool lookOnly);
extern bool calmaIsContactCell;
extern char *calmaRecordName();
extern void calmaSkipSet();
extern const char *calmaRecordName(int rtype);
extern void calmaSkipSet(const int *skipwhat);
extern bool calmaParseUnits(void);
extern int compport(const void *one, const void *two);
#define LB_EXTERNAL 0 /* Polygon external edge */
#define LB_INTERNAL 1 /* Polygon internal edge */
#define LB_INIT 2 /* Data not yet valid */
typedef struct LB1 {
char lb_type; /* Boundary Type (external or internal) */
Point lb_start; /* Start point */
struct LB1 *lb_next; /* Next point record */
} LinkedBoundary;
typedef struct BT1 {
LinkedBoundary *bt_first; /* Polygon list */
int bt_points; /* Number of points in this list */
struct BT1 *bt_next; /* Next polygon record */
} BoundaryTop;
extern int calmaAddSegment(LinkedBoundary **lbptr, bool poly_edge, int p1x, int p1y, int p2x, int p2y);
extern void calmaMergeSegments(LinkedBoundary *edge, BoundaryTop **blist, int num_points);
extern void calmaRemoveDegenerate(BoundaryTop *blist);
extern void calmaRemoveColinear(BoundaryTop *blist);
/* ------------------- Imports from CIF reading ----------------------- */
@ -233,4 +274,4 @@ extern Plane **cifCurReadPlanes;
extern HashTable CifCellTable;
extern Plane *cifEditCellPlanes[];
#endif /* _CALMAINT_H */
#endif /* _MAGIC__CALMA__CALMAINT_H */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -4,23 +4,23 @@
* Defines things shared internally by the cif module of Magic,
* but not generally needed outside the cif module.
*
* *********************************************************************
* * Copyright (C) 1985, 1990 Regents of the University of California. *
* * Permission to use, copy, modify, and distribute this *
* * software and its documentation for any purpose and without *
* * fee is hereby granted, provided that the above copyright *
* * notice appear in all copies. The University of California *
* * makes no representations about the suitability of this *
* * software for any purpose. It is provided "as is" without *
* * express or implied warranty. Export of this software outside *
* * of the United States of America may require an export license. *
* *********************************************************************
* * Copyright (C) 1985, 1990 Regents of the University of California. *
* * Permission to use, copy, modify, and distribute this *
* * software and its documentation for any purpose and without *
* * fee is hereby granted, provided that the above copyright *
* * notice appear in all copies. The University of California *
* * makes no representations about the suitability of this *
* * software for any purpose. It is provided "as is" without *
* * express or implied warranty. Export of this software outside *
* * of the United States of America may require an export license. *
* *********************************************************************
*
* rcsid "$Header: /usr/cvsroot/magic-8.0/cif/CIFint.h,v 1.3 2008/12/04 17:10:29 tim Exp $"
*/
#ifndef _CIFINT_H
#define _CIFINT_H
#ifndef _MAGIC__CIF__CIFINT_H
#define _MAGIC__CIF__CIFINT_H
#include "database/database.h"
@ -46,11 +46,17 @@
typedef struct bloat_data
{
int bl_plane; /* Plane on which a bloat or squares
* operation is valid.
* operation is valid. If -1, then the bloat
* types are CIF types.
*/
int bl_distance[TT_MAXTYPES];
} BloatData;
typedef struct bridge_data
{
int br_width; /* Minimum width rule for bridge */
} BridgeData;
typedef struct squares_data
{
int sq_border;
@ -69,6 +75,7 @@ typedef struct slots_data
int sl_lsize;
int sl_lsep;
int sl_offset;
int sl_start;
} SlotsData;
typedef struct cifop
@ -79,8 +86,9 @@ typedef struct cifop
* below for the legal ones.
*/
int co_distance; /* Grow or shrink distance (if needed). */
ClientData co_client; /* Pointer to a BloatData, SquaresData, or
* SlotsData structure, or NULL.
ClientData co_client; /* Pointer to a BloatData, SquaresData,
* SlotsData, or BridgeData structure,
* or NULL.
*/
struct cifop *co_next; /* Next in list of operations to perform. */
} CIFOp;
@ -95,6 +103,7 @@ typedef struct cifop
* the masks.
* CIFOP_GROW - Grow the current results uniformly by co_distance.
* CIFOP_GROW_G - Grow the current results to snap to the indicated grid.
* CIFOP_GROWMIN - Grow result such that no dimension is less than co_distance.
* CIFOP_SHRINK - Shrink the current results uniformly by co_distance.
* CIFOP_BLOAT - Find layers in paintMask, then bloat selectively
* according to bl_distance, and OR the results into
@ -121,32 +130,52 @@ typedef struct cifop
* the cell bounding box. This involves no magic type
* layers but may itself be acted upon with grow/shrink
* rules.
* CIFOP_BOUNDARY - Added 6/5/19---map the FIXED_BBOX property bounding
* box coordinates into CIF layer geometry.
* CIFOP_NET - Added 11/3/08---pull an entire electrical net into
* the CIF layer, selectively picking layers.
* CIFOP_MAXRECT - Reduce all areas to the largest internal fitting
* CIFOP_MAXRECT - Reduce all disjoint regions to the largest internal fitting
* rectangle.
* CIFOP_INTERACT - Select all disjoint regions which overlap a given set of types
* CIFOP_COPYUP - Added 5/5/16---make and keep a copy the resulting layer,
* which will be painted into parent cells instead of the
* current cell. This replaces the "fault" method.
* CIFOP_CLOSE - Added 11/25/19---close up areas smaller than indicated
* CIFOP_MANHATTAN - Added 3/27/25---remove or fill nonmanhattan areas
* CIFOP_BRIDGE - Added 6/11/20---Bridge across catecorner gaps
* CIFOP_BRIDGELIM - Added 27/07/20---Bridge across catecorner gaps, but with limiting layers
* CIFOP_MASKHINTS - Added 12/14/20---Add geometry from cell properties, if any.
*/
#define CIFOP_AND 1
#define CIFOP_OR 2
#define CIFOP_GROW 3
#define CIFOP_GROW_G 4
#define CIFOP_SHRINK 5
#define CIFOP_BLOAT 6
#define CIFOP_SQUARES 7
#define CIFOP_SLOTS 8
#define CIFOP_BLOATMAX 9
#define CIFOP_BLOATMIN 10
#define CIFOP_BLOATALL 11
#define CIFOP_ANDNOT 12
#define CIFOP_SQUARES_G 13
#define CIFOP_BBOX 14
#define CIFOP_NET 15
#define CIFOP_MAXRECT 16
#define CIFOP_COPYUP 17
#define CIFOP_GROWMIN 4
#define CIFOP_GROW_G 5
#define CIFOP_SHRINK 6
#define CIFOP_BLOAT 7
#define CIFOP_SQUARES 8
#define CIFOP_SLOTS 9
#define CIFOP_BLOATMAX 10
#define CIFOP_BLOATMIN 11
#define CIFOP_BLOATALL 12
#define CIFOP_ANDNOT 13
#define CIFOP_SQUARES_G 14
#define CIFOP_BBOX 15
#define CIFOP_BOUNDARY 16
#define CIFOP_NET 17
#define CIFOP_MAXRECT 18
#define CIFOP_INTERACT 19
#define CIFOP_COPYUP 20
#define CIFOP_CLOSE 21
#define CIFOP_MANHATTAN 22
#define CIFOP_BRIDGE 23
#define CIFOP_BRIDGELIM 24
#define CIFOP_MASKHINTS 25
/* Definitions of bit fields used in the value of co_client for CIFOP_INTERACT */
#define CIFOP_INT_NOT 0x1 /* Inverted sense (not interacting) */
#define CIFOP_INT_TOUCHING 0x2 /* Include both touching and overlapping */
/* Added by Tim 10/21/2004 */
/* The following structure is used to pass information on how to draw
@ -190,7 +219,7 @@ typedef struct
*/
int min_width; /* the minimum width rule in centi-microns
* for the layer. This is used by Grow Sliver
* to generate drc correct parent slivers
* to generate drc correct parent slivers
*/
#ifdef THREE_D
int cl_renderStyle; /* Style to render CIF layer with */
@ -204,12 +233,12 @@ typedef struct
*
* CIF_TEMP: Means that this is a temporary layer used to build
* up CIF information. It isn't output in the CIF file.
* CIF_BBOX_TOP: Indicates that the bounding box rectangle should
* only be generated if the cell is a top-level cell.
* CIF_LABEL: This layer is used to generate fixed labels in the
* output file.
*/
#define CIF_TEMP 1
#define CIF_BBOX_TOP 2
#define CIF_LABEL 2
/* The following data structure describes a complete set of CIF
* layers. The number of CIF layers (MAXCIFLAYERS) must not be
@ -250,7 +279,7 @@ typedef struct cifstyle
* file more readable). Default of 1.
* Unused for GDS input/output.
*/
int cs_expander; /* cs_scaleFactor / cs_expander = scale in
int cs_expander; /* cs_scaleFactor / cs_expander = scale in
* centimicrons. Default of 1. Value 10
* means cs_scaleFactor is measured in
* nanometers (millimicrons)
@ -272,9 +301,12 @@ typedef struct cifstyle
* layer.
*/
int cs_portLayer[TT_MAXTYPES];
/* Similar to cs_labelLayer, to distinguish
* between output types used for "normal"
* text and those used specifically for ports.
/* Similar to cs_labelLayer, to use as
* a type for geometry attached to port labels.
*/
int cs_portText[TT_MAXTYPES];
/* Similar to cs_labelLayer, to use as
* a text type for port labels
*/
CIFLayer *cs_layers[MAXCIFLAYERS];
/* Describes how to generate each layer.*/
@ -287,32 +319,57 @@ typedef struct cifstyle
#define CWF_GROW_SLIVERS 0x02
#define CWF_ANGSTROMS 0x04
#define CWF_GROW_EUCLIDEAN 0x08
#define CWF_SEE_VENDOR 0x10 /* Override vendor GDS flag in cells */
#define CWF_NO_ERRORS 0x20 /* Do not generate error msgs and fdbk */
#define CWF_SEE_NO_VENDOR 0x10 /* Hide magic's GDS from vendor cells */
#define CWF_NO_ERRORS 0x20 /* Do not generate error msgs and fdbk */
#define CWF_STRING_LIMIT 0x40 /* Use older Calma format character limit */
#define CWF_MINIMUM_GRID 0x80 /* Force minimum grid scaling */
/* procedures */
extern bool CIFNameToMask();
extern void CIFGenSubcells();
extern void CIFGenArrays();
extern void CIFGen();
extern void CIFClearPlanes();
extern Plane *CIFGenLayer();
extern void CIFInitCells();
extern int cifHierCopyFunc();
extern void CIFLoadStyle();
extern bool CIFNameToMask(char *name, TileTypeBitMask *result, TileTypeBitMask *depend);
extern void CIFGenSubcells(CellDef *def, Rect *area, Plane **output);
extern void CIFGenArrays(CellDef *def, Rect *area, Plane **output);
extern void CIFGen(CellDef *cellDef, CellDef *origDef, const Rect *area, Plane **planes, TileTypeBitMask *layers,
bool replace, bool genAllPlanes, bool hier, ClientData clientdata);
extern void CIFClearPlanes(Plane **planes);
extern Plane *CIFGenLayer(CIFOp *op, const Rect *area, CellDef *cellDef, CellDef *origDef, Plane *temps[],
bool hier, ClientData clientdata);
extern void CIFInitCells(void);
extern int cifHierCopyFunc(Tile *tile, TreeContext *cxp);
extern int cifHierCopyMaskHints(SearchContext *scx, ClientData clientData);
extern void CIFLoadStyle(char *stylename);
extern void CIFCopyMaskHints(SearchContext *scx, CellDef *targetDef);
/* C99 compat */
extern void CIFCoverageLayer(CellDef *rootDef, Rect *area, char *layer, bool dolist);
extern bool CIFWriteFlat(CellDef *rootDef, FILE *f);
extern void CIFScalePlanes(int scalen, int scaled, Plane **planearray);
extern void CIFInputRescale(int n, int d);
extern int CIFScaleCoord(int cifCoord, int snap_type);
extern int cifGrowSliver(Tile *tile, Rect *area);
extern int cifHierElementFunc(CellUse *use, Transform *transform, int x, int y, Rect *checkArea);
extern int cifSquareFunc(Rect *area, CIFOp *op, int *rows, int *columns, Rect *cut);
extern int cifSquareGridFunc(Rect *area, CIFOp *op, int *rows, int *columns, Rect *cut);
extern int cifSlotFunc(Rect *area, CIFOp *op, int *numY, int *numX, Rect *cut, bool vertical);
extern int CIFParseScale(char *true_scale, int *expander);
extern int cifParseCalmaNums(char *str, int *numArray, int numNums);
extern bool CIFReadTechLimitScale(int ns, int ds);
/* Shared variables and structures: */
extern Plane *CIFPlanes[]; /* Normal place to store CIF. */
extern CIFKeep *CIFStyleList; /* List of all CIF styles. */
extern CIFStyle *CIFCurStyle; /* Current style being used. */
extern CIFStyle *CIFDRCStyle; /* CIF style for DRC checking (optional) */
extern CellUse *CIFComponentUse; /* Flatten stuff in here if needed. */
extern CellDef *CIFComponentDef; /* Corresponds to CIFComponentUse. */
extern CellUse *CIFDummyUse; /* Used to dummy up a CellUse for a
* def.
*/
extern Plane *CIFTotalPlanes[]; /* Exported for diagnostics */
extern Plane *CIFComponentPlanes[]; /* Exported for diagnostics */
/* Valid values of CIFWarningLevel (see cif.h) */
typedef enum {CIF_WARN_DEFAULT, CIF_WARN_NONE, CIF_WARN_ALIGN,
@ -327,13 +384,13 @@ extern int CIFHierRects;
/* Tables used for painting and erasing CIF. */
extern PaintResultType CIFPaintTable[], CIFEraseTable[];
extern const PaintResultType CIFPaintTable[], CIFEraseTable[];
/* Procedures and variables for reporting errors. */
extern int CIFErrorLayer;
extern CellDef *CIFErrorDef;
extern void CIFError();
extern void CIFError(Rect *area, char *message);
/* The following determines the tile type used to hold the CIF
* information on its paint plane.
@ -342,4 +399,4 @@ extern void CIFError();
#define CIF_SOLIDTYPE 1
extern TileTypeBitMask CIFSolidBits;
#endif /* _CIFINT_H */
#endif /* _MAGIC__CIF__CIFINT_H */

View File

@ -3,21 +3,21 @@
* This file contains global information for the CIF module,
* such as performance statistics.
*
* *********************************************************************
* * Copyright (C) 1985, 1990 Regents of the University of California. *
* * Permission to use, copy, modify, and distribute this *
* * software and its documentation for any purpose and without *
* * fee is hereby granted, provided that the above copyright *
* * notice appear in all copies. The University of California *
* * makes no representations about the suitability of this *
* * software for any purpose. It is provided "as is" without *
* * express or implied warranty. Export of this software outside *
* * of the United States of America may require an export license. *
* *********************************************************************
* * Copyright (C) 1985, 1990 Regents of the University of California. *
* * Permission to use, copy, modify, and distribute this *
* * software and its documentation for any purpose and without *
* * fee is hereby granted, provided that the above copyright *
* * notice appear in all copies. The University of California *
* * makes no representations about the suitability of this *
* * software for any purpose. It is provided "as is" without *
* * express or implied warranty. Export of this software outside *
* * of the United States of America may require an export license. *
* *********************************************************************
*/
#ifndef lint
static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/cif/CIFmain.c,v 1.3 2009/01/15 15:44:34 tim Exp $";
static const char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/cif/CIFmain.c,v 1.3 2009/01/15 15:44:34 tim Exp $";
#endif /* not lint */
#include <stdio.h>
@ -76,7 +76,7 @@ static int cifTotalHierRects = 0;
global CellDef *CIFErrorDef; /* Definition in which to record errors. */
global int CIFErrorLayer; /* Index of CIF layer associated with errors.*/
/*
* ----------------------------------------------------------------------------
*
@ -95,7 +95,7 @@ global int CIFErrorLayer; /* Index of CIF layer associated with errors.*/
*/
void
CIFPrintStats()
CIFPrintStats(void)
{
TxPrintf("CIF statistics (recent/total):\n");
cifTotalTileOps += CIFTileOps;
@ -128,7 +128,7 @@ CIFPrintStats()
* Results:
* Internal units-to-(nanometers * convert) conversion factor (float).
* Use convert = 1000 for centimicrons-to-microns conversion
*
*
* Side effects:
* None.
*
@ -136,8 +136,8 @@ CIFPrintStats()
*/
float
CIFGetOutputScale(convert)
int convert;
CIFGetOutputScale(
int convert)
{
if (CIFCurStyle == NULL) return 1.0;
@ -145,6 +145,28 @@ CIFGetOutputScale(convert)
(float)(CIFCurStyle->cs_expander * convert));
}
/*
* ----------------------------------------------------------------------------
*
* CIFGetScale --
*
* Same as the above routine, but provides the scalefactor to get CIF
* units from centimicrons (which generally means just returning the
* expander value to show if units have been declared in nanometers or
* angstroms).
*
* ----------------------------------------------------------------------------
*/
float
CIFGetScale(
int convert)
{
if (CIFCurStyle == NULL) return 1.0;
return (1.0 / (float)(CIFCurStyle->cs_expander * convert));
}
/*
* ----------------------------------------------------------------------------
*
@ -163,10 +185,10 @@ CIFGetOutputScale(convert)
*/
void
CIFPrintStyle(dolist, doforall, docurrent)
bool dolist; /* Return as a list if true */
bool doforall; /* Print all known styles if true */
bool docurrent; /* Print current style if true */
CIFPrintStyle(
bool dolist, /* Return as a list if true */
bool doforall, /* Print all known styles if true */
bool docurrent) /* Print current style if true */
{
CIFKeep *style;
@ -212,7 +234,7 @@ CIFPrintStyle(dolist, doforall, docurrent)
}
}
/*
* ----------------------------------------------------------------------------
*
@ -232,12 +254,13 @@ CIFPrintStyle(dolist, doforall, docurrent)
*/
void
CIFSetStyle(name)
char *name; /* Name of the new style. If NULL, just
CIFSetStyle(
char *name) /* Name of the new style. If NULL, just
* print out the valid styles.
*/
{
CIFKeep *style, *match;
CIFKeep *style, *match, *exactmatch;
bool ambiguous = FALSE;
int length;
if (name == NULL) return;
@ -247,18 +270,25 @@ CIFSetStyle(name)
for (style = CIFStyleList; style != NULL; style = style->cs_next)
{
if (strncmp(name, style->cs_name, length) == 0)
if (!strcmp(name, style->cs_name)) {
match = style;
ambiguous = FALSE;
break;
}
else if (!strncmp(name, style->cs_name, length))
{
if (match != NULL)
{
TxError("CIF output style \"%s\" is ambiguous.\n", name);
CIFPrintStyle(FALSE, TRUE, TRUE);
return;
}
if (match != NULL) ambiguous = TRUE;
match = style;
}
}
if (ambiguous)
{
TxError("CIF output style \"%s\" is ambiguous.\n", name);
CIFPrintStyle(FALSE, TRUE, TRUE);
return;
}
if (match != NULL)
{
CIFLoadStyle(match->cs_name);
@ -269,7 +299,7 @@ CIFSetStyle(name)
TxError("\"%s\" is not one of the CIF output styles Magic knows.\n", name);
CIFPrintStyle(FALSE, TRUE, TRUE);
}
/*
* ----------------------------------------------------------------------------
*
@ -290,10 +320,10 @@ CIFSetStyle(name)
*/
bool
CIFNameToMask(name, result, depend)
char *name;
TileTypeBitMask *result;
TileTypeBitMask *depend;
CIFNameToMask(
char *name,
TileTypeBitMask *result,
TileTypeBitMask *depend)
{
int i, j;
CIFOp *op;
@ -327,7 +357,23 @@ CIFNameToMask(name, result, depend)
{
cl = CIFCurStyle->cs_layers[j];
for (op = cl->cl_ops; op != NULL; op = op->co_next)
{
TTMaskSetMask(depend, &op->co_cifMask);
/* Bloat layers may depend on CIF layers */
/* Currently supported only with bloat-all */
if (op->co_opcode == CIFOP_BLOATALL)
{
BloatData *bloats = (BloatData *)op->co_client;
TileType ttype;
if (bloats->bl_plane < 0) /* Use CIF types */
for (ttype = 0; ttype < TT_MAXTYPES; ttype++)
if (bloats->bl_distance[ttype] > 0)
TTMaskSetType(depend, ttype);
}
}
}
}
return TRUE;
@ -346,7 +392,7 @@ CIFNameToMask(name, result, depend)
TxError(".\n");
return FALSE;
}
/*
* ----------------------------------------------------------------------------
*
@ -368,11 +414,11 @@ CIFNameToMask(name, result, depend)
*/
void
CIFError(area, message)
Rect *area; /* Place in CIFErrorDef where there was a
CIFError(
Rect *area, /* Place in CIFErrorDef where there was a
* problem in generating CIFErrorLayer.
*/
char *message; /* Short note about what went wrong. */
char *message) /* Short note about what went wrong. */
{
char msg[200];
@ -385,7 +431,7 @@ CIFError(area, message)
DBWFeedbackAdd(area, msg, CIFErrorDef, CIFCurStyle->cs_scaleFactor,
STYLE_PALEHIGHLIGHTS);
}
/*
* ----------------------------------------------------------------------------
*
@ -406,7 +452,7 @@ CIFError(area, message)
*/
int
CIFOutputScaleFactor()
CIFOutputScaleFactor(void)
{
if (CIFCurStyle == NULL) return 1;
return CIFCurStyle->cs_scaleFactor;

View File

@ -5,21 +5,21 @@
* both definitions and calls, and user-defined features
* like labels.
*
* *********************************************************************
* * Copyright (C) 1985, 1990 Regents of the University of California. *
* * Permission to use, copy, modify, and distribute this *
* * software and its documentation for any purpose and without *
* * fee is hereby granted, provided that the above copyright *
* * notice appear in all copies. The University of California *
* * makes no representations about the suitability of this *
* * software for any purpose. It is provided "as is" without *
* * express or implied warranty. Export of this software outside *
* * of the United States of America may require an export license. *
* *********************************************************************
* * Copyright (C) 1985, 1990 Regents of the University of California. *
* * Permission to use, copy, modify, and distribute this *
* * software and its documentation for any purpose and without *
* * fee is hereby granted, provided that the above copyright *
* * notice appear in all copies. The University of California *
* * makes no representations about the suitability of this *
* * software for any purpose. It is provided "as is" without *
* * express or implied warranty. Export of this software outside *
* * of the United States of America may require an export license. *
* *********************************************************************
*/
#ifndef lint
static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/cif/CIFrdcl.c,v 1.5 2010/08/25 17:33:55 tim Exp $";
static const char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/cif/CIFrdcl.c,v 1.5 2010/08/25 17:33:55 tim Exp $";
#endif /* not lint */
#include <stdio.h>
@ -103,7 +103,7 @@ typedef struct {
*/
char *cifSubcellId = NULL;
/*
* ----------------------------------------------------------------------------
*
@ -126,8 +126,8 @@ char *cifSubcellId = NULL;
*/
void
CIFReadCellInit(ptrkeys)
int ptrkeys;
CIFReadCellInit(
int ptrkeys)
{
int i;
@ -150,7 +150,7 @@ CIFReadCellInit(ptrkeys)
* cifForgetCell --
*
* This local procedure is used to find a cell in the subcell
* table and remove its CellDef entry.
* table and remove its CellDef entry.
*
* Results:
* FALSE if no such entry was found, otherwise TRUE.
@ -162,8 +162,8 @@ CIFReadCellInit(ptrkeys)
*/
bool
cifForgetCell(cifNum)
int cifNum;
cifForgetCell(
int cifNum)
{
HashEntry *h;
@ -196,8 +196,8 @@ cifForgetCell(cifNum)
*/
void
cifUniqueCell(cifNum)
int cifNum;
cifUniqueCell(
int cifNum)
{
HashEntry *h;
CellDef *def, *testdef;
@ -234,7 +234,7 @@ cifUniqueCell(cifNum)
CIFReadError("Warning: cell definition %d reused.\n", cifNum);
}
/*
* ----------------------------------------------------------------------------
*
@ -256,8 +256,8 @@ cifUniqueCell(cifNum)
*/
CellDef *
cifFindCell(cifNum)
int cifNum; /* The CIF number of the desired cell. */
cifFindCell(
int cifNum) /* The CIF number of the desired cell. */
{
HashEntry *h;
CellDef *def, *testdef;
@ -273,7 +273,7 @@ cifFindCell(cifNum)
def = DBCellLookDef(name);
if (def == NULL)
{
def = DBCellNewDef(name, (char *) NULL);
def = DBCellNewDef(name);
/* Tricky point: call DBReComputeBbox here to make SURE
* that the cell has a valid bounding box. Otherwise,
@ -299,10 +299,10 @@ cifFindCell(cifNum)
*/
void
CIFScalePlanes(scalen, scaled, planearray)
int scalen;
int scaled;
Plane **planearray;
CIFScalePlanes(
int scalen,
int scaled,
Plane **planearray)
{
int pNum;
Plane *newplane;
@ -346,10 +346,11 @@ CIFScalePlanes(scalen, scaled, planearray)
*
* ----------------------------------------------------------------------------
*/
void
CIFInputRescale(n, d)
int n, d;
CIFInputRescale(
int n,
int d)
{
CIFReadStyle *istyle = cifCurReadStyle;
CIFReadLayer *cl;
@ -386,8 +387,10 @@ CIFInputRescale(n, d)
}
}
CIFScalePlanes(n, d, cifEditCellPlanes);
if (cifEditCellPlanes != cifSubcellPlanes)
CIFScalePlanes(n, d, cifCurReadPlanes);
if (cifCurReadPlanes != cifEditCellPlanes)
CIFScalePlanes(n, d, cifEditCellPlanes);
if ((const Plane*)cifEditCellPlanes != (const Plane*)cifSubcellPlanes && cifCurReadPlanes != cifSubcellPlanes)
CIFScalePlanes(n, d, cifSubcellPlanes);
CIFReadWarning("CIF style %s: units rescaled by factor of %d / %d\n",
@ -415,10 +418,10 @@ CIFInputRescale(n, d)
*/
bool
CIFParseStart()
CIFParseStart(void)
{
int number;
if (cifSubcellBeingRead)
{
CIFReadError("definition start inside other definition; ignored.\n");
@ -489,7 +492,7 @@ CIFParseStart()
cifCurReadPlanes = cifSubcellPlanes;
return TRUE;
}
/*
* ----------------------------------------------------------------------------
@ -500,9 +503,9 @@ CIFParseStart()
* ----------------------------------------------------------------------------
*/
int cifCheckPaintFunc(tile, clientData)
Tile *tile;
ClientData clientData;
int cifCheckPaintFunc(
Tile *tile,
ClientData clientData)
{
return 1;
}
@ -510,9 +513,9 @@ int cifCheckPaintFunc(tile, clientData)
/* Callback function for copying paint from one CIF cell into another */
int
cifCopyPaintFunc(tile, cifCopyRec)
Tile *tile;
CIFCopyRec *cifCopyRec;
cifCopyPaintFunc(
Tile *tile,
CIFCopyRec *cifCopyRec)
{
int pNum;
TileType dinfo;
@ -538,6 +541,40 @@ cifCopyPaintFunc(tile, cifCopyRec)
return 0;
}
/*
* ----------------------------------------------------------------------------
*
* cifMaskHintFunc --
*
* For each tile in the scanned plane, convert the tile into a coordinate
* string by appending the coordinates to the list passed as clientData.
*
* Results:
* Return 0 to keep the search going.
*
* Side effects:
* Allocates memory for and seeds a linked rect entry
*
* ----------------------------------------------------------------------------
*/
int
cifMaskHintFunc(
Tile *tile,
LinkedRect **lrecp)
{
Rect r;
LinkedRect *newlr;
newlr = (LinkedRect *)mallocMagic(sizeof(LinkedRect));
newlr->r_next = *lrecp;
(*lrecp) = newlr;
TiToRect(tile, &newlr->r_r);
return 0;
}
/*
* ----------------------------------------------------------------------------
*
@ -557,20 +594,24 @@ cifCopyPaintFunc(tile, cifCopyRec)
*/
int
CIFPaintCurrent()
CIFPaintCurrent(
int filetype)
{
extern int cifMakeBoundaryFunc(Tile *tile, ClientData clientdata); /* Forward declaration. */
extern int cifPaintCurrentFunc(Tile *tile, TileType type); /* Forward declaration. */
Plane *plane, *swapplane;
int i;
for (i = 0; i < cifCurReadStyle->crs_nLayers; i++)
{
TileType type;
extern int cifPaintCurrentFunc(); /* Forward declaration. */
CIFOp *op;
plane = CIFGenLayer(cifCurReadStyle->crs_layers[i]->crl_ops,
&TiPlaneRect, (CellDef *) NULL, cifCurReadPlanes);
&TiPlaneRect, (CellDef *)NULL, (CellDef *)NULL,
cifCurReadPlanes, FALSE, (ClientData)NULL);
/* Generate a paint/erase table, then paint from the CIF
* plane into the current Magic cell.
*/
@ -599,13 +640,13 @@ CIFPaintCurrent()
Plane **parray;
extern char *(cifReadLayers[MAXCIFRLAYERS]);
/* NOTE: There should be no need to check for cd_client
* here as cd_client should not be CLIENTDEFAULT if CDFLATGDS
* is set in flags. This condition has occurred, though, and
* needs to be debugged.
/* NOTE: The condition cd_client == 0 when CDFLATGDS
* indicates that the cell was already in memory when the
* GDS was read. This condition should be properly caught
* and handled.
*/
if ((cifReadCellDef->cd_flags & CDFLATGDS) &&
(cifReadCellDef->cd_client != (ClientData)CLIENTDEFAULT))
if ((cifReadCellDef->cd_flags & CDFLATGDS) &&
(cifReadCellDef->cd_client != (ClientData)0))
parray = (Plane **)cifReadCellDef->cd_client;
else
{
@ -641,6 +682,23 @@ CIFPaintCurrent()
}
}
}
else if (op == NULL)
{
/* Handle boundary layer */
op = cifCurReadStyle->crs_layers[i]->crl_ops;
while (op)
{
if (op->co_opcode == CIFOP_BOUNDARY) break;
op = op->co_next;
}
if (op && (DBSrPaintArea((Tile *)NULL, plane, &TiPlaneRect,
&DBAllButSpaceBits, cifCheckPaintFunc,
(ClientData)NULL) == 1))
DBSrPaintArea((Tile *) NULL, plane, &TiPlaneRect,
&CIFSolidBits, cifMakeBoundaryFunc, INT2CD(filetype));
}
/* Swap planes */
swapplane = cifCurReadPlanes[type];
@ -651,15 +709,175 @@ CIFPaintCurrent()
{
DBSrPaintArea((Tile *) NULL, plane, &TiPlaneRect,
&CIFSolidBits, cifPaintCurrentFunc,
(ClientData)type);
INT2CD(type));
}
/* Recycle the plane, which was dynamically allocated. */
DBFreePaintPlane(plane);
TiFreePlane(plane);
}
/* If mask hints were requested, then for each GDS/CIF layer in the */
/* input, if the layer has a corresponding output layer and the */
/* output layer has a mask hints operator, then generate the output */
/* plane for that layer, compare to the input plane, and create */
/* mask hint properties to make the output the same as the input. */
if ((CalmaMaskHints != NULL) && (!TTMaskIsZero(CalmaMaskHints)))
{
int j;
CIFOp *op, newop, subop;
Plane *presult;
TileTypeBitMask genMask;
int *in_out_map;
extern char *(cifReadLayers[MAXCIFRLAYERS]);
TTMaskZero(&genMask);
in_out_map = (int *)mallocMagic(cifNReadLayers * sizeof(int));
for (i = 0; i < cifNReadLayers; i++)
{
if (!TTMaskHasType(CalmaMaskHints, i)) continue;
/* Does the input layer have a corresponding output layer? */
in_out_map[i] = -1;
for (j = 0; j < CIFCurStyle->cs_nLayers; j++)
{
if (!strcmp(CIFCurStyle->cs_layers[j]->cl_name, cifReadLayers[i]))
{
/* Does the layer have a mask-hints operator? */
for (op = CIFCurStyle->cs_layers[j]->cl_ops; op; op = op->co_next)
if (op->co_opcode == CIFOP_MASKHINTS)
{
TTMaskSetType(&genMask, j);
in_out_map[i] = j;
break;
}
}
if (in_out_map[i] >= 0) break;
}
}
/* Multiply input planes to the same scale as the generated output */
CIFScalePlanes(CIFCurStyle->cs_scaleFactor, cifCurReadStyle->crs_scaleFactor,
cifCurReadPlanes);
/* Generate the output for these layers from the cell contents */
CIFClearPlanes(CIFPlanes);
/* TO-DO: Replace DBAllTypeBits with genMask. Requires that genMask */
/* be expanded to include all dependent layers. */
CIFGen(cifReadCellDef, cifReadCellDef, &TiPlaneRect, CIFPlanes, &DBAllTypeBits,
TRUE, FALSE, FALSE, (ClientData)NULL);
/* Set up double operator for OR and ANDNOT functions */
newop.co_opcode = CIFOP_OR;
newop.co_distance = 0;
newop.co_next = &subop;
newop.co_client = (ClientData)NULL;
TTMaskZero(&newop.co_paintMask);
subop.co_opcode = CIFOP_ANDNOT;
subop.co_distance = 0;
subop.co_next = NULL;
subop.co_client = (ClientData)NULL;
TTMaskZero(&subop.co_paintMask);
for (i = 0; i < cifNReadLayers; i++)
{
LinkedRect *lrec = NULL;
char *propstr = NULL;
char locstr[512];
Plane *tempp;
if (!TTMaskHasType(CalmaMaskHints, i)) continue;
j = in_out_map[i];
if (j < 0) continue;
TTMaskSetOnlyType(&subop.co_cifMask, j);
/* Replace last layer + 1 on CIFPlanes with input layer i */
tempp = CIFPlanes[CIFCurStyle->cs_nLayers];
TTMaskSetOnlyType(&newop.co_cifMask, CIFCurStyle->cs_nLayers);
CIFPlanes[CIFCurStyle->cs_nLayers] = cifCurReadPlanes[i];
CIFCurStyle->cs_nLayers++;
/* Compute result (i AND-NOT j), which will be all the areas of
* the input on layer i that are not generated by writing output
* layer j.
*/
presult = CIFGenLayer(&newop, &TiPlaneRect, (CellDef *)NULL,
(CellDef *)NULL, CIFPlanes, FALSE, (ClientData)NULL);
/* Scan the resulting plane and generate linked Rect structures for
* each shape found.
*/
DBSrPaintArea((Tile *)NULL, presult, &TiPlaneRect, &CIFSolidBits,
cifMaskHintFunc, (ClientData)&lrec);
if (lrec != NULL)
{
char *propname;
propname = (char *)mallocMagic(11 + strlen(cifReadLayers[i]));
sprintf(propname, "MASKHINTS_%s", cifReadLayers[i]);
propstr = (char *)NULL;
/* Turn all linked Rects into a mask-hints property in the
* target cell.
*/
while (lrec != NULL)
{
char *newstr;
sprintf(locstr, "%d %d %d %d",
lrec->r_r.r_xbot / CIFCurStyle->cs_scaleFactor,
lrec->r_r.r_ybot / CIFCurStyle->cs_scaleFactor,
lrec->r_r.r_xtop / CIFCurStyle->cs_scaleFactor,
lrec->r_r.r_ytop / CIFCurStyle->cs_scaleFactor);
if (propstr == NULL)
{
newstr = (char *)mallocMagic(strlen(locstr) + 1);
sprintf(newstr, "%s", locstr);
}
else
{
newstr = (char *)mallocMagic(strlen(locstr)
+ strlen(propstr) + 2);
sprintf(newstr, "%s %s", propstr, locstr);
freeMagic(propstr);
}
propstr = newstr;
free_magic1_t mm1 = freeMagic1_init();
freeMagic1(&mm1, lrec);
lrec = lrec->r_next;
freeMagic1_end(&mm1);
}
/* NOTE: propstr is transferred to the CellDef and should
* not be free'd here.
*/
DBPropPut(cifReadCellDef, propname, propstr);
freeMagic(propname);
}
/* Delete the generated plane */
DBFreePaintPlane(presult);
TiFreePlane(presult);
/* Replace the input plane that was shuffled out */
CIFCurStyle->cs_nLayers--;
CIFPlanes[CIFCurStyle->cs_nLayers] = tempp;
}
/* Free up the planes used to create the output */
CIFClearPlanes(CIFPlanes);
freeMagic((char *)in_out_map);
}
/* Now go through all the current planes and zero them out. */
for (i = 0; i < MAXCIFRLAYERS; i++)
@ -668,14 +886,91 @@ CIFPaintCurrent()
return 0;
}
/* Below is the search function invoked for each CIF tile type
* found for the current layer.
*/
/* Use CIF layer geometry to define a fixed bounding box for the current cell */
int
cifPaintCurrentFunc(tile, type)
Tile *tile; /* Tile of CIF information. */
TileType type; /* Magic type to be painted. */
cifMakeBoundaryFunc(
Tile *tile, /* Tile of CIF information. */
ClientData clientdata) /* Pass the file type (CIF or CALMA) */
{
/* It is assumed that there is one rectangle for the boundary. */
/* If there are multiple rectangles defined with the boundary */
/* layer, then the last one defines the FIXED_BBOX property. */
Rect area;
char propertyvalue[128], *storedvalue;
int savescale;
int filetype = (int)CD2INT(clientdata);
TiToRect(tile, &area);
area.r_xtop = CIFScaleCoord(area.r_xtop, COORD_EXACT);
savescale = cifCurReadStyle->crs_scaleFactor;
area.r_ytop = CIFScaleCoord(area.r_ytop, COORD_EXACT);
if (savescale != cifCurReadStyle->crs_scaleFactor)
{
area.r_xtop *= (savescale / cifCurReadStyle->crs_scaleFactor);
savescale = cifCurReadStyle->crs_scaleFactor;
}
area.r_xbot = CIFScaleCoord(area.r_xbot, COORD_EXACT);
if (savescale != cifCurReadStyle->crs_scaleFactor)
{
area.r_xtop *= (savescale / cifCurReadStyle->crs_scaleFactor);
area.r_ytop *= (savescale / cifCurReadStyle->crs_scaleFactor);
savescale = cifCurReadStyle->crs_scaleFactor;
}
area.r_ybot = CIFScaleCoord(area.r_ybot, COORD_EXACT);
if (savescale != cifCurReadStyle->crs_scaleFactor)
{
area.r_xtop *= (savescale / cifCurReadStyle->crs_scaleFactor);
area.r_ytop *= (savescale / cifCurReadStyle->crs_scaleFactor);
area.r_xbot *= (savescale / cifCurReadStyle->crs_scaleFactor);
}
if (cifReadCellDef->cd_flags & CDFIXEDBBOX)
{
char *propvalue;
bool found;
/* Only flag a warning if the redefined boundary was */
/* different from the original. */
propvalue = (char *)DBPropGet(cifReadCellDef, "FIXED_BBOX", &found);
if (found)
{
Rect bbox;
if (sscanf(propvalue, "%d %d %d %d", &bbox.r_xbot, &bbox.r_ybot,
&bbox.r_xtop, &bbox.r_ytop) == 4)
{
if ((bbox.r_xbot != area.r_xbot) ||
(bbox.r_ybot != area.r_ybot) ||
(bbox.r_xtop != area.r_xtop) ||
(bbox.r_ytop != area.r_ytop))
{
if (filetype == FILE_CIF)
CIFReadError("Warning: Cell %s boundary was redefined.\n",
cifReadCellDef->cd_name);
else
CalmaReadError("Warning: Cell %s boundary was redefined.\n",
cifReadCellDef->cd_name);
}
}
}
}
sprintf(propertyvalue, "%d %d %d %d",
area.r_xbot, area.r_ybot, area.r_xtop, area.r_ytop);
storedvalue = StrDup((char **)NULL, propertyvalue);
DBPropPut(cifReadCellDef, "FIXED_BBOX", storedvalue);
cifReadCellDef->cd_flags |= CDFIXEDBBOX;
return 0;
}
/* Paint CIF layer geometry into the current cell def as magic layer "type" */
int
cifPaintCurrentFunc(
Tile *tile, /* Tile of CIF information. */
TileType type) /* Magic type to be painted. */
{
Rect area;
int pNum;
@ -730,7 +1025,7 @@ cifPaintCurrentFunc(tile, type)
return 0; /* To keep the search alive. */
}
/*
* ----------------------------------------------------------------------------
*
@ -750,7 +1045,7 @@ cifPaintCurrentFunc(tile, type)
*/
bool
CIFParseFinish()
CIFParseFinish(void)
{
if (!cifSubcellBeingRead)
{
@ -758,12 +1053,12 @@ CIFParseFinish()
CIFSkipToSemi();
return FALSE;
}
if (cifSubcellId != NULL)
if (cifSubcellId != NULL)
{
CIFReadError("pending call identifier %s discarded.\n", cifSubcellId);
(void) StrDup(&cifSubcellId, (char *) NULL);
}
/* Take the `F'. */
TAKE();
@ -772,8 +1067,8 @@ CIFParseFinish()
* the appropriate cell of the database. Then restore the saved
* layer info.
*/
CIFPaintCurrent();
CIFPaintCurrent(FILE_CIF);
DBAdjustLabels(cifReadCellDef, &TiPlaneRect);
DBReComputeBbox(cifReadCellDef);
@ -785,7 +1080,7 @@ CIFParseFinish()
cifCurReadPlanes = cifEditCellPlanes;
return TRUE;
}
/*
* ----------------------------------------------------------------------------
*
@ -805,7 +1100,7 @@ CIFParseFinish()
*/
bool
CIFParseDelete()
CIFParseDelete(void)
{
int number;
@ -825,7 +1120,7 @@ CIFParseDelete()
CIFSkipToSemi();
return TRUE;
}
/*
* ----------------------------------------------------------------------------
*
@ -847,7 +1142,7 @@ CIFParseDelete()
*/
char *
cifParseName()
cifParseName(void)
{
char ch;
char *bufferp;
@ -857,7 +1152,7 @@ cifParseName()
for (ch = PEEK() ; ch == ' ' || ch == '\t' ; ch = PEEK())
TAKE();
/* Read the string. */
bufferp = &buffer[0];
@ -868,7 +1163,7 @@ cifParseName()
*bufferp = '\0';
return buffer;
}
/*
* ----------------------------------------------------------------------------
*
@ -889,7 +1184,7 @@ cifParseName()
*/
bool
cifParseUser9()
cifParseUser9(void)
{
char *name;
@ -901,7 +1196,7 @@ cifParseUser9()
}
return TRUE;
}
/*
* ----------------------------------------------------------------------------
*
@ -921,13 +1216,13 @@ cifParseUser9()
*/
bool
CIFParseCall()
CIFParseCall(void)
{
int called;
Transform transform;
CellUse *use;
CellDef *def;
/* Take the `C'. */
TAKE();
@ -966,7 +1261,7 @@ CIFParseCall()
(void) StrDup(&cifSubcellId, (char *) NULL);
return TRUE;
}
/*
* ----------------------------------------------------------------------------
*
@ -988,7 +1283,7 @@ CIFParseCall()
*/
bool
cifParseUser91()
cifParseUser91(void)
{
if (cifSubcellId != NULL)
{
@ -998,7 +1293,7 @@ cifParseUser91()
(void) StrDup(&cifSubcellId, cifParseName());
return TRUE;
}
/*
* ----------------------------------------------------------------------------
*
@ -1019,7 +1314,7 @@ cifParseUser91()
*/
bool
cifParseUser94()
cifParseUser94(void)
{
Rect rectangle;
char *name = NULL;
@ -1051,7 +1346,7 @@ cifParseUser94()
* current cell. Tricky business: in order for the default
* label location to be computed
*/
CIFSkipBlanks();
if (PEEK() != ';')
{
@ -1083,12 +1378,12 @@ cifParseUser94()
flags = LABEL_STICKY;
else
flags = 0;
(void) DBPutLabel(cifReadCellDef, &rectangle, -1, name, type, flags);
(void) DBPutLabel(cifReadCellDef, &rectangle, -1, name, type, flags, 0);
}
freeMagic(name);
return TRUE;
}
/*
* ----------------------------------------------------------------------------
*
@ -1109,7 +1404,7 @@ cifParseUser94()
*/
bool
cifParseUser95()
cifParseUser95(void)
{
/* Modified by BIM 1/8/2018 */
Rect rectangle;
@ -1127,12 +1422,12 @@ cifParseUser95()
CIFSkipToSemi();
return FALSE;
}
savescale = cifCurReadStyle->crs_scaleFactor;
/* The center coordinates returned are in CIF units *2 */
/* the values will be halved later before conversion to magic units */
if (! CIFParsePoint(&center, 2))
{
CIFReadError("95 command, but no location; ignored.\n");
@ -1156,10 +1451,10 @@ cifParseUser95()
lowerleft.p_x = center.p_x - size.p_x;
lowerleft.p_y = center.p_y - size.p_y;
upperright.p_x = center.p_x + size.p_x;
upperright.p_y = center.p_y + size.p_y;
if ((lowerleft.p_x % 2 == 0) && (lowerleft.p_y % 2 == 0)) {
/* if possible convert values to CIF units by dividing by two */
@ -1177,9 +1472,9 @@ cifParseUser95()
CIFInputRescale(2, 1);
}
/* now scale each of the co-ordinates in turn */
lowerleft.p_x = CIFScaleCoord(lowerleft.p_x, COORD_ANY);
savescale = cifCurReadStyle->crs_scaleFactor;
@ -1244,13 +1539,13 @@ cifParseUser95()
flags = LABEL_STICKY;
else
flags = 0;
(void) DBPutLabel(cifReadCellDef, &rectangle, -1, name, type, flags);
(void) DBPutLabel(cifReadCellDef, &rectangle, -1, name, type, flags, 0);
}
freeMagic(name);
return TRUE;
}
/*
* ----------------------------------------------------------------------------
*
@ -1269,7 +1564,7 @@ cifParseUser95()
* ----------------------------------------------------------------------------
*/
bool
CIFParseUser()
CIFParseUser(void)
{
char ch;
@ -1298,7 +1593,7 @@ CIFParseUser()
return FALSE;
}
}
/*
* ----------------------------------------------------------------------------
*
@ -1321,8 +1616,8 @@ CIFParseUser()
*/
void
CIFReadCellCleanup(type)
int type; // 0 = CIF, 1 = GDS, because routine is used by both
CIFReadCellCleanup(
int filetype)
{
HashEntry *h;
HashSearch hs;
@ -1332,10 +1627,10 @@ CIFReadCellCleanup(type)
if (cifSubcellBeingRead)
{
if (type == 0)
if (filetype == FILE_CIF)
CIFReadError("CIF ended partway through a symbol definition.\n");
else
calmaReadError("GDS ended partway through a symbol definition.\n");
CalmaReadError("GDS ended partway through a symbol definition.\n");
(void) CIFParseFinish();
}
@ -1348,32 +1643,36 @@ CIFReadCellCleanup(type)
def = (CellDef *) HashGetValue(h);
if (def == NULL)
{
if (type == 0)
if (filetype == FILE_CIF)
CIFReadError("cell table has NULL entry (Magic error).\n");
else
calmaReadError("cell table has NULL entry (Magic error).\n");
CalmaReadError("cell table has NULL entry (Magic error).\n");
continue;
}
flags = def->cd_flags;
if (!(flags & CDAVAILABLE))
{
if (type == 0)
if (filetype == FILE_CIF)
CIFReadError("cell %s was used but not defined.\n", def->cd_name);
else
calmaReadError("cell %s was used but not defined.\n", def->cd_name);
CalmaReadError("cell %s was used but not defined.\n", def->cd_name);
}
def->cd_flags &= ~CDPROCESSEDGDS;
if ((type == 0 && CIFNoDRCCheck == FALSE) ||
(type == 1 && CalmaNoDRCCheck == FALSE))
if ((filetype == FILE_CIF && CIFNoDRCCheck == FALSE) ||
(filetype == FILE_CALMA && CalmaNoDRCCheck == FALSE))
DRCCheckThis(def, TT_CHECKPAINT, &def->cd_bbox);
DBWAreaChanged(def, &def->cd_bbox, DBW_ALLWINDOWS, &DBAllButSpaceBits);
DBCellSetModified(def, TRUE);
/* Only mark cell as needing a timestamp update if the timestamp is zero */
if (def->cd_timestamp != 0)
def->cd_flags &= ~CDGETNEWSTAMP;
}
/* Do geometrical processing on the top-level cell. */
CIFPaintCurrent();
CIFPaintCurrent(FILE_CIF);
DBAdjustLabels(EditCellUse->cu_def, &TiPlaneRect);
DBReComputeBbox(EditCellUse->cu_def);
DBWAreaChanged(EditCellUse->cu_def, &EditCellUse->cu_def->cd_bbox,
@ -1394,54 +1693,32 @@ CIFReadCellCleanup(type)
if (def->cd_flags & CDFLATGDS)
{
/* These cells have been flattened and are no longer needed. */
/* Do not remove the actual CellDef, though, because it is */
/* still instanced, and that instance tells the GDS write */
/* routine that the subcell needs to be included in the */
/* output. But all clientdata and labels should be removed. */
int pNum;
Plane **cifplanes = (Plane **)def->cd_client;
UndoDisable();
for (pNum = 0; pNum < MAXCIFRLAYERS; pNum++)
/* cifplanes should be valid, but don't crash magic if not */
if (cifplanes != (Plane **)0)
{
if (cifplanes[pNum] != NULL)
for (pNum = 0; pNum < MAXCIFRLAYERS; pNum++)
{
DBFreePaintPlane(cifplanes[pNum]);
TiFreePlane(cifplanes[pNum]);
if (cifplanes[pNum] != NULL)
{
DBFreePaintPlane(cifplanes[pNum]);
TiFreePlane(cifplanes[pNum]);
}
}
freeMagic((char *)def->cd_client);
}
freeMagic((char *)def->cd_client);
def->cd_client = (ClientData)CLIENTDEFAULT;
def->cd_client = (ClientData)0;
def->cd_flags &= ~CDFLATGDS;
/* If the CDFLATTENED flag was not set, then this geometry */
/* was never instantiated, and should generate a warning. */
if (!(def->cd_flags & CDFLATTENED))
CIFReadError("%s read error: Unresolved geometry in cell"
" %s maps to no magic layers\n",
(type == 0) ? "CIF" : "GDS", def->cd_name);
#if 0
/* Remove the cell if it has no parents, no children, and no geometry */
/* To-do: Check that these conditions are valid */
if (def->cd_parents == (CellUse *)NULL)
{
char *savename = StrDup((char **)NULL, def->cd_name);
if (DBCellDeleteDef(def) == FALSE)
{
CIFReadError("%s read error: Unable to delete cell %s\n",
(type == 0) ? "CIF" : "GDS", savename);
}
else
{
if (type == 0)
TxPrintf("CIF read: Removed flattened cell %s\n", savename);
else
TxPrintf("GDS read: Removed flattened cell %s\n", savename);
}
freeMagic(savename);
}
#endif
UndoEnable();
}
}

View File

@ -3,24 +3,25 @@
* This file contains procedures that turn polygons into
* rectangles, as part of CIF file reading.
*
* *********************************************************************
* * Copyright (C) 1985, 1990 Regents of the University of California. *
* * Permission to use, copy, modify, and distribute this *
* * software and its documentation for any purpose and without *
* * fee is hereby granted, provided that the above copyright *
* * notice appear in all copies. The University of California *
* * makes no representations about the suitability of this *
* * software for any purpose. It is provided "as is" without *
* * express or implied warranty. Export of this software outside *
* * of the United States of America may require an export license. *
* *********************************************************************
* * Copyright (C) 1985, 1990 Regents of the University of California. *
* * Permission to use, copy, modify, and distribute this *
* * software and its documentation for any purpose and without *
* * fee is hereby granted, provided that the above copyright *
* * notice appear in all copies. The University of California *
* * makes no representations about the suitability of this *
* * software for any purpose. It is provided "as is" without *
* * express or implied warranty. Export of this software outside *
* * of the United States of America may require an export license. *
* *********************************************************************
*/
#ifndef lint
static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/cif/CIFrdpoly.c,v 1.3 2010/06/24 12:37:15 tim Exp $";
static const char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/cif/CIFrdpoly.c,v 1.3 2010/06/24 12:37:15 tim Exp $";
#endif /* not lint */
#include <stdio.h>
#include <stdlib.h> /* For qsort() */
#include "utils/magic.h"
#include "utils/geometry.h"
#include "tiles/tile.h"
@ -28,12 +29,13 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
#include "database/database.h"
#include "cif/CIFint.h"
#include "cif/CIFread.h"
#include "calma/calma.h"
#include "utils/malloc.h"
#define HEDGE 0 /* Horizontal edge */
#define REDGE 1 /* Rising edge */
#define FEDGE -1 /* Falling edge */
/*
* ----------------------------------------------------------------------------
*
@ -52,11 +54,15 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
* ----------------------------------------------------------------------------
*/
int
cifLowX(a, b)
CIFPath **a, **b;
int
cifLowX(
const void *aa,
const void *bb)
{
Point *p, *q;
const CIFPath **a = (const CIFPath **)aa;
const CIFPath **b = (const CIFPath **)bb;
const Point *p, *q;
p = &(*a)->cifp_point;
q = &(*b)->cifp_point;
@ -66,7 +72,7 @@ cifLowX(a, b)
return (1);
return (0);
}
/*
* ----------------------------------------------------------------------------
*
@ -85,17 +91,20 @@ cifLowX(a, b)
* ----------------------------------------------------------------------------
*/
int
cifLowY(a, b)
Point **a, **b;
int
cifLowY(
const void *aa,
const void *bb)
{
const Point **a = (const Point **)aa;
const Point **b = (const Point **)bb;
if ((*a)->p_y < (*b)->p_y)
return (-1);
if ((*a)->p_y > (*b)->p_y)
return (1);
return (0);
}
/*
* ----------------------------------------------------------------------------
*
@ -117,10 +126,10 @@ cifLowY(a, b)
*/
bool
cifOrient(edges, nedges, dir)
CIFPath *edges[]; /* Array of edges to be categorized. */
int dir[]; /* Array to hold directions. */
int nedges; /* Size of arrays. */
cifOrient(
CIFPath *edges[], /* Array of edges to be categorized. */
int nedges, /* Size of arrays. */
int dir[]) /* Array to hold directions. */
{
Point *p, *q;
int n;
@ -157,7 +166,7 @@ cifOrient(edges, nedges, dir)
}
return (TRUE);
}
/*
* ----------------------------------------------------------------------------
*
@ -177,10 +186,11 @@ cifOrient(edges, nedges, dir)
*/
bool
cifCross(edge, dir, ybot, ytop)
CIFPath *edge; /* Pointer to first of 2 path points in edge */
int dir; /* Direction of edge */
int ybot, ytop; /* Range of interest */
cifCross(
CIFPath *edge, /* Pointer to first of 2 path points in edge */
int dir, /* Direction of edge */
int ybot,
int ytop) /* Range of interest */
{
int ebot, etop;
@ -200,7 +210,7 @@ cifCross(edge, dir, ybot, ytop)
return (FALSE);
}
/*
* ----------------------------------------------------------------------------
*
@ -221,11 +231,12 @@ cifCross(edge, dir, ybot, ytop)
*/
LinkedRect *
CIFPolyToRects(path, plane, resultTbl, ui)
CIFPath *path; /* Path describing a polygon. */
Plane *plane; /* Plane to draw on */
PaintResultType *resultTbl;
PaintUndoInfo *ui;
CIFPolyToRects(
CIFPath *path, /* Path describing a polygon. */
Plane *plane, /* Plane to draw on */
const PaintResultType *resultTbl,
PaintUndoInfo *ui,
bool isCalma) /* TRUE for Calma, FALSE for CIF */
{
int npts = 0, n, *dir, curr, wrapno;
int xbot, xtop, ybot, ytop;
@ -239,6 +250,9 @@ CIFPolyToRects(path, plane, resultTbl, ui)
if ((tail->cifp_x != path->cifp_x) || (tail->cifp_y != path->cifp_y))
{
if (isCalma)
CalmaReadError("Boundary is not closed.\n" );
p = (CIFPath *) mallocMagic ((unsigned) sizeof (CIFPath));
p->cifp_x = path->cifp_x;
p->cifp_y = path->cifp_y;

View File

@ -4,21 +4,21 @@
* particular, it contains the routines to handle paint,
* including rectangles, wires, flashes, and polygons.
*
* *********************************************************************
* * Copyright (C) 1985, 1990 Regents of the University of California. *
* * Permission to use, copy, modify, and distribute this *
* * software and its documentation for any purpose and without *
* * fee is hereby granted, provided that the above copyright *
* * notice appear in all copies. The University of California *
* * makes no representations about the suitability of this *
* * software for any purpose. It is provided "as is" without *
* * express or implied warranty. Export of this software outside *
* * of the United States of America may require an export license. *
* *********************************************************************
* * Copyright (C) 1985, 1990 Regents of the University of California. *
* * Permission to use, copy, modify, and distribute this *
* * software and its documentation for any purpose and without *
* * fee is hereby granted, provided that the above copyright *
* * notice appear in all copies. The University of California *
* * makes no representations about the suitability of this *
* * software for any purpose. It is provided "as is" without *
* * express or implied warranty. Export of this software outside *
* * of the United States of America may require an export license. *
* *********************************************************************
*/
#ifndef lint
static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/cif/CIFrdpt.c,v 1.2 2010/06/24 12:37:15 tim Exp $";
static const char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/cif/CIFrdpt.c,v 1.2 2010/06/24 12:37:15 tim Exp $";
#endif /* not lint */
#include <stdio.h>
@ -37,7 +37,9 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
#include "cif/CIFint.h"
#include "cif/CIFread.h"
/* C99 compat */
#include "textio/textio.h"
/*
* ----------------------------------------------------------------------------
*
@ -63,13 +65,13 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
*/
bool
CIFParseBox()
CIFParseBox(void)
{
Point center;
Point direction;
Rect rectangle, r2;
int savescale;
/* Take the 'B'. */
TAKE();
@ -122,7 +124,7 @@ CIFParseBox()
rectangle.r_xbot = -rectangle.r_xtop;
rectangle.r_ybot = -rectangle.r_ytop;
/* Optional direction vector: have to build transform to do rotate. */
if (CIFParseSInteger(&direction.p_x))
@ -147,7 +149,7 @@ CIFParseBox()
DBPaintPlane(cifReadPlane, &r2, CIFPaintTable, (PaintUndoInfo *) NULL);
return TRUE;
}
/*
* ----------------------------------------------------------------------------
*
@ -174,13 +176,13 @@ CIFParseBox()
*/
bool
CIFParseFlash()
CIFParseFlash(void)
{
int diameter;
int savescale;
Point center;
Rect rectangle;
/* Take the 'R'. */
TAKE();
@ -234,11 +236,13 @@ CIFParseFlash()
*/
void
CIFPropRecordPath(def, pathheadp, iswire)
CellDef *def;
CIFPath *pathheadp;
CIFPropRecordPath(
CellDef *def,
CIFPath *pathheadp,
bool iswire,
char *propname)
{
extern float CIFGetOutputScale();
extern float CIFGetOutputScale(int convert);
CIFPath *pathp;
char *pathstr, *sptr;
int components;
@ -273,7 +277,7 @@ CIFPropRecordPath(def, pathheadp, iswire)
/* Reallocate pathstr to be no larger than needed to hold the path contents */
StrDup(&pathstr, pathstr);
DBPropPut(def, "path", (ClientData)pathstr);
DBPropPut(def, propname, (ClientData)pathstr);
}
/*
@ -312,13 +316,13 @@ CIFPropRecordPath(def, pathheadp, iswire)
*/
void
CIFPaintWirePath(pathheadp, width, endcap, plane, ptable, ui)
CIFPath *pathheadp;
int width;
bool endcap;
Plane *plane;
PaintResultType *ptable;
PaintUndoInfo *ui;
CIFPaintWirePath(
CIFPath *pathheadp,
int width,
bool endcap,
Plane *plane,
const PaintResultType *ptable,
PaintUndoInfo *ui)
{
CIFPath *pathp, *previousp, *nextp, *polypath;
CIFPath *returnpath, *newpath, *savepath;
@ -334,18 +338,20 @@ CIFPaintWirePath(pathheadp, width, endcap, plane, ptable, ui)
pathp = pathheadp->cifp_next;
if (pathp != NULL)
{
free_magic1_t mm1 = freeMagic1_init();
while (pathp->cifp_next != NULL)
{
if (pathp->cifp_next->cifp_x == pathp->cifp_x &&
pathp->cifp_next->cifp_y == pathp->cifp_y)
{
previousp->cifp_next = pathp->cifp_next;
freeMagic(pathp);
freeMagic1(&mm1, pathp);
}
else
previousp = pathp;
pathp = pathp->cifp_next;
}
freeMagic1_end(&mm1);
}
previousp = pathheadp;
@ -435,7 +441,8 @@ CIFPaintWirePath(pathheadp, width, endcap, plane, ptable, ui)
/* Wire reverses direction. Break wire here, */
/* draw, and start new polygon. */
TxError("Warning: direction reversal in path.\n");
TxError("Warning: direction reversal in path at (%d, %d).\n",
pathp->cifp_x, pathp->cifp_y);
phi = theta;
if (endcap)
@ -447,7 +454,8 @@ CIFPaintWirePath(pathheadp, width, endcap, plane, ptable, ui)
firstpoint = TRUE;
}
else {
TxError("Error: mitre limit exceeded at wire junction.\n");
TxError("Error: mitre limit exceeded at wire junction at (%d, %d).\n",
pathp->cifp_x, pathp->cifp_y);
TxError("Route has been truncated.\n");
break;
}
@ -477,14 +485,16 @@ CIFPaintWirePath(pathheadp, width, endcap, plane, ptable, ui)
/* Slow draw for non-Manhattan paths: */
/* Break the area up into triangles and rectangles */
rectp = CIFPolyToRects(polypath, plane, ptable, ui);
rectp = CIFPolyToRects(polypath, plane, ptable, ui, FALSE);
CIFFreePath(polypath);
free_magic1_t mm1 = freeMagic1_init();
for (; rectp != NULL ; rectp = rectp->r_next)
{
DBPaintPlane(plane, &rectp->r_r, ptable, ui);
freeMagic((char *) rectp);
freeMagic1(&mm1, (char *) rectp);
}
freeMagic1_end(&mm1);
polypath = NULL;
}
else
@ -558,18 +568,18 @@ CIFPaintWirePath(pathheadp, width, endcap, plane, ptable, ui)
*/
LinkedRect *
PaintPolygon(pointlist, number, plane, ptable, ui, keep)
Point *pointlist; /* Array of Point structures */
int number; /* total number of points */
Plane *plane; /* Plane structure to paint into */
PaintResultType *ptable; /* Paint result table */
PaintUndoInfo *ui; /* Undo record */
bool keep; /* Return list of rects if true */
PaintPolygon(
Point *pointlist, /* Array of Point structures */
int number, /* total number of points */
Plane *plane, /* Plane structure to paint into */
PaintResultType *ptable, /* Paint result table */
PaintUndoInfo *ui, /* Undo record */
bool keep) /* Return list of rects if true */
{
LinkedRect *rectp, *rectlist;
CIFPath *newpath, *cifpath = (CIFPath *)NULL;
int i;
for (i = 0; i < number; i++)
{
newpath = (CIFPath *) mallocMagic((unsigned) sizeof (CIFPath));
@ -579,14 +589,16 @@ PaintPolygon(pointlist, number, plane, ptable, ui, keep)
cifpath = newpath;
}
rectlist = CIFPolyToRects(cifpath, plane, ptable, ui);
rectlist = CIFPolyToRects(cifpath, plane, ptable, ui, FALSE);
CIFFreePath(cifpath);
free_magic1_t mm1 = freeMagic1_init();
for (rectp = rectlist; rectp != NULL ; rectp = rectp->r_next)
{
DBPaintPlane(plane, &rectp->r_r, ptable, ui);
if (!keep) freeMagic((char *) rectp);
if (!keep) freeMagic1(&mm1, (char *) rectp);
}
freeMagic1_end(&mm1);
return (keep) ? rectlist : (LinkedRect *)NULL;
}
@ -613,18 +625,18 @@ PaintPolygon(pointlist, number, plane, ptable, ui, keep)
*/
void
PaintWireList(pointlist, number, width, endcap, plane, ptable, ui)
Point *pointlist; /* Array of Point structures */
int number; /* total number of points */
int width; /* Route width of path */
bool endcap; /* Whether or not to add 1/2 width endcaps */
Plane *plane; /* Plane structure to paint into */
PaintResultType *ptable; /* Paint result table */
PaintUndoInfo *ui; /* Undo record */
PaintWireList(
Point *pointlist, /* Array of Point structures */
int number, /* total number of points */
int width, /* Route width of path */
bool endcap, /* Whether or not to add 1/2 width endcaps */
Plane *plane, /* Plane structure to paint into */
PaintResultType *ptable, /* Paint result table */
PaintUndoInfo *ui) /* Undo record */
{
CIFPath *newpath, *cifpath = (CIFPath *)NULL;
int i;
for (i = 0; i < number; i++)
{
newpath = (CIFPath *) mallocMagic((unsigned) sizeof (CIFPath));
@ -636,7 +648,7 @@ PaintWireList(pointlist, number, width, endcap, plane, ptable, ui)
CIFPaintWirePath(cifpath, width, endcap, plane, ptable, ui);
}
/*
* ----------------------------------------------------------------------------
*
@ -657,7 +669,7 @@ PaintWireList(pointlist, number, width, endcap, plane, ptable, ui)
*/
bool
CIFParseWire()
CIFParseWire(void)
{
int width;
CIFPath *pathheadp, *polypath;
@ -683,7 +695,8 @@ CIFParseWire()
width /= cifReadScale2;
savescale = cifReadScale1;
if (!CIFParsePath(&pathheadp, 2))
pathheadp = CIFParsePath(2);
if (pathheadp == NULL)
{
CIFReadError("wire, but improper path; ignored.\n");
CIFSkipToSemi();
@ -697,7 +710,7 @@ CIFParseWire()
return TRUE;
}
/*
* ----------------------------------------------------------------------------
*
@ -717,7 +730,7 @@ CIFParseWire()
*/
bool
CIFParseLayer()
CIFParseLayer(void)
{
#define MAXCHARS 4
char name[MAXCHARS+1];
@ -744,7 +757,7 @@ CIFParseLayer()
/* Set current plane for use by the routines that parse geometric
* elements.
*/
type = CIFReadNameToType(name, FALSE);
if (type < 0)
{
@ -760,7 +773,7 @@ CIFParseLayer()
CIFSkipToSemi();
return TRUE;
}
/*
* ----------------------------------------------------------------------------
*
@ -780,7 +793,7 @@ CIFParseLayer()
*/
bool
CIFParsePoly()
CIFParsePoly(void)
{
CIFPath *pathheadp;
LinkedRect *rectp;
@ -793,7 +806,8 @@ CIFParsePoly()
CIFSkipToSemi();
return FALSE;
}
if (!CIFParsePath(&pathheadp, 1))
pathheadp = CIFParsePath(1);
if (pathheadp == NULL)
{
CIFReadError("polygon, but improper path; ignored.\n");
CIFSkipToSemi();
@ -803,7 +817,7 @@ CIFParsePoly()
/* Convert the polygon to rectangles. */
rectp = CIFPolyToRects(pathheadp, cifReadPlane, CIFPaintTable,
(PaintUndoInfo *)NULL);
(PaintUndoInfo *)NULL, FALSE);
CIFFreePath(pathheadp);
if (rectp == NULL)
{
@ -813,11 +827,13 @@ CIFParsePoly()
CIFSkipToSemi();
return FALSE;
}
free_magic1_t mm1 = freeMagic1_init();
for (; rectp != NULL ; rectp = rectp->r_next)
{
DBPaintPlane(cifReadPlane, &rectp->r_r, CIFPaintTable,
(PaintUndoInfo *) NULL);
freeMagic((char *) rectp);
freeMagic1(&mm1, (char *) rectp);
}
freeMagic1_end(&mm1);
return TRUE;
}

View File

@ -4,21 +4,21 @@
* pertain to reading CIF files, and builds the tables used by
* the CIF-reading code.
*
* *********************************************************************
* * Copyright (C) 1985, 1990 Regents of the University of California. *
* * Permission to use, copy, modify, and distribute this *
* * software and its documentation for any purpose and without *
* * fee is hereby granted, provided that the above copyright *
* * notice appear in all copies. The University of California *
* * makes no representations about the suitability of this *
* * software for any purpose. It is provided "as is" without *
* * express or implied warranty. Export of this software outside *
* * of the United States of America may require an export license. *
* *********************************************************************
* * Copyright (C) 1985, 1990 Regents of the University of California. *
* * Permission to use, copy, modify, and distribute this *
* * software and its documentation for any purpose and without *
* * fee is hereby granted, provided that the above copyright *
* * notice appear in all copies. The University of California *
* * makes no representations about the suitability of this *
* * software for any purpose. It is provided "as is" without *
* * express or implied warranty. Export of this software outside *
* * of the United States of America may require an export license. *
* *********************************************************************
*/
#ifndef lint
static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/cif/CIFrdtech.c,v 1.4 2010/09/15 15:45:30 tim Exp $";
static const char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/cif/CIFrdtech.c,v 1.4 2010/09/15 15:45:30 tim Exp $";
#endif /* not lint */
#include <stdio.h>
@ -40,6 +40,9 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
#include "calma/calmaInt.h"
#include "utils/malloc.h"
/* C99 compat */
#include "cif/cif.h"
/* Pointer to a list of all the CIF-reading styles: */
CIFReadKeep *cifReadStyleList = NULL;
@ -59,11 +62,8 @@ CIFReadLayer *cifCurReadLayer; /* Current layer being processed. */
CIFOp *cifCurReadOp; /* Last geometric operation seen. */
/* Forward declarations */
void cifReadStyleInit();
void CIFReadLoadStyle();
/* Label types used by the "labels" statement option */
typedef enum { LABEL_TYPE_NONE, LABEL_TYPE_TEXT, LABEL_TYPE_PORT } labelType;
void cifReadStyleInit(void);
void CIFReadLoadStyle(char *stylename);
/*
* ----------------------------------------------------------------------------
@ -90,8 +90,9 @@ typedef enum { LABEL_TYPE_NONE, LABEL_TYPE_TEXT, LABEL_TYPE_PORT } labelType;
*/
bool
CIFReadTechLimitScale(ns, ds)
int ns, ds;
CIFReadTechLimitScale(
int ns,
int ds)
{
int gridup, scaledown;
int scale, limit, mult;
@ -131,9 +132,9 @@ CIFReadTechLimitScale(ns, ds)
*/
int
CIFReadNameToType(name, newOK)
char *name; /* Name of a CIF layer. */
bool newOK; /* TRUE means OK to create a new layer if this
CIFReadNameToType(
char *name, /* Name of a CIF layer. */
bool newOK) /* TRUE means OK to create a new layer if this
* name is one we haven't seen before.
*/
{
@ -145,7 +146,7 @@ CIFReadNameToType(name, newOK)
/* Only accept this layer if it's in the current CIF style or
* it's OK to add new layers to the current style.
*/
if (!TTMaskHasType(&cifCurReadStyle->crs_cifLayers, i) && !newOK)
continue;
if (strcmp(cifReadLayers[i], name) == 0)
@ -176,7 +177,7 @@ CIFReadNameToType(name, newOK)
cifNReadLayers += 1;
return cifNReadLayers-1;
}
/*
* ----------------------------------------------------------------------------
*
@ -196,40 +197,40 @@ CIFReadNameToType(name, newOK)
*/
int
CIFCalmaLayerToCifLayer(layer, datatype, calmaStyle)
int layer; /* Calma layer number */
int datatype; /* Calma datatype */
CIFReadStyle *calmaStyle;
CIFCalmaLayerToCifLayer(
int layer, /* Calma layer number */
int datatype, /* Calma datatype */
CIFReadStyle *calmaStyle)
{
CalmaLayerType clt;
HashEntry *he;
clt.clt_layer = layer;
clt.clt_type = datatype;
if (he = HashLookOnly(&(calmaStyle->cifCalmaToCif), (char *) &clt))
if ((he = HashLookOnly(&(calmaStyle->cifCalmaToCif), (char *) &clt)))
return ((spointertype) HashGetValue(he));
/* Try wildcarding the datatype */
clt.clt_type = -1;
if (he = HashLookOnly(&(calmaStyle->cifCalmaToCif), (char *) &clt))
if ((he = HashLookOnly(&(calmaStyle->cifCalmaToCif), (char *) &clt)))
return ((spointertype) HashGetValue(he));
/* Try wildcarding the layer */
clt.clt_layer = -1;
clt.clt_type = datatype;
if (he = HashLookOnly(&(calmaStyle->cifCalmaToCif), (char *) &clt))
if ((he = HashLookOnly(&(calmaStyle->cifCalmaToCif), (char *) &clt)))
return ((spointertype) HashGetValue(he));
/* Try wildcarding them both, for a default value */
clt.clt_layer = -1;
clt.clt_type = -1;
if (he = HashLookOnly(&(calmaStyle->cifCalmaToCif), (char *) &clt))
if ((he = HashLookOnly(&(calmaStyle->cifCalmaToCif), (char *) &clt)))
return ((spointertype) HashGetValue(he));
/* No luck */
return (-1);
}
/*
* ----------------------------------------------------------------------------
*
@ -251,9 +252,10 @@ CIFCalmaLayerToCifLayer(layer, datatype, calmaStyle)
*/
void
CIFParseReadLayers(string, mask)
char *string; /* Comma-separated list of CIF layers. */
TileTypeBitMask *mask; /* Where to store bit mask. */
CIFParseReadLayers(
char *string, /* Comma-separated list of CIF layers. */
TileTypeBitMask *mask, /* Where to store bit mask. */
bool newok) /* If TRUE, create new layers if they don't exist */
{
int i;
char *p;
@ -267,11 +269,11 @@ CIFParseReadLayers(string, mask)
p = strchr(string, ',');
if (p != NULL)
*p = 0;
i = CIFReadNameToType(string, TRUE);
i = CIFReadNameToType(string, newok);
if (i >= 0)
TTMaskSetType(mask, i);
else
else if (newok)
{
HashEntry *he;
TileTypeBitMask *amask;
@ -283,13 +285,15 @@ CIFParseReadLayers(string, mask)
TTMaskSetMask(mask, amask);
}
}
else
TxError("Error: CIF layer \"%s\" is unknown.\n", string);
if (p == NULL) break;
*p = ',';
for (string = p; *string == ','; string += 1) /* do nothing */;
}
}
/*
* ----------------------------------------------------------------------------
*
@ -310,7 +314,7 @@ CIFParseReadLayers(string, mask)
*/
void
cifNewReadStyle()
cifNewReadStyle(void)
{
int i;
CIFOp *op;
@ -325,8 +329,10 @@ cifNewReadStyle()
layer = cifCurReadStyle->crs_layers[i];
if (layer != NULL)
{
free_magic1_t mm1 = freeMagic1_init();
for (op = layer->crl_ops; op != NULL; op = op->co_next)
freeMagic((char *)op);
freeMagic1(&mm1, (char *)op);
freeMagic1_end(&mm1);
freeMagic((char *)layer);
}
}
@ -350,7 +356,7 @@ cifNewReadStyle()
*/
void
cifReadStyleInit()
cifReadStyleInit(void)
{
int i;
@ -372,7 +378,7 @@ cifReadStyleInit()
cifCurReadStyle->crs_layers[i] = NULL;
}
}
/*
*
* ----------------------------------------------------------------------------
@ -392,23 +398,25 @@ cifReadStyleInit()
*/
void
CIFReadTechInit()
CIFReadTechInit(void)
{
CIFReadKeep *style;
/* Cleanup any old info. */
cifNewReadStyle();
freeMagic(cifCurReadStyle);
cifCurReadStyle = NULL;
/* forget the list of styles */
free_magic1_t mm1 = freeMagic1_init();
for (style = cifReadStyleList; style != NULL; style = style->crs_next)
{
{
freeMagic(style->crs_name);
freeMagic(style);
freeMagic1(&mm1, style);
}
freeMagic1_end(&mm1);
cifReadStyleList = NULL;
}
@ -430,14 +438,14 @@ CIFReadTechInit()
*/
void
CIFReadTechStyleInit()
CIFReadTechStyleInit(void)
{
cifNReadLayers = 0;
cifCurReadLayer = NULL;
cifCurReadOp = NULL;
}
/*
* ----------------------------------------------------------------------------
*
@ -457,10 +465,10 @@ CIFReadTechStyleInit()
*/
/* ARGSUSED */
bool
CIFReadTechLine(sectionName, argc, argv)
char *sectionName; /* Name of this section ("cifinput"). */
int argc; /* Number of fields on line. */
char *argv[]; /* Values of fields. */
CIFReadTechLine(
char *sectionName, /* Name of this section ("cifinput"). */
int argc, /* Number of fields on line. */
char *argv[]) /* Values of fields. */
{
CIFOp *newOp = NULL;
CIFReadKeep *newStyle, *p;
@ -477,7 +485,7 @@ CIFReadTechLine(sectionName, argc, argv)
* make sure there's already a style around, and create one if
* there isn't.
*/
if (strcmp(argv[0], "style") == 0)
{
if (argc != 2)
@ -493,7 +501,7 @@ CIFReadTechLine(sectionName, argc, argv)
return TRUE;
}
}
for (newStyle = cifReadStyleList; newStyle != NULL;
for (newStyle = cifReadStyleList; newStyle != NULL;
newStyle = newStyle->crs_next)
{
if (!strncmp(newStyle->crs_name, argv[1], l))
@ -547,7 +555,7 @@ CIFReadTechLine(sectionName, argc, argv)
for (p = cifReadStyleList; p->crs_next; p = p->crs_next);
p->crs_next = newStyle;
}
if (cptr == NULL)
break;
else
@ -556,7 +564,7 @@ CIFReadTechLine(sectionName, argc, argv)
newStyle = saveStyle;
}
}
if (cifCurReadStyle == NULL)
{
cifNewReadStyle();
@ -608,7 +616,7 @@ CIFReadTechLine(sectionName, argc, argv)
if (cifCurReadStyle == NULL) return FALSE;
if ((cifCurReadStyle->crs_status != TECH_PENDING) &&
(cifCurReadStyle->crs_status != TECH_SUSPENDED)) return TRUE;
/* Process scalefactor lines next. */
if (strcmp(argv[0], "scalefactor") == 0)
@ -624,8 +632,10 @@ CIFReadTechLine(sectionName, argc, argv)
if (argc >= 3)
{
if(!strncmp(argv[argc - 1], "nanom", 5))
if (!strncmp(argv[argc - 1], "nanom", 5))
cifCurReadStyle->crs_multiplier = 10;
else if (!strncmp(argv[argc - 1], "angstr", 6))
cifCurReadStyle->crs_multiplier = 100;
}
if (cifCurReadStyle->crs_scaleFactor <= 0)
@ -638,7 +648,7 @@ CIFReadTechLine(sectionName, argc, argv)
}
/* Process "gridlimit" lines. */
if (strncmp(argv[0], "grid", 4) == 0)
{
if (StrIsInt(argv[1]))
@ -696,7 +706,7 @@ CIFReadTechLine(sectionName, argc, argv)
return TRUE;
}
}
if (cptr == NULL)
break;
else
@ -738,13 +748,13 @@ CIFReadTechLine(sectionName, argc, argv)
/* Handle a special case of a list of layer names on the
* layer line. Turn them into an OR operation.
*/
if (argc == 3)
{
cifCurReadOp = (CIFOp *) mallocMagic(sizeof(CIFOp));
cifCurReadOp->co_opcode = CIFOP_OR;
cifCurReadOp->co_client = (ClientData)NULL;
CIFParseReadLayers(argv[2], &cifCurReadOp->co_cifMask);
CIFParseReadLayers(argv[2], &cifCurReadOp->co_cifMask, TRUE);
TTMaskZero(&cifCurReadOp->co_paintMask);
cifCurReadOp->co_next = NULL;
cifCurReadOp->co_distance = 0;
@ -788,13 +798,13 @@ CIFReadTechLine(sectionName, argc, argv)
/* Handle a special case of a list of layer names on the
* layer line. Turn them into an OR operation.
*/
if (argc == 3)
{
cifCurReadOp = (CIFOp *) mallocMagic(sizeof(CIFOp));
cifCurReadOp->co_opcode = CIFOP_OR;
cifCurReadOp->co_client = (ClientData)NULL;
CIFParseReadLayers(argv[2], &cifCurReadOp->co_cifMask);
CIFParseReadLayers(argv[2], &cifCurReadOp->co_cifMask, TRUE);
TTMaskZero(&cifCurReadOp->co_paintMask);
cifCurReadOp->co_next = NULL;
cifCurReadOp->co_distance = 0;
@ -837,7 +847,7 @@ CIFReadTechLine(sectionName, argc, argv)
/* Figure out which Magic layer should get labels from which
* CIF layers.
*/
if (strcmp(argv[0], "labels") == 0)
{
TileTypeBitMask mask;
@ -858,17 +868,42 @@ CIFReadTechLine(sectionName, argc, argv)
calmaLabelType = LABEL_TYPE_TEXT;
else if (!strcmp(argv[2], "port"))
calmaLabelType = LABEL_TYPE_PORT;
else if (!strncmp(argv[2], "cell", 4))
calmaLabelType = LABEL_TYPE_CELLID;
else
goto wrongNumArgs;
}
else
goto wrongNumArgs;
}
CIFParseReadLayers(argv[1], &mask);
for (i=0; i<MAXCIFRLAYERS; i+=1)
CIFParseReadLayers(argv[1], &mask, TRUE);
for (i = 0; i < MAXCIFRLAYERS; i++)
{
if (TTMaskHasType(&mask,i))
if (TTMaskHasType(&mask, i))
{
/* Only one magic type can be assigned to a GDS layer, so
* multiple assignments should be flagged as errors. BUT,
* this is a common historic error. Since reattachments
* should be handled rationally (by code added 10/17/2023
* to DBlabel.c), there is no urgent need to flag an issue
* unless the new layer does not exist on the same plane
* as the old one.
*/
if (cifCurReadStyle->crs_labelLayer[i] != TT_SPACE)
{
int p1, p2;
p1 = DBPlane(cifCurReadLayer->crl_magicType);
p2 = DBPlane(cifCurReadStyle->crs_labelLayer[i]);
if (!DBTypeOnPlane(cifCurReadLayer->crl_magicType, p2) &&
!DBTypeOnPlane(cifCurReadStyle->crs_labelLayer[i], p1))
TechError("Labels on layer \"%s\" attached to \"%s\" "
"supersedes prior attachment to \"%s\".\n",
cifReadLayers[i],
DBTypeLongNameTbl[cifCurReadLayer->crl_magicType],
DBTypeLongNameTbl[cifCurReadStyle->crs_labelLayer[i]]);
}
cifCurReadStyle->crs_labelLayer[i]
= cifCurReadLayer->crl_magicType;
if (argc == 3)
@ -883,17 +918,17 @@ CIFReadTechLine(sectionName, argc, argv)
* will cause the layers to be ignored when encountered in
* cells.
*/
if (strcmp(argv[0], "ignore") == 0)
{
TileTypeBitMask mask;
int i;
if (argc != 2) goto wrongNumArgs;
CIFParseReadLayers(argv[1], &mask);
CIFParseReadLayers(argv[1], &mask, TRUE);
/* trash the value in crs_labelLayer so that any labels on this
layer get junked, also. dcs 4/11/90
*/
* layer get junked, also. dcs 4/11/90
*/
for (i=0; i < cifNReadLayers; i++)
{
if (TTMaskHasType(&mask,i))
@ -909,22 +944,23 @@ CIFReadTechLine(sectionName, argc, argv)
/* miscellaneous cif-reading boolean options */
if(strcmp(argv[0], "options") == 0) {
if (strcmp(argv[0], "options") == 0) {
int i;
if (argc < 2) goto wrongNumArgs;
for(i = 1; i < argc; i++) {
if(strcmp(argv[i], "ignore-unknown-layer-labels") == 0)
for (i = 1; i < argc; i++) {
if (strcmp(argv[i], "ignore-unknown-layer-labels") == 0)
cifCurReadStyle->crs_flags |= CRF_IGNORE_UNKNOWNLAYER_LABELS;
if(strcmp(argv[i], "no-reconnect-labels") == 0)
cifCurReadStyle->crs_flags |= CRF_NO_RECONNECT_LABELS;
/* Allow "no-reconnect-labels", although it has been deprecated */
else if (strcmp(argv[i], "no-reconnect-labels") != 0)
TechError("Unknown cifinput option \"%s\".\n", argv[i]);
}
return TRUE;
}
/* Anything below here is a geometric operation, so we can
* do some set-up that is common to all the operations.
*/
if (cifCurReadLayer == NULL)
{
TechError("Must define layer before specifying operations.\n");
@ -952,6 +988,8 @@ CIFReadTechLine(sectionName, argc, argv)
newOp->co_opcode = CIFOP_SHRINK;
else if (strcmp(argv[0], "copyup") == 0)
newOp->co_opcode = CIFOP_COPYUP;
else if (strcmp(argv[0], "boundary") == 0)
newOp->co_opcode = CIFOP_BOUNDARY;
else
{
TechError("Unknown statement \"%s\".\n", argv[0]);
@ -965,9 +1003,8 @@ CIFReadTechLine(sectionName, argc, argv)
case CIFOP_OR:
case CIFOP_COPYUP:
if (argc != 2) goto wrongNumArgs;
CIFParseReadLayers(argv[1], &newOp->co_cifMask);
CIFParseReadLayers(argv[1], &newOp->co_cifMask, TRUE);
break;
case CIFOP_GROW:
case CIFOP_GROW_G:
case CIFOP_SHRINK:
@ -999,7 +1036,7 @@ CIFReadTechLine(sectionName, argc, argv)
return TRUE;
}
/*
* ----------------------------------------------------------------------------
*
@ -1019,7 +1056,7 @@ CIFReadTechLine(sectionName, argc, argv)
*/
void
CIFReadTechFinal()
CIFReadTechFinal(void)
{
/* Reduce the scale by the multiplier, as much as possible while */
/* keeping all CIF input ops in integer units. */
@ -1063,8 +1100,8 @@ CIFReadTechFinal()
* ----------------------------------------------------------------------------
*/
void
CIFReadLoadStyle(stylename)
char *stylename;
CIFReadLoadStyle(
char *stylename)
{
SectionID invcifr;
@ -1079,7 +1116,7 @@ CIFReadLoadStyle(stylename)
/* CIFReadTechFinal(); */ /* Taken care of by TechLoad() */
CIFTechInputScale(DBLambda[0], DBLambda[1], TRUE);
}
/*
* ----------------------------------------------------------------------------
*
@ -1106,8 +1143,8 @@ CIFReadLoadStyle(stylename)
*/
int
CIFReadGetGrowSize(type)
TileType type;
CIFReadGetGrowSize(
TileType type)
{
CIFReadStyle *istyle = cifCurReadStyle;
CIFOp *op;
@ -1161,8 +1198,8 @@ CIFReadGetGrowSize(type)
*/
float
CIFGetInputScale(convert)
int convert;
CIFGetInputScale(
int convert)
{
/* Avoid divide-by-0 error if there is no cif input style */
/* in the tech file. */
@ -1194,10 +1231,10 @@ CIFGetInputScale(convert)
*/
void
CIFPrintReadStyle(dolist, doforall, docurrent)
bool dolist; /* Return as a list if true */
bool doforall; /* Return list of all styles if true */
bool docurrent; /* Return current style if true */
CIFPrintReadStyle(
bool dolist, /* Return as a list if true */
bool doforall, /* Return list of all styles if true */
bool docurrent) /* Return current style if true */
{
CIFReadKeep *style;
@ -1244,7 +1281,7 @@ CIFPrintReadStyle(dolist, doforall, docurrent)
}
}
/*
* ----------------------------------------------------------------------------
*
@ -1265,8 +1302,8 @@ CIFPrintReadStyle(dolist, doforall, docurrent)
*/
void
CIFSetReadStyle(name)
char *name; /* Name of the new style. If NULL,
CIFSetReadStyle(
char *name) /* Name of the new style. If NULL,
* just print the name of the current
* style.
*/
@ -1302,7 +1339,7 @@ CIFSetReadStyle(name)
TxError("\"%s\" is not one of the CIF input styles Magic knows.\n", name);
CIFPrintReadStyle(FALSE, TRUE, TRUE);
}
/*
* ----------------------------------------------------------------------------
*
@ -1326,10 +1363,10 @@ CIFSetReadStyle(name)
*/
int
cifParseCalmaNums(str, numArray, numNums)
char *str; /* String to parse */
int *numArray; /* Array to fill in */
int numNums; /* Maximum number of entries in numArray */
cifParseCalmaNums(
char *str, /* String to parse */
int *numArray, /* Array to fill in */
int numNums) /* Maximum number of entries in numArray */
{
int numFilled, num;
@ -1389,9 +1426,10 @@ cifParseCalmaNums(str, numArray, numNums)
*/
int
CIFTechInputScale(n, d, opt)
int n, d;
bool opt;
CIFTechInputScale(
int n,
int d,
bool opt)
{
CIFReadStyle *istyle = cifCurReadStyle;
CIFReadLayer *cl;

View File

@ -5,21 +5,21 @@
* reading CIF files, plus a bunch of utility routines
* for skipping white space, parsing numbers and points, etc.
*
* *********************************************************************
* * Copyright (C) 1985, 1990 Regents of the University of California. *
* * Permission to use, copy, modify, and distribute this *
* * software and its documentation for any purpose and without *
* * fee is hereby granted, provided that the above copyright *
* * notice appear in all copies. The University of California *
* * makes no representations about the suitability of this *
* * software for any purpose. It is provided "as is" without *
* * express or implied warranty. Export of this software outside *
* * of the United States of America may require an export license. *
* *********************************************************************
* * Copyright (C) 1985, 1990 Regents of the University of California. *
* * Permission to use, copy, modify, and distribute this *
* * software and its documentation for any purpose and without *
* * fee is hereby granted, provided that the above copyright *
* * notice appear in all copies. The University of California *
* * makes no representations about the suitability of this *
* * software for any purpose. It is provided "as is" without *
* * express or implied warranty. Export of this software outside *
* * of the United States of America may require an export license. *
* *********************************************************************
*/
#ifndef lint
static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/cif/CIFrdutils.c,v 1.4 2010/06/24 12:37:15 tim Exp $";
static const char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/cif/CIFrdutils.c,v 1.4 2010/06/24 12:37:15 tim Exp $";
#endif /* not lint */
#include <stdio.h>
@ -27,6 +27,12 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
#include <stdarg.h>
#include <ctype.h>
/*
* C99 compat
* Mind: tcltk/tclmagic.h must be included prior to all the other headers
*/
#include "tcltk/tclmagic.h"
#include "utils/magic.h"
#include "utils/geometry.h"
#include "tiles/tile.h"
@ -40,6 +46,16 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
#include "utils/undo.h"
#include "utils/malloc.h"
/* C99 compat */
#include "lef/lef.h"
#include "drc/drc.h"
#include "extract/extract.h"
#include "wiring/wiring.h"
#include "router/router.h"
#include "mzrouter/mzrouter.h"
#include "irouter/irouter.h"
#include "plow/plow.h"
/* The following variables are used to provide one character of
* lookahead. cifParseLaAvail is TRUE if cifParseLaChar contains
* a valid character, FALSE otherwise. The PEEK and TAKE macros
@ -60,6 +76,7 @@ FILE *cifErrorFile;
int cifLineNumber; /* Number of current line. */
int cifTotalWarnings; /* Number of warnings detected */
int cifTotalErrors; /* Number of errors detected */
bool cifSeenSnapWarning; /* Track this to prevent excessive messaging */
/* The variables used below hold general information about what
* we're currently working on.
@ -92,7 +109,7 @@ Plane *cifReadPlane; /* Plane into which to paint material
* NULL means no layer command has
* been seen for the current cell.
*/
/*
* ----------------------------------------------------------------------------
*
@ -112,7 +129,7 @@ Plane *cifReadPlane; /* Plane into which to paint material
/* VARARGS1 */
void
CIFReadError(char *format, ...)
CIFReadError(const char *format, ...)
{
va_list args;
@ -120,7 +137,10 @@ CIFReadError(char *format, ...)
if (CIFWarningLevel == CIF_WARN_NONE) return;
if ((cifTotalErrors < 100) || (CIFWarningLevel != CIF_WARN_LIMIT))
{
TxError("Error at line %d of CIF file: ", cifLineNumber);
if (cifLineNumber > 0)
TxError("Error at line %d of CIF file: ", cifLineNumber);
else
TxError("CIF file read error: ");
va_start(args, format);
Vfprintf(stderr, format, args);
va_end(args);
@ -130,10 +150,10 @@ CIFReadError(char *format, ...)
TxError("Error limit set: Remaining errors will not be reported.\n");
}
}
void
CIFReadWarning(char *format, ...)
CIFReadWarning(const char *format, ...)
{
va_list args;
@ -141,7 +161,10 @@ CIFReadWarning(char *format, ...)
if (CIFWarningLevel == CIF_WARN_NONE) return;
if ((cifTotalWarnings < 100) || (CIFWarningLevel != CIF_WARN_LIMIT))
{
TxError("Warning at line %d of CIF file: ", cifLineNumber);
if (cifLineNumber > 0)
TxError("Warning at line %d of CIF file: ", cifLineNumber);
else
TxError("CIF file read warning: ");
va_start(args, format);
Vfprintf(stderr, format, args);
va_end(args);
@ -182,9 +205,9 @@ CIFReadWarning(char *format, ...)
*/
int
CIFScaleCoord(cifCoord, snap_type)
int cifCoord; /* A coordinate in CIF units. */
int snap_type; /* How to deal with fractional results */
CIFScaleCoord(
int cifCoord, /* A coordinate in CIF units. */
int snap_type) /* How to deal with fractional results */
{
int result, scale, remain, denom;
int mult, mfactor;
@ -212,8 +235,10 @@ CIFScaleCoord(cifCoord, snap_type)
switch (snap_type)
{
case COORD_EXACT:
CIFReadWarning("Input off lambda grid by %d/%d; grid redefined.\n",
if (!cifSeenSnapWarning)
CIFReadWarning("Input off lambda grid by %d/%d; grid redefined.\n",
remain, denom);
cifSeenSnapWarning = TRUE;
CIFTechInputScale(1, denom, FALSE);
CIFTechOutputScale(1, denom);
@ -237,8 +262,10 @@ CIFScaleCoord(cifCoord, snap_type)
case COORD_HALF_U: case COORD_HALF_L:
if (denom > 2)
{
CIFReadWarning("Input off lambda grid by %d/%d; grid redefined.\n",
remain, denom);
if (!cifSeenSnapWarning)
CIFReadWarning("Input off lambda grid by %d/%d; "
"grid redefined.\n", remain, denom);
cifSeenSnapWarning = TRUE;
/* scale to nearest half-lambda */
if (!(denom & 0x1)) denom >>= 1;
@ -249,8 +276,10 @@ CIFScaleCoord(cifCoord, snap_type)
PlowAfterTech();
ExtTechScale(1, denom);
WireTechScale(1, denom);
#ifdef ROUTE_MODULE
MZAfterTech();
IRAfterTech();
#endif
#ifdef LEF_MODULE
LefTechScale(1, denom);
#endif
@ -271,8 +300,10 @@ CIFScaleCoord(cifCoord, snap_type)
break;
case COORD_ANY:
CIFReadWarning("Input off lambda grid by %d/%d; snapped to grid.\n",
abs(remain), abs(denom));
if (!cifSeenSnapWarning)
CIFReadWarning("Input off lambda grid by %d/%d; snapped to grid.\n",
abs(remain), abs(denom));
cifSeenSnapWarning = TRUE;
/* Careful: must round down a bit more for negative numbers, in
* order to ensure that a point exactly halfway between Magic units
@ -294,7 +325,7 @@ CIFScaleCoord(cifCoord, snap_type)
return result;
}
/*
* ----------------------------------------------------------------------------
*
@ -314,8 +345,8 @@ CIFScaleCoord(cifCoord, snap_type)
*/
bool
cifIsBlank(ch)
int ch;
cifIsBlank(
int ch)
{
if ( isdigit(ch) || isupper(ch)
@ -327,7 +358,7 @@ cifIsBlank(ch)
}
else return TRUE;
}
/*
* ----------------------------------------------------------------------------
*
@ -347,9 +378,9 @@ cifIsBlank(ch)
*/
void
CIFSkipBlanks()
CIFSkipBlanks(void)
{
while (cifIsBlank(PEEK())) {
if (TAKE() == '\n')
{
@ -357,7 +388,7 @@ CIFSkipBlanks()
}
}
}
/*
* ----------------------------------------------------------------------------
*
@ -376,7 +407,7 @@ CIFSkipBlanks()
*/
void
CIFSkipSep()
CIFSkipSep(void)
{
int ch;
@ -387,7 +418,7 @@ CIFSkipSep()
}
}
}
/*
* ----------------------------------------------------------------------------
*
@ -406,10 +437,10 @@ CIFSkipSep()
*/
void
CIFSkipToSemi()
CIFSkipToSemi(void)
{
int ch;
for (ch = PEEK() ; ((ch != ';') && (ch != EOF)) ; ch = PEEK()) {
if (TAKE() == '\n')
{
@ -417,7 +448,7 @@ CIFSkipToSemi()
}
}
}
/*
* ----------------------------------------------------------------------------
*
@ -435,9 +466,9 @@ CIFSkipToSemi()
*/
void
CIFSkipSemi()
CIFSkipSemi(void)
{
CIFSkipBlanks();
if (PEEK() != ';') {
CIFReadError("`;\' expected.\n");
@ -446,7 +477,7 @@ CIFSkipSemi()
TAKE();
CIFSkipBlanks();
}
/*
* ----------------------------------------------------------------------------
*
@ -466,8 +497,8 @@ CIFSkipSemi()
*/
bool
CIFParseSInteger(valuep)
int *valuep;
CIFParseSInteger(
int *valuep)
{
bool is_signed;
char buffer[ BUFSIZ ];
@ -492,7 +523,7 @@ CIFParseSInteger(valuep)
*valuep = -(*valuep);
return TRUE;
}
/*
* ----------------------------------------------------------------------------
*
@ -511,8 +542,8 @@ CIFParseSInteger(valuep)
*/
bool
CIFParseInteger(valuep)
int *valuep;
CIFParseInteger(
int *valuep)
{
if (!CIFParseSInteger(valuep))
@ -552,9 +583,9 @@ CIFParseInteger(valuep)
*/
bool
CIFParsePoint(pointp, iscale)
Point *pointp;
int iscale;
CIFParsePoint(
Point *pointp,
int iscale)
{
int rescale;
@ -610,7 +641,7 @@ CIFParsePoint(pointp, iscale)
return TRUE;
}
/*
* ----------------------------------------------------------------------------
*
@ -620,12 +651,11 @@ CIFParsePoint(pointp, iscale)
* one or more points.
*
* Results:
* TRUE is returned if the path was parsed successfully,
* FALSE otherwise.
* non-NULL CIFPath* the caller takes ownership of
* if the path was parsed successfully, otherwise NULL.
*
* Side effects:
* Modifies the parameter pathheadpp to point to the path
* that is constructed.
* None
*
* Corrections:
* CIF coordinates are multiplied by 2 to cover the case where
@ -637,17 +667,16 @@ CIFParsePoint(pointp, iscale)
* ----------------------------------------------------------------------------
*/
bool
CIFParsePath(pathheadpp, iscale)
CIFPath **pathheadpp;
int iscale;
CIFPath *
CIFParsePath(
int iscale)
{
CIFPath *pathtailp, *newpathp;
CIFPath *pathheadp, *pathtailp, *newpathp;
bool nonManhattan = FALSE; /* diagnostic only */
CIFPath path;
int savescale;
*pathheadpp = NULL;
pathheadp = NULL;
pathtailp = NULL;
path.cifp_next = NULL;
while (TRUE)
@ -659,12 +688,12 @@ CIFParsePath(pathheadpp, iscale)
savescale = cifReadScale1;
if (!CIFParsePoint(&path.cifp_point, iscale))
{
CIFFreePath(*pathheadpp);
return FALSE;
CIFFreePath(pathheadp);
return NULL;
}
if (savescale != cifReadScale1)
{
CIFPath *phead = *pathheadpp;
CIFPath *phead = pathheadp;
int newscale = cifReadScale1 / savescale;
while (phead != NULL)
{
@ -675,7 +704,7 @@ CIFParsePath(pathheadpp, iscale)
}
newpathp = (CIFPath *) mallocMagic((unsigned) (sizeof (CIFPath)));
*newpathp = path;
if (*pathheadpp)
if (pathheadp)
{
/*
* Check that this segment is Manhattan. If not, remember the
@ -692,10 +721,10 @@ CIFParsePath(pathheadpp, iscale)
}
pathtailp->cifp_next = newpathp;
}
else *pathheadpp = newpathp;
else pathheadp = newpathp;
pathtailp = newpathp;
}
return (*pathheadpp != NULL);
return pathheadp;
}
/*
@ -707,7 +736,7 @@ CIFParsePath(pathheadpp, iscale)
* first three points in the given CIF path.
*
* Results:
* TRUE if point is inside, FALSE if outside or on the border
* TRUE if point is inside, FALSE if outside or on the border
*
* Side effects:
* None.
@ -715,9 +744,9 @@ CIFParsePath(pathheadpp, iscale)
*/
bool
test_insideness(start, tpoint)
CIFPath *start;
Point *tpoint;
test_insideness(
CIFPath *start,
Point *tpoint)
{
Rect tmprect, irect;
@ -748,15 +777,16 @@ test_insideness(start, tpoint)
* Side effects:
* value of respt contains point to which segment will be
* truncated.
*
*
* ----------------------------------------------------------------------------
*/
bool
seg_intersect(tstart, bf, bs, respt)
CIFPath *tstart;
Point *bf, *bs;
Point *respt;
seg_intersect(
CIFPath *tstart,
Point *bf,
Point *bs,
Point *respt)
{
int afx = tstart->cifp_x;
int afy = tstart->cifp_y;
@ -819,9 +849,10 @@ seg_intersect(tstart, bf, bs, respt)
*/
bool
path_intersect(pathHead, start, respt)
CIFPath *pathHead, *start;
Point *respt;
path_intersect(
CIFPath *pathHead,
CIFPath *start,
Point *respt)
{
CIFPath *path, *segcrossed, *new;
Point tmppt;
@ -850,7 +881,7 @@ path_intersect(pathHead, start, respt)
/* with the smaller absolute distance takes precedence.) */
if (test_insideness(start, &path->cifp_point)) {
int tmpdist = abs(newdist); /* save this value */
int tmpdist = abs(newdist); /* save this value */
if (path->cifp_x == path->cifp_next->cifp_x ||
path->cifp_y == path->cifp_next->cifp_y)
{
@ -924,8 +955,8 @@ path_intersect(pathHead, start, respt)
*/
bool
is_clockwise(pathHead)
CIFPath *pathHead;
is_clockwise(
CIFPath *pathHead)
{
CIFPath *path, *midx = NULL, *last;
Point *p1, *p2, *p3;
@ -1018,11 +1049,11 @@ is_clockwise(pathHead)
*/
void
CIFMakeManhattanPath(pathHead, plane, resultTbl, ui)
CIFPath *pathHead;
Plane *plane;
PaintResultType *resultTbl;
PaintUndoInfo *ui;
CIFMakeManhattanPath(
CIFPath *pathHead,
Plane *plane,
const PaintResultType *resultTbl,
PaintUndoInfo *ui)
{
CIFPath *new, *new2, *next, *path;
int xinit, xdiff, xincr, xlast, x;
@ -1066,7 +1097,7 @@ CIFMakeManhattanPath(pathHead, plane, resultTbl, ui)
edir = CIFEdgeDirection(first, last);
if (edir == CIF_DIAG_DL || edir == CIF_DIAG_UR)
{
new->cifp_x = first->cifp_x;
new->cifp_x = first->cifp_x;
new->cifp_y = last->cifp_y;
}
else /* edir == CIF_DIAG_DR || edir == CIF_DIAG_UL */
@ -1125,11 +1156,15 @@ CIFMakeManhattanPath(pathHead, plane, resultTbl, ui)
/* Final check---ensure that rectangle is not degenerate */
if (plane && (tr.r_xtop - tr.r_xbot > 0) && (tr.r_ytop - tr.r_ybot > 0))
{
DBNMPaintPlane(plane, type, &tr, resultTbl, ui);
GEO_EXPAND(&tr, 1, &tr);
DBMergeNMTiles(plane, &tr, ui);
}
}
}
/*
* ----------------------------------------------------------------------------
*
@ -1152,8 +1187,9 @@ CIFMakeManhattanPath(pathHead, plane, resultTbl, ui)
*/
int
CIFEdgeDirection(first, last)
CIFPath *first, *last; /* Edge to be categorized. */
CIFEdgeDirection(
CIFPath *first,
CIFPath *last) /* Edge to be categorized. */
{
if (first->cifp_x < last->cifp_x)
@ -1178,7 +1214,7 @@ CIFEdgeDirection(first, last)
return CIF_DOWN;
return CIF_ZERO;
}
/*
* ----------------------------------------------------------------------------
*
@ -1200,8 +1236,8 @@ CIFEdgeDirection(first, last)
*/
void
CIFCleanPath(pathHead)
CIFPath *pathHead;
CIFCleanPath(
CIFPath *pathHead)
{
CIFPath *next, *path, *prev, *last;
int dir1, dir2;
@ -1219,8 +1255,8 @@ CIFCleanPath(pathHead)
path = next;
if (!path) return;
}
while (next = path->cifp_next)
while ((next = path->cifp_next))
{
if ((dir2 = CIFEdgeDirection(path, next)) == CIF_ZERO)
{
@ -1253,7 +1289,7 @@ path_inc:
if (!pathHead->cifp_next)
{
/* Ensure that the resulting path is closed. */
if ((pathHead->cifp_x != path->cifp_x) ||
if ((pathHead->cifp_x != path->cifp_x) ||
(pathHead->cifp_y != path->cifp_y))
{
next = (CIFPath *) mallocMagic((unsigned) (sizeof (CIFPath)));
@ -1281,7 +1317,7 @@ path_inc:
}
}
}
/*
* ----------------------------------------------------------------------------
*
@ -1299,16 +1335,18 @@ path_inc:
*/
void
CIFFreePath(path)
CIFPath *path; /* Path to be freed. */
CIFFreePath(
CIFPath *path) /* Path to be freed. */
{
free_magic1_t mm1 = freeMagic1_init();
while (path != NULL)
{
freeMagic((char *) path);
freeMagic1(&mm1, (char *) path);
path = path->cifp_next;
}
freeMagic1_end(&mm1);
}
/*
* ----------------------------------------------------------------------------
*
@ -1328,13 +1366,13 @@ CIFFreePath(path)
*/
void
cifCommandError()
cifCommandError(void)
{
CIFReadError("unknown command `%c'; ignored.\n" , PEEK());
CIFSkipToSemi();
}
/*
* ----------------------------------------------------------------------------
*
@ -1353,7 +1391,7 @@ cifCommandError()
*/
bool
cifParseEnd()
cifParseEnd(void)
{
TAKE();
CIFSkipBlanks();
@ -1364,7 +1402,7 @@ cifParseEnd()
}
return TRUE;
}
/*
* ----------------------------------------------------------------------------
*
@ -1382,11 +1420,11 @@ cifParseEnd()
*/
bool
cifParseComment()
cifParseComment(void)
{
int opens;
int ch;
/*
* take the '('
*/
@ -1411,7 +1449,7 @@ cifParseComment()
} while (opens > 0);
return TRUE;
}
/*
* ----------------------------------------------------------------------------
*
@ -1433,9 +1471,9 @@ cifParseComment()
* ----------------------------------------------------------------------------
*/
Transform *
CIFDirectionToTrans(point)
Point *point; /* Direction vector from origin. */
const Transform *
CIFDirectionToTrans(
const Point *point) /* Direction vector from origin. */
{
if ((point->p_x != 0) && (point->p_y == 0))
{
@ -1453,7 +1491,7 @@ CIFDirectionToTrans(point)
point->p_x, point->p_y);
return &GeoIdentityTransform;
}
/*
* ----------------------------------------------------------------------------
*
@ -1474,8 +1512,8 @@ CIFDirectionToTrans(point)
*/
bool
CIFParseTransform(transformp)
Transform *transformp;
CIFParseTransform(
Transform *transformp)
{
char ch;
Point point;
@ -1548,7 +1586,7 @@ CIFParseTransform(transformp)
return TRUE;
}
/*
* ----------------------------------------------------------------------------
*
@ -1568,8 +1606,8 @@ CIFParseTransform(transformp)
*/
void
CIFReadFile(file)
FILE *file; /* File from which to read CIF. */
CIFReadFile(
FILE *file) /* File from which to read CIF. */
{
/* We will use 1-word CIF numbers as keys in this hash table */
CIFReadCellInit(1);
@ -1585,6 +1623,7 @@ CIFReadFile(file)
cifTotalWarnings = 0;
cifTotalErrors = 0;
CifPolygonCount = 0;
cifSeenSnapWarning = FALSE;
cifInputFile = file;
cifReadScale1 = 1;
@ -1660,6 +1699,6 @@ CIFReadFile(file)
CIFReadError("no \"End\" statement.\n");
done:
CIFReadCellCleanup(0);
CIFReadCellCleanup(FILE_CIF);
UndoEnable();
}

View File

@ -5,24 +5,24 @@
* by the CIF writing code. The definitions are only used internally
* to this module.
*
* *********************************************************************
* * Copyright (C) 1985, 1990 Regents of the University of California. *
* * Permission to use, copy, modify, and distribute this *
* * software and its documentation for any purpose and without *
* * fee is hereby granted, provided that the above copyright *
* * notice appear in all copies. The University of California *
* * makes no representations about the suitability of this *
* * software for any purpose. It is provided "as is" without *
* * express or implied warranty. Export of this software outside *
* * of the United States of America may require an export license. *
* *********************************************************************
* * Copyright (C) 1985, 1990 Regents of the University of California. *
* * Permission to use, copy, modify, and distribute this *
* * software and its documentation for any purpose and without *
* * fee is hereby granted, provided that the above copyright *
* * notice appear in all copies. The University of California *
* * makes no representations about the suitability of this *
* * software for any purpose. It is provided "as is" without *
* * express or implied warranty. Export of this software outside *
* * of the United States of America may require an export license. *
* *********************************************************************
*
*
* rcsid "$Header: /usr/cvsroot/magic-8.0/cif/CIFread.h,v 1.3 2010/08/25 17:33:55 tim Exp $
*/
#ifndef _CIFREAD_H
#define _CIFREAD_H
#ifndef _MAGIC__CIF__CIFREAD_H
#define _MAGIC__CIF__CIFREAD_H
#include "cif/CIFint.h"
@ -54,8 +54,8 @@ typedef struct
* the "crl_magicType" should be interpreted as a CIF layer.
*/
#define CIFR_SIMPLE 1
#define CIFR_TEMPLAYER 2
#define CIFR_SIMPLE 1
#define CIFR_TEMPLAYER 2
/* The following structure defines a complete CIF read-in style.
* The constant MAXCIFRLAYERS must be less than TT_MAXTYPES, and
@ -104,8 +104,10 @@ typedef struct cifrstyle
/* Gives the Magic layer to use for labels
* on each possible CIF layer.
*/
bool crs_labelSticky[MAXCIFRLAYERS];
/* Marker if label layer makes sticky labels */
/* enum labelType */ unsigned char crs_labelSticky[MAXCIFRLAYERS];
/* Marker if label layer makes sticky labels
* enum labelType LABEL_TYPE_xxxxxx
*/
CIFReadLayer *crs_layers[MAXCIFRLAYERS];
HashTable cifCalmaToCif; /* Table mapping from Calma layer numbers to
* CIF layers
@ -115,7 +117,6 @@ typedef struct cifrstyle
/* option bitmasks used in crs_flags */
#define CRF_IGNORE_UNKNOWNLAYER_LABELS 1
#define CRF_NO_RECONNECT_LABELS 2
/* Methods to deal with fractional results of conversion from CIF to magic */
/* units (see routine CIFScaleCoord() for details). */
@ -153,22 +154,45 @@ typedef struct cifpath
/* Procedures */
extern bool CIFParseBox(), CIFParseWire(), CIFParsePoly();
extern bool CIFParseFlash(), CIFParseLayer(), CIFParseStart();
extern bool CIFParseFinish(), CIFParseDelete(), CIFParseUser();
extern bool CIFParseCall(), CIFParseTransform(), CIFParseInteger();
extern bool CIFParsePath(), CIFParsePoint(), CIFParseSInteger();
extern void CIFSkipToSemi(), CIFSkipSep(), CIFSkipBlanks();
extern void CIFFreePath(), CIFCleanPath();
extern void CIFReadCellInit(), CIFReadCellCleanup();
extern LinkedRect *CIFPolyToRects();
extern Transform *CIFDirectionToTrans();
extern int CIFReadNameToType();
extern bool CIFParseBox(void);
extern bool CIFParseWire(void);
extern bool CIFParsePoly(void);
extern bool CIFParseFlash(void);
extern bool CIFParseLayer(void);
extern bool CIFParseStart(void);
extern bool CIFParseFinish(void);
extern bool CIFParseDelete(void);
extern bool CIFParseUser(void);
extern bool CIFParseCall(void);
extern bool CIFParseTransform(Transform *transformp);
extern bool CIFParseInteger(int *valuep);
extern CIFPath *CIFParsePath(int iscale);
extern bool CIFParsePoint(Point *pointp, int iscale);
extern bool CIFParseSInteger(int *valuep);
extern void CIFSkipToSemi(void);
extern void CIFSkipSep(void);
extern void CIFSkipBlanks(void);
extern void CIFFreePath(CIFPath *path);
extern void CIFCleanPath(CIFPath *pathHead);
extern void CIFReadCellInit(int ptrkeys);
extern void CIFReadCellCleanup(int filetype);
extern LinkedRect *CIFPolyToRects(CIFPath *path, Plane *plane, const PaintResultType *resultTbl,
PaintUndoInfo *ui, bool isCalma);
extern const Transform *CIFDirectionToTrans(const Point *point);
extern int CIFReadNameToType(char *name, bool newOK);
extern int CIFCalmaLayerToCifLayer(int layer, int datatype, CIFReadStyle *calmaStyle);
extern void CIFPropRecordPath(CellDef *def, CIFPath *pathheadp, bool iswire, char *propname);
extern void CIFPaintWirePath(CIFPath *pathheadp, int width, bool endcap, Plane *plane,
const PaintResultType *ptable, PaintUndoInfo *ui);
extern void CIFMakeManhattanPath(CIFPath *pathHead, Plane *plane, const PaintResultType *resultTbl, PaintUndoInfo *ui);
extern int CIFEdgeDirection(CIFPath *first, CIFPath *last);
/* Variable argument procedures require complete prototype */
extern void CIFReadError(char *format, ...);
extern void CIFReadWarning(char *format, ...);
extern void CIFReadError(const char *format, ...) ATTR_FORMAT_PRINTF_1;
extern void CIFReadWarning(const char *format, ...) ATTR_FORMAT_PRINTF_1;
/* Variables shared by the CIF-reading modules, see CIFreadutils.c
* for more details:
@ -197,4 +221,4 @@ extern int cifParseLaChar;
? (cifParseLaAvail = FALSE, cifParseLaChar) \
: (cifParseLaChar = getc(cifInputFile)))
#endif /* _CIFREAD_H */
#endif /* _MAGIC__CIF__CIFREAD_H */

View File

@ -3,24 +3,25 @@
* This file provides procedures for displaying CIF layers on
* the screen using the highlight facilities.
*
* *********************************************************************
* * Copyright (C) 1985, 1990 Regents of the University of California. *
* * Permission to use, copy, modify, and distribute this *
* * software and its documentation for any purpose and without *
* * fee is hereby granted, provided that the above copyright *
* * notice appear in all copies. The University of California *
* * makes no representations about the suitability of this *
* * software for any purpose. It is provided "as is" without *
* * express or implied warranty. Export of this software outside *
* * of the United States of America may require an export license. *
* *********************************************************************
* * Copyright (C) 1985, 1990 Regents of the University of California. *
* * Permission to use, copy, modify, and distribute this *
* * software and its documentation for any purpose and without *
* * fee is hereby granted, provided that the above copyright *
* * notice appear in all copies. The University of California *
* * makes no representations about the suitability of this *
* * software for any purpose. It is provided "as is" without *
* * express or implied warranty. Export of this software outside *
* * of the United States of America may require an export license. *
* *********************************************************************
*/
#ifndef lint
static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/cif/CIFsee.c,v 1.5 2010/06/24 12:37:15 tim Exp $";
static const char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/cif/CIFsee.c,v 1.5 2010/06/24 12:37:15 tim Exp $";
#endif /* not lint */
#include <stdio.h>
#include "tcltk/tclmagic.h"
#include "utils/magic.h"
#include "utils/geometry.h"
#include "tiles/tile.h"
@ -34,6 +35,9 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
#include "textio/textio.h"
#include "utils/undo.h"
/* C99 compat */
#include "drc/drc.h"
/* The following variable holds the CellDef into which feedback
* is to be placed for displaying CIF.
*/
@ -72,9 +76,9 @@ typedef struct {
*/
int
cifPaintDBFunc(tile, pld)
Tile *tile; /* Tile of CIF information. */
PaintLayerData *pld;
cifPaintDBFunc(
Tile *tile, /* Tile of CIF information. */
PaintLayerData *pld)
{
Rect area;
int pNum;
@ -128,14 +132,14 @@ cifPaintDBFunc(tile, pld)
*/
void
CIFPaintLayer(rootDef, area, cifLayer, magicLayer, paintDef)
CellDef *rootDef; /* Cell for which to generate CIF. Must be
CIFPaintLayer(
CellDef *rootDef, /* Cell for which to generate CIF. Must be
* the rootDef of a window.
*/
Rect *area; /* Area in which to generate CIF. */
char *cifLayer; /* CIF layer to highlight on the screen. */
int magicLayer; /* Magic layer to paint with the result */
CellDef *paintDef; /* CellDef to paint into (may be NULL) */
Rect *area, /* Area in which to generate CIF. */
char *cifLayer, /* CIF layer to highlight on the screen. */
int magicLayer, /* Magic layer to paint with the result */
CellDef *paintDef) /* CellDef to paint into (may be NULL) */
{
int oldCount, i;
char msg[100];
@ -162,8 +166,14 @@ CIFPaintLayer(rootDef, area, cifLayer, magicLayer, paintDef)
scx.scx_trans = GeoIdentityTransform;
(void) DBTreeSrTiles(&scx, &DBAllButSpaceAndDRCBits, 0,
cifHierCopyFunc, (ClientData) CIFComponentDef);
CIFCopyMaskHints(&scx, CIFComponentDef);
DBTreeSrCells(&scx, 0, cifHierCopyMaskHints,
(ClientData)CIFComponentDef);
oldCount = DBWFeedbackCount;
CIFGen(CIFComponentDef, area, CIFPlanes, &depend, TRUE, TRUE);
CIFGen(CIFComponentDef, rootDef, area, CIFPlanes, &depend, TRUE, TRUE, FALSE,
(ClientData)NULL);
DBCellClearDef(CIFComponentDef);
/* Report any errors that occurred. */
@ -207,9 +217,9 @@ CIFPaintLayer(rootDef, area, cifLayer, magicLayer, paintDef)
*/
int
cifSeeFunc(tile, sld)
Tile *tile; /* Tile to be entered as feedback. */
SeeLayerData *sld; /* Layer and explanation for the feedback. */
cifSeeFunc(
Tile *tile, /* Tile to be entered as feedback. */
SeeLayerData *sld) /* Layer and explanation for the feedback. */
{
Rect area;
@ -248,12 +258,12 @@ cifSeeFunc(tile, sld)
*/
void
CIFSeeLayer(rootDef, area, layer)
CellDef *rootDef; /* Cell for which to generate CIF. Must be
CIFSeeLayer(
CellDef *rootDef, /* Cell for which to generate CIF. Must be
* the rootDef of a window.
*/
Rect *area; /* Area in which to generate CIF. */
char *layer; /* CIF layer to highlight on the screen. */
Rect *area, /* Area in which to generate CIF. */
char *layer) /* CIF layer to highlight on the screen. */
{
int oldCount, i;
char msg[100];
@ -276,8 +286,13 @@ CIFSeeLayer(rootDef, area, layer)
scx.scx_trans = GeoIdentityTransform;
(void) DBTreeSrTiles(&scx, &DBAllButSpaceAndDRCBits, 0,
cifHierCopyFunc, (ClientData) CIFComponentDef);
CIFCopyMaskHints(&scx, CIFComponentDef);
DBTreeSrCells(&scx, 0, cifHierCopyMaskHints,
(ClientData)CIFComponentDef);
oldCount = DBWFeedbackCount;
CIFGen(CIFComponentDef, area, CIFPlanes, &depend, TRUE, TRUE);
CIFGen(CIFComponentDef, rootDef, area, CIFPlanes, &depend, TRUE, TRUE,
FALSE, (ClientData)NULL);
DBCellClearDef(CIFComponentDef);
/* Report any errors that occurred. */
@ -311,7 +326,7 @@ CIFSeeLayer(rootDef, area, layer)
}
UndoEnable();
}
/*
* ----------------------------------------------------------------------------
*
@ -333,14 +348,14 @@ CIFSeeLayer(rootDef, area, layer)
*/
void
CIFSeeHierLayer(rootDef, area, layer, arrays, subcells)
CellDef *rootDef; /* Def in which to compute CIF. Must be
CIFSeeHierLayer(
CellDef *rootDef, /* Def in which to compute CIF. Must be
* the root definition of a window.
*/
Rect *area; /* Area in which to generate CIF. */
char *layer; /* CIF layer to be highlighted. */
bool arrays; /* TRUE means show array interactions. */
bool subcells; /* TRUE means show subcell interactions. */
Rect *area, /* Area in which to generate CIF. */
char *layer, /* CIF layer to be highlighted. */
bool arrays, /* TRUE means show array interactions. */
bool subcells) /* TRUE means show subcell interactions. */
{
int i, oldCount;
SeeLayerData sld;
@ -358,7 +373,7 @@ CIFSeeHierLayer(rootDef, area, layer, arrays, subcells)
CIFGenSubcells(rootDef, area, CIFPlanes);
if (arrays)
CIFGenArrays(rootDef, area, CIFPlanes);
/* Report any errors that occurred. */
if (DBWFeedbackCount != oldCount)
@ -366,7 +381,7 @@ CIFSeeHierLayer(rootDef, area, layer, arrays, subcells)
TxPrintf("%d problems occurred. See feedback entries.\n",
DBWFeedbackCount - oldCount);
}
(void) sprintf(msg, "CIF layer \"%s\"", layer);
cifSeeDef = rootDef;
sld.text = msg;
@ -411,10 +426,11 @@ typedef struct {
} coverstats;
void
CIFCoverageLayer(rootDef, area, layer)
CellDef *rootDef; /* Def in which to compute CIF coverage */
Rect *area; /* Area in which to compute coverage */
char *layer; /* CIF layer for coverage computation. */
CIFCoverageLayer(
CellDef *rootDef, /* Def in which to compute CIF coverage */
Rect *area, /* Area in which to compute coverage */
char *layer, /* CIF layer for coverage computation. */
bool dolist) /* If TRUE, report only the value, in decimal */
{
coverstats cstats;
int i, scale;
@ -422,7 +438,7 @@ CIFCoverageLayer(rootDef, area, layer)
SearchContext scx;
TileTypeBitMask mask, depend;
float fcover;
int cifCoverageFunc();
int cifCoverageFunc(Tile *tile, ClientData *arg);
bool doBox = (area != &rootDef->cd_bbox) ? TRUE : FALSE;
/* Check out the CIF layer name. */
@ -440,9 +456,14 @@ CIFCoverageLayer(rootDef, area, layer)
scx.scx_trans = GeoIdentityTransform;
(void) DBTreeSrTiles(&scx, &DBAllButSpaceAndDRCBits, 0,
cifHierCopyFunc, (ClientData) CIFComponentDef);
CIFGen(CIFComponentDef, area, CIFPlanes, &depend, TRUE, TRUE);
CIFCopyMaskHints(&scx, CIFComponentDef);
DBTreeSrCells(&scx, 0, cifHierCopyMaskHints,
(ClientData)CIFComponentDef);
CIFGen(CIFComponentDef, rootDef, area, CIFPlanes, &depend, TRUE, TRUE,
FALSE, (ClientData)NULL);
DBCellClearDef(CIFComponentDef);
cstats.coverage = 0;
cstats.bounds.r_xbot = cstats.bounds.r_xtop = 0;
cstats.bounds.r_ybot = cstats.bounds.r_ytop = 0;
@ -466,24 +487,38 @@ CIFCoverageLayer(rootDef, area, layer)
atotal = (long long)(cstats.bounds.r_xtop - cstats.bounds.r_xbot);
atotal *= (long long)(cstats.bounds.r_ytop - cstats.bounds.r_ybot);
TxPrintf("%s Area = %lld CIF units^2\n", doBox ? "Cursor Box" :
if (dolist)
{
#ifdef MAGIC_WRAPPER
Tcl_Obj *pobj;
pobj = Tcl_NewDoubleObj((double)fcover);
Tcl_SetObjResult(magicinterp, pobj);
#else
TxPrintf("%g\n", fcover);
#endif
}
else
{
TxPrintf("%s Area = %lld CIF units^2\n", doBox ? "Cursor Box" :
"Cell", btotal);
TxPrintf("Layer Bounding Area = %lld CIF units^2\n", atotal);
TxPrintf("Layer Total Area = %lld CIF units^2\n", cstats.coverage);
TxPrintf("Coverage in %s = %1.1f%%\n", doBox ? "box" :
TxPrintf("Layer Bounding Area = %lld CIF units^2\n", atotal);
TxPrintf("Layer Total Area = %lld CIF units^2\n", cstats.coverage);
TxPrintf("Coverage in %s = %1.1f%%\n", doBox ? "box" :
"cell", 100.0 * fcover);
}
}
int
cifCoverageFunc(tile, arg)
Tile *tile;
ClientData *arg;
cifCoverageFunc(
Tile *tile,
ClientData *arg)
{
coverstats *cstats = (coverstats *)arg;
Rect r;
TiToRect(tile, &r);
cstats->coverage += (long long)((r.r_xtop - r.r_xbot) * (r.r_ytop - r.r_ybot));
cstats->coverage += (long long)(r.r_xtop - r.r_xbot) * (long long)(r.r_ytop - r.r_ybot);
GeoInclude(&r, &cstats->bounds);
return(0);

File diff suppressed because it is too large Load Diff

View File

@ -3,21 +3,21 @@
*
* Output of CIF.
*
* *********************************************************************
* * Copyright (C) 1985, 1990 Regents of the University of California. *
* * Permission to use, copy, modify, and distribute this *
* * software and its documentation for any purpose and without *
* * fee is hereby granted, provided that the above copyright *
* * notice appear in all copies. The University of California *
* * makes no representations about the suitability of this *
* * software for any purpose. It is provided "as is" without *
* * express or implied warranty. Export of this software outside *
* * of the United States of America may require an export license. *
* *********************************************************************
* * Copyright (C) 1985, 1990 Regents of the University of California. *
* * Permission to use, copy, modify, and distribute this *
* * software and its documentation for any purpose and without *
* * fee is hereby granted, provided that the above copyright *
* * notice appear in all copies. The University of California *
* * makes no representations about the suitability of this *
* * software for any purpose. It is provided "as is" without *
* * express or implied warranty. Export of this software outside *
* * of the United States of America may require an export license. *
* *********************************************************************
*/
#ifndef lint
static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/cif/CIFwrite.c,v 1.2 2010/06/24 12:37:15 tim Exp $";
static const char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/cif/CIFwrite.c,v 1.2 2010/06/24 12:37:15 tim Exp $";
#endif /* not lint */
#include <stdlib.h>
@ -44,14 +44,15 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
#include "textio/textio.h"
/* Forward declarations */
extern int cifWriteInitFunc();
extern int cifWriteMarkFunc();
extern int cifWritePaintFunc();
extern int cifWriteUseFunc();
extern void cifOutPreamble();
extern void cifOut();
extern void cifOutFunc();
extern int GrClipTriangle();
extern int cifWriteInitFunc(CellDef *def);
extern int cifWriteMarkFunc(CellUse *use);
extern int cifWritePaintFunc(Tile *tile, FILE *f);
extern int cifWriteLabelFunc(Tile *tile, FILE *f);
extern int cifWriteUseFunc(CellUse *use, FILE *f);
extern void cifOutPreamble(FILE *outf, CellDef *cell);
extern void cifOut(FILE *outf);
extern void cifOutFunc(CellDef *def, FILE *f);
extern void GrClipTriangle(Rect *r, Rect *c, int clipped, TileType dinfo, Point *points, int *np);
/* Current cell number in CIF numbering scheme */
@ -86,7 +87,7 @@ char *CIFPathPrefix = NULL;
bool CIFHierWriteDisable = FALSE;
bool CIFArrayWriteDisable = FALSE;
/*
* ----------------------------------------------------------------------------
*
@ -117,12 +118,13 @@ bool CIFArrayWriteDisable = FALSE;
*/
bool
CIFWrite(rootDef, f)
CellDef *rootDef; /* Pointer to CellDef to be written */
FILE *f; /* Open output file */
CIFWrite(
CellDef *rootDef, /* Pointer to CellDef to be written */
FILE *f) /* Open output file */
{
bool good;
int oldCount = DBWFeedbackCount;
CellDef *err_def;
CellUse dummy;
/*
@ -132,14 +134,20 @@ CIFWrite(rootDef, f)
*/
dummy.cu_def = rootDef;
DBCellReadArea(&dummy, &rootDef->cd_bbox);
err_def = DBCellReadArea(&dummy, &rootDef->cd_bbox, TRUE);
if (err_def != NULL)
{
TxError("Failure to read in entire subtree of the cell.\n");
TxError("Failed on cell %s.\n", err_def->cd_name);
return (FALSE);
}
DBFixMismatch();
if (CIFCurStyle->cs_reducer == 0)
{
TxError("The current CIF output style can only be used for writing\n");
TxError("Calma output. Try picking another output style.\n");
return (TRUE);
return (FALSE);
}
/*
@ -159,8 +167,8 @@ CIFWrite(rootDef, f)
cifOutPreamble(f, rootDef);
cifOut(f);
StackFree(cifStack);
if ((int) rootDef->cd_client < 0)
rootDef->cd_client = (ClientData) (- (int) rootDef->cd_client);
if ((int) CD2INT(rootDef->cd_client) < 0)
rootDef->cd_client = INT2CD(- (int) CD2INT(rootDef->cd_client));
/* See if any problems occurred. */
@ -174,11 +182,11 @@ CIFWrite(rootDef, f)
* Now we are almost done.
* Just output a call on the root cell
*/
fprintf(f, "C %d;\nEnd\n", (int) rootDef->cd_client);
fprintf(f, "C %d;\nEnd\n", (int) CD2INT(rootDef->cd_client));
good = !ferror(f);
return (good);
}
/*
* ----------------------------------------------------------------------------
*
@ -197,13 +205,13 @@ CIFWrite(rootDef, f)
*/
int
cifWriteInitFunc(def)
CellDef *def;
cifWriteInitFunc(
CellDef *def)
{
def->cd_client = (ClientData) 0;
return (0);
}
/*
* ----------------------------------------------------------------------------
*
@ -221,16 +229,16 @@ cifWriteInitFunc(def)
*/
int
cifWriteMarkFunc(use)
CellUse *use;
cifWriteMarkFunc(
CellUse *use)
{
if (use->cu_def->cd_client != (ClientData) 0) return 0;
use->cu_def->cd_client = (ClientData) cifCellNum;
use->cu_def->cd_client = INT2CD(cifCellNum);
cifCellNum -= 1;
StackPush((ClientData) use->cu_def, cifStack);
return (0);
}
/*
* ----------------------------------------------------------------------------
*
@ -247,9 +255,9 @@ cifWriteMarkFunc(use)
*/
void
cifOutPreamble(outf, cell)
FILE *outf;
CellDef *cell;
cifOutPreamble(
FILE *outf,
CellDef *cell)
{
extern char *MagicVersion;
extern char *MagicCompileTime;
@ -277,7 +285,7 @@ cifOutPreamble(outf, cell)
fprintf(outf,"( @@style : %s );\n", CIFCurStyle->cs_name);
fprintf(outf,"( @@date : %s );\n", now);
}
/*
* ----------------------------------------------------------------------------
*
@ -296,24 +304,24 @@ cifOutPreamble(outf, cell)
*/
void
cifOut(outf)
FILE *outf;
cifOut(
FILE *outf)
{
CellDef *def;
bool needHier;
while (!StackEmpty(cifStack))
{
def = (CellDef *) StackPop(cifStack);
if ((int) def->cd_client >= 0) continue; /* Already output */
if ((int) CD2INT(def->cd_client) >= 0) continue; /* Already output */
if (SigInterruptPending) continue;
def->cd_client = (ClientData) (- (int) def->cd_client);
def->cd_client = INT2CD(- (int) CD2INT(def->cd_client));
/* Read the cell in if it is not already available. */
if ((def->cd_flags & CDAVAILABLE) == 0)
{
if (!DBCellRead(def, (char *) NULL, TRUE, NULL)) continue;
}
if (!DBCellRead(def, TRUE, TRUE, NULL))
continue;
/* Add any subcells to the stack. This must be done before
* outputting CIF to make sure that the subcells all have
@ -327,7 +335,7 @@ cifOut(outf)
cifOutFunc(def, outf);
}
}
/*
* ----------------------------------------------------------------------------
*
@ -345,16 +353,16 @@ cifOut(outf)
*/
void
cifOutFunc(def, f)
CellDef *def; /* Pointer to cell def to be written */
FILE *f; /* Open output file */
cifOutFunc(
CellDef *def, /* Pointer to cell def to be written */
FILE *f) /* Open output file */
{
Rect bigArea;
Label *lab;
int type;
CIFLayer *layer;
fprintf(f, "DS %d %d %d;\n", (int) def->cd_client,
fprintf(f, "DS %d %d %d;\n", (int) CD2INT(def->cd_client),
CIFCurStyle->cs_reducer, 2 * CIFCurStyle->cs_expander);
if (def->cd_name != (char *) NULL)
@ -374,23 +382,31 @@ cifOutFunc(def, f)
* Output all the tiles associated with this cell. Skip temporary
* layers.
*/
GEO_EXPAND(&def->cd_bbox, CIFCurStyle->cs_radius, &bigArea);
CIFErrorDef = def;
CIFGen(def, &bigArea, CIFPlanes, &DBAllTypeBits, TRUE, TRUE);
CIFGen(def, def, &bigArea, CIFPlanes, &DBAllTypeBits, TRUE, TRUE, FALSE,
(ClientData)NULL);
if (!CIFHierWriteDisable)
CIFGenSubcells(def, &bigArea, CIFPlanes);
CIFGenSubcells(def, &bigArea, CIFPlanes);
if (!CIFArrayWriteDisable)
CIFGenArrays(def, &bigArea, CIFPlanes);
CIFGenArrays(def, &bigArea, CIFPlanes);
for (type = 0; type < CIFCurStyle->cs_nLayers; type++)
{
layer = CIFCurStyle->cs_layers[type];
if (layer->cl_flags & CIF_TEMP) continue;
cifPaintLayerName = layer->cl_name;
cifPaintScale = 1;
(void) DBSrPaintArea((Tile *) NULL, CIFPlanes[type],
&TiPlaneRect, &CIFSolidBits, cifWritePaintFunc,
(ClientData) f);
if (layer->cl_flags & CIF_LABEL)
DBSrPaintArea((Tile *) NULL, CIFPlanes[type],
&TiPlaneRect, &CIFSolidBits, cifWriteLabelFunc,
(ClientData) f);
else
DBSrPaintArea((Tile *) NULL, CIFPlanes[type],
&TiPlaneRect, &CIFSolidBits, cifWritePaintFunc,
(ClientData) f);
}
/* Output labels */
@ -449,7 +465,7 @@ cifOutFunc(def, f)
(void) DBCellEnum(def, cifWriteUseFunc, (ClientData) f);
fprintf(f, "DF;\n");
}
/*
* ----------------------------------------------------------------------------
*
@ -468,16 +484,16 @@ cifOutFunc(def, f)
*/
int
cifWriteUseFunc(use, f)
CellUse *use;
FILE *f;
cifWriteUseFunc(
CellUse *use,
FILE *f)
{
int x, y, topx, topy;
int realx, realy;
Transform *t;
int cifnum;
cifnum = (int) use->cu_def->cd_client;
cifnum = (int) CD2INT(use->cu_def->cd_client);
if (cifnum < 0) cifnum = (-cifnum);
topx = use->cu_xhi - use->cu_xlo;
if (topx < 0) topx = -topx;
@ -494,7 +510,7 @@ cifWriteUseFunc(use, f)
* use identifier, which should include array subscripting
* information.
*/
/*
* Insert a 91 user command to label the next cell
*/
@ -546,7 +562,68 @@ cifWriteUseFunc(use, f)
}
return 0;
}
/*
* ----------------------------------------------------------------------------
*
* cifWriteLabelFunc --
*
* Filter function used to write out a label corresponding to a
* single paint tile. The CIF layer name is used as the label to
* output.
*
* Results:
* Always return 0
*
* Side effects:
* Writes to the disk file.
*
* ----------------------------------------------------------------------------
*/
int
cifWriteLabelFunc(
Tile *tile, /* Tile to be written out. */
FILE *f) /* File in which to write. */
{
Rect r;
int type;
Point center, size;
if (IsSplit(tile)) return 0; /* Ignore non-manhattan tiles */
if (cifPaintLayerName == NULL) return 0; /* Shouldn't happen */
TiToRect(tile, &r);
type = CIFCurStyle->cs_labelLayer[TiGetType(tile)];
center.p_x = r.r_xbot + r.r_xtop;
center.p_y = r.r_ybot + r.r_ytop;
center.p_x *= CIFCurStyle->cs_scaleFactor;
center.p_x /= CIFCurStyle->cs_reducer;
center.p_y *= CIFCurStyle->cs_scaleFactor;
center.p_y /= CIFCurStyle->cs_reducer;
if (CIFDoAreaLabels)
{
size.p_x = r.r_xtop - r.r_xbot;
size.p_y = r.r_ytop - r.r_ybot;
size.p_x *= 2 * CIFCurStyle->cs_scaleFactor;
size.p_x /= CIFCurStyle->cs_reducer;
size.p_y *= 2 * CIFCurStyle->cs_scaleFactor;
size.p_y /= CIFCurStyle->cs_reducer;
fprintf(f, "95 %s %d %d %d %d;\n",
cifPaintLayerName, size.p_x, size.p_y, center.p_x, center.p_y);
}
else
{
fprintf(f, "94 %s %d %d;\n",
cifPaintLayerName, center.p_x, center.p_y);
}
return 0;
}
/*
* ----------------------------------------------------------------------------
*
@ -564,9 +641,9 @@ cifWriteUseFunc(use, f)
*/
int
cifWritePaintFunc(tile, f)
Tile *tile; /* Tile to be written out. */
FILE *f; /* File in which to write. */
cifWritePaintFunc(
Tile *tile, /* Tile to be written out. */
FILE *f) /* File in which to write. */
{
Rect r;
@ -614,15 +691,15 @@ cifWritePaintFunc(tile, f)
CIFRects += 1;
return 0;
}
/*
* ----------------------------------------------------------------------------
*
* CIFWriteFlat --
*
* Write out the entire tree rooted at the supplied CellDef in CIF format,
* to the specified file, but write non-hierarchical CIF.
*
* to the specified file, but write non-hierarchical CIF.
*
* Results:
* TRUE if the cell could be written successfully, FALSE otherwise.
*
@ -634,9 +711,9 @@ cifWritePaintFunc(tile, f)
*
* Algorithm:
* We operate on the cell in chunks chosen to keep the memory utilization
* reasonable. Foreach chunk, we use DBTreeSrTiles and cifHierCopyFunc to
* flatten the
* chunk into a yank buffer ("eliminating" the subcell problem), then use
* reasonable. Foreach chunk, we use DBTreeSrTiles and cifHierCopyFunc to
* flatten the
* chunk into a yank buffer ("eliminating" the subcell problem), then use
* cifOut to generate the CIF.
* No hierarchical design rule checking or bounding box computation
* occur during this operation -- both are explicitly avoided.
@ -645,9 +722,9 @@ cifWritePaintFunc(tile, f)
*/
bool
CIFWriteFlat(rootDef, f)
CellDef *rootDef; /* Pointer to CellDef to be written */
FILE *f; /* Open output file */
CIFWriteFlat(
CellDef *rootDef, /* Pointer to CellDef to be written */
FILE *f) /* Open output file */
{
bool good;
int oldCount = DBWFeedbackCount;
@ -664,11 +741,11 @@ CIFWriteFlat(rootDef, f)
cifOutPreamble(f, rootDef);
/*
* Now process each chunk. We cheat and use cifOut(), so we need to have
* Now process each chunk. We cheat and use cifOut(), so we need to have
* a stack for the single flattened "component" to be on.
*/
{
{
scx.scx_use = CIFDummyUse;
scx.scx_trans = GeoIdentityTransform;
GEO_EXPAND(&rootDef->cd_bbox, CIFCurStyle->cs_radius, &scx.scx_area);
@ -696,10 +773,10 @@ CIFWriteFlat(rootDef, f)
* Just output a call on the root cell
*/
fprintf(f, "C %d;\nEnd\n", (int) CIFComponentDef->cd_client);
fprintf(f, "C %d;\nEnd\n", (int) CD2INT(CIFComponentDef->cd_client));
DBCellClearDef(CIFComponentDef);
good = !ferror(f);
/* Report any errors that occurred. */
if (DBWFeedbackCount != oldCount)

View File

@ -1,45 +0,0 @@
CIFgen.o: CIFgen.c ../utils/magic.h ../utils/geometry.h ../tiles/tile.h \
../utils/hash.h ../database/database.h ../cif/CIFint.h ../calma/calma.h \
../commands/commands.h ../windows/windows.h ../select/selInt.h \
../utils/stack.h ../utils/malloc.h ../utils/maxrect.h
CIFhier.o: CIFhier.c ../utils/magic.h ../utils/geometry.h ../tiles/tile.h \
../utils/hash.h ../database/database.h ../cif/CIFint.h ../cif/cif.h \
../drc/drc.h ../textio/textio.h ../utils/undo.h ../utils/malloc.h \
../utils/signals.h
CIFmain.o: CIFmain.c ../tcltk/tclmagic.h ../utils/magic.h \
../utils/geometry.h ../tiles/tile.h ../utils/hash.h \
../database/database.h ../cif/CIFint.h ../textio/textio.h \
../windows/windows.h ../dbwind/dbwind.h ../utils/styles.h
CIFrdcl.o: CIFrdcl.c ../utils/magic.h ../utils/malloc.h \
../utils/geometry.h ../tiles/tile.h ../utils/hash.h ../utils/undo.h \
../database/database.h ../cif/CIFint.h ../cif/CIFread.h ../utils/utils.h \
../windows/windows.h ../dbwind/dbwind.h ../utils/main.h ../drc/drc.h
CIFrdpt.o: CIFrdpt.c ../utils/magic.h ../utils/geometry.h ../tiles/tile.h \
../utils/hash.h ../utils/malloc.h ../database/database.h \
../windows/windows.h ../utils/main.h ../cif/CIFint.h ../cif/CIFread.h
CIFrdpoly.o: CIFrdpoly.c ../utils/magic.h ../utils/geometry.h \
../tiles/tile.h ../utils/hash.h ../database/database.h ../cif/CIFint.h \
../cif/CIFread.h ../utils/malloc.h
CIFrdtech.o: CIFrdtech.c ../tcltk/tclmagic.h ../utils/magic.h \
../utils/geometry.h ../tiles/tile.h ../utils/hash.h \
../database/database.h ../utils/tech.h ../textio/textio.h \
../utils/utils.h ../cif/CIFint.h ../cif/CIFread.h ../calma/calmaInt.h \
../utils/malloc.h
CIFrdutils.o: CIFrdutils.c ../utils/magic.h ../utils/geometry.h \
../tiles/tile.h ../utils/hash.h ../database/database.h ../cif/CIFint.h \
../cif/CIFread.h ../cif/cif.h ../textio/textio.h ../utils/signals.h \
../utils/undo.h ../utils/malloc.h
CIFsee.o: CIFsee.c ../utils/magic.h ../utils/geometry.h ../tiles/tile.h \
../utils/hash.h ../database/database.h ../windows/windows.h \
../graphics/graphics.h ../dbwind/dbwind.h ../utils/styles.h \
../cif/CIFint.h ../textio/textio.h ../utils/undo.h
CIFtech.o: CIFtech.c ../utils/magic.h ../utils/geometry.h ../tiles/tile.h \
../utils/hash.h ../database/database.h ../utils/tech.h ../utils/utils.h \
../utils/styles.h ../cif/CIFint.h ../calma/calmaInt.h ../textio/textio.h \
../utils/malloc.h ../cif/cif.h ../drc/drc.h
CIFwrite.o: CIFwrite.c ../utils/magic.h ../utils/geometry.h \
../tiles/tile.h ../utils/utils.h ../utils/hash.h ../database/database.h \
../database/databaseInt.h ../utils/tech.h ../utils/stack.h \
../utils/undo.h ../cif/cif.h ../cif/CIFint.h ../utils/signals.h \
../windows/windows.h ../dbwind/dbwind.h ../utils/styles.h \
../textio/textio.h

View File

@ -4,24 +4,24 @@
* This procedure defines things that are exported by the
* cif module to the rest of the world.
*
* *********************************************************************
* * Copyright (C) 1985, 1990 Regents of the University of California. *
* * Permission to use, copy, modify, and distribute this *
* * software and its documentation for any purpose and without *
* * fee is hereby granted, provided that the above copyright *
* * notice appear in all copies. The University of California *
* * makes no representations about the suitability of this *
* * software for any purpose. It is provided "as is" without *
* * express or implied warranty. Export of this software outside *
* * of the United States of America may require an export license. *
* *********************************************************************
* * Copyright (C) 1985, 1990 Regents of the University of California. *
* * Permission to use, copy, modify, and distribute this *
* * software and its documentation for any purpose and without *
* * fee is hereby granted, provided that the above copyright *
* * notice appear in all copies. The University of California *
* * makes no representations about the suitability of this *
* * software for any purpose. It is provided "as is" without *
* * express or implied warranty. Export of this software outside *
* * of the United States of America may require an export license. *
* *********************************************************************
*
*
* rcsid "$Header: /usr/cvsroot/magic-8.0/cif/cif.h,v 1.4 2010/06/24 12:37:15 tim Exp $
*/
#ifndef _CIF_H
#define _CIF_H
#ifndef _MAGIC__CIF__CIF_H
#define _MAGIC__CIF__CIF_H
#include "database/database.h"
@ -30,6 +30,10 @@
* depends on the size of the layout.
*/
/* Passed to CIFPaintCurrent() for print statement formatting */
#define FILE_CIF 0
#define FILE_CALMA 1
/* Exported global variables (commands/CmdCD.c) */
extern int CIFWarningLevel;
@ -47,42 +51,48 @@ extern bool CIFUnfracture;
/* Procedures that parse the cif sections of a technology file. */
extern void CIFTechStyleInit();
extern void CIFTechInit();
extern bool CIFTechLine();
extern void CIFTechFinal();
extern void CIFTechOutputScale();
extern void CIFTechInputScale();
extern bool CIFTechLimitScale();
extern void CIFReadTechStyleInit();
extern void CIFReadTechInit();
extern bool CIFReadTechLine();
extern void CIFReadTechFinal();
extern void CIFTechStyleInit(void);
extern void CIFTechInit(void);
extern bool CIFTechLine(char *sectionName, int argc, char *argv[]);
extern void CIFTechFinal(void);
extern void CIFTechOutputScale(int n, int d);
extern int CIFTechInputScale(int n, int d, bool opt);
extern bool CIFTechLimitScale(int ns, int ds);
extern void CIFReadTechStyleInit(void);
extern void CIFReadTechInit(void);
extern bool CIFReadTechLine(char *sectionName, int argc, char *argv[]);
extern void CIFReadTechFinal(void);
extern void CIFParseReadLayers(char *string, TileTypeBitMask *mask, bool newok);
/* Externally-visible procedures: */
extern float CIFGetOutputScale();
extern float CIFGetInputScale();
extern int CIFGetDefaultContactSize();
extern float CIFGetOutputScale(int convert);
extern float CIFGetScale(int convert);
extern float CIFGetInputScale(int convert);
extern int CIFPaintCurrent();
extern void CIFSeeLayer();
extern void CIFPaintLayer();
extern void CIFSeeHierLayer();
extern void CIFPrintStats();
extern int CIFPaintCurrent(int filetype);
extern void CIFSeeLayer(CellDef *rootDef, Rect *area, char *layer);
extern void CIFPaintLayer(CellDef *rootDef, Rect *area, char *cifLayer, int magicLayer, CellDef *paintDef);
extern void CIFSeeHierLayer(CellDef *rootDef, Rect *area, char *layer, int arrays, int subcells);
extern void CIFPrintStats(void);
extern bool CIFWrite();
extern void CIFReadFile();
extern bool CIFWrite(CellDef *rootDef, FILE *f);
extern void CIFReadFile(FILE *file);
extern void CIFSetStyle();
extern void CIFSetReadStyle();
extern void CIFSetStyle(char *name);
extern void CIFSetReadStyle(char *name);
extern void CIFPrintStyle();
extern void CIFPrintReadStyle();
extern void CIFPrintStyle(bool dolist, bool doforall, bool docurrent);
extern void CIFPrintReadStyle(bool dolist, bool doforall, bool docurrent);
extern int CIFOutputScaleFactor();
extern int CIFOutputScaleFactor(void);
extern void PaintWireList();
extern LinkedRect *PaintPolygon();
extern void PaintWireList(Point *pointlist, int number, int width, int endcap, Plane *plane,
PaintResultType *ptable, PaintUndoInfo *ui);
extern LinkedRect *PaintPolygon(Point *pointlist, int number, Plane *plane, PaintResultType *ptable,
PaintUndoInfo *ui, int keep);
#endif /* _CIF_H */
/* C99 compat */
extern int CIFGetContactSize(TileType type, int *edge, int *spacing, int *border);
#endif /* _MAGIC__CIF__CIF_H */

View File

@ -3,21 +3,21 @@
*
* Commands for the color map editor.
*
* *********************************************************************
* * Copyright (C) 1985, 1990 Regents of the University of California. *
* * Permission to use, copy, modify, and distribute this *
* * software and its documentation for any purpose and without *
* * fee is hereby granted, provided that the above copyright *
* * notice appear in all copies. The University of California *
* * makes no representations about the suitability of this *
* * software for any purpose. It is provided "as is" without *
* * express or implied warranty. Export of this software outside *
* * of the United States of America may require an export license. *
* *********************************************************************
* * Copyright (C) 1985, 1990 Regents of the University of California. *
* * Permission to use, copy, modify, and distribute this *
* * software and its documentation for any purpose and without *
* * fee is hereby granted, provided that the above copyright *
* * notice appear in all copies. The University of California *
* * makes no representations about the suitability of this *
* * software for any purpose. It is provided "as is" without *
* * express or implied warranty. Export of this software outside *
* * of the United States of America may require an export license. *
* *********************************************************************
*/
#ifndef lint
static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/cmwind/CMWcmmnds.c,v 1.1.1.1 2008/02/03 20:43:50 tim Exp $";
static const char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/cmwind/CMWcmmnds.c,v 1.1.1.1 2008/02/03 20:43:50 tim Exp $";
#endif /* not lint */
#include <stdio.h>
@ -43,10 +43,11 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
/* Forward declarations: */
extern void cmwButtonUp(), cmwButtonDown();
extern void cbUpdate();
extern void RGBxHSV();
extern void HSVxRGB();
extern void cmwButtonUp(MagWindow *w, Point *p, int button);
extern void cmwButtonDown(MagWindow *w, Point *p, int button);
extern void cbUpdate(MagWindow *w, int code, double x, int replace);
extern bool RGBxHSV(double r, double g, double b, double *h, double *s, double *v);
extern void HSVxRGB(double h, double s, double v, double *r, double *g, double *b);
/* If a button is pressed over the top box in the window, which
* displays the current color, we must save the window in which
@ -64,7 +65,7 @@ bool cmwWatchButtonUp;
bool cmwModified = FALSE;
/*
* ----------------------------------------------------------------------------
*
@ -84,9 +85,9 @@ bool cmwModified = FALSE;
*/
void
CMWcommand(w, cmd)
MagWindow *w;
TxCommand *cmd;
CMWcommand(
MagWindow *w,
TxCommand *cmd)
{
switch (cmd->tx_button)
{
@ -137,13 +138,13 @@ CMWcommand(w, cmd)
*/
void
cmwButtonDown(w, p, button)
MagWindow *w; /* Window where the button was pressed. */
Point *p;
int button;
cmwButtonDown(
MagWindow *w, /* Window where the button was pressed. */
Point *p,
int button)
{
ColorBar *cb;
ColorPump *cp;
const ColorBar *cb;
const ColorPump *cp;
Point surfacePoint;
int x;
double dx;
@ -194,7 +195,7 @@ cmwButtonDown(w, p, button)
/* See if the cursor is over the current color area. If so, remember
* the fact and wait for the button to be released.
*/
if (GEO_ENCLOSE(&surfacePoint, &cmwCurrentColorArea))
{
cmwWindow = w;
@ -224,20 +225,20 @@ cmwButtonDown(w, p, button)
*/
void
cmwButtonUp(w, p, button)
MagWindow *w; /* Window where the button was released */
Point *p; /* Point where button was released, in window coords.*/
int button; /* Button that was released. */
cmwButtonUp(
MagWindow *w, /* Window where the button was released */
Point *p, /* Point where button was released, in window coords.*/
int button) /* Button that was released. */
{
CMWclientRec *crec;
int r, g, b, color, oldR, oldG, oldB;
extern int cmwRedisplayFunc();
extern int cmwRedisplayFunc(MagWindow *w, int color);
/* If the button wasn't depressed over the top box in the window
* (the one displaying the current color), then we ignore the
* button release.
*/
if (!cmwWatchButtonUp) return;
cmwWatchButtonUp = FALSE;
@ -246,7 +247,7 @@ cmwButtonUp(w, p, button)
* color values from the pixel underneath the cursor to the current
* color.
*/
/* Read the pixel from the window that was underneath the cursor when
* the button was released.
*/
@ -296,12 +297,12 @@ cmwButtonUp(w, p, button)
*/
void
cmwPushbutton(w, cmd)
MagWindow *w;
TxCommand *cmd;
cmwPushbutton(
MagWindow *w,
TxCommand *cmd)
{
int button;
static char *cmwButton[] = {"left", "middle", "right", NULL};
static const char * const cmwButton[] = {"left", "middle", "right", NULL};
if (cmd->tx_argc != 2)
{
@ -355,9 +356,9 @@ cmwPushbutton(w, cmd)
*/
void
cmwColor(w, cmd)
MagWindow *w;
TxCommand *cmd;
cmwColor(
MagWindow *w,
TxCommand *cmd)
{
int color, r, g, b;
CMWclientRec *crec;
@ -372,7 +373,7 @@ cmwColor(w, cmd)
}
else if (cmd->tx_argc == 2)
{
if (sscanf(cmd->tx_argv[1], "%i", &color) == 0)
if (sscanf(cmd->tx_argv[1], "%i", &color) != 1)
{
/* Invalid color---allow keywords "next" and "last" */
crec = (CMWclientRec *) w->w_clientData;
@ -426,10 +427,10 @@ cmwColor(w, cmd)
}
CMWloadWindow(w, color);
}
else
else
TxError("Usage: color [#|next|last|get|rgb]\n");
}
/*
* ----------------------------------------------------------------------------
*
@ -450,9 +451,9 @@ cmwColor(w, cmd)
*/
void
cmwSave(w, cmd)
MagWindow *w;
TxCommand *cmd;
cmwSave(
MagWindow *w,
TxCommand *cmd)
{
bool ok;
if ((cmd->tx_argc != 1) && (cmd->tx_argc != 4))
@ -473,7 +474,7 @@ cmwSave(w, cmd)
}
if (ok) cmwModified = FALSE;
}
/*
* ----------------------------------------------------------------------------
*
@ -495,9 +496,9 @@ cmwSave(w, cmd)
*/
void
cmwLoad(w, cmd)
MagWindow *w;
TxCommand *cmd;
cmwLoad(
MagWindow *w,
TxCommand *cmd)
{
if ((cmd->tx_argc != 1) && (cmd->tx_argc != 4))
{
@ -514,7 +515,7 @@ cmwLoad(w, cmd)
else (void) GrReadCMap(DBWStyleType, (char *) NULL,
MainMonType, ".", SysLibPath);
}
/*
* ----------------------------------------------------------------------------
*
@ -537,18 +538,18 @@ cmwLoad(w, cmd)
*/
void
cbUpdate(w, code, x, replace)
MagWindow *w; /* Window whose color is to be changed. */
int code; /* Indicates which color component to change. */
double x; /* Gives increment or new value for color. */
int replace; /* TRUE means replace component with x, FALSE
cbUpdate(
MagWindow *w, /* Window whose color is to be changed. */
int code, /* Indicates which color component to change. */
double x, /* Gives increment or new value for color. */
int replace) /* TRUE means replace component with x, FALSE
* means increment component by x.
*/
{
CMWclientRec *cr = (CMWclientRec *) w->w_clientData;
double values[6];
int r, g, b, nr, ng, nb;
extern int cmwRedisplayFunc();
extern int cmwRedisplayFunc(MagWindow *w, int color);
/* Get current color map values */
(void) GrGetColor(cr->cmw_color, &r, &g, &b);
@ -591,14 +592,14 @@ cbUpdate(w, code, x, replace)
}
int
cmwRedisplayFunc(w, color)
MagWindow *w; /* Window that may have to be redisplayed. */
int color; /* If this color is in window, redisplay the
cmwRedisplayFunc(
MagWindow *w, /* Window that may have to be redisplayed. */
int color) /* If this color is in window, redisplay the
* color bars in the window.
*/
{
ColorBar *cb;
ColorPump *cp;
const ColorBar *cb;
const ColorPump *cp;
Rect screenR;
CMWclientRec *cr = (CMWclientRec *) w->w_clientData;
@ -644,11 +645,11 @@ cmwRedisplayFunc(w, color)
*/
bool
CMWCheckWritten()
CMWCheckWritten(void)
{
bool indx;
char *prompt;
static char *(yesno[]) = {"no", "yes", NULL};
static const char * const yesno[] = {"no", "yes", NULL};
if (!cmwModified) return TRUE;
prompt = TxPrintString("The color map has been modified.\n"

View File

@ -4,21 +4,21 @@
* Procedures to interface the colormap editor with the window package
* for the purposes of window creation, deletion, and modification.
*
* *********************************************************************
* * Copyright (C) 1985, 1990 Regents of the University of California. *
* * Permission to use, copy, modify, and distribute this *
* * software and its documentation for any purpose and without *
* * fee is hereby granted, provided that the above copyright *
* * notice appear in all copies. The University of California *
* * makes no representations about the suitability of this *
* * software for any purpose. It is provided "as is" without *
* * express or implied warranty. Export of this software outside *
* * of the United States of America may require an export license. *
* *********************************************************************
* * Copyright (C) 1985, 1990 Regents of the University of California. *
* * Permission to use, copy, modify, and distribute this *
* * software and its documentation for any purpose and without *
* * fee is hereby granted, provided that the above copyright *
* * notice appear in all copies. The University of California *
* * makes no representations about the suitability of this *
* * software for any purpose. It is provided "as is" without *
* * express or implied warranty. Export of this software outside *
* * of the United States of America may require an export license. *
* *********************************************************************
*/
#ifndef lint
static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/cmwind/CMWmain.c,v 1.1.1.1 2008/02/03 20:43:50 tim Exp $";
static const char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/cmwind/CMWmain.c,v 1.1.1.1 2008/02/03 20:43:50 tim Exp $";
#endif /* not lint */
#include <stdio.h>
@ -44,12 +44,12 @@ global WindClient CMWclientID;
/* Forward and external declarations */
extern void cmwColor();
extern void cmwSave();
extern void cmwLoad();
extern void cmwPushbutton();
extern void RGBxHSV();
extern void CMWundoInit();
extern void cmwColor(MagWindow *w, TxCommand *cmd);
extern void cmwSave(MagWindow *w, TxCommand *cmd);
extern void cmwLoad(MagWindow *w, TxCommand *cmd);
extern void cmwPushbutton(MagWindow *w, TxCommand *cmd);
extern bool RGBxHSV(double r, double g, double b, double *h, double *s, double *v);
extern void CMWundoInit(void);
/* -------------------------------------------------------------------- */
@ -71,7 +71,7 @@ extern void CMWundoInit();
* | | - | | | | + | | - | | | | + | |
* | +---+ +----------------+ +---+ +---+ +----------------+ +---+ |
* | |
* | Blue Value
* | Blue Value
* | +---+ +----------------+ +---+ +---+ +----------------+ +---+ |
* | | - | | | | + | | - | | | | + | |
* | +---+ +----------------+ +---+ +---+ +----------------+ +---+ |
@ -89,54 +89,54 @@ extern void CMWundoInit();
* which pump is hit and which mouse button is used to hit it.
*/
ColorBar colorBars[] =
const ColorBar colorBars[] =
{
"Red", CB_RED, STYLE_RED, {2000, 8000, 10000, 9000},
{2000, 9500, 10000, 10500},
"Green", CB_GREEN, STYLE_GREEN, {2000, 5000, 10000, 6000},
{2000, 6500, 10000, 7500},
"Blue", CB_BLUE, STYLE_BLUE, {2000, 2000, 10000, 3000},
{2000, 3500, 10000, 4500},
"Hue", CB_HUE, STYLE_YELLOW, {14000, 8000, 22000, 9000},
{14000, 9500, 22000, 10500},
"Saturation", CB_SAT, STYLE_GRAY, {14000, 5000, 22000, 6000},
{14000, 6500, 22000, 7500},
"Value", CB_VALUE, STYLE_BROWN1, {14000, 2000, 22000, 3000},
{14000, 3500, 22000, 4500},
0
{"Red", CB_RED, STYLE_RED, {{ 2000, 8000}, {10000, 9000}},
{{ 2000, 9500}, {10000, 10500}}},
{"Green", CB_GREEN, STYLE_GREEN, {{ 2000, 5000}, {10000, 6000}},
{{ 2000, 6500}, {10000, 7500}}},
{"Blue", CB_BLUE, STYLE_BLUE, {{ 2000, 2000}, {10000, 3000}},
{{ 2000, 3500}, {10000, 4500}}},
{"Hue", CB_HUE, STYLE_YELLOW, {{14000, 8000}, {22000, 9000}},
{{14000, 9500}, {22000, 10500}}},
{"Saturation", CB_SAT, STYLE_GRAY, {{14000, 5000}, {22000, 6000}},
{{14000, 6500}, {22000, 7500}}},
{"Value", CB_VALUE, STYLE_BROWN1, {{14000, 2000}, {22000, 3000}},
{{14000, 3500}, {22000, 4500}}},
{0}
};
ColorPump colorPumps[] =
const ColorPump colorPumps[] =
{
CB_RED, -.0078, {500, 8000, 1500, 9000},
CB_RED, .0078, {10500, 8000, 11500, 9000},
CB_GREEN, -.0078, {500, 5000, 1500, 6000},
CB_GREEN, .0078, {10500, 5000, 11500, 6000},
CB_BLUE, -.0078, {500, 2000, 1500, 3000},
CB_BLUE, .0078, {10500, 2000, 11500, 3000},
CB_HUE, -.01, {12500, 8000, 13500, 9000},
CB_HUE, .01, {22500, 8000, 23500, 9000},
CB_SAT, -.01, {12500, 5000, 13500, 6000},
CB_SAT, .01, {22500, 5000, 23500, 6000},
CB_VALUE, -.01, {12500, 2000, 13500, 3000},
CB_VALUE, .01, {22500, 2000, 23500, 3000},
-1
{CB_RED, -.0078, {{ 500, 8000}, { 1500, 9000}}},
{CB_RED, .0078, {{10500, 8000}, {11500, 9000}}},
{CB_GREEN, -.0078, {{ 500, 5000}, { 1500, 6000}}},
{CB_GREEN, .0078, {{10500, 5000}, {11500, 6000}}},
{CB_BLUE, -.0078, {{ 500, 2000}, { 1500, 3000}}},
{CB_BLUE, .0078, {{10500, 2000}, {11500, 3000}}},
{CB_HUE, -.01, {{12500, 8000}, {13500, 9000}}},
{CB_HUE, .01, {{22500, 8000}, {23500, 9000}}},
{CB_SAT, -.01, {{12500, 5000}, {13500, 6000}}},
{CB_SAT, .01, {{22500, 5000}, {23500, 6000}}},
{CB_VALUE, -.01, {{12500, 2000}, {13500, 3000}}},
{CB_VALUE, .01, {{22500, 2000}, {23500, 3000}}},
{-1}
};
Rect cmwCurrentColorArea = {{6000, 12000}, {18000, 15000}};
Rect cmwCurrentColorTextBox = {{6000, 15500}, {18000, 16500}};
char *cmwCurrentColorText = "Color Being Edited";
const Rect cmwCurrentColorArea = {{6000, 12000}, {18000, 15000}};
const Rect cmwCurrentColorTextBox = {{6000, 15500}, {18000, 16500}};
const char * const cmwCurrentColorText = "Color Being Edited";
/* Bounding rectangle for entire window */
Rect colorWindowRect = {{0, 1500}, {24000, 17000}};
const Rect colorWindowRect = {{0, 1500}, {24000, 17000}};
/*
* ----------------------------------------------------------------------------
*
* CMWcreate --
*
* A new window has been created. Create and initialize the needed
* A new window has been created. Create and initialize the needed
* structures.
*
* Results:
@ -149,13 +149,13 @@ Rect colorWindowRect = {{0, 1500}, {24000, 17000}};
*/
bool
CMWcreate(window, argc, argv)
MagWindow *window;
int argc;
char *argv[];
CMWcreate(
MagWindow *window,
int argc,
char *argv[])
{
CMWclientRec *crec;
int color;
unsigned int color;
crec = (CMWclientRec *) mallocMagic(sizeof(CMWclientRec));
window->w_clientData = (ClientData) crec;
@ -171,7 +171,7 @@ CMWcreate(window, argc, argv)
CMWloadWindow(window, color);
return (TRUE);
}
/*
* ----------------------------------------------------------------------------
*
@ -189,8 +189,8 @@ CMWcreate(window, argc, argv)
*/
bool
CMWdelete(window)
MagWindow *window;
CMWdelete(
MagWindow *window)
{
CMWclientRec *cr;
@ -200,7 +200,7 @@ CMWdelete(window)
freeMagic((char *) cr);
return (TRUE);
}
/*
* ----------------------------------------------------------------------------
*
@ -218,16 +218,16 @@ CMWdelete(window)
*/
void
CMWreposition(window, newScreenArea, final)
MagWindow *window;
Rect *newScreenArea;
bool final;
CMWreposition(
MagWindow *window,
Rect *newScreenArea,
bool final)
{
if (final)
WindMove(window, &colorWindowRect);
}
/*
* ----------------------------------------------------------------------------
*
@ -244,14 +244,14 @@ CMWreposition(window, newScreenArea, final)
*/
void
CMWredisplay(w, rootArea, clipArea)
MagWindow *w; /* The window containing the area. */
Rect *rootArea; /* Redisplay area in surface coordinates. */
Rect *clipArea; /* An area on the screen to clip to. */
CMWredisplay(
MagWindow *w, /* The window containing the area. */
Rect *rootArea, /* Redisplay area in surface coordinates. */
Rect *clipArea) /* An area on the screen to clip to. */
{
CMWclientRec *cr;
ColorBar *cb;
ColorPump *cp;
const ColorBar *cb;
const ColorPump *cp;
Rect rect, screenR;
Point screenP;
double values[6], x;
@ -332,7 +332,7 @@ CMWredisplay(w, rootArea, clipArea)
* to that color. Instead, change the color in a particular style
* reserved for our own use.
*/
if (GEO_TOUCH(&cmwCurrentColorArea, rootArea))
{
GrStyleTable[STYLE_CMEDIT].color = cr->cmw_color;
@ -353,7 +353,7 @@ CMWredisplay(w, rootArea, clipArea)
GrUnlock(w);
}
/*
* ----------------------------------------------------------------------------
*
@ -372,9 +372,9 @@ CMWredisplay(w, rootArea, clipArea)
*/
void
CMWloadWindow(w, color)
MagWindow *w; /* Identifies window to which color is to be bound */
int color; /* New color to be bound to this window. */
CMWloadWindow(
MagWindow *w, /* Identifies window to which color is to be bound */
int color) /* New color to be bound to this window. */
{
CMWclientRec *cr = (CMWclientRec *) w->w_clientData;
char caption[40];
@ -389,7 +389,7 @@ CMWloadWindow(w, color)
/* move the contents of the window so the color bars show */
WindMove(w, &colorWindowRect);
}
/*
* ----------------------------------------------------------------------------
*
@ -407,7 +407,7 @@ CMWloadWindow(w, color)
*/
void
CMWinit()
CMWinit(void)
{
CMWclientID = WindAddClient("color", CMWcreate, CMWdelete,
CMWredisplay, CMWcommand,

View File

@ -4,21 +4,21 @@
* Procedures to translate between RGB color space and HSV color space.
* Courtesy of Ken Fishkin.
*
* *********************************************************************
* * Copyright (C) 1985, 1990 Regents of the University of California. *
* * Permission to use, copy, modify, and distribute this *
* * software and its documentation for any purpose and without *
* * fee is hereby granted, provided that the above copyright *
* * notice appear in all copies. The University of California *
* * makes no representations about the suitability of this *
* * software for any purpose. It is provided "as is" without *
* * express or implied warranty. Export of this software outside *
* * of the United States of America may require an export license. *
* *********************************************************************
* * Copyright (C) 1985, 1990 Regents of the University of California. *
* * Permission to use, copy, modify, and distribute this *
* * software and its documentation for any purpose and without *
* * fee is hereby granted, provided that the above copyright *
* * notice appear in all copies. The University of California *
* * makes no representations about the suitability of this *
* * software for any purpose. It is provided "as is" without *
* * express or implied warranty. Export of this software outside *
* * of the United States of America may require an export license. *
* *********************************************************************
*/
#ifndef lint
static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/cmwind/CMWrgbhsv.c,v 1.1.1.1 2008/02/03 20:43:50 tim Exp $";
static const char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/cmwind/CMWrgbhsv.c,v 1.1.1.1 2008/02/03 20:43:50 tim Exp $";
#endif /* not lint */
#include <stdio.h>
@ -45,9 +45,13 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
*/
bool
RGBxHSV( r, g, b, h, s, v)
double r, g, b;
double *h, *s, *v;
RGBxHSV(
double r,
double g,
double b,
double *h,
double *s,
double *v)
{
double max, delta;
double mr,mg,mb;
@ -90,10 +94,14 @@ RGBxHSV( r, g, b, h, s, v)
#define SETRGB(rr,gg,bb) *r=rr;*g=gg;*b=bb
void
HSVxRGB( h,s,v,r,g,b)
double h,s,v;
double *r,*g,*b;
{
HSVxRGB(
double h,
double s,
double v,
double *r,
double *g,
double *b)
{
double f,m,n,k;
int i;
double vs,vsf;
@ -125,9 +133,13 @@ double *r,*g,*b;
*/
bool
RGBxHSL( r, g, b, h, s, l )
double r, g, b;
double *h, *s, *l;
RGBxHSL(
double r,
double g,
double b,
double *h,
double *s,
double *l)
{
double min, max;
double delta, mr, mg, mb;
@ -184,9 +196,13 @@ RGBxHSL( r, g, b, h, s, l )
*/
void
HSLxRGB( h, s, l, r, g, b )
double h, s, l;
double *r, *g, *b;
HSLxRGB(
double h,
double s,
double l,
double *r,
double *g,
double *b)
{
double min;
double v;
@ -194,7 +210,7 @@ HSLxRGB( h, s, l, r, g, b )
int i;
double vsf;
if ( l <= 0.5)
if ( l <= 0.5)
v = l * (1.0 + s);
else
v = l + s - l*s;
@ -235,9 +251,11 @@ HSLxRGB( h, s, l, r, g, b )
*/
void
Correct_chromaticity(x, y, wx, wy)
double *x,*y;
double wx,wy;
Correct_chromaticity(
double *x,
double *y,
double wx,
double wy)
{
double oldx,oldy;
double slope;
@ -261,9 +279,13 @@ Correct_chromaticity(x, y, wx, wy)
*/
void
xyz_to_mrgb(x, y, z, mr, mg, mb)
double x, y, z;
double *mr, *mg, *mb;
xyz_to_mrgb(
double x,
double y,
double z,
double *mr,
double *mg,
double *mb)
{
*mr = 2.4513*x - 1.2249*y - 0.3237*z;
*mg = -1.4746*x + 2.5052*y + 0.0596*z;
@ -281,8 +303,10 @@ xyz_to_mrgb(x, y, z, mr, mg, mb)
*/
void
Make_mRGB_Nice(mR,mG,mB)
double *mR,*mG,*mB;
Make_mRGB_Nice(
double *mR,
double *mG,
double *mB)
{
double min,max;
double mr, mg, mb;

View File

@ -3,21 +3,21 @@
*
* Interface to the undo package for the color map editor.
*
* *********************************************************************
* * Copyright (C) 1985, 1990 Regents of the University of California. *
* * Permission to use, copy, modify, and distribute this *
* * software and its documentation for any purpose and without *
* * fee is hereby granted, provided that the above copyright *
* * notice appear in all copies. The University of California *
* * makes no representations about the suitability of this *
* * software for any purpose. It is provided "as is" without *
* * express or implied warranty. Export of this software outside *
* * of the United States of America may require an export license. *
* *********************************************************************
* * Copyright (C) 1985, 1990 Regents of the University of California. *
* * Permission to use, copy, modify, and distribute this *
* * software and its documentation for any purpose and without *
* * fee is hereby granted, provided that the above copyright *
* * notice appear in all copies. The University of California *
* * makes no representations about the suitability of this *
* * software for any purpose. It is provided "as is" without *
* * express or implied warranty. Export of this software outside *
* * of the United States of America may require an export license. *
* *********************************************************************
*/
#ifndef lint
static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/cmwind/CMWundo.c,v 1.1.1.1 2008/02/03 20:43:50 tim Exp $";
static const char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/cmwind/CMWundo.c,v 1.1.1.1 2008/02/03 20:43:50 tim Exp $";
#endif /* not lint */
#include <stdio.h>
@ -35,12 +35,6 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
*/
UndoType cmwUndoClientID;
/*
* Functions to play events forward/backward.
*/
void cmwUndoForw(), cmwUndoBack();
void cmwUndoStart(), cmwUndoDone();
/*
* A single undo event for the
* color map module.
@ -57,7 +51,15 @@ void cmwUndoStart(), cmwUndoDone();
* of an undo/redo command.
*/
bool cmwColorsChanged[256];
/*
* Functions to play events forward/backward.
*/
void cmwUndoForw(colorUE *up);
void cmwUndoBack(colorUE *up);
void cmwUndoStart(void);
void cmwUndoDone(void);
/*
* ----------------------------------------------------------------------------
*
@ -77,13 +79,13 @@ bool cmwColorsChanged[256];
*/
void
CMWundoInit()
CMWundoInit(void)
{
cmwUndoClientID = UndoAddClient(cmwUndoStart, cmwUndoDone, NULL, NULL,
cmwUndoForw, cmwUndoBack, "color map");
}
/*
* ----------------------------------------------------------------------------
*
@ -102,21 +104,21 @@ CMWundoInit()
*/
void
cmwUndoForw(up)
colorUE *up;
cmwUndoForw(
colorUE *up)
{
(void) GrPutColor(up->cue_color, up->new_r, up->new_g, up->new_b);
cmwColorsChanged[up->cue_color] = TRUE;
}
void
cmwUndoBack(up)
colorUE *up;
cmwUndoBack(
colorUE *up)
{
(void) GrPutColor(up->cue_color, up->old_r, up->old_g, up->old_b);
cmwColorsChanged[up->cue_color] = TRUE;
}
/*
* ----------------------------------------------------------------------------
*
@ -134,10 +136,14 @@ cmwUndoBack(up)
*/
void
cmwUndoColor(color, oldr, oldg, oldb, newr, newg, newb)
int color;
int oldr, oldg, oldb;
int newr, newg, newb;
cmwUndoColor(
int color,
int oldr,
int oldg,
int oldb,
int newr,
int newg,
int newb)
{
colorUE *up;
@ -153,7 +159,7 @@ cmwUndoColor(color, oldr, oldg, oldb, newr, newg, newb)
up->new_g = newg;
up->new_b = newb;
}
/*
* ----------------------------------------------------------------------------
*
@ -171,14 +177,14 @@ cmwUndoColor(color, oldr, oldg, oldb, newr, newg, newb)
*/
void
cmwUndoStart()
cmwUndoStart(void)
{
int i;
for (i = 0; i < 256; i++)
cmwColorsChanged[i] = FALSE;
}
/*
* ----------------------------------------------------------------------------
*
@ -198,13 +204,13 @@ cmwUndoStart()
*/
void
cmwUndoDone()
cmwUndoDone(void)
{
int i;
extern int cmwRedisplayFunc();
extern int cmwRedisplayFunc(MagWindow *w, int color);
for (i = 0; i < 256; i++)
if (cmwColorsChanged[i])
(void) WindSearch(CMWclientID, (ClientData) NULL, (Rect *) NULL,
cmwRedisplayFunc, (ClientData) i);
cmwRedisplayFunc, INT2CD(i));
}

View File

@ -1,16 +0,0 @@
CMWmain.o: CMWmain.c ../utils/magic.h ../utils/geometry.h \
../windows/windows.h ../database/database.h ../tiles/tile.h \
../utils/hash.h ../utils/main.h ../commands/commands.h \
../cmwind/cmwind.h ../textio/txcommands.h ../graphics/graphicsInt.h \
../graphics/graphics.h ../textio/textio.h ../utils/utils.h \
../utils/styles.h ../graphics/glyphs.h ../utils/malloc.h
CMWcmmnds.o: CMWcmmnds.c ../tcltk/tclmagic.h ../utils/magic.h \
../utils/geometry.h ../windows/windows.h ../tiles/tile.h ../utils/hash.h \
../database/database.h ../dbwind/dbwind.h ../utils/main.h \
../commands/commands.h ../cmwind/cmwind.h ../textio/txcommands.h \
../graphics/graphics.h ../textio/textio.h ../utils/utils.h \
../utils/styles.h ../utils/undo.h
CMWundo.o: CMWundo.c ../utils/magic.h ../utils/geometry.h \
../graphics/graphics.h ../windows/windows.h ../cmwind/cmwind.h \
../textio/txcommands.h ../utils/undo.h
CMWrgbhsv.o: CMWrgbhsv.c ../utils/magic.h

View File

@ -4,23 +4,23 @@
* Interface definitions for the 'glue' between the window
* manager and the color map editor.
*
* *********************************************************************
* * Copyright (C) 1985, 1990 Regents of the University of California. *
* * Permission to use, copy, modify, and distribute this *
* * software and its documentation for any purpose and without *
* * fee is hereby granted, provided that the above copyright *
* * notice appear in all copies. The University of California *
* * makes no representations about the suitability of this *
* * software for any purpose. It is provided "as is" without *
* * express or implied warranty. Export of this software outside *
* * of the United States of America may require an export license. *
* *********************************************************************
* * Copyright (C) 1985, 1990 Regents of the University of California. *
* * Permission to use, copy, modify, and distribute this *
* * software and its documentation for any purpose and without *
* * fee is hereby granted, provided that the above copyright *
* * notice appear in all copies. The University of California *
* * makes no representations about the suitability of this *
* * software for any purpose. It is provided "as is" without *
* * express or implied warranty. Export of this software outside *
* * of the United States of America may require an export license. *
* *********************************************************************
*
* rcsid $Header: /usr/cvsroot/magic-8.0/cmwind/cmwind.h,v 1.2 2009/09/10 20:32:51 tim Exp $
*/
#ifndef _CMWIND_H
#define _CMWIND_H
#ifndef _MAGIC__CMWIND__CMWIND_H
#define _MAGIC__CMWIND__CMWIND_H
#include "windows/windows.h"
#include "textio/txcommands.h"
@ -69,12 +69,16 @@ typedef struct
extern void CMWloadWindow(MagWindow *, int);
extern void CMWcommand(MagWindow *, TxCommand *);
extern Rect colorWindowRect;
extern const Rect colorWindowRect;
extern WindClient CMWclientID;
extern ColorBar colorBars[];
extern ColorPump colorPumps[];
extern Rect cmwCurrentColorArea;
extern const ColorBar colorBars[];
extern const ColorPump colorPumps[];
extern const Rect cmwCurrentColorArea;
extern void cmwUndoColor(int, int, int, int, int, int, int);
extern bool CMWCheckWritten(void);
#endif /* _CMWIND_H */
/* C99 compat */
extern void CMWinit(void);
#endif /* _MAGIC__CMWIND__CMWIND_H */

View File

@ -3,21 +3,21 @@
*
* Commands with names beginning with the letters A through B.
*
* *********************************************************************
* * Copyright (C) 1985, 1990 Regents of the University of California. *
* * Permission to use, copy, modify, and distribute this *
* * software and its documentation for any purpose and without *
* * fee is hereby granted, provided that the above copyright *
* * notice appear in all copies. The University of California *
* * makes no representations about the suitability of this *
* * software for any purpose. It is provided "as is" without *
* * express or implied warranty. Export of this software outside *
* * of the United States of America may require an export license. *
* *********************************************************************
* * Copyright (C) 1985, 1990 Regents of the University of California. *
* * Permission to use, copy, modify, and distribute this *
* * software and its documentation for any purpose and without *
* * fee is hereby granted, provided that the above copyright *
* * notice appear in all copies. The University of California *
* * makes no representations about the suitability of this *
* * software for any purpose. It is provided "as is" without *
* * express or implied warranty. Export of this software outside *
* * of the United States of America may require an export license. *
* *********************************************************************
*/
#ifndef lint
static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/commands/CmdAB.c,v 1.1.1.1 2008/02/03 20:43:50 tim Exp $";
static const char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/commands/CmdAB.c,v 1.1.1.1 2008/02/03 20:43:50 tim Exp $";
#endif /* not lint */
#include <stdio.h>
@ -44,13 +44,13 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
#include "utils/netlist.h"
#include "select/select.h"
/* ---------------------------------------------------------------------------
*
* CmdAddPath --
*
* Implement the "addpath" command: append to the global cell search path.
* (Usage superceded by extended "path" command; retained for compatibility)
* (Usage superseded by extended "path" command; retained for compatibility)
*
* Usage:
* addpath path
@ -70,9 +70,9 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
/*ARGSUSED*/
void
CmdAddPath( w, cmd )
MagWindow *w;
TxCommand *cmd;
CmdAddPath(
MagWindow *w,
TxCommand *cmd)
{
if (cmd->tx_argc != 2) {
TxError("Usage: %s appended_search_path\n", cmd->tx_argv[0]);
@ -80,7 +80,71 @@ CmdAddPath( w, cmd )
}
PaAppend(&Path, cmd->tx_argv[1]);
}
/*
* ----------------------------------------------------------------------------
*
* CmdArchive --
*
* Save an entire database to a "crash recovery"-type archive file, or
* load a database from a "crash recovery"-type archive file. Option
* "writeall" writes everything, including read-only PDK cells, while
* "readref" does not dereference and will prefer files found in the
* search path over content in the archive.
*
*
* Usage:
* archive write|writeall|read|readref file
*
* Results:
* None.
*
* Side effects:
* Writes a single file with the contents of the entire database,
* or loads the database with multiple cells from the file.
*
* ----------------------------------------------------------------------------
*/
void
CmdArchive(
MagWindow *w,
TxCommand *cmd)
{
int option = -1;
char *filename = NULL;
static const char * const cmdArchiveOpt[] = {"write", "writeall",
"read", "readref", 0};
if (cmd->tx_argc != 3)
TxError("Usage: %s write|writeall|read|readref filename\n", cmd->tx_argv[0]);
else
{
option = Lookup(cmd->tx_argv[1], cmdArchiveOpt);
if (option < 0)
{
TxError("Usage: %s write|writeall|read|readref filename\n", cmd->tx_argv[0]);
return;
}
}
filename = cmd->tx_argv[2];
switch(option) {
case 0: /* write */
DBWriteBackup(filename, TRUE, FALSE);
break;
case 1: /* writeall */
DBWriteBackup(filename, TRUE, TRUE);
break;
case 2: /* read */
DBReadBackup(filename, TRUE, TRUE);
break;
case 3: /* readref */
DBReadBackup(filename, TRUE, FALSE);
break;
}
}
/* Linked-list structure for returning information about arrayed cells */
@ -130,11 +194,11 @@ typedef struct LA1
#define ARRAY_DEFAULT 6
void
CmdArray(w, cmd)
MagWindow *w;
TxCommand *cmd;
CmdArray(
MagWindow *w,
TxCommand *cmd)
{
static char *cmdArrayOption[] = {
static const char * const cmdArrayOption[] = {
"count [[xlo] xhi [ylo] yhi] array subcells",
"width [value] set or return array x-spacing",
"height [value] set or return array y-spacing",
@ -144,7 +208,7 @@ CmdArray(w, cmd)
NULL
};
char **msg;
const char * const *msg;
int option, locargc, argstart;
bool doList = FALSE;
ArrayInfo a;
@ -156,7 +220,7 @@ CmdArray(w, cmd)
Tcl_Obj *tobj;
#endif
extern int selGetArrayFunc();
extern int selGetArrayFunc(CellUse *selUse, CellUse *use, Transform *trans, LinkedArray **arg);
locargc = cmd->tx_argc;
argstart = 1;
@ -173,7 +237,7 @@ CmdArray(w, cmd)
}
if (locargc <= 1)
goto badusage; /* Prohibits "array -list" alone */
option = Lookup(cmd->tx_argv[argstart], cmdArrayOption);
if (option < 0) {
if (locargc == 3 || locargc == 5)
@ -186,7 +250,7 @@ CmdArray(w, cmd)
/* Get all information about cell uses in the current selection */
(void) SelEnumCells(FALSE, (bool *) NULL, (SearchContext *) NULL,
(void) SelEnumCells(FALSE, (bool *) NULL, (SearchContext *) NULL,
selGetArrayFunc, (ClientData) &lahead);
/* Note: All "unimplemented functions" below will require a routine
@ -240,7 +304,7 @@ CmdArray(w, cmd)
goto badusage;
if (!StrIsInt(cmd->tx_argv[argstart + 1])
|| !StrIsInt(cmd->tx_argv[argstart + 2]))
|| !StrIsInt(cmd->tx_argv[argstart + 2]))
goto badusage;
if (locargc == 4)
@ -253,7 +317,7 @@ CmdArray(w, cmd)
}
else if (locargc == 6)
{
if (!StrIsInt(cmd->tx_argv[argstart + 3]) ||
if (!StrIsInt(cmd->tx_argv[argstart + 3]) ||
!StrIsInt(cmd->tx_argv[argstart + 4])) goto badusage;
a.ar_xlo = atoi(cmd->tx_argv[argstart + 1]);
a.ar_xhi = atoi(cmd->tx_argv[argstart + 2]);
@ -426,7 +490,7 @@ CmdArray(w, cmd)
case ARRAY_DEFAULT:
if (!StrIsInt(cmd->tx_argv[argstart])
|| !StrIsInt(cmd->tx_argv[argstart + 1]))
|| !StrIsInt(cmd->tx_argv[argstart + 1]))
goto badusage;
if (locargc == 3)
{
@ -438,7 +502,7 @@ CmdArray(w, cmd)
}
else
{
if (!StrIsInt(cmd->tx_argv[argstart + 2]) ||
if (!StrIsInt(cmd->tx_argv[argstart + 2]) ||
!StrIsInt(cmd->tx_argv[argstart + 3])) goto badusage;
a.ar_xlo = atoi(cmd->tx_argv[argstart]);
a.ar_xhi = atoi(cmd->tx_argv[argstart + 1]);
@ -466,11 +530,15 @@ badusage:
}
freelist:
la = lahead;
while (la != NULL)
{
freeMagic((char *)la);
la = la->ar_next;
la = lahead;
while (la != NULL)
{
free_magic1_t mm1 = freeMagic1_init();
freeMagic1(&mm1, (char *)la);
la = la->ar_next;
freeMagic1_end(&mm1);
}
}
return;
}
@ -480,14 +548,14 @@ freelist:
*/
int
selGetArrayFunc(selUse, use, trans, arg)
CellUse *selUse;
CellUse *use;
Transform *trans;
LinkedArray **arg;
selGetArrayFunc(
CellUse *selUse,
CellUse *use,
Transform *trans,
LinkedArray **arg)
{
/* Check "use" for array information and pass this to arrayInfo */
LinkedArray *la;
int xlo, xhi, ylo, yhi, xsep, ysep, t;
@ -510,17 +578,17 @@ selGetArrayFunc(selUse, use, trans, arg)
la->arrayInfo.ar_xhi = xhi;
la->arrayInfo.ar_ylo = ylo;
la->arrayInfo.ar_yhi = yhi;
/* Reverse the transformation in DBMakeArray */
ysep = (trans->t_d * use->cu_xsep - trans->t_a * use->cu_ysep);
ysep /= (trans->t_d * trans->t_b - trans->t_a * trans->t_e);
if (trans->t_a == 0)
xsep = (use->cu_ysep - trans->t_e * ysep) / trans->t_d;
else
xsep = (use->cu_xsep - trans->t_b * ysep) / trans->t_a;
la->arrayInfo.ar_xsep = xsep;
la->arrayInfo.ar_ysep = ysep;
@ -531,7 +599,7 @@ selGetArrayFunc(selUse, use, trans, arg)
return 0;
}
/*
* ----------------------------------------------------------------------------
*
@ -545,6 +613,8 @@ selGetArrayFunc(selUse, use, trans, arg)
* box size [width height]
* box position [llx lly] [-edit]
* box values [llx lly urx ury] [-edit]
* box remove
* box select
*
* box <direction> <distance> | cursor
*
@ -580,25 +650,29 @@ selGetArrayFunc(selUse, use, trans, arg)
#define BOX_SIZE 2
#define BOX_POSITION 3
#define BOX_VALUES 4
#define BOX_MOVE 5
#define BOX_GROW 6
#define BOX_SHRINK 7
#define BOX_CORNER 8
#define BOX_EXISTS 9
#define BOX_HELP 10
#define BOX_DEFAULT 11
#define BOX_REMOVE 5
#define BOX_SELECT 6
#define BOX_MOVE 7
#define BOX_GROW 8
#define BOX_SHRINK 9
#define BOX_CORNER 10
#define BOX_EXISTS 11
#define BOX_HELP 12
#define BOX_DEFAULT 13
void
CmdBox(w, cmd)
MagWindow *w;
TxCommand *cmd;
CmdBox(
MagWindow *w,
TxCommand *cmd)
{
static char *cmdBoxOption[] = {
static const char * const cmdBoxOption[] = {
"width [value] set or return box width",
"height [value] set or return box height",
"size [width height] set or return box size",
"position [llx lly] [-edit] set or return box position",
"values [llx lly urx ury] [-edit] set or return box coordinates",
"remove remove cursor box from display",
"select set box to selection bounding box",
"move <direction> <distance> move box position",
"grow <direction> <distance> expand box size",
"shrink <direction> <distance> shrink box size",
@ -609,7 +683,7 @@ CmdBox(w, cmd)
};
CellDef *rootBoxDef;
Rect rootBox, editbox, *boxptr;
Rect rootBox, editbox, savebox, *boxptr;
Point ll;
int option, direction, distancex, distancey;
int width, height;
@ -620,7 +694,7 @@ CmdBox(w, cmd)
bool needBox = TRUE; /* require that box be defined */
bool refEdit = FALSE; /* referenced to edit cell coordinates */
bool cursorRef = FALSE; /* reference position is the cursor */
char **msg;
const char * const *msg;
argc = cmd->tx_argc;
if (argc > 7) goto badusage;
@ -658,6 +732,12 @@ CmdBox(w, cmd)
windCheckOnlyWindow(&w, DBWclientID);
if (option == BOX_REMOVE)
{
DBWSetBox((CellDef *)NULL, &GeoNullRect);
return;
}
/*----------------------------------------------------------*/
/* Check for the command options which do not require a box */
/* to be present. */
@ -690,7 +770,7 @@ CmdBox(w, cmd)
#endif
return;
}
if (needBox)
{
if (refEdit)
@ -744,6 +824,7 @@ CmdBox(w, cmd)
/*----------------------------------------------------------*/
boxptr = (refEdit) ? &editbox : &rootBox;
savebox = *boxptr;
/*----------------------------------------------------------*/
/* Parse arguments according to class */
@ -784,6 +865,13 @@ CmdBox(w, cmd)
ToolMoveCorner(tcorner, &cmd->tx_p, TRUE, rootBoxDef);
break;
}
/* Recast command as "box values" for logging purposes */
ToolGetBox(&rootBoxDef, &rootBox);
sprintf(cmd->tx_argstring, "box values %di %di %di %di",
rootBox.r_xbot, rootBox.r_ybot,
rootBox.r_xtop, rootBox.r_ytop);
TxRebuildCommand(cmd);
return;
}
else if (DBWSnapToGrid != DBW_SNAP_USER)
@ -907,6 +995,19 @@ CmdBox(w, cmd)
boxptr->r_ytop = boxptr->r_ybot + height;
break;
case BOX_SELECT:
if (argc == 2)
{
Rect selarea;
GeoTransRect(&SelectUse->cu_transform, &SelectDef->cd_bbox, &selarea);
boxptr->r_xbot = selarea.r_xbot;
boxptr->r_ybot = selarea.r_ybot;
boxptr->r_xtop = selarea.r_xtop;
boxptr->r_ytop = selarea.r_ytop;
}
else goto badusage;
break;
case BOX_VALUES:
if (argc == 2)
{
@ -1093,13 +1194,13 @@ CmdBox(w, cmd)
if (area > 0)
TxPrintf(" area (units^2)");
TxPrintf("\n\nmicrons: %6.2f x %-6.2f (% 6.2f, % -6.2f), "
"(% 6.2f, % -6.2f)",
TxPrintf("\n\nmicrons: %6.3f x %-6.3f (% 6.3f, % -6.3f), "
"(% 6.3f, % -6.3f)",
(float)width *oscale, (float)height * oscale,
(float)boxptr->r_xbot * oscale, (float)boxptr->r_ybot * oscale,
(float)boxptr->r_xtop * oscale, (float)boxptr->r_ytop * oscale);
if (area > 0)
TxPrintf(" %-10.2f", (float)area * oscale * oscale);
TxPrintf(" %-10.3f", (float)area * oscale * oscale);
TxPrintf("\nlambda:");
if (DBLambda[0] != DBLambda[1])
@ -1122,7 +1223,7 @@ CmdBox(w, cmd)
boxptr->r_xbot, boxptr->r_ybot,
boxptr->r_xtop, boxptr->r_ytop);
if (area > 0)
TxPrintf(" %-10lld", area);
TxPrintf(" %-10"DLONG_PREFIX"d", area);
TxPrintf("\n");
break;
@ -1142,6 +1243,18 @@ badusage:
if (refEdit)
GeoTransRect(&EditToRootTransform, &editbox, &rootBox);
/*----------------------------------------------------------*/
/* Check for numerical overflow in box values */
/*----------------------------------------------------------*/
if (boxptr->r_ll.p_x < (MINFINITY + 2) || boxptr->r_ll.p_x > (INFINITY - 2) ||
boxptr->r_ll.p_y < (MINFINITY + 2) || boxptr->r_ll.p_y > (INFINITY - 2))
{
*boxptr = savebox;
TxError("Box out of bounds.\n");
return;
}
/*----------------------------------------------------------*/
/* Change the position of the box in the layout window */
/*----------------------------------------------------------*/

View File

@ -5,16 +5,16 @@
* functions which have been compiled as Tcl modules, using the Tcl
* interface.
*
* *********************************************************************
* * Copyright (C) 1985, 1990 Regents of the University of California. *
* * Permission to use, copy, modify, and distribute this *
* * software and its documentation for any purpose and without *
* * fee is hereby granted, provided that the above copyright *
* * notice appear in all copies. The University of California *
* * makes no representations about the suitability of this *
* * software for any purpose. It is provided "as is" without *
* * express or implied warranty. Export of this software outside *
* * of the United States of America may require an export license. *
* *********************************************************************
* * Copyright (C) 1985, 1990 Regents of the University of California. *
* * Permission to use, copy, modify, and distribute this *
* * software and its documentation for any purpose and without *
* * fee is hereby granted, provided that the above copyright *
* * notice appear in all copies. The University of California *
* * makes no representations about the suitability of this *
* * software for any purpose. It is provided "as is" without *
* * express or implied warranty. Export of this software outside *
* * of the United States of America may require an export license. *
* *********************************************************************
*/
@ -48,9 +48,9 @@
*/
void
CmdAutoExtToSim(w, cmd)
MagWindow *w;
TxCommand *cmd;
CmdAutoExtToSim(
MagWindow *w,
TxCommand *cmd)
{
int result;
@ -83,9 +83,9 @@ CmdAutoExtToSim(w, cmd)
*/
void
CmdAutoExtToSpice(w, cmd)
MagWindow *w;
TxCommand *cmd;
CmdAutoExtToSpice(
MagWindow *w,
TxCommand *cmd)
{
int result;
@ -119,9 +119,9 @@ CmdAutoExtToSpice(w, cmd)
*/
void
CmdAutoRoute(w, cmd)
MagWindow *w;
TxCommand *cmd;
CmdAutoRoute(
MagWindow *w,
TxCommand *cmd)
{
int result;
@ -154,9 +154,9 @@ CmdAutoRoute(w, cmd)
*/
void
CmdAutoPlot(w, cmd)
MagWindow *w;
TxCommand *cmd;
CmdAutoPlot(
MagWindow *w,
TxCommand *cmd)
{
int result;
@ -189,9 +189,9 @@ CmdAutoPlot(w, cmd)
*/
void
CmdAutoLef(w, cmd)
MagWindow *w;
TxCommand *cmd;
CmdAutoLef(
MagWindow *w,
TxCommand *cmd)
{
int result;

File diff suppressed because it is too large Load Diff

View File

@ -3,21 +3,21 @@
*
* Commands with names beginning with the letter E.
*
* *********************************************************************
* * Copyright (C) 1985, 1990 Regents of the University of California. *
* * Permission to use, copy, modify, and distribute this *
* * software and its documentation for any purpose and without *
* * fee is hereby granted, provided that the above copyright *
* * notice appear in all copies. The University of California *
* * makes no representations about the suitability of this *
* * software for any purpose. It is provided "as is" without *
* * express or implied warranty. Export of this software outside *
* * of the United States of America may require an export license. *
* *********************************************************************
* * Copyright (C) 1985, 1990 Regents of the University of California. *
* * Permission to use, copy, modify, and distribute this *
* * software and its documentation for any purpose and without *
* * fee is hereby granted, provided that the above copyright *
* * notice appear in all copies. The University of California *
* * makes no representations about the suitability of this *
* * software for any purpose. It is provided "as is" without *
* * express or implied warranty. Export of this software outside *
* * of the United States of America may require an export license. *
* *********************************************************************
*/
#ifndef lint
static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/commands/CmdE.c,v 1.4 2010/06/17 14:38:33 tim Exp $";
static const char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/commands/CmdE.c,v 1.4 2010/06/17 14:38:33 tim Exp $";
#endif /* not lint */
#include <stdio.h>
@ -42,9 +42,13 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
#include "drc/drc.h"
#include "textio/txcommands.h"
#include "extract/extract.h"
#include "extract/extractInt.h"
#include "select/select.h"
/* C99 compat */
#include "dbwind/dbwtech.h"
/*
* ----------------------------------------------------------------------------
*
@ -52,10 +56,12 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
*
* Implement the "edit" command.
* Use the cell that is currently selected as the edit cell. If more than
* one cell is selected, use the point to choose between them.
* one cell is selected, use the point to choose between them. If the
* optional argument "<instname>" is provided, then edit the specified
* instance (if it exists in the current layout window).
*
* Usage:
* edit
* edit [<instname>]
*
* Results:
* None.
@ -73,18 +79,29 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
static bool cmdFoundNewEdit;
void
CmdEdit(w, cmd)
MagWindow *w;
TxCommand *cmd;
CmdEdit(
MagWindow *w,
TxCommand *cmd)
{
Rect area, pointArea;
CellUse *usave;
CellUse *usave, *use = NULL;
CellDef *csave;
int cmdEditRedisplayFunc(); /* Forward declaration. */
int cmdEditEnumFunc(); /* Forward declaration. */
int cmdEditRedisplayFunc(MagWindow *w, Rect *area); /* Forward declaration. */
int cmdEditEnumFunc(CellUse *selUse, CellUse *use, Transform *transform, Rect *area); /* Forward declaration. */
bool noCurrentUse = FALSE;
if (cmd->tx_argc > 1)
if ((w != NULL) && (cmd->tx_argc == 2))
{
CellUse *rootUse;
SearchContext scx;
rootUse = (CellUse *)w->w_surfaceID;
bzero(&scx, sizeof(SearchContext));
DBTreeFindUse(cmd->tx_argv[1], rootUse, &scx);
use = scx.scx_use;
}
if ((use == NULL) && (cmd->tx_argc > 1))
{
TxError("Usage: edit\nMaybe you want the \"load\" command\n");
return;
@ -98,7 +115,7 @@ CmdEdit(w, cmd)
* only in windows where the edit cell is displayed differently from
* other cells.
*/
GeoTransRect(&EditToRootTransform, &(usave->cu_def->cd_bbox), &area);
(void) WindSearch(DBWclientID, (ClientData) NULL,
(Rect *) NULL, cmdEditRedisplayFunc, (ClientData) &area);
@ -106,21 +123,29 @@ CmdEdit(w, cmd)
DBWUndoOldEdit(EditCellUse, EditRootDef, &EditToRootTransform,
&RootToEditTransform);
}
/* Use the position of the point to select one of the currently-selected
* cells (if there are more than one). If worst comes to worst, just
* select any selected cell.
*/
(void) ToolGetPoint((Point *) NULL, &pointArea);
cmdFoundNewEdit = FALSE;
csave = EditRootDef;
usave = EditCellUse;
EditCellUse = NULL;
(void) SelEnumCells(FALSE, (bool *) NULL, (SearchContext *) NULL,
cmdEditEnumFunc, (ClientData) &pointArea);
if (use == NULL)
{
EditCellUse = NULL;
SelEnumCells(FALSE, (bool *) NULL, (SearchContext *) NULL,
cmdEditEnumFunc, (ClientData) &pointArea);
}
else
{
EditCellUse = use;
cmdFoundNewEdit = TRUE;
}
if (EditCellUse == (CellUse *)NULL)
{
@ -130,7 +155,7 @@ CmdEdit(w, cmd)
return;
}
else if (!(EditCellUse->cu_def->cd_flags & CDAVAILABLE))
DBCellRead(EditCellUse->cu_def, (char *)NULL, TRUE, NULL);
DBCellRead(EditCellUse->cu_def, TRUE, TRUE, NULL);
if (EditCellUse->cu_def->cd_flags & CDNOEDIT)
{
@ -154,6 +179,14 @@ CmdEdit(w, cmd)
GeoTransRect(&EditToRootTransform, &(EditCellUse->cu_def->cd_bbox), &area);
(void) WindSearch(DBWclientID, (ClientData) NULL,
(Rect *) NULL, cmdEditRedisplayFunc, (ClientData) &area);
if ((cmd->tx_argc == 1) && cmdFoundNewEdit)
{
/* Recast the command with the instance name for logging */
sprintf(cmd->tx_argstring, "edit %s", EditCellUse->cu_id);
TxRebuildCommand(cmd);
}
}
/* Search function to handle redisplays for CmdEdit: it checks to
@ -164,11 +197,11 @@ CmdEdit(w, cmd)
*/
int
cmdEditRedisplayFunc(w, area)
MagWindow *w; /* Window containing edit cell. */
Rect *area; /* Area to be redisplayed. */
cmdEditRedisplayFunc(
MagWindow *w, /* Window containing edit cell. */
Rect *area) /* Area to be redisplayed. */
{
static Rect origin = {-1, -1, 1, 1};
static const Rect origin = {{-1, -1}, {1, 1}};
Rect tmp;
DBWclientRec *crec = (DBWclientRec *) w->w_clientData;
@ -193,13 +226,13 @@ cmdEditRedisplayFunc(w, area)
*/
int
cmdEditEnumFunc(selUse, use, transform, area)
CellUse *selUse; /* Use from selection (not used). */
CellUse *use; /* Use from layout that corresponds to
cmdEditEnumFunc(
CellUse *selUse, /* Use from selection (not used). */
CellUse *use, /* Use from layout that corresponds to
* selUse (could be an array!).
*/
Transform *transform; /* Transform from use->cu_def to root coords. */
Rect *area; /* We're looking for a use containing this
Transform *transform, /* Transform from use->cu_def to root coords. */
Rect *area) /* We're looking for a use containing this
* area, in root coords.
*/
{
@ -227,7 +260,7 @@ cmdEditEnumFunc(selUse, use, transform, area)
/* It overlaps. Now find out which array element it points to,
* and adjust the transforms accordingly.
*/
DBArrayOverlap(use, &useArea, &xlo, &xhi, &ylo, &yhi);
GeoTransTrans(DBGetArrayTransform(use, xlo, ylo), transform,
&EditToRootTransform);
@ -272,20 +305,20 @@ cmdEditEnumFunc(selUse, use, transform, area)
#define OPTION_FLAGS 3
void
CmdElement(w, cmd)
MagWindow *w;
TxCommand *cmd;
CmdElement(
MagWindow *w,
TxCommand *cmd)
{
int option, type;
char **msg;
const char * const *msg;
Rect area;
int style;
CellDef *def;
CellUse *use;
bool getopt;
static char *cmdElementOption[] = {
static const char * const cmdElementOption[] = {
"add create a new element",
"delete delete an existing element",
"configure configure or query an existing element",
@ -295,14 +328,14 @@ CmdElement(w, cmd)
NULL
};
static char *cmdElementType[] = {
static const char * const cmdElementType[] = {
"line name style x1 y1 x2 y2",
"rectangle name style llx lly urx ury",
"text name style cx cy label",
NULL
};
static char *cmdConfigureType[] = {
static const char * const cmdConfigureType[] = {
"text get (or) replace <string>",
"style get (or) add <style> (or) remove <style>",
"position get (or) <point> (or) <rect>",
@ -357,10 +390,8 @@ CmdElement(w, cmd)
return;
}
}
if (!StrIsInt(cmd->tx_argv[5])) goto badusage;
area.r_xbot = atoi(cmd->tx_argv[5]);
if (!StrIsInt(cmd->tx_argv[6])) goto badusage;
area.r_ybot = atoi(cmd->tx_argv[6]);
area.r_xbot = cmdParseCoord(w, cmd->tx_argv[5], FALSE, TRUE);
area.r_ybot = cmdParseCoord(w, cmd->tx_argv[6], FALSE, FALSE);
switch (type)
{
@ -371,10 +402,8 @@ CmdElement(w, cmd)
cmdElementType[ELEMENT_LINE]);
return;
}
if (!StrIsInt(cmd->tx_argv[7])) goto badusage;
area.r_xtop = atoi(cmd->tx_argv[7]);
if (!StrIsInt(cmd->tx_argv[8])) goto badusage;
area.r_ytop = atoi(cmd->tx_argv[8]);
area.r_xtop = cmdParseCoord(w, cmd->tx_argv[7], FALSE, TRUE);
area.r_ytop = cmdParseCoord(w, cmd->tx_argv[8], FALSE, FALSE);
DBWElementAddLine(w, cmd->tx_argv[3], &area, def, style);
break;
case ELEMENT_RECT:
@ -384,10 +413,8 @@ CmdElement(w, cmd)
cmdElementType[ELEMENT_RECT]);
return;
}
if (!StrIsInt(cmd->tx_argv[7])) goto badusage;
area.r_xtop = atoi(cmd->tx_argv[7]);
if (!StrIsInt(cmd->tx_argv[8])) goto badusage;
area.r_ytop = atoi(cmd->tx_argv[8]);
area.r_xtop = cmdParseCoord(w, cmd->tx_argv[7], FALSE, TRUE);
area.r_ytop = cmdParseCoord(w, cmd->tx_argv[8], FALSE, FALSE);
DBWElementAddRect(w, cmd->tx_argv[3], &area, def, style);
break;
case ELEMENT_TEXT:
@ -501,21 +528,19 @@ CmdElement(w, cmd)
if (cmd->tx_argc >= 6)
{
if (!StrIsInt(cmd->tx_argv[4]) ||
!StrIsInt(cmd->tx_argv[5]))
goto badrect;
crect.r_xbot = atoi(cmd->tx_argv[4]);
crect.r_ybot = atoi(cmd->tx_argv[5]);
crect.r_xbot = cmdParseCoord(w, cmd->tx_argv[4],
FALSE, TRUE);
crect.r_ybot = cmdParseCoord(w, cmd->tx_argv[5],
FALSE, FALSE);
crect.r_xtop = crect.r_xbot; /* placeholder */
crect.r_ytop = crect.r_ybot; /* placeholder */
}
if (cmd->tx_argc == 8)
{
if (!StrIsInt(cmd->tx_argv[6]) ||
!StrIsInt(cmd->tx_argv[7]))
goto badrect;
crect.r_xtop = atoi(cmd->tx_argv[6]);
crect.r_ytop = atoi(cmd->tx_argv[7]);
crect.r_xtop = cmdParseCoord(w, cmd->tx_argv[6],
FALSE, TRUE);
crect.r_ytop = cmdParseCoord(w, cmd->tx_argv[7],
FALSE, FALSE);
}
if (cmd->tx_argc == 6 || cmd->tx_argc == 8)
@ -570,7 +595,7 @@ badusage:
}
/*
* ----------------------------------------------------------------------------
*
@ -581,7 +606,7 @@ badusage:
* EditCellUse->cu_def.
*
* Usage:
* erase [layers | cursor]
* erase [layers | cursor | pick x y]
*
* Results:
* None.
@ -602,24 +627,39 @@ static CellUse *cmdEraseCells[MAXCELLS];
static int cmdEraseCount;
void
CmdErase(w, cmd)
MagWindow *w;
TxCommand *cmd;
CmdErase(
MagWindow *w,
TxCommand *cmd)
{
Rect editRect, areaReturn;
TileTypeBitMask mask, errorLayersForErasure, activeLayersForErasure;
extern int cmdEraseCellsFunc();
extern int cmdEraseCellsFunc(SearchContext *scx, ClientData cdarg);
windCheckOnlyWindow(&w, DBWclientID);
if (w == (MagWindow *) NULL) return;
if ((cmd->tx_argc == 4) && !strcmp(cmd->tx_argv[1], "pick"))
{
Point editPoint, rootPoint;
editPoint.p_x = cmdParseCoord(w, cmd->tx_argv[2], FALSE, TRUE);
editPoint.p_y = cmdParseCoord(w, cmd->tx_argv[3], FALSE, FALSE);
GeoTransPoint(&EditToRootTransform, &editPoint, &rootPoint);
CmdPaintEraseButton(w, &rootPoint, FALSE, FALSE);
return;
}
if (cmd->tx_argc > 2)
{
TxError("Usage: %s [<layers> | cursor]\n", cmd->tx_argv[0]);
TxError("Usage: %s [<layers> | cursor | pick x y]\n", cmd->tx_argv[0]);
return;
}
if (!ToolGetEditBox(&editRect)) return;
if (EditCellUse == NULL)
{
TxError("No cell def being edited!\n");
return;
}
/*
* Erase with no arguments is the same as erasing
@ -631,7 +671,16 @@ CmdErase(w, cmd)
(void) CmdParseLayers("*,label", &mask);
else if (!strncmp(cmd->tx_argv[1], "cursor", 6))
{
CmdPaintEraseButton(w, &cmd->tx_p, FALSE);
Point editPoint, rootPoint;
CmdPaintEraseButton(w, &cmd->tx_p, FALSE, TRUE);
/* Recast the command as "erase pick x y" for logging purposes */
CmdGetRootPoint(&rootPoint, (Rect *)NULL);
GeoTransPoint(&RootToEditTransform, &rootPoint, &editPoint);
sprintf(cmd->tx_argstring, "erase pick %di %di", editPoint.p_x,
editPoint.p_y);
TxRebuildCommand(cmd);
return;
}
else if (!CmdParseLayers(cmd->tx_argv[1], &mask))
@ -674,7 +723,7 @@ CmdErase(w, cmd)
* area of interest, then erase all those cells. Continue
* this until all cells have been erased.
*/
scx.scx_use = EditCellUse;
scx.scx_x = scx.scx_y = 0;
scx.scx_area = editRect;
@ -710,20 +759,20 @@ CmdErase(w, cmd)
}
int
cmdEraseCellsFunc(scx, cdarg)
SearchContext *scx; /* Indicates cell found. */
ClientData cdarg; /* Not used. */
cmdEraseCellsFunc(
SearchContext *scx, /* Indicates cell found. */
ClientData cdarg) /* Not used. */
{
/* All this procedure does is to remember cells that are
* found, up to MAXCELLS of them.
*/
if (cmdEraseCount >= MAXCELLS) return 1;
cmdEraseCells[cmdEraseCount] = scx->scx_use;
cmdEraseCount += 1;
return 2;
}
/*
* ----------------------------------------------------------------------------
*
@ -748,17 +797,17 @@ ClientData cdarg; /* Not used. */
*/
void
CmdExpand(w, cmd)
MagWindow *w;
TxCommand *cmd;
CmdExpand(
MagWindow *w,
TxCommand *cmd)
{
int windowMask, boxMask, d;
Rect rootRect;
CellUse *rootBoxUse;
CellDef *rootBoxDef;
int cmdExpandFunc(); /* Forward reference. */
int cmdExpandFunc(CellUse *use, int windowMask); /* Forward reference. */
if (cmd->tx_argc > 2 || (cmd->tx_argc == 2
if (cmd->tx_argc > 2 || (cmd->tx_argc == 2
&& (strncmp(cmd->tx_argv[1], "toggle", strlen(cmd->tx_argv[1])) != 0)))
{
TxError("Usage: %s or %s toggle\n", cmd->tx_argv[0], cmd->tx_argv[0]);
@ -780,7 +829,7 @@ CmdExpand(w, cmd)
/* the cursor box and window to restore the original view. */
d = DBLambda[1];
do
do
{
if (d != DBLambda[1])
{
@ -820,16 +869,16 @@ CmdExpand(w, cmd)
*/
int
cmdExpandFunc(use, windowMask)
CellUse *use; /* Use that was just expanded. */
int windowMask; /* Window where it was expanded. */
cmdExpandFunc(
CellUse *use, /* Use that was just expanded. */
int windowMask) /* Window where it was expanded. */
{
if (use->cu_parent == NULL) return 0;
DBWAreaChanged(use->cu_parent, &use->cu_bbox, windowMask,
&DBAllButSpaceBits);
return 0;
}
/*
* ----------------------------------------------------------------------------
*
@ -855,14 +904,17 @@ cmdExpandFunc(use, windowMask)
#define EXTALL 0
#define EXTCELL 1
#define EXTDO 2
#define EXTHELP 3
#define EXTLENGTH 4
#define EXTNO 5
#define EXTPARENTS 6
#define EXTSHOWPARENTS 7
#define EXTSTYLE 8
#define EXTUNIQUE 9
#define EXTWARN 10
#define EXTHALO 3
#define EXTHELP 4
#define EXTLENGTH 5
#define EXTNO 6
#define EXTPARENTS 7
#define EXTPATH 8
#define EXTSHOWPARENTS 9
#define EXTSTEPSIZE 10
#define EXTSTYLE 11
#define EXTUNIQUE 12
#define EXTWARN 13
#define WARNALL 0
#define WARNDUP 1
@ -874,7 +926,10 @@ cmdExpandFunc(use, windowMask)
#define DOCAPACITANCE 2
#define DOCOUPLING 3
#define DOLENGTH 4
#define DORESISTANCE 5
#define DOLOCAL 5
#define DORESISTANCE 6
#define DOLABELCHECK 7
#define DOALIASES 8
#define LENCLEAR 0
#define LENDRIVER 1
@ -883,23 +938,27 @@ cmdExpandFunc(use, windowMask)
#define UNIQALL 0
#define UNIQTAGGED 1
#define UNIQNOPORTS 2
#define UNIQNOTOPPORTS 3
void
CmdExtract(w, cmd)
MagWindow *w;
TxCommand *cmd;
CmdExtract(
MagWindow *w,
TxCommand *cmd)
{
char **msg, *namep, *arg;
const char * const *msg;
char *namep, *arg;
int option, warn, len, n, all;
int dist;
bool no;
CellUse *selectedUse;
CellDef *selectedDef;
bool dolist = FALSE;
bool doforall = FALSE;
bool doLocal = FALSE;
int argc = cmd->tx_argc;
char **argv = cmd->tx_argv;
static char *cmdExtWarn[] =
static const char * const cmdExtWarn[] =
{
"all enable all warnings",
"dup warn when different nodes have the same name",
@ -907,44 +966,54 @@ CmdExtract(w, cmd)
"labels warn when subcell nodes are unlabelled",
NULL
};
static char *cmdExtOption[] =
static const char * const cmdExtOption[] =
{
"adjust compensate R and C hierarchically",
"all all options",
"capacitance extract substrate capacitance",
"coupling extract coupling capacitance",
"length compute driver-receiver pathlengths",
"local put all generated files in the current directory",
"resistance estimate resistance",
"labelcheck check for connections through sticky labels",
"aliases output all net name aliases",
NULL
};
static char *cmdExtLength[] =
static const char * const cmdExtLength[] =
{
"clear clear the driver and receiver tables",
"driver termName(s) identify a driving (output) terminal",
"receiver termName(s) identify a receiving (input) terminal",
NULL
};
static char *cmdExtUniq[] =
/* These must match definitions EXT_UNIQ_* in extract/extract.h: */
static const char * const cmdExtUniq[] =
{
"all extract matching labels as unique nodes",
"# extract tagged labels as unique nodes",
"noports ignore ports when making labels unique",
"notopports ignore top-level ports when making labels unique",
NULL
};
static char *cmdExtCmd[] =
{
static const char * const cmdExtCmd[] =
{
"all extract root cell and all its children",
"cell name extract selected cell into file \"name\"",
"do [option] enable extractor option",
"halo [value] print or set the sidewall halo distance",
"help print this help information",
"length [option] control pathlength extraction information",
"no [option] disable extractor option",
"parents extract selected cell and all its parents",
"path [path] if set, extract into the indicated path",
"showparents show all parents of selected cell",
"stepsize [value] print or set the extraction step size",
"style [stylename] set current extraction parameter style",
"unique [option] generate unique names when different nodes\n\
have the same name",
"warn [ [no] option] enable/disable reporting of non-fatal errors",
"warn [ [no] option] enable/disable reporting of non-serious errors",
NULL
};
@ -991,7 +1060,10 @@ CmdExtract(w, cmd)
if (argc == 1)
{
ExtIncremental(selectedUse);
if (!strcmp(selectedUse->cu_def->cd_name, UNNAMED))
TxError("Please name the cell before extracting.\n");
else
ExtIncremental(selectedUse);
return;
}
}
@ -1022,7 +1094,10 @@ CmdExtract(w, cmd)
break;
case EXTALL:
ExtAll(selectedUse);
if (!strcmp(selectedUse->cu_def->cd_name, UNNAMED))
TxError("Please name the cell before extracting.\n");
else
ExtAll(selectedUse);
return;
case EXTCELL:
@ -1034,9 +1109,69 @@ CmdExtract(w, cmd)
TxError("No cell selected\n");
return;
}
ExtCell(selectedUse->cu_def, namep, FALSE);
ExtractOneCell(selectedUse->cu_def, namep, FALSE);
return;
case EXTHALO:
if (ExtCurStyle == NULL)
{
TxError("No extraction style set.\n");
return;
}
else if (argc == 2)
{
#ifdef MAGIC_WRAPPER
Tcl_Obj *tobj;
tobj = Tcl_NewIntObj(ExtCurStyle->exts_sideCoupleHalo);
Tcl_SetObjResult(magicinterp, tobj);
#else
TxPrintf("Side overlap halo is %d\n", ExtCurStyle->exts_sideCoupleHalo);
#endif
return;
}
else if (argc != 3) goto wrongNumArgs;
/* argv[2] is a halo distance */
dist = cmdParseCoord(w, argv[2], TRUE, TRUE);
if (dist < 0)
{
TxError("Bad halo distance. Halo must be non-negative.");
return;
}
else
ExtCurStyle->exts_sideCoupleHalo = dist;
break;
case EXTSTEPSIZE:
if (ExtCurStyle == NULL)
{
TxError("No extraction style set.\n");
return;
}
else if (argc == 2)
{
#ifdef MAGIC_WRAPPER
Tcl_Obj *tobj;
tobj = Tcl_NewIntObj(ExtCurStyle->exts_stepSize);
Tcl_SetObjResult(magicinterp, tobj);
#else
TxPrintf("Extraction step size is %d\n", ExtCurStyle->exts_stepSize);
#endif
return;
}
else if (argc != 3) goto wrongNumArgs;
/* argv[2] is a step size */
dist = cmdParseCoord(w, argv[2], TRUE, TRUE);
if (dist <= 0)
{
TxError("Bad step size. Step size must be strictly positive.");
return;
}
else
ExtCurStyle->exts_stepSize = dist;
break;
case EXTPARENTS:
selectedUse = CmdGetSelectedCell((Transform *) NULL);
if (selectedUse == NULL)
@ -1044,7 +1179,10 @@ CmdExtract(w, cmd)
TxError("No cell selected\n");
return;
}
ExtParents(selectedUse);
if (!strcmp(selectedUse->cu_def->cd_name, UNNAMED))
TxError("Please name the cell before extracting.\n");
else
ExtParents(selectedUse);
return;
case EXTSHOWPARENTS:
@ -1057,6 +1195,13 @@ CmdExtract(w, cmd)
ExtShowParents(selectedUse);
return;
case EXTPATH:
if (argc == 2)
ExtPrintPath(dolist);
else
ExtSetPath(argv[2]);
return;
case EXTSTYLE:
if (argc == 2)
ExtPrintStyle(dolist, doforall, !doforall);
@ -1133,6 +1278,8 @@ CmdExtract(w, cmd)
TxPrintf("%s coupling\n", OPTSET(EXT_DOCOUPLING));
TxPrintf("%s length\n", OPTSET(EXT_DOLENGTH));
TxPrintf("%s resistance\n", OPTSET(EXT_DORESISTANCE));
TxPrintf("%s label check\n", OPTSET(EXT_DOLABELCHECK));
TxPrintf("%s aliases\n", OPTSET(EXT_DOALIASES));
return;
#undef OPTSET
}
@ -1160,6 +1307,18 @@ CmdExtract(w, cmd)
case DOCOUPLING: option = EXT_DOCOUPLING; break;
case DOLENGTH: option = EXT_DOLENGTH; break;
case DORESISTANCE: option = EXT_DORESISTANCE; break;
case DOLABELCHECK: option = EXT_DOLABELCHECK; break;
case DOALIASES: option = EXT_DOALIASES; break;
case DOLOCAL:
/* "extract do local" and "extract no local" are kept for
* backwards compatibility, but now effectively implement
* "extract path ." and "extract path none", respectively.
*/
if (no)
StrDup(&ExtLocalPath, NULL);
else
StrDup(&ExtLocalPath, ".");
return;
}
if (no) ExtOptions &= ~option;
else ExtOptions |= option;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -4,21 +4,21 @@
* The functions in this file are local to the commands module
* and not intended to be used by its clients.
*
* *********************************************************************
* * Copyright (C) 1985, 1990 Regents of the University of California. *
* * Permission to use, copy, modify, and distribute this *
* * software and its documentation for any purpose and without *
* * fee is hereby granted, provided that the above copyright *
* * notice appear in all copies. The University of California *
* * makes no representations about the suitability of this *
* * software for any purpose. It is provided "as is" without *
* * express or implied warranty. Export of this software outside *
* * of the United States of America may require an export license. *
* *********************************************************************
* * Copyright (C) 1985, 1990 Regents of the University of California. *
* * Permission to use, copy, modify, and distribute this *
* * software and its documentation for any purpose and without *
* * fee is hereby granted, provided that the above copyright *
* * notice appear in all copies. The University of California *
* * makes no representations about the suitability of this *
* * software for any purpose. It is provided "as is" without *
* * express or implied warranty. Export of this software outside *
* * of the United States of America may require an export license. *
* *********************************************************************
*/
#ifndef lint
static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/commands/CmdSubrs.c,v 1.2 2010/06/24 12:37:15 tim Exp $";
static const char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/commands/CmdSubrs.c,v 1.2 2010/06/24 12:37:15 tim Exp $";
#endif /* not lint */
#include <stdio.h>
@ -33,6 +33,7 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
#include "database/database.h"
#include "tiles/tile.h"
#include "utils/hash.h"
#include "utils/malloc.h"
#include "windows/windows.h"
#include "dbwind/dbwind.h"
#include "utils/main.h"
@ -51,9 +52,9 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
/* Forward declarations */
extern char *cmdCheckNewName();
extern int cmdSaveWindSet();
extern void CmdSetWindCaption();
extern char *cmdCheckNewName(CellDef *def, char *newName, bool tryRename, bool noninteractive);
extern int cmdSaveWindSet(MagWindow *window, CellDef *def);
extern void CmdSetWindCaption(CellUse *newEditUse, CellDef *rootDef);
TileTypeBitMask CmdYMLabel;
TileTypeBitMask CmdYMCell;
@ -99,11 +100,12 @@ TileTypeBitMask CmdYMAllButSpace;
*/
int
cmdScaleCoord(w, arg, is_relative, is_x, scale)
MagWindow *w;
char *arg;
bool is_relative, is_x;
int scale;
cmdScaleCoord(
MagWindow *w,
char *arg,
bool is_relative,
bool is_x,
int scale)
{
char *endptr;
double dval = 0;
@ -189,6 +191,11 @@ cmdScaleCoord(w, arg, is_relative, is_x, scale)
return round(dval);
}
}
else if (!strcmp(endptr, "u"))
/* Maybe "u" is too ambiguous but it is very commonly used as
* an abbreviation for "micron".
*/
mscale = 1000;
else if (!strncmp(endptr, "micron", 6))
mscale = 1000;
else if (!strncmp(endptr, "centimicron", 11) || !strcmp(endptr, "cu"))
@ -200,7 +207,8 @@ cmdScaleCoord(w, arg, is_relative, is_x, scale)
return round(dval);
}
}
dval /= CIFGetOutputScale(mscale);
if (!isspace(*endptr))
dval /= CIFGetOutputScale(mscale);
return round(dval);
}
@ -223,10 +231,11 @@ cmdScaleCoord(w, arg, is_relative, is_x, scale)
*/
int
cmdParseCoord(w, arg, is_relative, is_x)
MagWindow *w;
char *arg;
bool is_relative, is_x;
cmdParseCoord(
MagWindow *w,
char *arg,
bool is_relative,
bool is_x)
{
return cmdScaleCoord(w, arg, is_relative, is_x, 1);
}
@ -250,7 +259,7 @@ cmdParseCoord(w, arg, is_relative, is_x)
*/
void
CmdInit()
CmdInit(void)
{
TTMaskZero(&CmdYMLabel);
TTMaskSetType(&CmdYMLabel, L_LABEL);
@ -261,7 +270,7 @@ CmdInit()
CmdYMAllButSpace = DBAllButSpaceBits;
TTMaskClearType(&CmdYMAllButSpace, L_CELL);
}
/*
* ----------------------------------------------------------------------------
*
@ -284,11 +293,14 @@ CmdInit()
*/
void
cmdFlushCell(def)
CellDef *def;
cmdFlushCell(
CellDef *def,
bool force_deref)
{
CellUse *parentUse;
if (def == NULL) return;
/* Disallow flushing a cell that contains the edit cell as a child */
if (EditCellUse && (EditCellUse->cu_parent == def))
{
@ -298,6 +310,15 @@ cmdFlushCell(def)
}
UndoFlush();
if (force_deref)
{
/* Force dereferencing */
def->cd_flags |= CDDEREFERENCE;
freeMagic(def->cd_file);
def->cd_file = NULL;
}
DBWAreaChanged(def, &def->cd_bbox, DBW_ALLWINDOWS,
(TileTypeBitMask *) NULL);
for (parentUse = def->cd_parents; parentUse != NULL;
@ -309,7 +330,7 @@ cmdFlushCell(def)
}
DBCellClearDef(def);
DBCellClearAvail(def);
(void) DBCellRead(def, (char *) NULL, TRUE, NULL);
(void) DBCellRead(def, TRUE, TRUE, NULL);
DBCellSetAvail(def);
DBReComputeBbox(def);
DBCellSetModified(def, FALSE);
@ -323,7 +344,7 @@ cmdFlushCell(def)
&parentUse->cu_bbox);
}
}
/*
* ----------------------------------------------------------------------------
*
@ -354,9 +375,9 @@ cmdFlushCell(def)
*/
bool
CmdParseLayers(s, mask)
char *s;
TileTypeBitMask *mask;
CmdParseLayers(
char *s,
TileTypeBitMask *mask)
{
TileTypeBitMask newmask, tempmask;
char *dp, c;
@ -375,23 +396,23 @@ CmdParseLayers(s, mask)
#define LN_CONNECT 5
static struct
{
char *layer_name;
const char *layer_name;
int layer_value;
}
special[] =
const special[] =
{
"$", LN_DOLLAR,
"*", LN_ALL,
"errors", LN_ERRORS,
"labels", LN_LABELS,
"subcell", LN_CELL,
"connect", LN_CONNECT,
0,
{"$", LN_DOLLAR},
{"*", LN_ALL},
{"errors", LN_ERRORS},
{"labels", LN_LABELS},
{"subcell", LN_CELL},
{"connect", LN_CONNECT},
{0},
};
TTMaskZero(mask);
while (c = *s++)
while ((c = *s++))
{
switch (c)
{
@ -418,7 +439,7 @@ CmdParseLayers(s, mask)
type = DBTechNameTypes(name, &newmask);
if (type == -2)
{
which = LookupStruct(name, (LookupTable *) special, sizeof special[0]);
which = LookupStruct(name, (const LookupTable *) special, sizeof special[0]);
if (which >= 0)
{
switch (special[which].layer_value)
@ -440,7 +461,7 @@ CmdParseLayers(s, mask)
|| (window->w_client != DBWclientID))
return (FALSE);
crec = (DBWclientRec *) window->w_clientData;
DBSeeTypesAll(((CellUse *)window->w_surfaceID),
DBSeeTypesAll(((CellUse *)window->w_surfaceID),
&rootRect, crec->dbw_bitmask, &newmask);
TTMaskAndMask(&newmask, &crec->dbw_visibleLayers);
tempmask = DBAllButSpaceAndDRCBits;
@ -509,7 +530,7 @@ printTypes:
return (TRUE);
}
/*
* ----------------------------------------------------------------------------
*
@ -528,8 +549,8 @@ printTypes:
*/
TileType
cmdMaskToType(mask)
TileTypeBitMask *mask;
cmdMaskToType(
TileTypeBitMask *mask)
{
TileType type, t;
@ -548,7 +569,7 @@ cmdMaskToType(mask)
return (TT_SPACE);
return (type);
}
/*
* ----------------------------------------------------------------------------
*
@ -574,19 +595,21 @@ cmdMaskToType(mask)
*/
void
cmdSaveCell(cellDef, newName, noninteractive, tryRename)
CellDef *cellDef; /* Pointer to def of cell to be saved */
char *newName; /* Pointer to name of file in which cell is to be
cmdSaveCell(
CellDef *cellDef, /* Pointer to def of cell to be saved */
char *newName, /* Pointer to name of file in which cell is to be
* saved. May be NULL, in which case the name from
* the CellDef is taken.
*/
bool noninteractive;/* If true, try hard but don't ask the user
bool noninteractive,/* If true, try hard but don't ask the user
* questions.
*/
bool tryRename; /* We should rename the cell to the name of the
bool tryRename) /* We should rename the cell to the name of the
* place where it was saved.
*/
{
char *fileName = newName;
/* Eliminate the phony labels added for use by rsim */
#ifndef NO_SIM_MODULE
SimEraseLabels();
@ -597,46 +620,46 @@ cmdSaveCell(cellDef, newName, noninteractive, tryRename)
* cell changes to the name of the file in which it was
* saved.
*/
if (strcmp(cellDef->cd_name, UNNAMED) == 0)
{
if (newName == NULL)
TxPrintf("Must specify name for cell %s.\n", UNNAMED);
newName = cmdCheckNewName(cellDef, newName, TRUE, noninteractive);
if (newName == NULL) return;
fileName = cmdCheckNewName(cellDef, newName, TRUE, noninteractive);
if (fileName == NULL) return;
}
else if (newName != NULL)
{
newName = cmdCheckNewName(cellDef, newName, TRUE, noninteractive);
if (newName == NULL) return;
fileName = cmdCheckNewName(cellDef, newName, TRUE, noninteractive);
if (fileName == NULL) return;
}
else
{
if (cellDef->cd_file == NULL)
{
newName = cmdCheckNewName(cellDef, cellDef->cd_name,
fileName = cmdCheckNewName(cellDef, cellDef->cd_name,
TRUE, noninteractive);
if (newName == NULL) return;
if (fileName == NULL) return;
}
}
DBUpdateStamps();
if (!DBCellWrite(cellDef, newName))
DBUpdateStamps(cellDef);
if (!DBCellWrite(cellDef, fileName))
{
TxError("Could not write file. Cell not written.\n");
return;
goto cleanup;
}
if (!tryRename || (newName == NULL) || (strcmp(cellDef->cd_name, newName) == 0))
return;
if (!tryRename || (fileName == NULL) || (strcmp(cellDef->cd_name, fileName) == 0))
goto cleanup;
/* Rename the cell */
if (!DBCellRenameDef(cellDef, newName))
if (!DBCellRenameDef(cellDef, fileName))
{
/* This should never happen */
TxError("Magic error: there is already a cell named \"%s\"\n",
newName);
return;
fileName);
goto cleanup;
}
if (EditCellUse && (cellDef == EditCellUse->cu_def))
@ -655,11 +678,16 @@ cmdSaveCell(cellDef, newName, noninteractive, tryRename)
* We want to find all windows for which this is
* the root cell and update their captions.
*/
(void) WindSearch(DBWclientID, (ClientData) NULL, (Rect *) NULL,
(void) WindSearch(DBWclientID, (ClientData) NULL, (Rect *) NULL,
cmdSaveWindSet, (ClientData) cellDef);
}
cleanup:
if ((fileName != newName) && (fileName != cellDef->cd_name))
freeMagic(fileName);
return;
}
/*
* ----------------------------------------------------------------------------
*
@ -686,44 +714,51 @@ cmdSaveCell(cellDef, newName, noninteractive, tryRename)
*/
char *
cmdCheckNewName(def, newName, tryRename, noninteractive)
CellDef *def;
char *newName;
bool tryRename;
bool noninteractive;
cmdCheckNewName(
CellDef *def,
char *newName,
bool tryRename,
bool noninteractive)
{
static char newname[256];
static char *yesno[] = { "no", "yes", 0 };
static const char * const yesno[] = { "no", "yes", 0 };
char *filename;
char *prompt;
char *returnname;
int code;
FILE *f;
returnname = newName;
again:
if (newName == NULL)
if (returnname == NULL)
{
if (noninteractive) {
TxError("Can't write file named '%s'\n", def->cd_name);
return NULL;
};
TxPrintf("File for cell %s: [hit return to abort save] ", def->cd_name);
if (TxGetLine(newname, sizeof newname) == NULL || newname[0] == '\0')
returnname = (char *)mallocMagic(1024 * sizeof(char));
if (TxGetLine(returnname, sizeof returnname) == NULL || returnname[0] == '\0')
{
TxPrintf("Cell not saved.\n");
freeMagic(returnname);
return ((char *) NULL);
}
if (CmdIllegalChars(newname, "[],", "Cell name"))
if (CmdIllegalChars(returnname, "[],", "Cell name"))
{
freeMagic(returnname);
goto again;
newName = newname;
}
}
/* Remove any ".mag" file extension from the name */
else if (!strcmp(newName + strlen(newName) - 4, ".mag"))
*(newName + strlen(newName) - 4) = '\0';
if (strlen(returnname) > 4)
if (!strcmp(returnname + strlen(returnname) - 4, ".mag"))
*(returnname + strlen(returnname) - 4) = '\0';
if (strcmp(newName, def->cd_name) != 0)
if (strcmp(returnname, def->cd_name) != 0)
{
if (f = PaOpen(newName, "r", DBSuffix, ".", (char *) NULL, &filename))
if ((f = PaOpen(returnname, "r", DBSuffix, ".", (char *) NULL, &filename)))
{
(void) fclose(f);
if (noninteractive) {
@ -738,25 +773,57 @@ again:
if (code == 0)
{
/* No -- don't overwrite */
newName = NULL;
if (returnname != newName) freeMagic(returnname);
returnname = NULL;
goto again;
}
}
}
if (tryRename && DBCellLookDef(newName) != NULL)
if (tryRename && DBCellLookDef(returnname) != NULL)
{
TxError("Can't rename cell '%s' to '%s' because that cell already exists.\n",
def->cd_name, newName);
def->cd_name, returnname);
if (returnname != newName) freeMagic(returnname);
if (noninteractive) return NULL;
newName = NULL;
returnname = NULL;
goto again;
}
}
return (newName);
return (returnname);
}
/*
* ----------------------------------------------------------------------------
*
* nameEllipsis ---
*
* Truncate a string an append an ellipsis ("...") to the end if the string
* will overflow a fixed array length.
*
* ----------------------------------------------------------------------------
*/
static char *
nameEllipsis(
char *name,
int maxlen,
char **prefix)
{
int l = strlen(name);
if (l < maxlen)
{
*prefix = "";
return name;
}
else
{
*prefix = "...";
return &name[l - maxlen + 3];
}
}
/*
* ----------------------------------------------------------------------------
*
@ -781,23 +848,25 @@ again:
*/
int
cmdSaveWindSet(window, def)
MagWindow *window;
CellDef *def;
cmdSaveWindSet(
MagWindow *window,
CellDef *def)
{
char caption[200];
CellDef *rootDef;
char *name, *name_pfx;
rootDef = ((CellUse *) window->w_surfaceID)->cu_def;
if (rootDef != def)
return 0;
(void) sprintf(caption, "%s [NOT BEING EDITED]", def->cd_name);
name = nameEllipsis(def->cd_name, 175, &name_pfx);
(void) snprintf(caption, sizeof(caption), "%s%s [NOT BEING EDITED]", name_pfx, name);
(void) StrDup(&window->w_iconname, def->cd_name);
WindCaption(window, caption);
return 0;
}
/*
* ----------------------------------------------------------------------------
*
@ -833,20 +902,20 @@ static CellDef *newRootDef; /* Pointer to root def of window in which
*/
void
CmdSetWindCaption(newEditUse, rootDef)
CellUse *newEditUse; /* Pointer to new edit cell use */
CellDef *rootDef; /* Root cell def of the window in which the
CmdSetWindCaption(
CellUse *newEditUse, /* Pointer to new edit cell use */
CellDef *rootDef) /* Root cell def of the window in which the
* edit cell was selected.
*/
{
int cmdWindSet();
int cmdWindSet(MagWindow *window);
newEditDef = (newEditUse) ? newEditUse->cu_def : NULL;
newRootDef = rootDef;
(void) WindSearch(DBWclientID, (ClientData) NULL, (Rect *) NULL,
(void) WindSearch(DBWclientID, (ClientData) NULL, (Rect *) NULL,
cmdWindSet, (ClientData) 0);
}
/*
* ----------------------------------------------------------------------------
*
@ -874,18 +943,27 @@ CmdSetWindCaption(newEditUse, rootDef)
*/
int
cmdWindSet(window)
MagWindow *window;
cmdWindSet(
MagWindow *window)
{
char caption[200];
CellDef *wDef;
char *name[2], *name_pfx[2];
wDef = ((CellUse *) window->w_surfaceID)->cu_def;
if (wDef != newRootDef)
(void) sprintf(caption, "%s [NOT BEING EDITED]", wDef->cd_name);
else {
(void) sprintf(caption, "%s EDITING %s", wDef->cd_name,
newEditDef->cd_name);
if (wDef != newRootDef) {
name[0] = nameEllipsis(wDef->cd_name, 175, &name_pfx[0]);
(void) snprintf(caption, sizeof(caption), "%s%s [NOT BEING EDITED]",
name_pfx[0], name[0]);
} else {
name[0] = nameEllipsis(wDef->cd_name, 90, &name_pfx[0]);
name[1] = nameEllipsis(newEditDef->cd_name, 90, &name_pfx[1]);
(void) snprintf(caption, sizeof(caption), "%s%s EDITING %s%s",
name_pfx[0], name[0], name_pfx[1], name[1]);
#ifdef SCHEME_INTERPRETER
/* Add a binding to scheme variable "edit-cell" */
LispSetEdit (newEditDef->cd_name);
@ -897,7 +975,7 @@ cmdWindSet(window)
return 0;
}
/*
* ----------------------------------------------------------------------------
*
@ -922,9 +1000,9 @@ cmdWindSet(window)
*/
MagWindow *
CmdGetRootPoint(point, rect)
Point *point;
Rect *rect;
CmdGetRootPoint(
Point *point,
Rect *rect)
{
MagWindow *window;
@ -934,7 +1012,7 @@ CmdGetRootPoint(point, rect)
return (window);
}
/*
* ----------------------------------------------------------------------------
*
@ -957,9 +1035,9 @@ CmdGetRootPoint(point, rect)
*/
MagWindow *
CmdGetEditPoint(point, rect)
Point *point;
Rect *rect;
CmdGetEditPoint(
Point *point,
Rect *rect)
{
MagWindow *window;
Rect rootRect;
@ -974,7 +1052,7 @@ CmdGetEditPoint(point, rect)
return (window);
}
/*
* ----------------------------------------------------------------------------
*
@ -994,11 +1072,11 @@ CmdGetEditPoint(point, rect)
*/
bool
CmdWarnWrite()
CmdWarnWrite(void)
{
int count, code;
int cmdWarnWriteFunc();
static char *yesno[] = { "no", "yes", 0 };
int cmdWarnWriteFunc(CellDef *cellDef, int *pcount);
static const char * const yesno[] = { "no", "yes", 0 };
char *prompt;
count = 0;
@ -1010,26 +1088,26 @@ CmdWarnWrite()
prompt = TxPrintString("%d Magic cell%s been modified.\n Do you"
" want to exit magic and lose %s? ", count,
count == 1 ? " has" : "s have",
count == 1 ? "it" : "them");
count == 1 ? "it" : "them");
code = TxDialog(prompt, yesno, 0);
return (code) ? TRUE : FALSE;
}
int
cmdWarnWriteFunc(cellDef, pcount)
CellDef *cellDef;
int *pcount;
cmdWarnWriteFunc(
CellDef *cellDef,
int *pcount)
{
if ((cellDef->cd_flags & CDINTERNAL) == 0)
(*pcount)++;
return 0;
}
/*
* ----------------------------------------------------------------------------
* cmdExpandOneLevel --
*
* Expand (unexpand) a cell, and unexpand all of its children. This is
* Expand (unexpand) a cell, and unexpand all of its children. This is
* called by commands such as getcell, expand current cell, and load.
* Don't bother to unexpand children if we are unexpanding this cell.
*
@ -1042,30 +1120,30 @@ cmdWarnWriteFunc(cellDef, pcount)
*/
void
cmdExpandOneLevel(cu, bitmask, expand)
CellUse *cu;
int bitmask;
bool expand;
cmdExpandOneLevel(
CellUse *cu,
int bitmask,
bool expand)
{
extern int cmdExpand1func();
extern int cmdExpand1func(CellUse *cu, ClientData bitmask);
/* first, expand this cell use */
DBExpand(cu, bitmask, expand);
/* now, unexpand its direct children (ONE LEVEL ONLY) */
if (expand)
(void) DBCellEnum(cu->cu_def, cmdExpand1func, (ClientData) bitmask);
(void) DBCellEnum(cu->cu_def, cmdExpand1func, INT2CD(bitmask));
}
int
cmdExpand1func(cu, bitmask)
CellUse *cu;
ClientData bitmask;
cmdExpand1func(
CellUse *cu,
ClientData bitmask)
{
DBExpand(cu, (int) bitmask, FALSE);
DBExpand(cu, (int)CD2INT(bitmask), FALSE);
return 0;
}
/*
* ----------------------------------------------------------------------------
*
@ -1090,13 +1168,13 @@ Transform *cmdSelTrans; /* Shared between CmdGetSelectedCell and
*/
CellUse *
CmdGetSelectedCell(pTrans)
Transform *pTrans; /* If non-NULL, transform from selected
CmdGetSelectedCell(
Transform *pTrans) /* If non-NULL, transform from selected
* cell to root coords is stored here.
*/
{
CellUse *result = NULL;
int cmdGetSelFunc(); /* Forward declaration. */
int cmdGetSelFunc(CellUse *selUse, CellUse *realUse, Transform *transform, CellUse **pResult); /* Forward declaration. */
cmdSelTrans = pTrans;
(void) SelEnumCells(FALSE, (bool *) NULL, (SearchContext *) NULL,
@ -1106,18 +1184,29 @@ CmdGetSelectedCell(pTrans)
/* ARGSUSED */
int
cmdGetSelFunc(selUse, realUse, transform, pResult)
CellUse *selUse; /* Not used. */
CellUse *realUse; /* The first selected use. */
Transform *transform; /* Transform from coords of realUse to root. */
CellUse **pResult; /* Store realUse here. */
cmdGetSelFunc(
CellUse *selUse, /* Not used. */
CellUse *realUse, /* The first selected use. */
Transform *transform, /* Transform from coords of realUse to root. */
CellUse **pResult) /* Store realUse here. */
{
*pResult = realUse;
if (cmdSelTrans != NULL)
*cmdSelTrans = *transform;
return 1; /* Skip any other selected cells. */
}
/* The Open Group, Sep 2006, Austin/317 deprecated isascii(),
* Apparently it cannot be used portably in a localized application.
*/
static int
magic_isascii(int c)
{
return (c & ~0x7f) == 0;
}
/*
* ----------------------------------------------------------------------------
*
@ -1138,10 +1227,10 @@ cmdGetSelFunc(selUse, realUse, transform, pResult)
*/
bool
CmdIllegalChars(string, illegal, msg)
char *string; /* String to check for illegal chars. */
char *illegal; /* String containing illegal chars. */
char *msg; /* String identifying what string is
CmdIllegalChars(
char *string, /* String to check for illegal chars. */
char *illegal, /* String containing illegal chars. */
char *msg) /* String identifying what string is
* supposed to represent, for ease in
* printing error messages.
*/
@ -1150,7 +1239,7 @@ CmdIllegalChars(string, illegal, msg)
for (p = string; *p != 0; p++)
{
if (!isascii(*p)) goto error;
if (!magic_isascii(*p)) goto error;
if (iscntrl(*p)) goto error;
for (bad = illegal; *bad != 0; bad++)
{
@ -1159,7 +1248,7 @@ CmdIllegalChars(string, illegal, msg)
continue;
error:
if (!isascii(*p) || iscntrl(*p))
if (!magic_isascii(*p) || iscntrl(*p))
{
TxError("%s contains illegal control character 0x%x\n",
msg, *p);

File diff suppressed because it is too large Load Diff

View File

@ -6,24 +6,25 @@
* These commands are not intended to be used by the ordinary magic
* user, but are provided for the benefit of system maintainers/implementors.
*
* *********************************************************************
* * Copyright (C) 1985, 1990 Regents of the University of California. *
* * Permission to use, copy, modify, and distribute this *
* * software and its documentation for any purpose and without *
* * fee is hereby granted, provided that the above copyright *
* * notice appear in all copies. The University of California *
* * makes no representations about the suitability of this *
* * software for any purpose. It is provided "as is" without *
* * express or implied warranty. Export of this software outside *
* * of the United States of America may require an export license. *
* *********************************************************************
* * Copyright (C) 1985, 1990 Regents of the University of California. *
* * Permission to use, copy, modify, and distribute this *
* * software and its documentation for any purpose and without *
* * fee is hereby granted, provided that the above copyright *
* * notice appear in all copies. The University of California *
* * makes no representations about the suitability of this *
* * software for any purpose. It is provided "as is" without *
* * express or implied warranty. Export of this software outside *
* * of the United States of America may require an export license. *
* *********************************************************************
*/
#ifndef lint
static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/commands/CmdWizard.c,v 1.2 2008/02/10 19:30:19 tim Exp $";
static const char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/commands/CmdWizard.c,v 1.2 2008/02/10 19:30:19 tim Exp $";
#endif /* not lint */
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
@ -46,13 +47,20 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
#include "utils/utils.h"
#include "textio/txcommands.h"
/* For diagnostics */
#include "cif/CIFint.h"
#include "database/databaseInt.h"
/* C99 compat */
#include "extract/extract.h"
/* Forward declarations */
extern void cmdPsearchStats();
extern void cmdPsearchStats(char *str, struct tms *tl, struct tms *td, int count);
void cmdStatsHier(CellDef *, int, CellDef *);
/*
* ----------------------------------------------------------------------------
*
@ -75,9 +83,9 @@ void cmdStatsHier(CellDef *, int, CellDef *);
*/
void
CmdCoord(w, cmd)
MagWindow *w;
TxCommand *cmd;
CmdCoord(
MagWindow *w,
TxCommand *cmd)
{
MagWindow *pointW = (MagWindow *) NULL;
Rect editRect, rootRect;
@ -155,7 +163,7 @@ CmdCoord(w, cmd)
editRect.r_xtop, editRect.r_ytop);
TxPrintf("\n");
}
/*
* ----------------------------------------------------------------------------
*
@ -177,15 +185,242 @@ CmdCoord(w, cmd)
#ifndef NO_EXT
void
CmdExtractTest(w, cmd)
MagWindow *w;
TxCommand *cmd;
CmdExtractTest(
MagWindow *w,
TxCommand *cmd)
{
ExtractTest(w, cmd);
}
#endif
/*
* ----------------------------------------------------------------------------
*
* tileCountProc --
*
* Routine to count tiles.
*
* Return:
* 0 to keep the search going
*
* Side effects:
* Keeps count in clientData
*
* ----------------------------------------------------------------------------
*/
int
tileCountProc(
Tile *tile,
int *tcount)
{
(*tcount)++;
return 0;
}
/*
* ----------------------------------------------------------------------------
*
* showMem --
* CmdShowmem --
*
* Usage:
*
* showmem [outfile]
*
* Display all the (principle) internal memory usage for tiles, including
* all cell defs, and all CIF generated planes.
*
* Results:
* None.
*
* Side effects:
* May write to a disk file.
*
* ----------------------------------------------------------------------------
*/
void
showMem(
FILE *outf, /* File to which information is to be output */
bool verbose) /* If TRUE, output detailed erase table */
{
int ttotal, ttotal1, ttotal2;
int i;
Plane *plane;
CellDef *def;
int pNum;
HashSearch hs;
HashEntry *entry;
fprintf(outf, "Tile memory usage summary\n");
fprintf(outf, "Technology %s\n", DBTechName);
/* Search every cell def (including internal ones), count tiles,
* and add up the tile memory usage on every plane.
*/
/* Search the CIFPlanes and count tiles. */
/* CIFPlanes, CIFTotalPlanes, CIFComponentPlanes */
ttotal2 = 0;
if (CIFCurStyle != NULL)
{
fprintf(outf, "\nCIFPlanes:\n");
ttotal1 = 0;
for (i = 0; i < MAXCIFLAYERS; i++)
{
plane = CIFPlanes[i];
if (plane != NULL)
{
ttotal = 0;
DBSrPaintArea((Tile *)NULL, plane, &TiPlaneRect,
&DBAllTypeBits, tileCountProc, &ttotal);
ttotal1 += ttotal;
if (CIFCurStyle->cs_layers[i])
fprintf(outf, " layer %s: %ld\n",
CIFCurStyle->cs_layers[i]->cl_name,
(long)ttotal * (long)sizeof(Tile));
else
fprintf(outf, " layer %d: %d\n", i,
(long)ttotal * (long)sizeof(Tile));
}
}
fprintf(outf, " Subtotal: %ld bytes\n",
(long)ttotal1 * (long)sizeof(Tile));
ttotal2 += ttotal1;
fprintf(outf, "\nCIFTotalPlanes\n");
ttotal1 = 0;
for (i = 0; i < MAXCIFLAYERS; i++)
{
plane = CIFTotalPlanes[i];
if (plane != NULL)
{
ttotal = 0;
DBSrPaintArea((Tile *)NULL, plane, &TiPlaneRect,
&DBAllTypeBits, tileCountProc, &ttotal);
ttotal1 += ttotal;
if (CIFCurStyle->cs_layers[i])
fprintf(outf, " layer %s: %ld\n",
CIFCurStyle->cs_layers[i]->cl_name,
(long)ttotal * (long)sizeof(Tile));
else
fprintf(outf, " layer %d: %d\n", i,
(long)ttotal * (long)sizeof(Tile));
}
}
fprintf(outf, " Subtotal: %ld bytes\n",
(long)ttotal1 * (long)sizeof(Tile));
ttotal2 += ttotal1;
fprintf(outf, "\nCIFComponentPlanes\n");
ttotal1 = 0;
for (i = 0; i < MAXCIFLAYERS; i++)
{
plane = CIFComponentPlanes[i];
if (plane != NULL)
{
ttotal = 0;
DBSrPaintArea((Tile *)NULL, plane, &TiPlaneRect,
&DBAllTypeBits, tileCountProc, &ttotal);
ttotal1 += ttotal;
if (CIFCurStyle->cs_layers[i])
fprintf(outf, " layer %s: %ld bytes\n",
CIFCurStyle->cs_layers[i]->cl_name,
(long)ttotal * (long)sizeof(Tile));
else
fprintf(outf, " layer %d: %ld bytes\n", i,
(long)ttotal * (long)sizeof(Tile));
}
}
fprintf(outf, " Subtotal: %ld bytes\n",
(long)ttotal1 * (long)sizeof(Tile));
ttotal2 += ttotal1;
}
else
{
fprintf(outf, "CIF planes: No memory usage\n");
}
HashStartSearch(&hs);
while ((entry = HashNext(&dbCellDefTable, &hs)) != NULL)
{
def = (CellDef *)HashGetValue(entry);
if (def != (CellDef *)NULL)
{
fprintf(outf, "\nCell def %s\n", def->cd_name);
ttotal1 = 0;
for (pNum = 0; pNum < DBNumPlanes; pNum++)
{
plane = def->cd_planes[pNum];
if (plane != NULL)
{
ttotal = 0;
DBSrPaintArea((Tile *)NULL, plane, &TiPlaneRect,
&DBAllTypeBits, tileCountProc, &ttotal);
fprintf(outf, " plane %s: %ld bytes\n",
DBPlaneLongNameTbl[pNum],
(long)ttotal * (long)sizeof(Tile));
ttotal1 += ttotal;
}
}
fprintf(outf, " Subtotal: %ld bytes\n",
(long)ttotal1 * (long)sizeof(Tile));
ttotal2 += ttotal1;
}
}
fprintf(outf, " Grand total: %ld bytes\n",
(long)ttotal2 * (long)sizeof(Tile));
}
void
CmdShowmem(
MagWindow *w,
TxCommand *cmd)
{
FILE *outf;
bool verbose;
char **av;
int ac;
if (cmd->tx_argc > 3)
{
TxError("Usage: showmem [-v] [file]\n");
return;
}
verbose = FALSE;
av = &cmd->tx_argv[1];
ac = cmd->tx_argc - 1;
outf = stdout;
if (ac > 0 && strcmp(av[0], "-v") == 0)
{
verbose = TRUE;
av++, ac--;
}
if (ac > 0)
{
outf = fopen(av[0], "w");
if (outf == (FILE *) NULL)
{
perror(av[0]);
TxError("Nothing written\n");
return;
}
}
showMem(outf, verbose);
if (outf != stdout)
(void) fclose(outf);
}
/*
* ----------------------------------------------------------------------------
*
@ -208,9 +443,9 @@ CmdExtractTest(w, cmd)
*/
void
showTech(outf, verbose)
FILE *outf; /* File to which information is to be output */
bool verbose; /* If TRUE, output detailed erase table */
showTech(
FILE *outf, /* File to which information is to be output */
bool verbose) /* If TRUE, output detailed erase table */
{
int i, j;
int pNum;
@ -228,7 +463,7 @@ showTech(outf, verbose)
fprintf(outf, "\n");
fprintf(outf, "Types:\n");
for (i = 0; i < DBNumTypes; i++) {
int pl ; char *spl ;
int pl ; const char *spl ;
pl = DBPlane(i);
spl = ( pl <= 0 || pl > DBNumPlanes ) ? "??" : DBPlaneLongName(pl);
@ -355,9 +590,9 @@ showTech(outf, verbose)
}
void
CmdShowtech(w, cmd)
MagWindow *w;
TxCommand *cmd;
CmdShowtech(
MagWindow *w,
TxCommand *cmd)
{
FILE *outf;
bool verbose;
@ -397,7 +632,7 @@ CmdShowtech(w, cmd)
(void) fclose(outf);
}
/*
* ----------------------------------------------------------------------------
*
@ -423,16 +658,16 @@ CmdShowtech(w, cmd)
*/
void
CmdTilestats(w, cmd)
MagWindow *w;
TxCommand *cmd;
CmdTilestats(
MagWindow *w,
TxCommand *cmd)
{
CellUse *selectedUse;
FILE *outf = stdout;
bool allDefs = FALSE;
char **av = cmd->tx_argv + 1;
int ac = cmd->tx_argc - 1;
int cmdStatsFunc();
int cmdStatsFunc(CellDef *def, FILE *outf);
if (ac > 2)
{
@ -507,11 +742,12 @@ int totalTiles[TT_MAXTYPES];
*/
int
cmdStatsFunc(def, outf)
CellDef *def;
FILE *outf;
cmdStatsFunc(
CellDef *def,
FILE *outf)
{
int cmdStatsCount(), cmdStatsOutput();
int cmdStatsCount(CellDef *def, struct countClient *cc);
int cmdStatsOutput(CellDef *def, struct countClient *cc);
struct countClient cc;
int total;
TileType t;
@ -560,11 +796,11 @@ cmdStatsFunc(def, outf)
*/
int
cmdStatsCount(def, cc)
CellDef *def;
struct countClient *cc;
cmdStatsCount(
CellDef *def,
struct countClient *cc)
{
int cmdStatsCountTile();
int cmdStatsCountTile(Tile *tile, struct cellInfo *ci);
int pNum;
struct cellInfo *ci;
TileType t;
@ -591,9 +827,9 @@ cmdStatsCount(def, cc)
}
int
cmdStatsCountTile(tile, ci)
Tile *tile;
struct cellInfo *ci;
cmdStatsCountTile(
Tile *tile,
struct cellInfo *ci)
{
TileType type = TiGetType(tile);
@ -634,9 +870,10 @@ cmdStatsCountTile(tile, ci)
*/
void
cmdStatsHier(parent, nuses, child)
CellDef *parent, *child;
int nuses;
cmdStatsHier(
CellDef *parent,
int nuses,
CellDef *child)
{
struct cellInfo *pi, *ci;
TileType t;
@ -681,9 +918,9 @@ cmdStatsHier(parent, nuses, child)
*/
int
cmdStatsOutput(def, cc)
CellDef *def;
struct countClient *cc;
cmdStatsOutput(
CellDef *def,
struct countClient *cc)
{
TileType t;
struct cellInfo *ci;
@ -721,7 +958,7 @@ cmdStatsOutput(def, cc)
freeMagic((char *) ci);
return (0);
}
/*
* ----------------------------------------------------------------------------
*
@ -746,11 +983,11 @@ cmdStatsOutput(def, cc)
*/
void
CmdPsearch(w, cmd)
MagWindow *w;
TxCommand *cmd;
CmdPsearch(
MagWindow *w,
TxCommand *cmd)
{
char *RunStats();
char *RunStats(int flags, struct tms *lastt, struct tms *deltat);
static struct tms tlast, tdelta;
Point p;
Plane *plane;
@ -812,12 +1049,13 @@ CmdPsearch(w, cmd)
}
void
cmdPsearchStats(str, tl, td, count)
char *str;
struct tms *tl, *td;
int count;
cmdPsearchStats(
char *str,
struct tms *tl,
struct tms *td,
int count)
{
char *RunStats();
char *RunStats(int flags, struct tms *lastt, struct tms *deltat);
char *rstatp;
int us, ups;
@ -826,13 +1064,13 @@ cmdPsearchStats(str, tl, td, count)
ups = us / count;
TxPrintf("%s: %d searches, %d us/search [%s]\n", str, count, ups, rstatp);
}
/*
* ----------------------------------------------------------------------------
*
* CmdTsearch --
*
* Call TiSrArea() a number of times over an area the size and shape of
* Call DBSrPaintArea() a number of times over an area the size and shape of
* that specified by the box, each time over a different area in the
* edit cell.
*
@ -857,12 +1095,13 @@ int numTilesFound;
bool cmdTsearchDebug = FALSE;
void
CmdTsearch(w, cmd)
MagWindow *w;
TxCommand *cmd;
CmdTsearch(
MagWindow *w,
TxCommand *cmd)
{
int cmdTsrFunc();
char *RunStats(), *rstatp;
int cmdTsrFunc(Tile *tp);
char *RunStats(int flags, struct tms *lastt, struct tms *deltat);
char *rstatp;
static TileTypeBitMask mask;
static struct tms tlast, tdelta;
Rect rtool, rsearch;
@ -914,7 +1153,7 @@ CmdTsearch(w, cmd)
if (!TTMaskEqual(&mask, &DBZeroTypeBits))
numTilesFound = 0;
for (i = 0; i < count; i++)
{
/*****
@ -943,18 +1182,12 @@ CmdTsearch(w, cmd)
if (cmd->tx_argc < 5)
{
(void) TiSrArea((Tile *) NULL, plane, &rsearch,
(void) DBSrPaintArea((Tile *) NULL, plane, &rsearch, &DBAllTypeBits,
cmdTsrFunc, (ClientData) 0);
}
else
{
/****
if (strcmp(cmd->tx_argv[4], "mayo") == 0)
(void) TiSrAreaNR2((Tile *) NULL, plane, &rsearch, &mask,
cmdTsrFunc, (ClientData) 0);
else
****/
(void) DBSrPaintArea((Tile *) NULL, plane, &rsearch, &mask,
(void) DBSrPaintArea((Tile *) NULL, plane, &rsearch, &mask,
cmdTsrFunc, (ClientData) 0);
}
}
@ -975,15 +1208,15 @@ CmdTsearch(w, cmd)
}
int
cmdTsrFunc(tp)
Tile *tp;
cmdTsrFunc(
Tile *tp)
{
if (cmdTsearchDebug)
TxPrintf("%x\n", tp);
TxPrintf("%lx\n", (intptr_t) tp);
numTilesFound++;
return 0;
}
/*
* ----------------------------------------------------------------------------
*
@ -1002,9 +1235,9 @@ cmdTsrFunc(tp)
*/
void
CmdWatch(w, cmd)
MagWindow *w;
TxCommand *cmd;
CmdWatch(
MagWindow *w,
TxCommand *cmd)
{
DBWclientRec *crec;
int pNum;
@ -1045,7 +1278,7 @@ CmdWatch(w, cmd)
pNum = DBTechNamePlane(cmd->tx_argv[1]);
if (pNum < 0)
{
char *cp;
const char *cp;
TxError("Unrecognized plane: %s. Legal names are:\n",
cmd->tx_argv[1]);
for(pNum=0; pNum < PL_MAXTYPES; pNum++) {
@ -1055,8 +1288,16 @@ CmdWatch(w, cmd)
};
return;
}
crec->dbw_watchDef = EditCellUse->cu_def;
crec->dbw_watchTrans = EditToRootTransform;
if (EditCellUse != NULL)
{
crec->dbw_watchDef = EditCellUse->cu_def;
crec->dbw_watchTrans = EditToRootTransform;
}
else
{
crec->dbw_watchDef = ((CellUse *)w->w_surfaceID)->cu_def;
crec->dbw_watchTrans = ((CellUse *)w->w_surfaceID)->cu_transform;
}
}
crec->dbw_watchPlane = pNum;

View File

@ -1,62 +0,0 @@
CmdSubrs.o: CmdSubrs.c ../utils/magic.h ../utils/geometry.h \
../utils/utils.h ../database/database.h ../tiles/tile.h ../utils/hash.h \
../windows/windows.h ../dbwind/dbwind.h ../utils/main.h \
../commands/commands.h ../textio/textio.h ../cif/cif.h ../drc/drc.h \
../textio/txcommands.h ../utils/undo.h ../utils/macros.h ../sim/sim.h \
../select/select.h
CmdAB.o: CmdAB.c ../tcltk/tclmagic.h ../utils/magic.h ../utils/geometry.h \
../tiles/tile.h ../utils/hash.h ../database/database.h \
../windows/windows.h ../dbwind/dbwind.h ../utils/main.h \
../commands/commands.h ../utils/utils.h ../textio/textio.h ../drc/drc.h \
../cif/cif.h ../graphics/graphics.h ../textio/txcommands.h \
../utils/malloc.h ../utils/netlist.h ../select/select.h
CmdCD.o: CmdCD.c ../tcltk/tclmagic.h ../utils/magic.h ../utils/geometry.h \
../tiles/tile.h ../utils/hash.h ../database/database.h \
../windows/windows.h ../dbwind/dbwind.h ../utils/main.h \
../commands/commands.h ../utils/utils.h ../textio/textio.h ../drc/drc.h \
../graphics/graphics.h ../textio/txcommands.h ../cif/cif.h \
../calma/calma.h ../utils/styles.h ../router/rtrDcmpose.h \
../select/select.h ../utils/signals.h ../utils/malloc.h ../cif/CIFint.h \
../cif/CIFread.h
CmdE.o: CmdE.c ../tcltk/tclmagic.h ../utils/magic.h ../utils/styles.h \
../utils/geometry.h ../utils/utils.h ../tiles/tile.h ../utils/hash.h \
../database/database.h ../windows/windows.h ../graphics/graphics.h \
../dbwind/dbwind.h ../utils/main.h ../commands/commands.h \
../textio/textio.h ../utils/macros.h ../drc/drc.h ../textio/txcommands.h \
../extract/extract.h ../select/select.h
CmdFI.o: CmdFI.c ../tcltk/tclmagic.h ../utils/magic.h ../utils/geometry.h \
../utils/utils.h ../utils/undo.h ../tiles/tile.h ../utils/hash.h \
../database/database.h ../windows/windows.h ../dbwind/dbwind.h \
../utils/main.h ../commands/commands.h ../textio/textio.h \
../utils/macros.h ../drc/drc.h ../textio/txcommands.h ../utils/styles.h \
../graphics/graphics.h ../extract/extract.h ../utils/malloc.h \
../select/select.h ../sim/sim.h ../gcr/gcr.h
CmdLQ.o: CmdLQ.c ../tcltk/tclmagic.h ../utils/magic.h ../utils/malloc.h \
../utils/geometry.h ../utils/utils.h ../tiles/tile.h ../utils/hash.h \
../database/database.h ../database/fonts.h ../windows/windows.h \
../dbwind/dbwind.h ../utils/main.h ../commands/commands.h \
../textio/textio.h ../graphics/graphics.h ../drc/drc.h \
../textio/txcommands.h ../utils/undo.h ../select/select.h \
../netmenu/netmenu.h
CmdRS.o: CmdRS.c ../tcltk/tclmagic.h ../utils/magic.h ../utils/stack.h \
../utils/geometry.h ../utils/utils.h ../tiles/tile.h ../utils/hash.h \
../database/database.h ../database/fonts.h ../windows/windows.h \
../dbwind/dbwind.h ../utils/main.h ../commands/commands.h \
../textio/textio.h ../graphics/graphics.h ../utils/tech.h ../drc/drc.h \
../textio/txcommands.h ../utils/malloc.h ../utils/netlist.h \
../netmenu/netmenu.h ../select/select.h ../utils/signals.h ../sim/sim.h
CmdTZ.o: CmdTZ.c ../tcltk/tclmagic.h ../utils/magic.h ../utils/malloc.h \
../utils/geometry.h ../utils/utils.h ../tiles/tile.h ../utils/hash.h \
../database/database.h ../windows/windows.h ../dbwind/dbwind.h \
../utils/main.h ../commands/commands.h ../textio/textio.h \
../textio/txcommands.h ../utils/signals.h ../utils/undo.h \
../select/select.h ../utils/styles.h ../wiring/wiring.h \
../utils/netlist.h ../netmenu/netmenu.h ../utils/tech.h ../drc/drc.h
CmdWizard.o: CmdWizard.c ../utils/magic.h ../utils/geometry.h \
../utils/malloc.h ../tiles/tile.h ../utils/hash.h ../database/database.h \
../windows/windows.h ../dbwind/dbwind.h ../utils/main.h \
../commands/commands.h ../utils/runstats.h ../textio/textio.h \
../graphics/graphics.h ../utils/signals.h ../utils/utils.h \
../textio/txcommands.h
CmdAuto.o: CmdAuto.c ../tcltk/tclmagic.h ../utils/magic.h \
../utils/geometry.h ../windows/windows.h ../textio/txcommands.h

View File

@ -12,10 +12,9 @@ SRCS = CmdSubrs.c CmdAB.c CmdCD.c CmdE.c CmdFI.c \
module: ${MAGICDIR}/readline/readline lib${MODULE}.o
# Delegate this task to the readline/Makefile
${MAGICDIR}/readline/readline:
@if ( ! test -f ${MAGICDIR}/readline/readline ) ; then \
(cd ${MAGICDIR}/readline; ln -s `ls | grep readline` readline) ; \
fi
${MAKE} -C ${MAGICDIR}/readline readline-create-symlinks
include ${MAGICDIR}/defs.mak
include ${MAGICDIR}/rules.mak

View File

@ -3,16 +3,16 @@
*
* Definitions for the commands module.
*
* *********************************************************************
* * Copyright (C) 1985, 1990 Regents of the University of California. *
* * Permission to use, copy, modify, and distribute this *
* * software and its documentation for any purpose and without *
* * fee is hereby granted, provided that the above copyright *
* * notice appear in all copies. The University of California *
* * makes no representations about the suitability of this *
* * software for any purpose. It is provided "as is" without *
* * express or implied warranty. Export of this software outside *
* * of the United States of America may require an export license. *
* *********************************************************************
* * Copyright (C) 1985, 1990 Regents of the University of California. *
* * Permission to use, copy, modify, and distribute this *
* * software and its documentation for any purpose and without *
* * fee is hereby granted, provided that the above copyright *
* * notice appear in all copies. The University of California *
* * makes no representations about the suitability of this *
* * software for any purpose. It is provided "as is" without *
* * express or implied warranty. Export of this software outside *
* * of the United States of America may require an export license. *
* *********************************************************************
*
* Needs to include: tiles.h, database.h
@ -20,11 +20,12 @@
* rcsid $Header: /usr/cvsroot/magic-8.0/commands/commands.h,v 1.3 2009/01/19 15:43:03 tim Exp $
*/
#ifndef _COMMANDS_H
#define _COMMANDS_H
#ifndef _MAGIC__COMMANDS__COMMANDS_H
#define _MAGIC__COMMANDS__COMMANDS_H
#include "windows/windows.h"
#include "database/database.h"
#include "textio/txcommands.h" /* TxCommand */
/*
* Name of default yank buffer
@ -50,18 +51,28 @@ extern TileTypeBitMask CmdYMAllButSpace;
/* --------------------- Global procedure headers --------------------- */
extern MagWindow *CmdGetRootBox();
extern MagWindow *CmdGetEditPoint();
extern MagWindow *CmdGetRootPoint();
extern bool CmdWarnWrite();
extern bool CmdParseLayers();
extern void CmdAddSlop();
extern void CmdLabelProc();
extern void CmdSetWindCaption();
extern CellUse *CmdGetSelectedCell();
extern bool CmdIllegalChars();
extern void CmdDoMacro();
extern TileType CmdFindNetProc();
extern bool CmdCheckForPaintFunc();
extern MagWindow *CmdGetEditPoint(Point *point, Rect *rect);
extern MagWindow *CmdGetRootPoint(Point *point, Rect *rect);
extern bool CmdWarnWrite(void);
extern bool CmdParseLayers(char *s, TileTypeBitMask *mask);
extern void CmdLabelProc(char *text, int font, int size, int rotate, int offx, int offy,
int pos, bool sticky, TileType type);
extern void CmdSetWindCaption(CellUse *newEditUse, CellDef *rootDef);
extern CellUse *CmdGetSelectedCell(Transform *pTrans);
extern bool CmdIllegalChars(char *string, char *illegal, char *msg);
extern TileType CmdFindNetProc(char *nodename, CellUse *use, Rect *rect, bool warn_not_found, bool *isvalid);
extern bool CmdCheckForPaintFunc(void);
#endif /* _COMMANDS_H */
/* C99 compat */
extern int cmdScaleCoord(MagWindow *w, char *arg, bool is_relative, bool is_x, int scale);
extern void FlatCopyAllLabels(SearchContext *scx, TileTypeBitMask *mask, int xMask, CellUse *targetUse);
extern bool cmdDumpParseArgs(char *cmdName, MagWindow *w, TxCommand *cmd, CellUse *dummy, SearchContext *scx);
extern void cmdFlushCell(CellDef *def, bool force_deref);
extern int cmdParseCoord(MagWindow *w, char *arg, bool is_relative, bool is_x);
extern void cmdSaveCell(CellDef *cellDef, char *newName, bool noninteractive, bool tryRename);
extern void CmdInit(void);
extern void CmdDoProperty(CellDef *def, TxCommand *cmd, int argstart);
extern void CmdPaintEraseButton(MagWindow *w, Point *refPoint, bool isPaint, bool isScreen);
#endif /* _MAGIC__COMMANDS__COMMANDS_H */

2
configure vendored
View File

@ -9,4 +9,4 @@
# script itself. It also sets up CFLAGS without the default optimizer
# flag (-O2).
( CFLAGS="-g"; export CFLAGS; cd scripts ; ./configure $* )
( CFLAGS=${CFLAGS:-"-g"}; export CFLAGS; cd scripts ; ./configure "$@" )

View File

@ -3,16 +3,16 @@
*
* Computation of boundaries of a database tile plane.
*
* *********************************************************************
* * Copyright (C) 1985, 1990 Regents of the University of California. *
* * Permission to use, copy, modify, and distribute this *
* * software and its documentation for any purpose and without *
* * fee is hereby granted, provided that the above copyright *
* * notice appear in all copies. The University of California *
* * makes no representations about the suitability of this *
* * software for any purpose. It is provided "as is" without *
* * express or implied warranty. Export of this software outside *
* * of the United States of America may require an export license. *
* *********************************************************************
* * Copyright (C) 1985, 1990 Regents of the University of California. *
* * Permission to use, copy, modify, and distribute this *
* * software and its documentation for any purpose and without *
* * fee is hereby granted, provided that the above copyright *
* * notice appear in all copies. The University of California *
* * makes no representations about the suitability of this *
* * software for any purpose. It is provided "as is" without *
* * express or implied warranty. Export of this software outside *
* * of the United States of America may require an export license. *
* *********************************************************************
*/
@ -25,31 +25,44 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
#include "utils/geometry.h"
#include "database/database.h"
#include "tiles/tile.h"
typedef struct dbcellboundstruct
{
Rect *area;
bool extended;
Rect *extended;
bool found;
} DBCellBoundStruct;
/*
* --------------------------------------------------------------------
* DBBoundCellPlane ---
*
* Find the extents of all subcells of the cell "def", both the
* extent of geometry (rect) and the extent of geometry plus any
* labels extending outside the extent of geometry (extended).
*
* Results:
* TRUE if subcells were found and measured; FALSE if no subcells
* were found (in which case "extended" and "rect" may not be
* valid).
*
* Side effects:
* Values may be recorded in "extended" and "rect".
* --------------------------------------------------------------------
*/
int
DBBoundCellPlane(def, extended, rect)
CellDef *def;
bool extended;
Rect *extended;
Rect *rect;
{
TreeFilter filter;
DBCellBoundStruct cbs;
int dbCellBoundFunc();
Plane *plane;
filter.tf_func = NULL;
filter.tf_arg = (ClientData)&cbs;
@ -58,48 +71,32 @@ DBBoundCellPlane(def, extended, rect)
cbs.found = FALSE;
*rect = GeoNullRect;
if (TiSrArea((Tile *)NULL, def->cd_planes[PL_CELL],
&TiPlaneRect, dbCellBoundFunc, (ClientData) &filter) == 0)
if (DBSrCellPlaneArea(def->cd_cellPlane, &TiPlaneRect,
dbCellBoundFunc, (ClientData) &filter) == 0)
return cbs.found;
else
return -1;
}
int
dbCellBoundFunc(tile, fp)
Tile *tile;
dbCellBoundFunc(use, fp)
CellUse *use;
TreeFilter *fp;
{
CellUse *use;
CellTileBody *body;
Rect *bbox;
DBCellBoundStruct *cbs;
cbs = (DBCellBoundStruct *)fp->tf_arg;
for (body = (CellTileBody *) TiGetBody(tile); body != NULL;
body = body->ctb_next)
if (cbs->found)
{
use = body->ctb_use;
bbox = &use->cu_bbox;
if ((BOTTOM(tile) <= bbox->r_ybot) && (RIGHT(tile) >= bbox->r_xtop))
{
if (cbs->found)
{
if (cbs->extended)
GeoInclude(&use->cu_extended, cbs->area);
else
GeoInclude(&use->cu_bbox, cbs->area);
}
else
{
if (cbs->extended)
*cbs->area = use->cu_extended;
else
*cbs->area = use->cu_bbox;
cbs->found = TRUE;
}
}
GeoInclude(&use->cu_extended, cbs->extended);
GeoInclude(&use->cu_bbox, cbs->area);
}
else
{
*cbs->extended = use->cu_extended;
*cbs->area = use->cu_bbox;
cbs->found = TRUE;
}
return 0;
}
@ -181,7 +178,7 @@ DBBoundPlane(plane, rect)
return (TRUE);
}
/*
* --------------------------------------------------------------------
*

View File

@ -3,16 +3,16 @@
*
* Place and Delete subcells
*
* *********************************************************************
* * Copyright (C) 1985, 1990 Regents of the University of California. *
* * Permission to use, copy, modify, and distribute this *
* * software and its documentation for any purpose and without *
* * fee is hereby granted, provided that the above copyright *
* * notice appear in all copies. The University of California *
* * makes no representations about the suitability of this *
* * software for any purpose. It is provided "as is" without *
* * express or implied warranty. Export of this software outside *
* * of the United States of America may require an export license. *
* *********************************************************************
* * Copyright (C) 1985, 1990 Regents of the University of California. *
* * Permission to use, copy, modify, and distribute this *
* * software and its documentation for any purpose and without *
* * fee is hereby granted, provided that the above copyright *
* * notice appear in all copies. The University of California *
* * makes no representations about the suitability of this *
* * software for any purpose. It is provided "as is" without *
* * express or implied warranty. Export of this software outside *
* * of the United States of America may require an export license. *
* *********************************************************************
*/
@ -37,7 +37,7 @@ int placeCellFunc();
int deleteCellFunc();
Tile * clipCellTile();
void dupTileBody();
void cellTileMerge();
void cellTileMerge();
bool ctbListMatch();
void freeCTBList();
@ -45,7 +45,7 @@ struct searchArg
{
CellUse * celluse;
Rect * rect;
Plane * plane;
BPlane * bplane;
};
#define TOPLEFT 10
@ -55,7 +55,22 @@ struct searchArg
#define TOPBOTTOMLEFTRIGHT 15
int dbCellDebug = 0;
void
dbInstanceUnplace(CellUse *use)
{
ASSERT(use != (CellUse *) NULL, "dbInstanceUnplace");
/* It's important that this code run with interrupts disabled,
* or else we could leave the subcell tile plane in a weird
* state.
*/
BPDelete(use->cu_parent->cd_cellPlane, use);
}
/*
* ----------------------------------------------------------------------------
*
@ -86,33 +101,73 @@ DBCellFindDup(use, parent)
* something identical to use?
*/
{
Tile *tile;
CellTileBody *body;
CellUse *checkUse;
BPEnum bpe;
CellUse *dupUse;
tile = TiSrPoint((Tile *) NULL, parent->cd_planes[PL_CELL],
&use->cu_bbox.r_ll);
for (body = (CellTileBody *) TiGetBody(tile);
body != NULL;
body = body->ctb_next)
{
checkUse = body->ctb_use;
if (use->cu_def != checkUse->cu_def) continue;
if ((use->cu_bbox.r_xbot != checkUse->cu_bbox.r_xbot)
|| (use->cu_bbox.r_xtop != checkUse->cu_bbox.r_xtop)
|| (use->cu_bbox.r_ybot != checkUse->cu_bbox.r_ybot)
|| (use->cu_bbox.r_ytop != checkUse->cu_bbox.r_ytop))
continue;
return checkUse;
}
return (CellUse *) NULL;
BPEnumInit(&bpe, parent->cd_cellPlane, &use->cu_bbox, BPE_EQUAL,
"DBCellFindDup");
while ((dupUse = BPEnumNext(&bpe)))
if (dupUse->cu_def == use->cu_def)
{
bool transMatch, arrayMatch, notXarray, notYarray;
/* Transforms must be equal---Aligned bounding boxes are
* an insufficient measure of exact overlap. Also, array
* counts and separation must match for arrayed devices
*/
transMatch = ((dupUse->cu_transform.t_a == use->cu_transform.t_a) &&
(dupUse->cu_transform.t_b == use->cu_transform.t_b) &&
(dupUse->cu_transform.t_c == use->cu_transform.t_c) &&
(dupUse->cu_transform.t_d == use->cu_transform.t_d) &&
(dupUse->cu_transform.t_e == use->cu_transform.t_e) &&
(dupUse->cu_transform.t_f == use->cu_transform.t_f));
/* First check if both use and dupUse are not arrays. */
notXarray = (dupUse->cu_xhi == dupUse->cu_xlo) &&
(use->cu_xhi == use->cu_xlo);
notYarray = (dupUse->cu_yhi == dupUse->cu_ylo) &&
(use->cu_yhi == use->cu_ylo);
arrayMatch = (notXarray && notYarray);
/* If they are arrays, then the array parameters must match. */
if (!notXarray && notYarray)
{
arrayMatch = ((dupUse->cu_xhi - dupUse->cu_xlo) ==
(use->cu_xhi - use->cu_xlo)) &&
(dupUse->cu_xsep == use->cu_xsep);
}
else if (!notYarray && notXarray)
{
arrayMatch = ((dupUse->cu_yhi - dupUse->cu_ylo) ==
(use->cu_yhi - use->cu_ylo)) &&
(dupUse->cu_ysep == use->cu_ysep);
}
else if (!notYarray && !notXarray)
{
arrayMatch = (((dupUse->cu_xhi - dupUse->cu_xlo) ==
(use->cu_xhi - use->cu_xlo)) &&
(dupUse->cu_xsep == use->cu_xsep)) &&
(((dupUse->cu_yhi - dupUse->cu_ylo) ==
(use->cu_yhi - use->cu_ylo)) &&
(dupUse->cu_ysep == use->cu_ysep));
}
if (transMatch && arrayMatch)
break;
}
BPEnumTerm(&bpe);
return dupUse;
}
/*
* ----------------------------------------------------------------------------
*
* DBPlaceCell --
* DBPlaceCellNoModify --
*
* Add a CellUse to the subcell tile plane of a CellDef.
* Assumes prior check that the new CellUse is not an exact duplicate
@ -130,41 +185,74 @@ DBCellFindDup(use, parent)
*/
void
DBPlaceCell (celluse, targetcell)
CellUse * celluse; /* new celluse to add to subcell tile plane */
CellDef * targetcell; /* parent cell's definition */
DBPlaceCell (use, def)
CellUse * use; /* new celluse to add to subcell tile plane */
CellDef * def; /* parent cell's definition */
{
Rect rect; /* argument to TiSrArea(), placeCellFunc() */
Plane * plane; /* argument to TiSrArea(), placeCellFunc() */
struct searchArg arg; /* argument to placeCellFunc() */
Rect rect; /* argument to DBSrCellPlaneArea(), placeCellFunc() */
BPlane *bplane; /* argument to DBSrCellPlaneArea(), placeCellFunc() */
struct searchArg arg; /* argument to placeCellFunc() */
ASSERT(celluse != (CellUse *) NULL, "DBPlaceCell");
celluse->cu_parent = targetcell;
plane = targetcell->cd_planes[PL_CELL]; /* assign plane */
rect = celluse->cu_bbox;
/* rect = celluse->cu_extended; */
arg.rect = &rect;
arg.celluse = celluse;
arg.plane = plane;
ASSERT(use != (CellUse *) NULL, "DBPlaceCell");
ASSERT(def, "DBPlaceCell");
/* To do: Check non-duplicate placement, check non-duplicate ID */
use->cu_parent = def;
/* Be careful not to permit interrupts during this, or the
* database could be left in a trashed state.
*/
SigDisableInterrupts();
(void) TiSrArea((Tile *) NULL, plane, &rect, placeCellFunc,
(ClientData) &arg);
targetcell->cd_flags |= CDMODIFIED|CDGETNEWSTAMP;
BPAdd(def->cd_cellPlane, use);
def->cd_flags |= CDMODIFIED|CDGETNEWSTAMP;
if (UndoIsEnabled())
DBUndoCellUse(celluse, UNDO_CELL_PLACE);
DBUndoCellUse(use, UNDO_CELL_PLACE);
SigEnableInterrupts();
}
/* Like DBPlaceCell(), but don't change the flags of the parent cell. */
/* This is needed by the bounding box recalculation routine, which may */
/* cause the cell to be deleted and replaced for the purpose of */
/* capturing the bounding box information in the BPlane structure, but */
/* this does not mean that anything in the parent cell has changed. */
void
DBPlaceCellNoModify (use, def)
CellUse * use; /* new celluse to add to subcell tile plane */
CellDef * def; /* parent cell's definition */
{
Rect rect; /* argument to DBSrCellPlaneArea(), placeCellFunc() */
BPlane *bplane; /* argument to DBSrCellPlaneArea(), placeCellFunc() */
struct searchArg arg; /* argument to placeCellFunc() */
ASSERT(use != (CellUse *) NULL, "DBPlaceCell");
ASSERT(def, "DBPlaceCell");
/* To do: Check non-duplicate placement, check non-duplicate ID */
use->cu_parent = def;
/* Be careful not to permit interrupts during this, or the
* database could be left in a trashed state.
*/
SigDisableInterrupts();
BPAdd(def->cd_cellPlane, use);
if (UndoIsEnabled())
DBUndoCellUse(use, UNDO_CELL_PLACE);
SigEnableInterrupts();
}
/*
* ----------------------------------------------------------------------------
* DBDeleteCell --
*
* Remove a CellUse from the subcell tile plane of a CellDef.
* If "nomodify" is TRUE, then don't set the parent cell's CDMODIFIED flag.
* This is needed when recomputing the bounding box, which should not by
* itself change the modified state.
*
* Results:
* None.
@ -176,19 +264,10 @@ DBPlaceCell (celluse, targetcell)
*/
void
DBDeleteCell (celluse)
CellUse * celluse;
DBDeleteCell (use)
CellUse * use;
{
Rect rect; /* argument to TiSrArea(), deleteCellFunc() */
Plane * plane; /* argument to TiSrArea(), deleteCellFunc() */
struct searchArg arg; /* argument to deleteCellFunc() */
ASSERT(celluse != (CellUse *) NULL, "DBDeleteCell");
plane = celluse->cu_parent->cd_planes[PL_CELL]; /* assign plane */
rect = celluse->cu_bbox;
arg.rect = &rect;
arg.plane = plane;
arg.celluse = celluse;
ASSERT(use != (CellUse *) NULL, "DBDeleteCell");
/* It's important that this code run with interrupts disabled,
* or else we could leave the subcell tile plane in a weird
@ -196,511 +275,47 @@ DBDeleteCell (celluse)
*/
SigDisableInterrupts();
(void) TiSrArea((Tile *) NULL, plane, &rect, deleteCellFunc,
(ClientData) &arg);
celluse->cu_parent->cd_flags |= CDMODIFIED|CDGETNEWSTAMP;
dbInstanceUnplace(use);
use->cu_parent->cd_flags |= CDMODIFIED|CDGETNEWSTAMP;
if (UndoIsEnabled())
DBUndoCellUse(celluse, UNDO_CELL_DELETE);
celluse->cu_parent = (CellDef *) NULL;
DBUndoCellUse(use, UNDO_CELL_DELETE);
use->cu_parent = (CellDef *) NULL;
SigEnableInterrupts();
}
/*
* ----------------------------------------------------------------------------
* placeCellFunc --
* DBDeleteCellNoModify --
*
* Add a new subcell to a tile.
* Clip the tile with respect to the subcell's bounding box.
* Insert the new CellTileBody into the linked list in ascending order
* based on the celluse pointer.
* This function is passed to TiSrArea.
*
* Results:
* 0 is always returned.
*
* Side effects:
* Modifies the subcell tile plane of the appropriate CellDef.
* Allocates a new CellTileBody.
* ----------------------------------------------------------------------------
*/
int
placeCellFunc (tile, arg)
Tile * tile; /* target tile */
struct searchArg * arg; /* celluse, rect, plane */
{
Tile * tp;
CellTileBody * body, * ctp, * ctplast;
#ifdef CELLDEBUG
if (dbCellDebug) TxPrintf("placeCellFunc called %x\n",tile);
#endif /* CELLDEBUG */
tp = clipCellTile (tile, arg->plane, arg->rect);
body = (CellTileBody *) mallocMagic((unsigned) (sizeof (CellTileBody)));
body->ctb_use = arg->celluse;
ctp = (CellTileBody *) tp->ti_body;
ctplast = ctp;
while ((ctp != (CellTileBody *) NULL) && (ctp->ctb_use > body->ctb_use))
{
ctplast = ctp;
ctp = ctp->ctb_next;
}
body->ctb_next = ctp;
if (ctp == (CellTileBody *) tp->ti_body) /* empty list or front of list */
TiSetBody(tp, body);
else /* after at least one CellTileBody */
ctplast->ctb_next = body;
/* merge tiles back into the the plane */
/* requires that TiSrArea visit tiles in NW to SE wavefront */
if ( RIGHT(tp) == arg->rect->r_xtop)
{
if (BOTTOM(tp) == arg->rect->r_ybot)
cellTileMerge (tp, arg->plane, TOPBOTTOMLEFTRIGHT);
else
cellTileMerge (tp, arg->plane, TOPLEFTRIGHT);
}
else if (BOTTOM(tp) == arg->rect->r_ybot)
cellTileMerge (tp, arg->plane, TOPBOTTOMLEFT);
else
cellTileMerge (tp, arg->plane, TOPLEFT);
return 0;
}
/*
* ----------------------------------------------------------------------------
* deleteCellFunc --
*
* Remove a subcell from a tile.
* This function is passed to TiSrArea.
*
* Results:
* Always returns 0.
*
* Side effects:
* Modifies the subcell tile plane of the appropriate CellDef.
* Deallocates a CellTileBody.
* ----------------------------------------------------------------------------
*/
int
deleteCellFunc (tile, arg)
Tile * tile;
struct searchArg * arg; /* plane, rect */
{
CellTileBody * ctp; /* CellTileBody to be freed */
CellTileBody * ctplast; /* follows one behind ctp */
CellUse * celluse;
#ifdef CELLDEBUG
if (dbCellDebug) TxPrintf("deleteCellFunc called %x\n",tile);
#endif /* CELLDEBUG */
celluse = arg->celluse;
/* find the appropriate CellTileBody in the linked list */
ctp = (CellTileBody *) tile->ti_body;
ctplast = ctp;
while ((ctp != (CellTileBody *) NULL) && (ctp->ctb_use != celluse))
{
ctplast = ctp;
ctp = ctp->ctb_next;
}
/* there should have been a match */
if (ctp == (CellTileBody *) NULL)
{
ASSERT (ctp != (CellTileBody *) NULL, "deleteCellFunc");
return 0;
}
/* relink the list with one CellTileBody deleted */
if (ctp == ctplast) /* front of list */
TiSetBody(tile, ctp->ctb_next);
else /* beyond front of list */
ctplast->ctb_next = ctp->ctb_next;
freeMagic((char *) ctp);
/* merge tiles back into the the plane */
/* requires that TiSrArea visit tiles in NW to SE wavefront */
if ( RIGHT(tile) == arg->rect->r_xtop)
{
if (BOTTOM(tile) == arg->rect->r_ybot)
cellTileMerge (tile, arg->plane, TOPBOTTOMLEFTRIGHT);
else
cellTileMerge (tile, arg->plane, TOPLEFTRIGHT);
}
else if (BOTTOM(tile) == arg->rect->r_ybot)
cellTileMerge (tile, arg->plane, TOPBOTTOMLEFT);
else
cellTileMerge (tile, arg->plane, TOPLEFT);
return (0);
}
/*
* ----------------------------------------------------------------------------
* clipCellTile --
*
* Clip the given tile against the given rectangle.
*
* Results:
* Returns a pointer to the clipped tile.
*
* Side effects:
* Modifies the database plane that contains the given tile.
* ----------------------------------------------------------------------------
*/
Tile *
clipCellTile (tile, plane, rect)
Tile * tile;
Plane * plane;
Rect * rect;
{
Tile * newtile;
if (TOP(tile) > rect->r_ytop)
{
#ifdef CELLDEBUG
if (dbCellDebug) TxPrintf("clipCellTile calls TiSplitY TOP\n");
#endif /* CELLDEBUG */
newtile = TiSplitY (tile, rect->r_ytop); /* no merge */
dupTileBody (tile, newtile);
}
if (BOTTOM(tile) < rect->r_ybot)
{
#ifdef CELLDEBUG
if (dbCellDebug) TxPrintf("clipCellTile calls TiSplitY BOTTOM\n");
#endif /* CELLDEBUG */
newtile = tile;
tile = TiSplitY (tile, rect->r_ybot); /* no merge */
dupTileBody (newtile, tile);
}
if (RIGHT(tile) > rect->r_xtop)
{
#ifdef CELLDEBUG
if (dbCellDebug) TxPrintf("clipCellTile calls TiSplitX RIGHT\n");
#endif /* CELLDEBUG */
newtile = TiSplitX (tile, rect->r_xtop);
dupTileBody (tile, newtile);
cellTileMerge (newtile, plane, TOPBOTTOM);
}
if (LEFT(tile) < rect->r_xbot)
{
#ifdef CELLDEBUG
if (dbCellDebug) TxPrintf("clipCellTile calls TiSplitX LEFT\n");
#endif /* CELLDEBUG */
newtile = tile;
tile = TiSplitX (tile, rect->r_xbot);
dupTileBody (newtile, tile);
cellTileMerge (newtile, plane, TOPBOTTOM);
}
return (tile);
} /* clipCellTile */
/*
* ----------------------------------------------------------------------------
* dupTileBody --
*
* Duplicate the body of an old tile as the body for a new tile.
*
* Results:
* None.
*
* Side effects:
* Allocates new CellTileBodies unless the old tile was a space tile.
* ----------------------------------------------------------------------------
*/
void
dupTileBody (oldtp, newtp)
Tile * oldtp;
Tile * newtp;
{
CellTileBody * oldctb, * newctb, * newctblast;
oldctb = (CellTileBody *) oldtp->ti_body;
if (oldctb != (CellTileBody *) NULL)
{
newctb = (CellTileBody *) mallocMagic((unsigned) (sizeof (CellTileBody)));
TiSetBody(newtp, newctb);
newctb->ctb_use = oldctb->ctb_use;
oldctb = oldctb->ctb_next;
newctblast = newctb;
while (oldctb != (CellTileBody *) NULL)
{
newctb = (CellTileBody *) mallocMagic((unsigned) (sizeof (CellTileBody)));
newctblast->ctb_next = newctb;
newctb->ctb_use = oldctb->ctb_use;
oldctb = oldctb->ctb_next;
newctblast = newctb;
}
newctblast->ctb_next = (CellTileBody *) NULL;
}
else TiSetBody(newtp, NULL);
} /* dupTileBody */
/*
* ----------------------------------------------------------------------------
* cellTileMerge --
*
* Merge the given tile with its plane in the directions specified.
* Remove a CellUse from the subcell tile plane of a CellDef, as above,
* but don't set the parent cell's CDMODIFIED flag. This is needed when
* recomputing the bounding box, which should not by itself change the
* modified state.
*
* Results:
* None.
*
* Side effects:
* Modifies the database plane that contains the given tile.
* Modifies the subcell tile plane of the CellDef, sets the
* parent pointer of the deleted CellUse to NULL.
* ----------------------------------------------------------------------------
*/
void
cellTileMerge (tile, plane, direction)
Tile * tile;
Plane * plane;
int direction; /* TOP = 8, BOTTOM = 4, LEFT = 2, RIGHT = 1 */
DBDeleteCellNoModify (use)
CellUse * use;
{
Point topleft, bottomright;
Tile * dummy, * tpleft, * tpright, * tp1, * tp2;
ASSERT(use != (CellUse *) NULL, "DBDeleteCell");
#ifdef CELLDEBUG
if (dbCellDebug) TxPrintf("cellTileMerge %x\n",tile);
#endif /* CELLDEBUG */
/* It's important that this code run with interrupts disabled,
* or else we could leave the subcell tile plane in a weird
* state.
*/
topleft.p_x = LEFT(tile);
topleft.p_y = TOP(tile);
bottomright.p_x = RIGHT(tile);
bottomright.p_y = BOTTOM(tile);
if ((direction >> 1) % 2) /* LEFT */
{
tpright = tile;
tpleft = BL(tpright);
#ifdef CELLDEBUG
if (dbCellDebug) TxPrintf("LEFT %x %x\n",tpleft,tpright);
#endif /* CELLDEBUG */
while (BOTTOM(tpleft) < topleft.p_y) /* go up left edge */
{
if (ctbListMatch (tpleft, tpright))
{
if (BOTTOM(tpleft) < BOTTOM(tpright))
{
dummy = tpleft;
tpleft = TiSplitY (tpleft, BOTTOM (tpright));
dupTileBody (dummy, tpleft);
}
else if (BOTTOM(tpleft) > BOTTOM(tpright))
{
dummy = tpright;
tpright = TiSplitY (tpright, BOTTOM (tpleft));
dupTileBody (dummy, tpright);
}
if (TOP(tpleft) > TOP(tpright))
{
dummy = TiSplitY (tpleft, TOP(tpright));
dupTileBody (tpleft, dummy);
}
else if (TOP(tpright) > TOP(tpleft))
{
dummy = TiSplitY (tpright, TOP(tpleft));
dupTileBody (tpright, dummy);
}
freeCTBList (tpright);
TiJoinX (tpleft, tpright, plane); /* tpright disappears */
tpright = RT(tpleft);
if (BOTTOM(tpright) < topleft.p_y) tpleft = BL(tpright);
else tpleft = tpright; /* we're off the top of the tile */
/* this will break the while loop */
} /* if (ctbListMatch (tpleft, tpright)) */
else tpleft = RT(tpleft);
} /* while */
tile = tpleft; /* for TiSrPoint in next IF statement */
}
if (direction % 2) /* RIGHT */
{
tpright = TiSrPoint (tile, plane, &bottomright);
--(bottomright.p_x);
tpleft = TiSrPoint (tpright, plane, &bottomright);
++(bottomright.p_x);
#ifdef CELLDEBUG
if (dbCellDebug) TxPrintf("RIGHT %x %x\n",tpleft,tpright);
#endif /* CELLDEBUG */
while (BOTTOM(tpright) < topleft.p_y) /* go up right edge */
{
if (ctbListMatch (tpleft, tpright))
{
if (BOTTOM(tpright) < BOTTOM(tpleft))
{
dummy = tpright;
tpright = TiSplitY (tpright, BOTTOM(tpleft));
dupTileBody (dummy, tpright);
}
else if (BOTTOM(tpleft) < BOTTOM(tpright))
{
dummy = tpleft;
tpleft = TiSplitY (tpleft, BOTTOM(tpright));
dupTileBody (dummy, tpleft);
}
if (TOP(tpright) > TOP(tpleft))
{
dummy = TiSplitY (tpright, TOP(tpleft));
dupTileBody (tpright, dummy);
}
else if (TOP(tpleft) > TOP(tpright))
{
dummy = TiSplitY (tpleft, TOP(tpright));
dupTileBody (tpleft, dummy);
}
freeCTBList (tpright);
TiJoinX (tpleft, tpright, plane); /* tpright disappears */
tpright = RT(tpleft);
while (LEFT(tpright) > bottomright.p_x) tpright = BL(tpright);
/* tpleft can be garbage if we're off the top of the loop, */
/* but it doesn't matter since the expression tests tpright */
tpleft = BL(tpright);
} /* if (ctbListMatch (tpleft, tpright)) */
else
{
tpright = RT(tpright);
while (LEFT(tpright) > bottomright.p_x) tpright = BL(tpright);
tpleft = BL(tpright); /* left side merges may have */
/* created more tiles */
}
} /* while */
tile = tpright; /* for TiSrPoint in next IF statement */
}
if ((direction >> 3) % 2) /* TOP */
{
tp1 = TiSrPoint (tile, plane, &topleft); /* merge across top */
--(topleft.p_y);
tp2 = TiSrPoint (tile, plane, &topleft);/* top slice of original tile */
++(topleft.p_y);
#ifdef CELLDEBUG
if (dbCellDebug) TxPrintf("TOP %x %x\n",tp1,tp2);
#endif /* CELLDEBUG */
if ((LEFT(tp1) == LEFT(tp2) ) &&
(RIGHT(tp1) == RIGHT(tp2)) &&
(ctbListMatch (tp1, tp2) ))
{
freeCTBList (tp2);
TiJoinY (tp1, tp2, plane);
}
tile = tp1; /* for TiSrPoint in next IF statement */
}
if ((direction >> 2) % 2) /* BOTTOM */
{
--(bottomright.p_x);
/* bottom slice of orig tile */
tp1 = TiSrPoint (tile, plane, &bottomright);
--(bottomright.p_y);
tp2 = TiSrPoint (tile, plane, &bottomright); /* merge across bottom */
#ifdef CELLDEBUG
if (dbCellDebug) TxPrintf("BOTTOM %x %x\n",tp1,tp2);
#endif /* CELLDEBUG */
if ((LEFT(tp1) == LEFT(tp2) ) &&
(RIGHT(tp1) == RIGHT(tp2)) &&
(ctbListMatch (tp1, tp2) ))
{
freeCTBList (tp2);
TiJoinY (tp1, tp2, plane);
}
}
}
/*
* ----------------------------------------------------------------------------
* freeCTBList --
*
* Free all CellTileBodies attached to the give tile.
*
* Results:
* None.
*
* Side effects:
* Frees CellTileBodies.
* ----------------------------------------------------------------------------
*/
void
freeCTBList (tile)
Tile * tile;
{
CellTileBody * ctp, * ctplast;
ctp = (CellTileBody *) tile->ti_body;
while (ctp != (CellTileBody *) NULL)
{
ctplast = ctp;
ctp = ctp->ctb_next;
freeMagic((char *) ctplast);
}
TiSetBody(tile, NULL);
}
/*
* ----------------------------------------------------------------------------
* ctbListMatch --
*
* Compare two linked lists of CellTileBodies, assuming that they are
* sorted in ascending order by celluse pointers.
*
* Results:
* True if the tiles have identical lists of CellTileBodies.
*
* Side effects:
* None.
* ----------------------------------------------------------------------------
*/
bool
ctbListMatch (tp1, tp2)
Tile * tp1, * tp2;
{
CellTileBody * ctp1, * ctp2;
ctp1 = (CellTileBody *) tp1->ti_body;
ctp2 = (CellTileBody *) tp2->ti_body;
while (ctp1 && ctp2 && (ctp1->ctb_use == ctp2->ctb_use))
ctp1 = ctp1->ctb_next, ctp2 = ctp2->ctb_next;
return ((ctp1 == (CellTileBody *) NULL) && (ctp2 == (CellTileBody *) NULL));
SigDisableInterrupts();
dbInstanceUnplace(use);
if (UndoIsEnabled())
DBUndoCellUse(use, UNDO_CELL_DELETE);
use->cu_parent = (CellDef *) NULL;
SigEnableInterrupts();
}

View File

@ -4,16 +4,16 @@
* Procedures for calculating and changing cell bounding boxes,
* and for manipulating arrays of cells.
*
* *********************************************************************
* * Copyright (C) 1985, 1990 Regents of the University of California. *
* * Permission to use, copy, modify, and distribute this *
* * software and its documentation for any purpose and without *
* * fee is hereby granted, provided that the above copyright *
* * notice appear in all copies. The University of California *
* * makes no representations about the suitability of this *
* * software for any purpose. It is provided "as is" without *
* * express or implied warranty. Export of this software outside *
* * of the United States of America may require an export license. *
* *********************************************************************
* * Copyright (C) 1985, 1990 Regents of the University of California. *
* * Permission to use, copy, modify, and distribute this *
* * software and its documentation for any purpose and without *
* * fee is hereby granted, provided that the above copyright *
* * notice appear in all copies. The University of California *
* * makes no representations about the suitability of this *
* * software for any purpose. It is provided "as is" without *
* * express or implied warranty. Export of this software outside *
* * of the United States of America may require an export license. *
* *********************************************************************
*/
@ -34,7 +34,7 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
#include "dbwind/dbwind.h"
#include "utils/undo.h"
/*
*-----------------------------------------------------------------------------
*
@ -59,15 +59,15 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
*/
char *
DBPrintUseId(scx, name, size, display_only)
SearchContext *scx; /* Pointer to current search context, specifying a
DBPrintUseId(
SearchContext *scx, /* Pointer to current search context, specifying a
* cell use and X,Y array indices.
*/
char *name; /* Pointer to string into which we will copy the
char *name, /* Pointer to string into which we will copy the
* print name of this instance.
*/
int size; /* Maximum number of characters to copy into string. */
bool display_only; /* TRUE if called for displaying only */
int size, /* Maximum number of characters to copy into string. */
bool display_only) /* TRUE if called for displaying only */
{
CellUse *use = scx->scx_use;
char *sp, *id, *ep;
@ -105,7 +105,7 @@ DBPrintUseId(scx, name, size, display_only)
return (sp);
}
/*
* ----------------------------------------------------------------------------
*
@ -143,7 +143,7 @@ DBCellClearAvail(cellDef)
{
cellDef->cd_flags &= ~(CDNOTFOUND|CDAVAILABLE);
}
/*
* ----------------------------------------------------------------------------
*
@ -185,7 +185,7 @@ DBCellSetModified(cellDef, ismod)
if (ismod)
cellDef->cd_flags |= CDMODIFIED|CDGETNEWSTAMP;
}
/*
* ----------------------------------------------------------------------------
*
@ -253,7 +253,7 @@ DBComputeUseBbox(use)
GeoTransRect(&use->cu_transform, &childRect, &use->cu_bbox);
GeoTransRect(&use->cu_transform, &childExtend, &use->cu_extended);
}
/*
* ----------------------------------------------------------------------------
*
@ -276,7 +276,7 @@ DBIsChild(cu1, cu2)
{
return (cu1->cu_parent == cu2->cu_def);
}
/*
* ----------------------------------------------------------------------------
*
@ -305,7 +305,7 @@ DBSetArray(fromCellUse, toCellUse)
toCellUse->cu_xsep = fromCellUse->cu_xsep;
toCellUse->cu_ysep = fromCellUse->cu_ysep;
}
/*
* ----------------------------------------------------------------------------
*
@ -330,7 +330,7 @@ DBSetTrans(cellUse, trans)
cellUse->cu_transform = *trans;
DBComputeUseBbox(cellUse);
}
/*
* ----------------------------------------------------------------------------
*
@ -389,7 +389,7 @@ DBMakeArray(cellUse, rootToCell, xlo, ylo, xhi, yhi, xsep, ysep)
DBComputeUseBbox(cellUse);
}
/*
* ----------------------------------------------------------------------------
*
@ -483,7 +483,7 @@ DBArrayOverlap(cu, parentRect, pxlo, pxhi, pylo, pyhi)
* The intent is that "outlo" will be the smaller of the two
* coordinates, and "outhi" the larger.
*/
/* Even though it should never happen, handle zero spacings
* gracefully.
*/
@ -545,7 +545,7 @@ DBArrayOverlap(cu, parentRect, pxlo, pxhi, pylo, pyhi)
*pyhi = outyhi;
}
}
/*
* ----------------------------------------------------------------------------
*
@ -616,16 +616,12 @@ dbReComputeBboxFunc(cellDef, boundProc, recurseProc)
bool foundAny;
int pNum;
/* Cells which declare their bounding box to be fixed */
/* must return immediately. */
if (cellDef->cd_flags & CDFIXEDBBOX) return;
/*
* Include area of subcells separately
*/
if ((foundAny = DBBoundCellPlane(cellDef, TRUE, &rect)) > 0)
area = rect;
if (!((foundAny = DBBoundCellPlane(cellDef, &extended, &rect)) > 0))
extended = GeoNullRect;
area = rect;
for (pNum = PL_PAINTBASE; pNum < DBNumPlanes; pNum++)
if (pNum != PL_DRC_CHECK)
@ -639,7 +635,7 @@ dbReComputeBboxFunc(cellDef, boundProc, recurseProc)
}
/*
* Include the area of labels, too.
* Include the area of label anchors, too.
*/
for (label = cellDef->cd_labels; label != NULL; label = label->lab_next)
{
@ -661,7 +657,11 @@ dbReComputeBboxFunc(cellDef, boundProc, recurseProc)
}
}
extended = area;
/* Make sure the extended bounding box includes the area of all
* paint material just found, then include the area of all text
* in the current cell.
*/
GeoInclude(&area, &extended);
if (foundAny)
{
for (label = cellDef->cd_labels; label != NULL; label = label->lab_next)
@ -678,6 +678,7 @@ dbReComputeBboxFunc(cellDef, boundProc, recurseProc)
degenerate = TRUE;
area.r_xbot = area.r_ybot = 0;
area.r_xtop = area.r_ytop = 1;
extended = area;
}
else degenerate = FALSE;
@ -692,7 +693,11 @@ dbReComputeBboxFunc(cellDef, boundProc, recurseProc)
if (area.r_ybot == area.r_ytop)
area.r_ytop = area.r_ybot + 1;
if (degenerate) extended = area;
if (extended.r_xbot == extended.r_xtop)
extended.r_xtop = extended.r_xbot + 1;
if (extended.r_ybot == extended.r_ytop)
extended.r_ytop = extended.r_ybot + 1;
/* Did the bounding box change? If not then there's no need to
* recompute the parents. If the cell has no material, then
@ -728,7 +733,7 @@ dbReComputeBboxFunc(cellDef, boundProc, recurseProc)
*/
parent = use->cu_parent;
DBDeleteCell(use);
DBDeleteCellNoModify(use);
use->cu_parent = parent;
}
@ -756,7 +761,7 @@ dbReComputeBboxFunc(cellDef, boundProc, recurseProc)
if ((parent = use->cu_parent) != (CellDef *) NULL)
{
parent->cd_flags |= CDBOXESCHANGED;
DBPlaceCell(use, parent);
DBPlaceCellNoModify(use, parent);
if (last != parent)
{
if (last != NULL) (*recurseProc)(last);
@ -770,7 +775,7 @@ dbReComputeBboxFunc(cellDef, boundProc, recurseProc)
if ((last != NULL) && (parent != NULL)) (*recurseProc)(parent);
UndoEnable();
}
/*
* ----------------------------------------------------------------------------
*
@ -817,7 +822,7 @@ DBComputeArrayArea(area, cellUse, x, y, prect)
prect->r_ybot = area->r_ybot + ydelta;
prect->r_ytop = area->r_ytop + ydelta;
}
/*
* ----------------------------------------------------------------------------
*

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -3,16 +3,16 @@
*
* Cell selection.
*
* *********************************************************************
* * Copyright (C) 1985, 1990 Regents of the University of California. *
* * Permission to use, copy, modify, and distribute this *
* * software and its documentation for any purpose and without *
* * fee is hereby granted, provided that the above copyright *
* * notice appear in all copies. The University of California *
* * makes no representations about the suitability of this *
* * software for any purpose. It is provided "as is" without *
* * express or implied warranty. Export of this software outside *
* * of the United States of America may require an export license. *
* *********************************************************************
* * Copyright (C) 1985, 1990 Regents of the University of California. *
* * Permission to use, copy, modify, and distribute this *
* * software and its documentation for any purpose and without *
* * fee is hereby granted, provided that the above copyright *
* * notice appear in all copies. The University of California *
* * makes no representations about the suitability of this *
* * software for any purpose. It is provided "as is" without *
* * express or implied warranty. Export of this software outside *
* * of the United States of America may require an export license. *
* *********************************************************************
*/
@ -55,7 +55,7 @@ struct selectArg
/* Forward declarations */
int dbSelectCellSr();
/*
* ----------------------------------------------------------------------------
*
@ -251,7 +251,7 @@ dbSelectCellSr(scx, arg)
/* compute lastArea (using long long to avoid overflow). */
{
int xDiff, yDiff;
xDiff = pbx->r_xtop - pbx->r_xbot;
yDiff = pbx->r_ytop - pbx->r_ybot;
/* BY NP */
@ -281,7 +281,7 @@ dbSelectCellSr(scx, arg)
n = arg->csa_bestpath->tp_last - arg->csa_bestpath->tp_next;
strncpy(arg->csa_bestpath->tp_next, cpath->tp_first, n);
arg->csa_bestpath->tp_next[n] = '\0';
/* Pop last component of current path */
cpath->tp_next = savenext;
*savenext = '\0';
@ -308,7 +308,7 @@ dbSelectCellSr(scx, arg)
/* compute bestArea (using long long to avoid overflow). */
{
int xDiff, yDiff;
xDiff = pbx->r_xtop - pbx->r_xbot;
yDiff = pbx->r_ytop - pbx->r_ybot;
bestArea = (dlong)xDiff * (dlong)yDiff;

Some files were not shown because too many files have changed in this diff Show More