IHP-GmbH / IHP-Open-PDK

130nm BiCMOS Open Source PDK, dedicated for Analog, Mixed Signal and RF Design
Apache License 2.0
381 stars 60 forks source link

qucs-s simulation with xyce #153

Open FhatuL opened 3 months ago

FhatuL commented 3 months ago

Hi,

I wanted to ask, regarding the qucs-s HBT models, is it possible to run the simulations using xyce instead of ngspice? Every time I try to use the xyce simulator i get this error -> Netlist error: Number of nodes for subcircuit instance XNPN13G2L1 does not agree with number of nodes in subcircuit IHP_PDK_NONLINEAR_COMPONENTS_NPN13G2L

KrzysztofHerman commented 3 months ago

Hi @FhatuL, could you please share your testcase ?

FhatuL commented 3 months ago

Hi @KrzysztofHerman , please let me know if i missed something:

Expected Behavior

While using the HBT models, I am expecting the simulation to run without errors when using xyce

Actual Behavior

While trying to run a simulation with xyce, netlist errors occur. image of error: image

Steps to Reproduce the Problem

  1. Create a schematic and use one of the HBT models, in this case I used the npn13G2l model.
  2. Add an include script for the HBT models, in my case, I just copied the include syntax provided in one of the example schematics for qucs-s in the repository.
  3. Make sure xyce is selected as the simulator
  4. Insert a simulation type in the schematic, for my case I was using the S parameter simulation
  5. Try to run the simulation Image of my schematic: image
KrzysztofHerman commented 3 months ago

@FhatuL does it run when you use ngspice ? Anyway QUCS-S only generate the netlist and then calls the simulator.

FhatuL commented 3 months ago

@KrzysztofHerman It runs when I use ngspice yes.

KrzysztofHerman commented 3 months ago

Could you please provide the netlist an message log. You can generate it pressing F5 and F6

FhatuL commented 3 months ago

find attached netlist1.txt log1.txt

sergeiandreyev commented 3 months ago

based on the log it seems that all the .parameters commands in cornerHBT.lib file are not supported in Xyce, so the parameters are not set and simulation of course could not run we need to change the syntax of the models in a way to be supported by Xyce (like we did for diodes and resistors models)

sergeiandreyev commented 3 months ago

ok, after the change .parameters to .param (Xyce syntax) I'm still getting the 'incorrect number of nodes' error

sergeiandreyev commented 3 months ago

ok, found it .SUBCKT IHP_PDK_nonlinear_components_npn13G2l gnd c b e bn t Nx=1 El=1 here gnd is the extra pin

sergeiandreyev commented 3 months ago

or the other way around, you should add additional pin to the line 10: Xnpn13G2l1 0 _net0 _net1 0 gnd IHP_PDK_nonlinear_components_npn13G2l Nx=1 El=1

sergeiandreyev commented 3 months ago

so now I'm stuck with this error: Model is required for device QNPN13G2L and no valid model card found. I'm using Xyce v7.6

FhatuL commented 3 months ago

ok, found it .SUBCKT IHP_PDK_nonlinear_components_npn13G2l gnd c b e bn t Nx=1 El=1 here gnd is the extra pin

is it the circuit symbol that causes this extra pin to appear? How could i remove it since the netlist is auto-generated in my case.

KrzysztofHerman commented 3 months ago

in the line 259 of this file you have this definition: .SUBCKT IHP_PDK_nonlinear_components_npn13G2l gnd c b e bn t Nx=1 El=1. You could try to remove gnd, which seems to be optional, and let us know how it goes.

sergeiandreyev commented 3 months ago

is it the circuit symbol that causes this extra pin to appear? How could i remove it since the netlist is auto-generated in my case.

I think it comes from this file -> link lines 259-261

dwarning commented 3 months ago

Beside .parameters statements you have to change level model parameter from 9 to 12 in file sg13g2_hbt_mod.lib.

dwarning commented 3 months ago

Just a copy of the 3 hbt files into the xyce model folder with these changes is sufficient. But the netlister seems not to fit xyce requirements for this nested loop: Bildschirmfoto vom 2024-07-03 14-34-50

sergeiandreyev commented 3 months ago

thank you, @dwarning ! now at least Xyce is running on my side (standalone)

dwarning commented 3 months ago

The problem with the nested loop arises after a copy from ngspice schematic. Removing the both parameter sweeps, save and re-insert again solved the problem.

FhatuL commented 3 months ago

Just a copy of the 3 hbt files into the xyce model folder with these changes is sufficient. But the netlister seems not to fit xyce requirements for this nested loop: Bildschirmfoto vom 2024-07-03 14-34-50

Thank you, doing what you said got it to work.

FhatuL commented 3 months ago

Also, removing the extra gnd port on line 259 in the IHP_PDK_nonlinear_components.lib, although it does allow the simulation to run, it gives totally different simulation results compared to when it is there with ngspice. For xyce I just added an extra .PortSym and that seems to have gotten rid of the Number of nodes for subcircuit instance XNPN13G2L2 does not agree with number of nodes in subcircuit error.

sergeiandreyev commented 3 months ago

@FhatuL, great! Could you please attach the final updated netlist here for reference? On PDK side, we will provide model files with required changes in libs.tech/xyce/models folder

FhatuL commented 3 months ago

@FhatuL, great! Could you please attach the final updated netlist here for reference? On PDK side, we will provide model files with required changes in libs.tech/xyce/models folder

.SUBCKT IHP_PDK_nonlinear_components_npn13G2l gnd c b e bn t Nx=1 El=1 .INCLUDE ../../.qucs/IHP-Open-PDK-main/ihp-sg13g2/libs.tech/xyce/models/sg13g2_hbt_mod.lib X1 c b e bn t npn13G2l Nx={Nx} El={El} .ENDS

.LIB ../../.qucs/IHP-Open-PDK-main/ihp-sg13g2/libs.tech/xyce/models/cornerHBT.lib hbt_typ

Xnpn13G2l1 0 _net0 _net1 0 gnd 0 IHP_PDK_nonlinear_components_npn13G2l Nx=1 El=1 C1 _net2 _net1 1N C2 _net0 _net3 1N L1 _net0 _net4 1M L2 _net5 _net1 1M I1 0 _net5 DC 2U P1 _net2 0 port=1 z0=50 AC 0.316228 SIN 0 0.316228 1MEG P2 _net3 0 port=2 z0=50 AC 0.316228 SIN 0 0.316228 1MEG

V1 _net4 0 DC 1 .AC LIN 201 10G 30G .LIN format=touchstone sparcalc=1 .PRINT ac format=std file=spice4qucs_sparam.prn sdb(1,1) s(1,1) sp(1,1) y(1,1) z(1,1) sdb(1,2) s(1,2) sp(1,2) y(1,2) z(1,2) sdb(2,1) s(2,1) sp(2,1) y(2,1) z(2,1) sdb(2,2) s(2,2) sp(2,2) y(2,2) z(2,2) .END

sergeiandreyev commented 2 months ago

Hi @FhatuL, we pushed the HBT models for Xyce to the dev branch: https://github.com/IHP-GmbH/IHP-Open-PDK/commit/d2c5295c38314a709f2376c70ccd9328f2d99dbf So we have only the Qucs-S netlisting issue left