Commit Graph

6613 Commits

Author SHA1 Message Date
Holger Vogt dc8c7db718 Fix a bug in simple diode, when ilimit is set, but not epsilon.
Make model more similar to LTSPICE
Add an example
2022-09-29 16:14:25 +02:00
Holger Vogt 8d86aa84d8 Remove parameter noiseless in simple diode model.
The model is noiseless anyway.
2022-09-29 16:05:30 +02:00
Brian Taylor 21f62db206 Remove unnecessary hierarchical level check. 2022-09-24 11:57:18 +02:00
Brian Taylor 41b7c867ff Fix memory leaks in ff/latch code. 2022-09-23 14:59:17 +02:00
Brian Taylor 93bd661a3e If ps_udevice_msgs >= 2, print complete line of unsupported PSpice instance. For debugging purposes. 2022-09-23 14:59:01 +02:00
Giles Atkinson 583ee06232 Fix bug reported by Anant Devi in user discussion 22/9/22.
A function call, vi(v) was misparsed as the special token i(vsource)
for the current in a voltage source.
2022-09-23 13:15:07 +02:00
Giles Atkinson 31fcd7d561 Correct the digital state resolution table, that was previously asymmetric.
An equivalent change is mentioned in the SPICE OPUS change history.
2022-09-23 13:15:07 +02:00
Giles Atkinson af09a06cdb Add bidirectional digital/analog bridge. 2022-09-23 13:15:07 +02:00
Giles Atkinson 118b997642 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-09-23 13:15:07 +02:00
Giles Atkinson 9d780f8bb4 Fix bug #602 "Warning message trying to linearize a transient analysis vector"
by changing the way "ngspice -a" (autorun option) works.  The inserted code
now checks whether a simulation has already run by examining $curplot
before forcing "run".  Also at most one simulation is forced to run.
2022-09-23 13:15:07 +02:00
Giles Atkinson 2f9403d143 Prevent overwriting of previous debug output when expanding auto-bridge deck. 2022-09-23 13:15:07 +02:00
Giles Atkinson 8156745c97 Rewrite code with Visual Studio complaints. 2022-09-23 13:15:06 +02:00
Holger Vogt 2d4c1379af Transfer i(xx) to xxx#branch only when i is the first
character of the token or preceeded by a space.
2022-09-23 12:58:47 +02:00
Holger Vogt c7b0438ce7 Just to notify that this might need a better solution 2022-09-23 12:04:20 +02:00
Holger Vogt 41e92be956 FIXME: This is a hack to re-enable 'make check'
Do not print warning if in batch mode.
2022-09-21 10:04:22 +02:00
Holger Vogt cfba8a5cd3 Note: ix: dc value used for op instead of transient time=0 value
Former warning message or note only issued when dc value and
value at transient time=0 differ.
2022-09-20 22:50:17 +02:00
Holger Vogt bce48859df Note: vs: dc value used for op instead of transient time=0 value
Former warning message or note only issued when dc value and
value at transient time=0 differ.
2022-09-20 22:47:24 +02:00
Holger Vogt ba394d5903 Warning message, when 'run' is called without job
(tran, op, ac etc.) is defined.
2022-09-20 20:09:42 +02:00
Holger Vogt 6237639ec5 Change error messages to warning messages, because simulator moves on
and command is ignored.
Make messages more verbose (which command?).
2022-09-20 13:28:55 +02:00
Holger Vogt 64b429d6f8 Don't send error message to stdout, but to stderr. 2022-09-18 16:00:21 +02:00
Holger Vogt 453350bf2f safeguard against circuit not being abvailable,
avoid crash
2022-09-18 11:11:56 +02:00
Holger Vogt 8dba70c7cc add parameter description 2022-09-18 11:10:59 +02:00
Brian Taylor 78f732a8a1 Add comment about ps_udevice_msgs variable. Set to 1 will print PSpice instance names and types which are not supported and are found when processing a subckt. 2022-09-14 15:01:39 +02:00
Holger Vogt 3d625bc1ef pwlts: a pwl v/i source with time input, smoothing and limiting functions 2022-09-09 15:24:37 +02:00
Holger Vogt f5a172ce4e Make the Error message a Warning message,
because ngspice may move on
2022-09-07 16:27:29 +02:00
Holger Vogt 8ef0c03fa6 Prevent a crash if (due to input error) the node_table is not available. 2022-09-04 17:35:47 +02:00
Holger Vogt c7fa70d109 Add special savecurrents options:
options savecurrents_bsim3, savecurrents_bsim4, and savecurrents_mos1
will save all device currents as listed in chapts 31.6.1, .8 and .9
of the ngspice manual. Pure savecurrents will yield a subset of MOS1
currents, as seen before.
2022-09-02 15:06:40 +02:00
Holger Vogt e9fcb9b332 Prevent crash in gettok() and similar functions by checking for NULL
input. Return NULL instead.
2022-09-01 16:57:54 +02:00
Holger Vogt 04ded78ef6 Prevent crashes when nodes or tables are not available,
e.g. due to missing input file.
2022-08-31 15:43:20 +02:00
Holger Vogt bfab06e04b Improved error message: more info on the bad set form 2022-08-31 15:42:30 +02:00
Giles Atkinson 3901c0a865 Remove search for "family" parameters on subcircuits in XSPICE
automatic bridging support as string-valued parameter support is
not yet intgrated.
2022-08-31 15:34:09 +02:00
Giles Atkinson 495172f532 Latest auto-bridge code from development branch. 2022-08-31 15:34:04 +02:00
Giles Atkinson 148cecf919 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-08-31 15:33:59 +02:00
Holger Vogt ff62468c1f Iterations for op or dc may start with arguments 0 for ln().
To cope with this, and potential overflow in exp function,
some limits have been added.
2022-08-30 20:02:46 +02:00
Holger Vogt 0be7461dd9 Enable power measurement for W switch 2022-08-29 20:30:23 +02:00
Holger Vogt b83a0d3fdf Allow individual current measurements in switches or
linear dependent sources.
2022-08-29 14:12:43 +02:00
Holger Vogt 655a81da7a .probe alli improved:
* Enable current mesurement for I source
* Look at only the first 2 nodes of S and W switches
and F and G controlled current sources, measure current
with = voltage source added to second node. So we get
I(Fx), I(Gx), I(Sx), and I(Wx).
2022-08-29 12:23:13 +02:00
Giles Atkinson 682b849603 Make FROM/TO work in TRIG/TARG and WHEN variants of .meas/meas command.
Discussion at
https://sourceforge.net/p/ngspice/discussion/133842/thread/973e152274/
2022-08-17 15:30:56 +02:00
Holger Vogt cc866ead29 Check for tran at first when linearize is called. 2022-08-17 15:14:06 +02:00
Brian Taylor a361d63ca1 Make a trivial change to support (n)and3a, (n)or3a, (n)xor3a types. These are not used in any of the Micro Cap libraries. Completes support for Pspice tristate gate types. 2022-08-06 10:43:17 +02:00
Brian Taylor f0876163e8 If variable ps_port_directions >= 2, also show the translated Xspice statements. 2022-08-06 10:43:02 +02:00
Brian Taylor 47753ad5b2 Ignore IO models in a subckt. Setting variable ps_port_directions to a non-zero int prints the directions (IN, OUT, INOUT) of subckt ports. 2022-08-06 10:42:50 +02:00
Brian Taylor 15d987ad0f Check for name collisions between nodes generated during translation from Pspice to Xspice and instance pin or subckt port names. These are reported as ERRRORs. 2022-08-06 10:42:43 +02:00
Holger Vogt 3fc3997cef 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-08-05 17:30:08 +02:00
Holger Vogt 874aca4a86 Avoid an endless loop: Safeguard function
search_plain_identifier(char *str, const char *identifier)
against identifiers being an empty string.
2022-08-01 18:30:50 +02:00
Holger Vogt 227bb9c419 If a node name to be plotted ends by ':power', its type is set to POWER.
Thus 'settype power nodename(s)' in the examples is no longer necessary.
2022-07-31 15:49:50 +02:00
Holger Vogt 382b6c534b Update to .probe command:
If no .save or save command given by the user, add '.save all' internally.
To do so, check for .save or save.
Update to the .probe p command (power measurement)
Add probe_int_ to internal nodes and instance names, where appropriate.
These nodes will be disregarded when setting up the plot structure.
2022-07-31 15:47:32 +02:00
Holger Vogt 0b3383546c Handle .if ... .else ... .endif before .csparam is executed,
thus allowing parameter entry to .control section being dependent
on .if
2022-07-24 15:54:29 +02:00
Giles Atkinson f878878bd8 Remove some dead code in the dec_bridge code model. 2022-07-24 12:23:24 +02:00
Giles Atkinson 659b426cf8 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-07-24 12:23:19 +02:00
Giles Atkinson 2406846a21 Extend the output and partial derivatives of the output from the 2/3-D
table lookup models (XSPICE) continuously outside the defined
rectangle or cube, as it may help convergence and avoid ambiguity caused
by rounding at the boundaries.  See bug #591 "Wrong 2D table model output".
The value is that of the nearest point in the region while the reported
derivative is ramped to zero outside the boundaries.
Also fixes incorrect output at the upper limit in each dimension.
2022-07-24 12:23:15 +02:00
Giles Atkinson ec725c3814 Fix memory leak by moving the state transition table to a STATIC_VAR
whose memory can be recovered by a call back.  Also make cfunc.mod
less ugly.
2022-07-24 12:23:05 +02:00
Holger Vogt 44930ebcb1 Function guess_type may yield the wrong type, because
it does not cover all of the the many, many options possible.
This commit fixes bug597, where [current] was interpreted as
capacitance.
2022-07-24 12:17:29 +02:00
Holger Vogt eee07be10d Improve (a little) the plotting of digital data with plot option digiplot:
Repair scaling on MS Windows:
Suppress y axis lettering and unit:
Allow or dis-allow grid.
2022-07-20 15:11:51 +02:00
Holger Vogt 758ecd1d60 tabs to spaces 2022-07-18 23:29:59 +02:00
Holger Vogt 298eb556cd Make error message more verbose: Instead of only "no such parameter on this device",
give name of bad parameter and respective line in netlist.
2022-07-18 23:28:51 +02:00
Holger Vogt d61682360e Prevent crash when ca or d are not defined. May happen when
.endc is missing.
2022-07-18 23:23:55 +02:00
Holger Vogt b04e3dd89f WinGUI: Add a button 'Stop' to stop a simulation in intercative
or control mode. ngspice enters interactive mode and waits for user
commands. Simulation result vectors are available up to the
(time) point of stopping. Simulation may continue by command
'resume', however now in interactive mode, a control flow stays
interrupted.
2022-07-16 17:27:38 +02:00
Holger Vogt d57909eef1 Re-format cktdojob.c 2022-07-16 17:24:41 +02:00
Holger Vogt 6ee4db9af4 Correct comment: Command circbyline is not involved,
we are sending the netlist as an array.
2022-07-16 17:23:59 +02:00
Holger Vogt 8d91f44026 Suppress I/O redirection for command 'circbyline'.
This enables sending commands like
circbyline btest testnode 0 v=((v(in1) - v(in2)) < 0.1 ? 0.111 : v(in1))
2022-07-16 17:23:11 +02:00
Holger Vogt e3b13e0494 Consecutive tran and ac simulation may lead to gross errors
when TC or scale is used on the instance line of C and L.
Reason is the missing reset when CKTtemp is called once during each
simulation command. TC or scale is then applied again and again,
a reset is missing.

This patch adds a reset, i.e. the capacitance or inductance is
reset to its instance value in a call to *temp. It fixes bug#594.

Command 'alter' has been tested.

Resistance has not been tackled by this bug, because the line
here->RESconduct = here->RESm / (here->RESresist * factor * here->RESscale);
differs from
here->CAPcapac = here->CAPcapac * factor * here->CAPscale;
in that there is no accumulation of correction factors with here->RESconduct
2022-07-08 09:32:34 +02:00
Holger Vogt 72cfc681e5 Move evaluation of statistical functions inside of a B source
to after numparam expansion, thus allow parameters in functions agauss etc.

Replace gettok by new gettok_np to ignore characters ( ) ,
which may be left over after parameter expansion.

This fixes bug 593.
2022-07-06 18:54:34 +02:00
Holger Vogt 905b1eae8c Remove inner couple {...} from {{...}} only when instance is not
a behavioral source which will be translated to a B source.
2022-07-06 18:46:47 +02:00
Holger Vogt 86dedbd1f5 Add a new function char* gettok_np(char** s)
which finds a token, while scanning over (), like
they were white spaces. It also proceeds with s while
still finding (), (which gettok_noparens does not do).
2022-07-06 18:43:48 +02:00
Holger Vogt 474a1e47b8 Avoid jump in phase when crossing 90° boundaries.
Code similar to cx_cph in cmath1.c
2022-07-03 11:28:00 +02:00
Brian Taylor ec6938ed70 There needs to be 2 variants of d0_gff. One for d_dlatch, the other for d_srlatch. 2022-07-01 15:55:26 +02:00
Brian Taylor 6418fe75b7 Clean out dead code in model processing. 2022-07-01 15:55:15 +02:00
Brian Taylor 4c2152c74f Add support for srff. 2022-07-01 15:55:06 +02:00
Brian Taylor b64f684a62 Remove debug code. 2022-07-01 15:55:00 +02:00
Brian Taylor 4d9f834f5e Remove invalid check. 2022-07-01 15:54:45 +02:00
Brian Taylor ca26dc2585 Add optional debug code to check for name collisions. Connector nodes between gates now have a con_ prefix. 2022-07-01 15:54:35 +02:00
Brian Taylor 933b13d544 Prevent multiple d_zero_inv99 models per subckt. 2022-07-01 15:54:27 +02:00
Brian Taylor 5f9146b40a Follow convention, use eq() macro. Show replacement cards when ngdebug=TRUE. 2022-07-01 15:54:18 +02:00
Brian Taylor a7b6cb9af7 Create pin and port lists only when variable ps_pins_and_ports is set != 0. 2022-07-01 15:54:08 +02:00
Brian Taylor 01e988d604 Remove optional:, params:, text: before generating a ports list. 2022-07-01 15:53:56 +02:00
Brian Taylor 9b390c1ca9 Retain the param: section after removing the optional: section from a Pspice subckt declaration. 2022-07-01 15:53:47 +02:00
Brian Taylor 69ef28de4a Add more comments. Move incompatible input name checks to add_..._inout_timing_model() functions for dff, jkff, dltch. 2022-07-01 15:53:19 +02:00
Brian Taylor 3ca14e44ed Add counter test. Check for usage of $d_lo, $d_hi, $d_nc usage with dff, jkff, dltch which will not translate to Xspice. 2022-07-01 15:53:02 +02:00
Brian Taylor ff3a704710 Get rid of -Wpedantic warnings. 2022-07-01 15:52:39 +02:00
Brian Taylor 79625f10f5 Remove debugging asserts. 2022-07-01 15:52:14 +02:00
Brian Taylor 55a5c0cb0a Generate lists of subckt ports indicating direction (in, out, inout.) 2022-07-01 15:52:01 +02:00
Brian Taylor d41bff8373 Stopped memory leak in continuation cards when removing old cards. 2022-07-01 15:51:53 +02:00
Brian Taylor fff87ebb81 Slight cleanup. Some work ensuring that generated names do not collide may be necessary. 2022-07-01 15:51:37 +02:00
Brian Taylor 93d067775f For debug tracing, list the cards before and after udevice replacements. 2022-07-01 15:51:24 +02:00
Brian Taylor de2dc6f1d5 Add pullup/down. Skip spurious '*' line. 2022-07-01 15:51:12 +02:00
Brian Taylor 0513fb5c8f Add support for oa/oai compound gates. 2022-07-01 15:50:46 +02:00
Brian Taylor 63cec9668c Fix a memory leak. Cleanup the code a bit. All-digital Pspice subckts with U* devices for most used gates/ff can be handled. More extensive test cases are necessary. Also, interfacing subckts with analog ports is not implemented. 2022-07-01 15:50:34 +02:00
Brian Taylor 701ed7beb0 Replace Pspice U* and .model cards with their Xspice equivalent statements. There are still memory leaks which will be plugged next. The .subckts have only digital ports, which will need to addressed for mixed A/D designs. 2022-07-01 15:50:22 +02:00
Brian Taylor e27881fe44 Add translation of ao/aoi compound gates. 2022-07-01 15:49:52 +02:00
Brian Taylor 4de648c8de Trial run at scanning cards for Pspice U* devices and models. #define INTEGRATE_UDEVICES to turn it on. No new cards are created yet, just lots of debugging info. 2022-07-01 15:49:39 +02:00
Brian Taylor 4d52539765 Add brief usage notes and makefile. asserts will need to be removed after integration is complete. 2022-07-01 15:49:24 +02:00
Brian Taylor 3e86af3989 Add default zero delay models d0_gate, d0_eff, d0_gff, d0_tgate. Use tprintf. 2022-07-01 15:49:09 +02:00
Brian Taylor 5b332a1aba Initial files for translating Pspice u.. instances and timing models into Xspice equivalents. Standard gates, tristate gates, dff, jkff, dlatch are supported. Compound gates and pullup/down are not done. Makefile and frontend/inpcom.c changes have not been finished. These modifications will be needed to complete integration. 2022-07-01 15:48:43 +02:00
Holger Vogt 8ff547c5da No error message when Optran returned 0 2022-06-30 20:03:58 +02:00
Holger Vogt c9a864933b re-format indmask.c 2022-06-26 11:43:18 +02:00
Holger Vogt 8023402db8 Add missing parameter retrival 2022-06-26 11:40:10 +02:00
Holger Vogt a2d7c342dd Asl Lundin's correction only when suitable modelparameters are given. 2022-06-26 11:39:43 +02:00
Holger Vogt 5e60ef4644 Make warning message on missing init file more verbose. 2022-06-22 22:02:09 +02:00
Holger Vogt 5e1e2bb4b7 remove typo 2022-06-22 22:01:34 +02:00