Weird SPICE conditional expression syntax a?b?c:d -- what d

N

Ned Konz

Guest
I'm trying to use a SPICE model for the MC34063 that I downloaded from
ON Semi
(http://www.onsemi.com/pub/Collateral/MC34063A%20SPICE%20MODEL.ZIP) in
LTSPICE.

I'm running into problems with the syntax of this file.

First, I had to deal with the missing bitwise negation operator (~);
this was easy enough to do.

But then I was stumped by a syntax that I didn't recognize, and I wasn't
able to find any explanation in 5 or 6 different SPICE variants' manuals
that I was able to find on line.

There are a couple of lines in this file that use (what appears to be)
the ternary conditional operator strangely:

B3 9 0 V=(v(6,90) > 3) ? v(diff,90) > 1 ? 0 : v(vdd)
B1 4 90 V=(v(6,90) > 3) ? (v(diff,90) > -1) ? v(vdd) : 0

That is, there are more '?' than ':' characters. I've always used these
in pairs, but then I'm familiar with them from C and other languages.

This syntax is not acceptable to LTSPICE, and I haven't been able to
find any of the many SPICE manuals available on line that actually
discuss variations on the normal

cond ? a : b

syntax.

Could anyone here tell me how to rewrite the above two expressions using
a "normal" syntax for the conditional operator?

As an aside, can anyone think why the author of this file didn't bother
to clarify the meaning of lines like the following by throwing in a few
extra parentheses:

B7 16 90 V=V(vdd,90)-1.5 > 1.25 ? 1.25 : V(vdd,90)-1.25 < 0 ? 0
:V(vdd,90)-1.25

Perhaps they were being charged for each character?

Thanks,
Ned Konz
 
"Ned Konz" <ned@bike-nomad.com> schrieb im Newsbeitrag
news:Ab6dnZ5pDKlsLazYnZ2dnUVZ_oSdnZ2d@wavecable.com...
I'm trying to use a SPICE model for the MC34063 that I downloaded from ON
Semi (http://www.onsemi.com/pub/Collateral/MC34063A%20SPICE%20MODEL.ZIP)
in LTSPICE.

I'm running into problems with the syntax of this file.

First, I had to deal with the missing bitwise negation operator (~); this
was easy enough to do.

But then I was stumped by a syntax that I didn't recognize, and I wasn't
able to find any explanation in 5 or 6 different SPICE variants' manuals
that I was able to find on line.
Hello Ned,

You will find here examples for a translation of the IF-statements to
PSPICE.
LTspice correctly runs most of the PSPICE netlists.

http://perso.orange.fr/cbasso/Spice.htm

There are a couple of lines in this file that use (what appears to be) the
ternary conditional operator strangely:

B3 9 0 V=(v(6,90) > 3) ? v(diff,90) > 1 ? 0 : v(vdd)
B1 4 90 V=(v(6,90) > 3) ? (v(diff,90) > -1) ? v(vdd) : 0

That is, there are more '?' than ':' characters. I've always used these in
pairs, but then I'm familiar with them from C and other languages.
This model has been written for ICAP/4 SPICE from Intusoft.
You can download a manual from their web page.

http://www.intusoft.com/

This syntax is not acceptable to LTSPICE, and I haven't been able to find
any of the many SPICE manuals available on line that actually discuss
variations on the normal

cond ? a : b

syntax.

Could anyone here tell me how to rewrite the above two expressions using a
"normal" syntax for the conditional operator?

As an aside, can anyone think why the author of this file didn't bother to
clarify the meaning of lines like the following by throwing in a few extra
parentheses:

B7 16 90 V=V(vdd,90)-1.5 > 1.25 ? 1.25 : V(vdd,90)-1.25 < 0 ? 0
:V(vdd,90)-1.25
Perhaps they were being charged for each character?
No. Every SPICE has its own syntax for behavioral models.
You can see similar differences between the many programming languages.

There is more you have to take care about.
The default logic levels are 0.3V and 3.5V in ICAP/4. In LTspice they are 0V
and 1V.

Thanks,
Ned Konz
I wonder that you haven't heard of the LTspice Yahoo group.

http://tech.groups.yahoo.com/group/LTspice/
Files > Examples > SMPS
Take a look to the example with the MC34063 in this folder.

Best regards,
Helmut
 
Helmut Sennewald wrote:
"Ned Konz" <ned@bike-nomad.com> schrieb im Newsbeitrag
news:Ab6dnZ5pDKlsLazYnZ2dnUVZ_oSdnZ2d@wavecable.com...
I'm trying to use a SPICE model for the MC34063 that I downloaded from ON
Semi (http://www.onsemi.com/pub/Collateral/MC34063A%20SPICE%20MODEL.ZIP)
in LTSPICE.

I'm running into problems with the syntax of this file.

First, I had to deal with the missing bitwise negation operator (~); this
was easy enough to do.

But then I was stumped by a syntax that I didn't recognize, and I wasn't
able to find any explanation in 5 or 6 different SPICE variants' manuals
that I was able to find on line.

Hello Ned,

You will find here examples for a translation of the IF-statements to
PSPICE.
LTspice correctly runs most of the PSPICE netlists.

http://perso.orange.fr/cbasso/Spice.htm
Thanks! I have his book. Though I believe that LTspice has the ?:
operator. What is causing the problem is that some of the '?' are not
matched with the ':' in the given expressions.

Ah... Reading the manual you pointed to (thanks!) I see that the original:

B3 9 0 V=(v(6,90) > 3) ? v(diff,90) > 1 ? 0 : v(vdd)

would be translated as:

B3 9 0 V={ if ((v(6,90) > 3) & (v(diff,90) > 1)), 0, v(vdd)) }

is this right?


No. Every SPICE has its own syntax for behavioral models.
You can see similar differences between the many programming languages.

There is more you have to take care about.
The default logic levels are 0.3V and 3.5V in ICAP/4. In LTspice they are 0V
and 1V.
Ah. I didn't know that.

I wonder that you haven't heard of the LTspice Yahoo group.

http://tech.groups.yahoo.com/group/LTspice/
Files > Examples > SMPS
Take a look to the example with the MC34063 in this folder.
Thanks for the pointers and the tips. I'll use the model there instead
of banging on this one.

Ned Konz
 

Welcome to EDABoard.com

Sponsor

Back
Top