Appendix B

RF Simulation Cheat Sheet

The syntax of every analysis used in the course, on one page: ngspice's small-signal, S-parameter, noise and transient analyses, Xyce's harmonic balance, .LIN and MPDE, the openEMS and Palace workflows, Touchstone files and the course's Python helpers. Every line here was run in IIC-OSIC-TOOLS 2026.10 (ngspice-47, Xyce 7.10) for Chapter 2, which explains what the analyses do.

Contents

B.1 ngspice: netlist pieces

Piece Syntax Notes
SG13G2 HBT models .lib /foss/pdks/ihp-sg13g2/libs.tech/ngspice/models/cornerHBT.lib hbt_typ VBIC; no OSDI needed
SiGe HBT XQ1 c b 0 0 npn13G2 Nx=4 pins c b e substrate; Nx emitter fingers
Port V1 in 0 dc 0 ac 1 portnum 1 z0 50 ac 1: 1 V behind 50 Ω; ac 0: 50 Ω termination
Sine source VS src 0 dc 0 sin(0 {va} 2.44g) offset, peak, frequency; add RS src in 50
Power in dBm .param pin=-20 and .param va={sqrt(8*50*1e-3*pow(10, pin/10))} peak EMF for available power pin
Noise source VN src 0 dc 0 trnoise(287.9u 5p 0 0) rms, sample time, 1/f exponent, 1/f amplitude
Behavioural source B1 t 0 I = -4m*v(t) + 4m*v(t)*v(t)*v(t)  
Initial condition C1 t 0 4.3p IC=0.1 used with uic
Device quantity print @q.xq1.qnpn13g2[gm], .save @q.xq1.qnpn13g2[cbe] path: device letter, x instance, model

B.2 ngspice: analyses (in a .control block)

Analysis Syntax Result vectors and remarks
Operating point op then print i(vcc) v(b)  
DC sweep dc vbb 0.80 0.90 0.0005  
AC ac dec 50 100meg 10g, ac lin 351 0.5e9 4e9 \(S_{21} = 2v_{out}/v_s\) with ports
Noise noise v(out) v1 lin 1 2.44g 2.44g 1 inoise_spectrum, onoise_spectrum (V/√Hz) in plot noise1 (setplot noise1); last argument 1: every source’s contribution, onoise_<name>; port resistance is noiseless
S-parameters sp lin 351 0.5e9 4e9 1, sp dec 50 1e8 1e11 0 s_i_j, y_i_j, z_i_j; with the noise flag 1: nf, nfmin (dB, at the simulation temperature), rn (Ω), sopt, cy_i_j
Temperature option temp=16.85 27 °C by default
Transient tran 1p 80n 0 1p step, stop, start, maximum step; without it the step can reach tstep or tstop/50
Fourier (last period) fourier 2.44g v(out) harmonics, phases and THD
Spectrum linearize v(out), set specwindow=hanning, fft v(out) whole run, windowed
Measure meas tran vmax MAX v(t) from=190n to=200n, meas tran ra RMS v(a) from=0 to=100n  
Periodic steady state pss 2.4e9 30e-9 t 128 7 50 1e-3 uic guess, stabilization time, node, points, harmonics, iterations, tolerance; oscillators only; plot pss1 (time domain)
Run time rusage “Total analysis time”
Output set filetype=ascii, write out.raw all  

~/.spiceinit in IIC-OSIC-TOOLS sets ngbehavior=hsa, ng_nomodcheck and enable_noisy_r (behavioural resistors noisy in .noise); it is read by a plain shell (bash -c), not by a login shell (bash -lc).

B.3 Xyce

Task Syntax Remarks
SG13G2 HBT models .lib /foss/pdks/ihp-sg13g2/libs.tech/xyce/models/cornerHBT.lib hbt_typ MOSFETs need -plugin .../xyce/plugins/Xyce_Plugin_PSP103_VA.so
Single-tone HB .hb 2.44e9 and .options hbint numfreq=8 startupperiods=4 harmonics 0 to 8; four transient periods for the initial guess
Two-tone HB .hb 2.440e9 2.442e9 and .options hbint numfreq=7,7 intmodmax=7 57 frequencies incl. DC
HB output .print hb_fd v(out) i(VCC), .print hb_td v(out) two-sided spectrum: one-sided peak = 2 × printed value; job.cir.HB.FD.prn, .HB.TD.prn
Power sweep .param pin=-40, .step pin -40 0 1, .step VA list 1m 10m one block per step in the .prn file
S-parameters P1 in 0 port=1 z0=50, P2 out 0 port=2 z0=50, .ac lin 351 0.5e9 4e9, .lin sparcalc=1 format=touchstone2 lintype=s job.cir.s2p; touchstone2 writes data order 12_21, format=touchstone writes version 1.0
Noise .noise v(out) V1 lin 36 0.5e9 4e9 1 and .print noise inoise onoise V²/Hz; every source’s contribution in job.cir.NOISE.dat
MPDE .mpde 100p 20n and .options mpdeint n2=32 oscsrc=VS diff=1 and .print mpde v(out) diff=1 (centred differences) needed for accurate amplitudes
Transient .tran 1p 80n, .print tran v(out), .measure tran ra RMS v(a)  
FFT .fft v(out) np=4096 start=39.01639e-9 stop=80n window=rect format=unorm numbers only in start/stop
Not available .hb with .noise (rejected); TRNOISE sources (no noise)  

B.4 openEMS and Palace (IHP workflows)

IHP’s workflows read a GDS layout (ports drawn on special layers 201, 202, …) and an XML stack description, in the container at /foss/pdks/ihp-sg13g2/libs.tech/openems/openems_ihp_sg13g2/workflow and /foss/pdks/ihp-sg13g2/libs.tech/palace/workflow. The course’s copies write their results into the repository:

docker run --rm --entrypoint /bin/bash -v "$PWD":/work -w /work hpretl/iic-osic-tools:2026.10 \
    -lc "python3 tools/em/ch02_line.py --mesh-only"     # mesh size only
docker run --rm --entrypoint /bin/bash -v "$PWD":/work -w /work hpretl/iic-osic-tools:2026.10 \
    -lc "python3 tools/em/ch02_line.py --cell 1"        # openEMS (FDTD), writes tools/em/ch02_line.s2p

The openEMS model in Python, in the order the script uses it (modules.* are IHP’s helpers):

ports = simulation_setup.all_simulation_ports()
ports.add_port(simulation_setup.simulation_port(portnumber=1, voltage=1, port_Z0=50, source_layernum=201,
               from_layername="Metal1", to_layername="TopMetal2", direction="z"))
materials, dielectrics, metals = stackup_reader.read_substrate("SG13G2_nosub.xml")
layernumbers = metals.getlayernumbers()
layernumbers.extend(ports.portlayers)
polygons = gds_reader.read_gds("line_simple_viaport.gds", layernumbers, purposelist=[0], metals_list=metals,
                               preprocess=False, merge_polygon_size=0)
FDTD = openEMS(EndCriteria=1e-4)                  # -40 dB of energy
FDTD.SetGaussExcite(55e9, 55e9)                   # 0-110 GHz
FDTD.SetBoundaryCond(["PEC"] * 6)
FDTD = simulation_setup.setupSimulation([1], ports, FDTD, materials, dielectrics, metals, polygons,
               max_cellsize, 1.0, 50, 1e-6, xy_mesh_function=util_meshlines.create_xy_mesh_from_polygons)
excitation_path = utilities.get_excitation_path(sim_path, [1])
FDTD.Run(excitation_path, numThreads=4)
s21 = utilities.calculate_Sij(2, 1, f, sim_path, ports)

Palace (FEM) through IHP’s gds2palace, which meshes with gmsh and writes Palace’s JSON configuration:

docker run --rm --entrypoint /bin/bash -v "$PWD":/work -w /work hpretl/iic-osic-tools:2026.10 \
    -lc "python3 tools/em/ch02_line_palace.py --np 2 --order 1 --freqs 2.44,10,25,50,75,100"
from gds2palace import *            # in /foss/pdks/ihp-sg13g2/libs.tech/palace/workflow
settings = {"unit": 1e-6, "margin": 50, "fstart": 0e9, "fstop": 100e9, "fstep": 2.5e9,
            "refined_cellsize": 2, "cells_per_wavelength": 10, "meshsize_max": 70,
            "adaptive_mesh_iterations": 0, "no_gui": True}        # no_gui (not nogui) skips the gmsh window
# ... ports, stack and polygons as for openEMS, then:
settings.update({"simulation_ports": ports, "materials_list": materials, "dielectrics_list": dielectrics,
                 "metals_list": metals, "layernumbers": layernumbers, "allpolygons": polygons,
                 "sim_path": sim_path, "model_basename": "ch02_line_palace"})
config_name, data_dir = simulation_setup.create_palace(ports.all_active_excitations(), settings)
cfg = json.load(open(config_name))
cfg["Solver"]["Order"] = 1                                       # IHP's default is 2
cfg["Solver"]["Driven"]["Samples"] = [{"Type": "Point", "Freq": [2.44, 10, 25, 50, 75, 100], "SaveStep": 0}]
cfg["Solver"]["Driven"].pop("AdaptiveTol", None)
json.dump(cfg, open(config_name, "w"), indent=1)
palace -np 2 config.json        # in the folder of config.json; results in output/<name>/port-S.csv

port-S.csv has one row per frequency (GHz) with the magnitude (dB) and angle (degrees) of S[i][j] for every pair of ports; palace.json next to it gives the number of unknowns and elements.

B.5 Touchstone files

! comment
# Hz S RI R 50
2.440000e+09  Re(S11) Im(S11)  Re(S21) Im(S21)  Re(S12) Im(S12)  Re(S22) Im(S22)

The option line gives the frequency unit (Hz, kHz, MHz, GHz), the parameter (S, Y, Z), the format (RI real–imaginary, MA magnitude–degrees, DB dB–degrees) and the reference impedance. The extension gives the number of ports (.s1p, .s2p). Version 1.0 orders a two-port as S11 S21 S12 S22; version 2.0 adds keywords in brackets ([Version] 2.0, [Number of Ports], [Two-Port Data Order] 12_21 or 21_12, [Network Data], [End]).

B.6 The course’s Python helpers (tools/rfic)

Call What it does
run(lines, "sg13g2", ["op", "sp lin 351 0.5e9 4e9 1"], libs=("hbt",)) ngspice with the PDK models; returns res["op1"], res["sp1"], … (dicts of numpy arrays) and res["log"]
run(..., vectors=["v(out)"], temp=27, keep=True) save only some vectors; keep the job folder (res["dir"])
xyce(lines, libs=("hbt",)) Xyce; returns res["hb_fd"], res["hb_td"], res["s2p"], res["noise_dat"], … (one entry per output file)
read_raw(path), read_prn(path) parse an ngspice ASCII raw file, a Xyce .prn file
sp_matrix(res["sp1"]), freq(res["sp1"]) S[f, 2, 2] and the frequencies
stability(S), gmax(S), transducer_gain(S, gs, gl) K and µ, maximum available or stable gain, GT
gamma(z), zin(g), gamma_in(S, gl), gamma_out(S, gs) reflection coefficients and impedances
nf_from_params(gs, nfmin_db, rn, gopt) noise figure for a source reflection gs
hb_tone(res["hb_fd"], "v(out)", f) one-sided complex peak amplitude at f
tone_powers(t, v, f0, nharm=3, ncycles=40) harmonic powers (dBm in 50 Ω) from the end of a transient, coherent
db(), db10(), dbm(), dbm2w(), vpk2dbm() unit conversions
read_snp(path), write_s2p(path, f, S) Touchstone 1.0 files
crossing(x, y, level, log=False) first crossing of a level (for P1dB)

Back to top

SkillSurf · RFIC Design with Open-Source Tools, draft v0.1 (November 2026). Every source is listed on the References page.

This course was written with the help of AI tools and may contain mistakes. If you find one, please tell us through SkillSurf or email skillsurfedu@gmail.com, and we will correct it.

This site uses Just the Docs, a documentation theme for Jekyll.