Hello,
there is a bug with parameter passing in nested subcircuits.
It is not limited to the netlist form, but to provide the minimal problem I have used the netlist below.
For the problem see the comment below.
.subckt top params: V=1
V1 1 0 {V}
.ends top
.subckt sub params: V=1
* passing parameter, working ok
V1 1 0 {V}
.subckt nested params: V=1
V1 1 0 {V}
.ends nested
* top level with parameter passing, working ok
X1 top params: V={V}
* nested with default parameter, working ok
X2 nested
* nested with fixed parameter, working ok
X3 nested params: V=2
***************************************************
********************bug in LTspice********************
* QSPICE has no problems with that (but other problems)
***************************************************
* nested with parameter passing, not working ok
* => WARNING: Can't resolve .param v=v
X4 nested params: V={V}
***************************************************
.ends sub
.op
X1 sub params: V=1
I tested it with QSPICE also and it has no problem here (but another).
Hi haubmi ,
This is indeed a bug in LTspice, and a fix is in the works. Curious about what result you got in QSPICE.
Thanks,
mike
Please find the results of QSPICE in the comments of the netlist I used in QSPICE.
Problems:
1. passing parameters to top level subckt does not work.
2. internal nodes not accessible
3. flattened netlist is not accessible
4. subckts without ports can be defined but not instantiated
.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
I am also experiencing the same error on the Mac Version 17.2.4.
Has soon is this going to be patched?
The following returns: WARNING: Can't resolve .param=n_e
.subckt WE760308 NA NB NC ND params: D=0m
.PARAMS
+ L_MAG = TABLE(D, 0m, 62u, 3m, 38u, 6m, 32u, 8m, 29u, 10m, 28u)
+ L_LEAK = 5u
+ N_E = TABLE(D, 0m, 0.958, 3m, 0.835, 6m, 0.671, 8m, 0.552, 10m, 0.469)
L1 NA NB {L_MAG}
L2 NA N1 {L_LEAK}
X1 N1 NB NC ND XFOR N={N_E}
.subckt XFOR A1 A2 B1 B2 params: N=1
E1 B1 B2 A1 A2 {N}
F1 A1 A2 E1 {-N}
.ends
.ends
I am also experiencing the same error on the Mac Version 17.2.4.
Has soon is this going to be patched?
The following returns: WARNING: Can't resolve .param=n_e
.subckt WE760308 NA NB NC ND params: D=0m
.PARAMS
+ L_MAG = TABLE(D, 0m, 62u, 3m, 38u, 6m, 32u, 8m, 29u, 10m, 28u)
+ L_LEAK = 5u
+ N_E = TABLE(D, 0m, 0.958, 3m, 0.835, 6m, 0.671, 8m, 0.552, 10m, 0.469)
L1 NA NB {L_MAG}
L2 NA N1 {L_LEAK}
X1 N1 NB NC ND XFOR N={N_E}
.subckt XFOR A1 A2 B1 B2 params: N=1
E1 B1 B2 A1 A2 {N}
F1 A1 A2 E1 {-N}
.ends
.ends