Holger Vogt
3341b2e045
Bug 665: enable compiling the code models with link time optimization.
...
Fix provided by Giles Atkinson.
Still the build of ngspice fails (tested with Cygwin) at the linking stage.
2024-05-01 10:25:12 +02:00
Holger Vogt
ace932e1b9
Patches provided by Carsten Schoenert: Misspellings, File access
2023-12-31 13:51:05 +01:00
Holger Vogt
f99a137eb3
Patch for snprintf provided by Marco Atzeri
2023-12-29 10:59:56 +01:00
Holger Vogt
d1abc8f6c7
typo
2023-12-22 13:11:21 +01:00
Giles Atkinson
ffcf3b24d9
Improve efficiency and irreversible CM support in EVTcall_hybrids() by
...
halting calls to code models as soon as the timestep is chenged.
This should have been included in 508fad0f55 .
2023-12-19 14:26:56 +01:00
Giles Atkinson
c18447f9f5
Add the support files for co-simulation with Verilog code
...
compiled by Verilator. Also add script files to Visual Studio builds
that are already installed by the Makefile builds.
2023-11-27 20:55:59 +00:00
Giles Atkinson
566e2938f4
Add XSPICE code model d_cosim, a generic adaptor for digital cosimulation.
2023-11-27 14:50:21 +00:00
Giles Atkinson
12fe7b90c4
Add new code model function cm_irreversible(). This may only be
...
called from an XSPICE code model's INIT call and has three effects:
the instance is treated as "hybrid" even when it does not use both
port types; its position in the hybrids array is adusted; and it
is explicitly notifed when called just befoore the end of an
analog time-step.
2023-11-26 18:30:53 +00:00
Giles Atkinson
34e6c4abea
Convert XSPICE's hybrid_index array to instance pointers.
...
That simplifies code and will be needed for irreversible code model support.
2023-11-26 18:29:23 +00:00
dwarning
2cf2693706
few code cleanings
2023-11-12 17:04:36 +01:00
Giles Atkinson
10386ee3e3
Commit [35d338]ngspice partly reverted commit 423f9a9db to fix deletion
...
of source files if make was accidentally used in the source tree.
That caused the original bug to return. Fix the problem by deleting
the generated source files by name (no such files exist in source.
Also make the generated files depend on cmpp, making 'make clean'
unnecessary after a chenge to cmpp.
2023-11-09 12:08:02 +00:00
dwarning
35d338f256
partly revert commit 423f9a9db - don't remove xspice/icm .c files
2023-11-08 07:59:36 +01:00
Brian Taylor
04c68d5f30
Cleanup child processes on Windows VisualC and Mingw. On Linux those processes quit when ngspice quits.
2023-10-28 19:45:24 +02:00
Brian Taylor
4219efb5d5
Make it explicit that null output ports are not allowed. The output port vector bounds are always >= 1.
2023-10-28 19:43:46 +02:00
Brian Taylor
c83d11c9c0
Call cm_cexit() to prevent the simulator running when d_process initialization errors occur.
2023-10-28 19:43:23 +02:00
Holger Vogt
21761207bc
Change license to 3-clause BSD (see
...
https://sourceforge.net/p/ngspice/ngspice/merge-requests/6/?limit=25#fd4f/73e6 )
2023-10-28 14:55:13 +02:00
Brian Taylor
09f070f582
Error handling improvements in cfunc.mod. Ensure that d_process.h wiil always respond to version and interface checks sent from sendheader. This is needed so that the pipe reads in sendheader do not cause Windows to hang when the interface version and in/out counts do not match. This hang was the cause of errors not being reported and the Windows gui hanging. Startup and header checks are now detected in cm_d_process, and the simulator will run but with runtime errors since a d_process model cannot be completely instantiated after initial errors. It would be good to find a means of gracefully halting the simulation run.
2023-10-28 11:00:33 +02:00
Brian Taylor
8c72a76844
Another attempt at clean up of error handling and reporting. It's OK on limux and cygwin, but Windows VisualC is being stubborn. I would prefer not to have to call exit(1) just for Windows, since then nothing is reported and the gui disappears in a puff of smoke. Even without the exit calls nothing gets reported with the Windows gui which will hang when there are errors detected by d_process.
2023-10-28 11:00:28 +02:00
Brian Taylor
4eae039779
Add modifications note.
2023-10-28 11:00:23 +02:00
Brian Taylor
4530cde8e2
Use Xspice cm_message_send to report errors rathen than printing to stderr and calling exit. When a d_process model has errors found in start(), sendheader(), and dprocess_exchangedata() these are reported, but if the model is run a SIGINT is raised. There must be a better way of stopping the simulator.
2023-10-28 11:00:18 +02:00
Brian Taylor
df28fabc42
Restore the deleted unused params to be backword compatible. Handle the case where the d_process instance has a null in vector, so that N_din is zero. This allows the model to be just a pattern generator. Add include to cmproto.h to avoid a forward ref. to an enum type.
2023-10-28 11:00:03 +02:00
Brian Taylor
307ba1985b
Remove unused reset_state param; do not allow null in and out, so there is at least 1 input and 1 output.
2023-10-28 10:59:52 +02:00
Brian Taylor
7820940be3
Remove the unused reset_delay param.
2023-10-28 10:59:42 +02:00
Brian Taylor
e762047fc2
Add array bounds check, fix typos.
2023-10-28 10:59:34 +02:00
Brian Taylor
022a340ddb
Fix VisualC and Mingw compiler warnings.
2023-10-28 10:59:11 +02:00
Brian Taylor
cccb4a1559
Add callback to free process memory.
2023-10-28 10:58:39 +02:00
Brian Taylor
33780055ee
Add MODIFICATIONS note, cleanup white space.
2023-10-28 10:58:28 +02:00
Brian Taylor
5c4352d02f
Add __MINGW64__ defines for builds on mingw with msys.
2023-10-28 10:58:15 +02:00
Brian Taylor
3bb6e86015
Add Windows Visual Studio support for the Isotel d_process xspice digital model. The Isotel mixedsim-master/examples/embedded/motorforce C code needs to have minor changes for _MSC_VER defines, and are not included with this commit. The changes relate to using #pragma pack(push, 1)...#pragma pack(pop) around some structs, and setting stdin/stdout in binary mode. It is doubtful that the cfunc.mod will compile on mingw or cygwin since I don't know if they support pipe/fork/exec/spawn calls. The code builds and runs on Windows, Linux, and MacOS. In the future, Giles Atkinson is looking at allowing Xspice models to load shared libraries (.dll, .so) which will avoid creating and communicating with an external program.
2023-10-28 10:58:06 +02:00
Holger Vogt
10d7297798
Add cm_cecit(). If the input file could not be opened, stop ngspice.
2023-10-21 15:52:10 +02:00
Holger Vogt
19ebfb1887
Add a code model function cm_exit(const int exitcode).
...
This function calls controlled_exit(exitcode) to shut
down gracefully.
2023-10-18 22:46:27 +02:00
Holger Vogt
7c3cb8169c
This is a re-write of the PWM generator.
...
It is modelled according to the new d_OSC by Giles Atkinson.
Here frequency is fixed and duty cycle is controlled by an
analog input.
2023-10-07 17:13:55 +02:00
Giles Atkinson
423f9a9db2
Fix a build bug for XSPICE: files generated for code models are
...
not removed when doing 'make clean' from release/src/xspice or above.
2023-09-23 17:03:09 +02:00
Giles Atkinson
62471ecede
Fix two bugs in cmpp: an unmatched right bracket in cfunc.mod
...
causes an infinite parsing loop (mod_yacc.y) and XSPICE macros
are replaced in string literals (mod_lex.l).
2023-09-16 00:19:36 +02:00
Holger Vogt
dbc5042263
Prevent a crash if port cntrl is set to NULL
2023-09-15 23:42:08 +02:00
Francesco Lannutti
fe89da2b2c
Getting rid of SPARSE for Initial Circuit Matrix creation. Now KLU is totally independent from SPARSE. This opens up the interface for other solvers as well
...
SPARSE can still used through '.options sparse', but it isn't possible to switch from KLU to SPARSE and viceversa at run-time
2023-08-16 11:14:18 +02:00
Francesco Lannutti
4c351f51bd
Moved the KLU binding structures to be property of the XSPICE connections, instead of XSPICE instances
2023-08-16 11:14:16 +02:00
Francesco Lannutti
534394c0bb
First attempt of KLU support for XSPICE
2023-08-16 11:14:16 +02:00
Holger Vogt
cb0e794907
Prevent buffer overflow, remove unused
2023-08-13 11:31:01 +02:00
Holger Vogt
de98e49956
Set brackets to remove gcc compiler warning
2023-08-12 23:59:56 +02:00
Giles Atkinson
ad02a7c47a
Remove duplicate definition of variable idp, as compiler may warn.
2023-08-12 22:46:16 +02:00
Holger Vogt
d173deea64
Activate callback, remove memory leak
2023-08-12 15:10:49 +02:00
Giles Atkinson
738881a014
Complete version of intertial delay for d_tristate. The State and
...
Strength members are treated independently and combined in the output.
2023-08-11 11:40:02 +02:00
Giles Atkinson
ee7250e11f
Fix a crash when trying to auto-bridge a real-valued event node
...
and improve an error message.
2023-08-11 11:38:45 +02:00
Holger Vogt
75ce3c95e3
eprvcd [-a] [-t timescale] node node ...
...
timescale is now given by minimum 1fs, maximum 1s.
2023-07-31 14:30:53 +02:00
Holger Vogt
7c0bbcd9b2
Remove vs2022 linker warning (ctx potentially uninitialized)
2023-07-31 14:30:29 +02:00
Holger Vogt
da3dda3269
replace exp10() by pow(10, ...),
...
exp10 not available in VS2022
2023-07-31 14:30:21 +02:00
Holger Vogt
dc5291fa91
fopen_with_path enable path search (directory of recent inputs or
...
NGSPICE_INPUT_DIR)
2023-07-31 14:30:13 +02:00
Giles Atkinson
4df2e69009
Fix Bug #629 - "XSPICE d_osc failures". The old code has been completely
...
replaced by a new design that is faster, more reliable and does not
usually insert analog breakpoints.
2023-07-31 14:29:36 +02:00
Giles Atkinson
4cc0ac846d
Add an option for parameters to the xfer code model to be provided
...
in a Touchstone-format file instead of as a model parameter.
The change to mif_inp2.c allows the "table" parameter to be omitted.
2023-07-31 14:28:40 +02:00
Giles Atkinson
84821a4cf5
Add support for including analog node changes in VCD file output,
...
and an option to explicitly set the VCD timestep. Correct the
output value for high-impedance nodes.
2023-07-31 14:28:29 +02:00
Giles Atkinson
576f218945
Fix the NAND and NOR variants of XSPICE code model multi_input_pwl
...
and add an example of its use with the E-source NAND variant.
2023-07-31 14:25:40 +02:00
Giles Atkinson
3a260fd4d9
Fix Bug 584 - "XSPICE dac_bridge model shows incorrect output timing."
...
Remove reliance on exact breakpoint timing and tidy code.
2023-07-31 14:25:31 +02:00
Giles Atkinson
e5a931e537
Improve commands for vector scales. "setscale" can now change
...
or clear the scale of an individual vector and "compose" can
explicitly create a vector from XSPICE event node history.
2023-07-15 11:28:48 +02:00
Giles Atkinson
d31568bd83
Add parsing and translation of the FREQ form of E-source devices,
...
integrated with the existing parsing of AND/NAND/OR/NOR forms (inpcom.c).
For the implementation, add a new analog XSPICE code model, xfer.
Add an example to examples/sp.
2023-07-15 11:15:08 +02:00
Giles Atkinson
eeb912228a
When creating a plot vector from XSPICE event history, add a
...
final point at the end of the vector, so that a plotted line
does not end at the last event, leaving an odd spike.
2023-07-15 11:13:19 +02:00
Giles Atkinson
9099a922fd
Apply a patch from Aleksey Morozov to fix a bug that he identified
...
and reproduced. It is the same as Bug #331 -
"XSpice skips digital output point" except that it applies to the
instance queue, not the event queue.
2023-07-15 11:12:31 +02:00
Holger Vogt
678a6582f6
A preliminary fix to reduce the amount of missing pulses considerably.
...
Probably not yet the final solution.
2023-05-27 10:40:32 +02:00
Giles Atkinson
5aa48cab0b
Do not generate netlist lines that use non-existent libraries.
...
To support that, give global scope to function inp_pathresolve()
in inpcom.c. Update internal documentation (long comment).
2023-04-01 13:56:12 +02:00
Holger Vogt
062785319a
When '.probe alli' is set, disable auto bridging and set a flag
2023-03-24 22:10:18 +01:00
Giles Atkinson
5197200fb3
Fix crash reported by Brian Taylor. If "source" is used after
...
analysis, the circuit is both deleted and destroyed. Beware of
double frees.
2023-03-22 14:30:18 +01:00
Giles Atkinson
98333ee89a
Fix a memory leak reported by Brian Taylor that was introduced
...
by commit 4d8e17487b .
2023-03-22 14:30:11 +01:00
Giles Atkinson
e25f8bd522
Add inertial delay to missed d_xnor and tidy blank lines in d_xor.
2023-03-22 14:29:03 +01:00
Giles Atkinson
cecce5163e
Inertial delay for remaining simple gates and buffers:
...
nand or xor open_c open_e, but not tristate.
2023-03-22 14:28:51 +01:00
Giles Atkinson
db38d4ad54
Correct timing of transitions to UNKNOWN.
2023-03-22 14:28:37 +01:00
Giles Atkinson
4623a04615
Interim version of inertial delay for tristate buffer.
...
This does not handle three-way or mixed transitions.
2023-03-22 14:28:15 +01:00
Giles Atkinson
e3b4df6a51
First group of digital code models with improved implementation
...
of inertial delay: buffer, inverter, and, nor. Also adds
utility function cm_is_inertial(().
2023-03-22 14:27:54 +01:00
Giles Atkinson
2643e3b17f
New code-model library functions cm_schedule_output() and cm_getvar().
...
To be used in the inertial delay code for digital code models.
2023-03-22 14:27:35 +01:00
Giles Atkinson
c1659a64c3
Change output event setup in evtload.c so that, when making an event call
...
to a code model, there is no longer a reference to the value of the event
at the head of the free list. That allows all such free lists (with the
same data type) to be combined, probably improving performance.
This is in preparation for full implementation of inertial delay for
digital nodes.
2023-03-22 14:27:19 +01:00
Giles Atkinson
2d0561f386
Allow string-valued parameters to XSPICE device models with no default.
...
The code model then sees the value NULL. Needed for the "family"
parameter on logic models, used by automatic bridge insertion.
2023-03-22 14:27:06 +01:00
Giles Atkinson
06aa693852
A new fix for Bug #331 : "XSpice skips digital output point".
...
The problem was caused by removing an output queue from the "modified"
list when it had been modified by processing one of its events.
2023-03-18 14:33:02 +01:00
Giles Atkinson
7457a2684b
Revert "Fixes bug #331"
...
This reverts commit 6d9876229c , because
it was found to break examples/xspice/various/xspice_c3.cir
(see discussion in bug report for February 2023) and an alternative
fix is available.
2023-03-18 14:32:53 +01:00
Holger Vogt
5924ae2dfb
bug report 619 by Hanspeter Niederstrasser
...
remove double inclusion of stdlib.h
Correction of commit 9e432838c ("Patch by Robert Turnbull: remove warning messages", 2023-02-05)
2023-03-18 14:30:56 +01:00
Holger Vogt
3ff9643f49
Add a scale factor 'a' (atto, 1e-18)
2023-03-18 14:30:03 +01:00
holger
f9ed3fd080
Patch by Robert Turnbull: remove warning messages
2023-02-05 11:25:42 +01:00
Giles Atkinson
7ead974a5a
Prevent crash when cm_analog_set_temp_bkpt() is called during OPtran().
2022-12-11 15:35:31 +01:00
Giles Atkinson
73e8fed0fc
Fix warnings from gcc 10.2.1.
2022-12-11 15:35:14 +01:00
Holger Vogt
ba6ff75dab
Trim trailing spaces
2022-12-11 15:22:30 +01:00
Holger Vogt
f26c9146f5
Don't allocate memory for control array at every time step
...
Use loc instead, setting it up once during INIT
2022-12-11 15:22:01 +01:00
Holger Vogt
e47049f31a
Add STATIC_VAR_TABLE locdata
...
Add CALLBACK cm_d_pwm_callback
Reserve memory for x, y arrays only once during INIT
2022-12-11 15:15:22 +01:00
Holger Vogt
ed6f802948
Add a guard on parameter 'position', limit to
...
1e-9 to 0.999999999
FIXME: the given parameter limits from ifspec.ifs are not recognized.
2022-10-22 15:54:12 +02:00
Holger Vogt
2d8ea17d65
Update on author
2022-10-22 15:54:01 +02:00
Holger Vogt
61d23b99ff
Patch required to allow compiling at Fedora with -Werror=format-security
...
Provided by Mamoru Tasaka
2022-10-22 15:53:45 +02:00
Giles Atkinson
01c4a5dff2
Fix memory leak reported by Brian Taylor.
2022-10-14 13:52:34 +02:00
Holger Vogt
9166f202a6
Streamline the simple diode model.
2022-10-08 16:50:47 +02:00
Holger Vogt
ec6a902fb9
Fix a bug in simple diode, when ilimit is set, but not epsilon.
...
Make model more similar to LTSPICE
Add an example
2022-10-08 16:50:38 +02:00
Giles Atkinson
d9952575dd
Correct the digital state resolution table, that was previously asymmetric.
...
An equivalent change is mentioned in the SPICE OPUS change history.
2022-10-08 16:48:20 +02:00
Giles Atkinson
372d9b2c87
Add bidirectional digital/analog bridge.
2022-10-08 16:48:11 +02:00
Giles Atkinson
e80b724460
Add two functions to the Code Model Library: cm_get_node_name()
...
makes circuit node names available to diagnostics, while
cm_probe_node() is needed for a bidirectional A/D bridge.
2022-10-08 16:47:50 +02:00
Giles Atkinson
06131d8107
Rewrite code with Visual Studio complaints.
2022-10-08 16:47:09 +02:00
Holger Vogt
519ce44227
safeguard against circuit not being abvailable,
...
avoid crash
2022-10-08 16:43:41 +02:00
Holger Vogt
1d026475a2
pwlts: a pwl v/i source with time input, smoothing and limiting functions
2022-10-07 13:39:16 +02:00
Holger Vogt
0af4932c6f
Prevent a crash if (due to input error) the node_table is not available.
2022-10-07 13:37:57 +02:00
Holger Vogt
2126230b64
Prevent crashes when nodes or tables are not available,
...
e.g. due to missing input file.
2022-10-07 13:22:59 +02:00
Giles Atkinson
a0357b3432
Remove search for "family" parameters on subcircuits in XSPICE
...
automatic bridging support as string-valued parameter support is
not yet intgrated.
2022-10-07 13:20:34 +02:00
Giles Atkinson
4115064fd5
Latest auto-bridge code from development branch.
2022-10-07 13:20:17 +02:00
Giles Atkinson
b1341c8e30
Insert XSPICE bridging devices automatically when an analogue node
...
has the same name as an XSPICE event node (including digital nodes).
The function Evtcheck_nodes() is replaced by a new version in its
own file.
2022-10-07 13:19:59 +02:00
Holger Vogt
c8ed9590b7
Handle the case when control voltages on and off are equal.
...
Update the linear switch: add the limits to resistance ron, roff
Update the log switch: correct the resistance calculation for
von < voff
Add some examples for the pswitch.
2022-10-07 13:12:56 +02:00
Giles Atkinson
8038021369
Remove some dead code in the dec_bridge code model.
2022-10-07 13:09:36 +02:00
Giles Atkinson
88d5e723ed
Fix double free in XSPICE CALLBACK functions as desribed here:
...
https://sourceforge.net/p/ngspice/mailman/message/37677362/
and add missing CALLBACKs in models that use STATIC_VARs with
pointer values.
2022-10-07 13:09:15 +02:00