Params: keyword on X call and in .subckt definition, make this optional?

This is not a Qspice bug but can issue of compatibility with spice netlists that may have been developed using other simulators that dont require the PARAMS keyword. It also comes up when trying to run with certain foundry libraries.

Specifically,

Qspice seems to use something like this when parameters are to be passed,

XMN1 IREF IREF VG VG IBMNFET PARAMS: W=‘2U’ L=‘1U’ F=‘1’

On other hand, many spice simulators have dropped the requirement for PARAMS: on the line or will run with or without PARAMS: (this is something that comes from PSPICE I believe)

This runs fine on several simulators we run.

XMN1 IREF IREF VG VG IBMNFET W=‘2U’ L=‘1U’ F=‘1’

Without the PARAMS, Qspice gives an error message that it cant find subckt F=1

The same with the .subckt definition … PARAMS is usually not required these days.

Again, not a bug but if the simulator could interpret parameters in the absence of the PARAMS keyword it would eliminate problems when running spice existing netlists from some vendors.

Something for the future perhaps.

Thanks!
Kevin

I think the problem was the hspice-style single quotes. That is, instead of

XMN1 IREF IREF VG VG IBMNFET W=‘2U’ L=‘1U’ F=‘1’

you could have used

XMN1 IREF IREF VG VG IBMNFET W=2U L=1U F=1 ; no quotes

For unrelated reasons, specifically some in-house simulation issues, I just completely re did parameter evaluation and subcircuit parameter passing. As part of that, I made the single quotes better tolerated, at least if you use the ASCII single quote and not the left/right signal quotes as are in the post, but that might have been the way the forum software dealt with your text.

There was one place where “params:” was required: if you wanted to add parameters to the subcircuit definition:

.subckt oldschool A B params: x=23 y=13 ; “params:” was required

.ends oldschool

But this afternoon’s build allows this:

.subckt oldschool A B x=23 y=13 ; now “params:” in not required

.ends oldschool

BTW, QSPICE usually doesn’t need any single quotes or curly braces. It’s actually safer not to use them because they’re a distraction to its lexicon and grammar.

Redoing the parameter evaluation, subcircuit parameter passing, and subcircuit node name mangling might have introduced some new problems. Please report those to one of e-mail address on the Help=>About dialog.

thanks,

–Mike

Thanks Mike… I will give this a try and will send you a note on outcome.

Kind Regards,
Kevin

Hi Mike… ok, some success but a couple of issues too.

First, not requiring params: seems to be working for me. Also true for single quotes on the Xcall and .subckt .

However, when I tried to run a couple of larger test cases I ran into a couple of more issues.

These are,

1- use of keyword value= in G & E elements does not work in qspice as in other spice flavors
I change these to B elements to fix

2- After switching to B elements with same equations, including single quotes, qspice gave an error that seemed related to the single quotes as removing the quotes allowed qspice to run.

The stripped down test case is below, 3 versions with step by step changes made until it ran.

Again, not strictly qspice errors, more of a backward compatibility issue I thought you would like to know about. … Kevin


Netlists are below

*=== Confirma Hierarchical Spice Netlister for KiCad… ver 0.1

  • Schematic=tq_qspice_param_passing
  • Number of schematic nodes= 5
    XU2 INP INN OUT B_DIFF2SEBUF GAIN=2
    V1 IN 0 SIN ( 0 1 70E6 0 0 0 )
    XU1 0 IN INP INN S2DIFBUF_Q
    *== End top level schem

*=== start existing subcircuit cir
.subckt B_DIFF2SEBUF INP INM OUT

  • GAIN=‘1’
  • Schematic=B_DIFF2SEBUF
  • Number of schematic nodes= 4
    I2 INP 0 DC 1N AC 0
    R1 0 OUT 1G
    R3 INP 0 1G
    R2 INM 0 1G
    E1 OUT 0 VALUE=‘(V(INP)-V(INM))*GAIN’
    I1 INM 0 DC 1N AC 0

.ends

  • Single-ended to differential unity buffer with CM terminal
  • XS2DIFBUF A4 A1 A2 A3 S2DIFBUF
    .SUBCKT S2DIFBUF_Q 4 1 2 3
    E1 2 4 1 0 0.5
    E2 4 3 1 0 0.5
    R18 1 0 1G
    R20 4 0 1G
    .ENDS

.end

qspice reports,

Fatal error: Error: too few nodes: e1 out 0 value=‘(v(inp)-v(inm))*gain’

Checking qspice docs I found,

  • value= not permitted in vcvs
  • corrected by changing E1 to BE1 etc

==================================================

Run 2

  • Number of schematic nodes= 5
    XU2 INP INN OUT B_DIFF2SEBUF GAIN=2
    V1 IN 0 SIN ( 0 1 70E6 0 0 0 )
    XU1 0 IN INP INN S2DIFBUF_Q
    *== End top level schem

*=== start existing subcircuit cir
.subckt B_DIFF2SEBUF INP INM OUT

  • GAIN=‘1’
  • Schematic=B_DIFF2SEBUF
  • Number of schematic nodes= 4
    I2 INP 0 DC 1N AC 0
    R1 0 OUT 1G
    R3 INP 0 1G
    R2 INM 0 1G
    *E1 OUT 0 VALUE=‘(V(INP)-V(INM))*GAIN’ <============= change here, switch to B element!
    BE1 OUT 0 V=‘(V(INP)-V(INM))*GAIN’
    I1 INM 0 DC 1N AC 0

.ends

  • Single-ended to differential unity buffer with CM terminal
  • XS2DIFBUF A4 A1 A2 A3 S2DIFBUF
    .SUBCKT S2DIFBUF_Q 4 1 2 3
    E1 2 4 1 0 0.5
    E2 4 3 1 0 0.5
    R18 1 0 1G
    R20 4 0 1G
    .ENDS

.end

qspice reports,

C:\Y\KiCad_UCOSMprojects\CMOS_lp_transceivers\tq_qspice_param_passing.src
Ignoring shorted resistor: “R20•XU1”
Warning: Error: Node voltages such as V(n01) can not be used in netlist parameter expressions because these parameters are evaluated before the simulation starts.
Fatal error: Error: no such function ‘’’
The problem occured while parsing the line:
“BE1•XU2 OUT 0 V•XU2=‘(V(INP)-V(INN))*GAIN•XU2’”

*** Removed the single quotes on the B element and that seemed to fix it.

This netlist ran fine

*=== Confirma Hierarchical Spice Netlister for KiCad… ver 0.1

  • Schematic=tq_qspice_param_passing
  • Number of schematic nodes= 5
    XU2 INP INN OUT B_DIFF2SEBUF GAIN=2
    V1 IN 0 SIN ( 0 1 70E6 0 0 0 )
    XU1 0 IN INP INN S2DIFBUF_Q
    *== End top level schem

*=== start existing subcircuit cir
.subckt B_DIFF2SEBUF INP INM OUT

  • GAIN=‘1’
  • Schematic=B_DIFF2SEBUF
  • Number of schematic nodes= 4
    I2 INP 0 DC 1N AC 0
    R1 0 OUT 1G
    R3 INP 0 1G
    R2 INM 0 1G
    *E1 OUT 0 VALUE=‘(V(INP)-V(INM))*GAIN’ <============= change here, switch to B element!
    BE1 OUT 0 V=(V(INP)-V(INM))*GAIN <============= change here, removed single quote around equation!
    I1 INM 0 DC 1N AC 0

.ends

  • Single-ended to differential unity buffer with CM terminal
  • XS2DIFBUF A4 A1 A2 A3 S2DIFBUF
    .SUBCKT S2DIFBUF_Q 4 1 2 3
    E1 2 4 1 0 0.5
    E2 4 3 1 0 0.5
    R18 1 0 1G
    R20 4 0 1G
    .ENDS

.end

E-source Value = … syntax is legacy syntax from PSpice. It get used in model and QSPICE runs it flawless, I believer,

But the syntax is supposed to use curly braces

Wrong:

E1 OUT 0 VALUE=‘(V(INP)-V(INM))*GAIN’

Right:

E1 OUT 0 VALUE={V(INP)-V(INM))*GAIN}

You can find the PSpice documention on line.

–Mike

Why is this valid (even if legacy) syntax not mentioned in the QSPICE documentation file? How are users expected to learn what forms can be used without complete and correct documentation? Is repeated trial end error by multiple users for years to come all that can be done?

SPICE is 50 years old this year. It has a legacy. Recommended use is documented at the best of my ability.

But as it is desirable to be able to run old models without have to re-author them, there will be undocumented abilities[1].

–Mike

1] But no, there isn’t a list of undocumented abilities. If there were, they wouldn’t be undocumented.

“Undocumented LTspice” implies that information may not be “officially documented”

1 Like