Hi everyone,
I am aware Qspice supports .if statement and I have an indication that .case statement is supported as well (well to be fair, I tried it and QSpice did not rejected which does not mean is “supported”).
Is anyone having a clue what might be its syntax? On the same topic, .if statement is undocumented so I expect insider inputs
.
What I expect?
.case ()
.<case_keyword???> value:
QSpice statements …
.<case_default_keyword???>:
QSpice statements …
.endcase
Thanks for hints in advance,
Marius
never heard of .case directive in SPICE.
B-sources support if() function, and you can use multiple if() functions for nested if conditions.

Or upload a screen capture of explaining what you want to do in Qspice.
**note: .if directive is undocument, for conditional netlist.
Hi @KSKelvin,
Thanks for reply.
I am aware that .if statement is not a standard Spice statement - encountered it in Spectre and HSpice, I guess. Being able to alter the netlist (before run time), it is a very usefull way to change the netlist based on a parameter.
My use case is like below (I may want to prevent nested if’s, and being noticed that .if is undocummented, I thought of writing a .case as well).
- below param definitions is a must
- there are 16 possible cases
- the intent is to .plot only enabled signals
- based on their indexes
.param en0=1, en1=1, en2=0, en3=0
.if (en0==1) && (en1==1)
.plot v(signal0) v(signal1)
.endif
.if (en0==0) && (en1==1)
.plot v(signal1)
.endif
…
I tried to write as below. Expected a syntax error, but not. This not 100% indicative the directive is parsed and processed but I wanted to share a thought.
.case en1
.plot v(signal1)
.endcase
The end result was that signal1 was ploted when en1=1.
Regards,
Marius
PS: the primary intent of this post is for me to clarify if there is a possibility that .case statement is available in Qspice.
About warning or error for unrecognized dot command
QSpice currently does not return a warning or error if you include an unrecognized dot command. For example, if you type .abcdef, QSpice will simply ignore that line in the netlist without informing you. Therefore, the absence of a warning or error is not a way to verify whether a dot command exists.
About awareness of a Qspice feature
Regarding .if, it is mentioned in the QSpice revision history, which is how we became aware of its existence. Any feature implemented in QSpice without being mentioned in the Help file or revision history is likely known only to the person who requested it.
08/29/2024 Implemented initial support for .if/.else/.endif conditional netlist processing.
09/17/2025 Improved HSPICE .if/.else/.endif compatibility.
About nested .if
I think what you are currently looking for does not exist in QSpice; If the .if directive supported elseif condition, it would be quite close to what you want. But currently, it only supports .if/.else/.endif. Conditional statements can be nested, but in your case, it would be very hard to read. I have used a two-layer setup before.
2 Likes
Hi @KSKelvin,
Thanks for reply.
Makes sense; I might have been misled by the lack or error.
Regards,
Marius
1 Like