Problems with parameters and subcircuit

I was trying if QSPICE had the same problem as LTspice in passing parameters to nested subcircuits.

The good news is: QSPICE has no problem passing parametrs to nested subcircuits.

The bad news is: It has another problem. You can*t pass parameters to instances of top level subcircuits in a subcircuit. LTspice has no problem with this.

Another minor problem is: You can define a subcircuit without any pins. But if you make an instance of this, QSPICE complains. LTspice has no problem with this.

In LTspice we get also the internal nodes of the subcircuit in the waveform viewer trace list.
In QSPICE I don’t see the internal traces. Is there a switch so that the internal nodes are saved and are visible in the waveform viewer trace dialog?

In LTspice we get the flattened netlist in the error log.
How can we get the flattened netlist in QSPICE?

.subckt test params: V=1
V1 1 0 {V}
.ends test

.subckt top 1 params: V=1
V1 1 0 {V}
.ends top

.subckt sub 1 params: V=1

; passing parameter, working ok
V1 1 0 {V}

.subckt nested 1 params: V=1
V1 1 0 {V}
.ends nested

; top level with parameter passing
; nok, Fatal error: Unknown subckt: x1 2 top
; LTspice has no problem with that!
; X1 2 top params: V={V}

; nested with default parameter
; ok, but internal node not listed in waveform viewer
; how do we get to see the flatted netlist?
; LTspice has no problem with that!
X2 3 nested

; nested with fixed parameter
; ok, but internal node not listed in waveform viewer
; how do we get to see the flatted netlist?
; LTspice has no problem with that!
X3 4 nested params: V=2

; nested with parameter passing
; ok, but internal node not listed in waveform viewer
; how do we get to see the flatted netlist?
; LTspice has a problem with that!
; => WARNING: Can’t resolve .param v=v
X4 5 nested params: V={V}

.ends sub

.op

; Fatal error: Too few ports(pins) for subcircuit type “test” (instance: x1)
; definition has no ports, no error for definition (good), but why error for instance (bad)?
; LTspice has no problem with that!
;X1 test params: V=1

X2 2 top params: V=1
X3 3 sub params: V=2

Remove “.txt” to get the .qsch file you can open directly. Remove one of the “;” to see the problems.

ok-nested_subckt_parameter.qsch.txt (1.4 KB)