Commit Graph

133 Commits

Author SHA1 Message Date
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 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 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 bcd81c74b2 tclmagic.c: RLIMIT_NOFILE to 4096 on startup (only for TCL9 envs) 2025-04-09 15:19:25 -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 aa35a612b0 tclmagic.c: match new textio prototypes for constified implementations 2025-02-23 10:24:40 -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
Darryl L. Miles efcf36f348 Remove superfluous parenthesis around regular type declarations 2025-01-04 11:31:17 -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 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 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 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 Miles 0259fdc990 tclmagic.c: printf style constify fmt call-site 2025-01-03 09:08:14 +00: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 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
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 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 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 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 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
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 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 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 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 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 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 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 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 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
Brad Smith c8940ab219 Allow for bash in locations other than /bin 2023-04-22 14:13:57 -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 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 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 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 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 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 075262b2ef Added the ability to read compressed .mag files (writing is not yet
supported).  Fixed the long-standing issue in which DRC does not
get stopped by the "drc off" command (the behavior for interrupting
the DRC was dependent on the DRC being turned on, and the "drc off"
command was turning it off before breaking, causing the interrupt
to be ignored).
2022-11-02 17:12:46 -04:00
Alessandro De Laurenzis b306a39560 Compatibility with C99 standard
This commit makes the code (mostly) C99-compatible, enabling to compile
it without the -Wno-error=implicit-function-declaration flag. This
way, Magic becomes usable on arm64 architectures, specifically on Apple
computers with M1/M2 SoC.
2022-10-29 06:07:46 +02:00
Tim Edwards 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
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 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