XOR logical operator in behavioral source expressions

Hello,

I noticed that LTspice logical XOR operator is “^”.
I’m using qspice for some projects and noticed that the “^” operator (I used in behavioral sources) has different function, i.e. a power function represented by “**” or ^":
“B. Behavioral voltage or current source. Raise left hand side to power of right hand side. Same as ‘^’.” (Qspice doc of behavioral source).
Anyway, the result I got is a NXOR effect when I tried this on two boolean signals on QSPICE.

My questions are the followings:

  • Is there any reason of the difference between qspice and ltspice regarding the “^” operator ?
  • Is there a dedicated operator I missed in the qspice doc to achieve XOR effect ?

Regards,

From my knowledge, LTspice no longer seems to support the use of the “^” operator and has replaced it with the XOR() function for B-source boolean operations. Things change over time.
My guess is that the “^” operator now refers more to exponentiation in many programming languages nowadays.

Qspice still supports boolean operations with B-source, and according to the Qspice Help, it offers the NOT (!), AND (&), and OR (|) operators. With these operators, you can create a custom function for XOR. Here is an example for your reference.

As a reminder, Qspice offers logic gates and digital devices as standard simulation devices!

B-Source Boolean.qsch (4.9 KB)

Thanks for the example and explanations. I marked it as solved as the .func does the job.

1 Like