In Ngspice 26 from git, it looks like the NINT(x) function (Nearest integer, half integers rounded towards even) function is not recognised when used in dependent (B) sources.
The netlist below illustrates the problem:
.param boo=-2.5
V1 IN GND {0.5} SIN(0 4.1 1k)
V2 REF1 GND {ref}
V3 REF2 GND {NINT(boo)}
.TRAN 1u 1m
*.OP
probe V(in) V(ref1) V(ref2) ; V(nint_function1) V(nint_function2) V(nint_function3)
.END
The netlist above runs without errors if the B1 - B3 lines are commented out. Running the netlist with B1, B2 and B3 lines uncommented produces an error report containing this information:
==============================
:
Error: no such function 'nint'
Error: no such function 'nint'
Error: no such function 'nint'
Error on line 24 : b1 nint_function1 0 v= nint ( 2.0000000000e+00 )
parameter value out of range or the wrong type
Error on line 25 : b2 nint_function2 0 v= nint ( -2.50000000000000000e+00 )
parameter value out of range or the wrong type
Error on line 26 : b3 nint_function3 0 v= nint ( v(in) )
parameter value out of range or the wrong type
:
===============================
Many thanks for your attention,
Andy.
signality.co.uk
The ngspice-26 manual does not list nint(x) as a supported function, and
mentions that nint(x) is allowed in param statements. Therefore the
signaled behavior is formally not a B-source bug.
I think numparm is to blame, as:
should have worked for B1 and B2 ( B1 <- 2, B2 <- 2.5).
Reason: numparm does not substitute the NINT(<x>) strings. </x>
nint(x) is defined in the table on page 57 of:
http://ngspice.sourceforge.net/docs/ngspice-manual.pdf
However, it is not clear to me exactly what this table is defining: it has
no title and is not clearly referenced in the text.
This is the only place that nint(x) is described.
Does this table refer specifically to functions that can be used only in
.param statements?
If so, can they also be used in expressions for independent sources and
other component values like:
R1 net1 gnd {nint(5.6)}
V1 net2 gnd sin(0 1 {nint(2.5k)})
Coming from using LTspice, I'd expected to find that if a function is
defined then it would work in any context.
It would certainly make the user's life much simpler (but not the
developers!).
:)
signality.co.uk
On 18 September 2014 18:31, marcel hendrix mhx_at_sf@users.sf.net wrote:
Related
Bugs:
#292"The ngspice-26 manual does not list nint(x) as a supported function,"
Not sure that's true now: it was announced as a new feature in the ngspice
release 26, January 12th, 2014 and is in thesame table on page 57 in the
stable released manual:
http://ngspice.sourceforge.net/docs/ngspice26-manual.pdf
Cheers,
signality.co.uk
On 18 September 2014 22:33, Andy Fierman andyfierman@signality.co.uk
wrote:
Related
Bugs:
#292I looked at the release notes, and nint is not for B-sources (note the
different formulation for pwr). That this is clear to me is probably
because I am (by now) well aware of the 3 different ngspice parsers.
(Yes, I believe that they should be transparent.)
I recommend to retract the bug report for the B-source parser and
file one for the bug in numparam instead.
-marcel
Hello Andy, Marcel,
Its not a numparm bug, but a missing implementation in the B parser.
Some time ago, I've put some effort into the numparm parser
to make some details compatibel to another spice.
Thats somewhat expressed in the regression test
tests/regression/parser/xpressn-1.cir
For example nint() was missing, got implemented, and was then tested there.
Concerning this (numparm) section, I currently know of the various
pwr pwrs ^ and ** operators, which need to be polished too.
I've not cared about the B world at that time.
Thus, indeed its a bug/missing feature
and a similiar regression .cir file needs to be written for B too
(and for .control of course)
Robert
Last edit: Robert Larice 2014-09-19
Hello Andy,
I've pushed commits to implement nint for 'B' and for '.control'
A regression test is pushed as well.
Thanks for the report.
Robert
Robert,
Many thanks!
Deep joy.
Cheers,
signality.co.uk
On 20 September 2014 16:34, Robert Larice rlar@users.sf.net wrote:
Related
Bugs:
#292Hi,
If I run the netlist below in ngpsice.com (release 26) then the tilde in:
ainv1 ~ind outd buff
inverts the input OK.
If I remove the tilde so that line becomes:
ainv1 ind outd buff
and insert one into:
aoutbridge1 [~outd] [out] dac
then that inverts the input OK too.
However, if I run this in EasyEDA using ngspice from git then the tilde is
ignored in either location.
This is the example shared on ngspice.com:
http://www.ngspice.com/index.php?public_circuit=CFHOrs
and on EasyEDA:
http://easyeda.com/editor#id=QQ20mH31Z
Cheers,
signality.co.uk
.tran 1.2u 1.2m
.param
**
**
VCC1 vcc 0 1
V1 in 0 pulse(0 1 0 10n 10n 500u 1m)
*
ainbridge1 [in] [ind] adc1
.model adc1 adc_bridge(in_low = {in_low} in_high = {in_high})
*
ainv1 ~ind outd buff ; inversion using [~ind] works OK
*
.model buff d_buffer(rise_delay = {tdhi} fall_delay = {tdlo}
*
aoutbridge1 [outd] [out] dac ; inversion using [~outd] works OK here too
*
.model dac dac_bridge(out_low = {out_low} out_high = {out_high} out_undef =
{out_undef}
*
*.probe v(in) v(out)
*
.end