RF PCB Design Resources

Touchstone File Guide | S2P S4P Format & Use

A complete guide to the Touchstone file format covering S1P through S4P syntax, version 2.0 keywords, common parsing errors, and practical validation techniques for RF and microwave design workflows.

VNA displaying S-parameter measurement with calibration kit on lab bench

What Is a Touchstone File?

A Touchstone file (extension .snp, where n is the port count) is the universal ASCII format for storing frequency-domain network-parameter data—S, Y, Z, H or G parameters—so that simulators, VNAs and EDA tools can exchange measured or modeled RF behavior of a component or interconnect. The format was originally defined by EEsof (now part of Keysight) and later standardized as the IBIS Touchstone 2.0 specification. If you work with anything from a 0402 capacitor model at 10 MHz to a 77 GHz automotive radar channel, you will handle Touchstone files daily.

File Extensions and Port Count

RF PCB with microstrip traces and SMA connectors viewed from above
Extension Ports Typical Use
.s1p 1 Antenna return loss, single-port impedance
.s2p 2 Filters, amplifiers, transmission lines, cables
.s3p 3 Circulators, T-junctions
.s4p 4 Differential pairs, baluns, couplers
.s6p / .s8p+ 6 / 8+ Multi-lane SerDes channels, switch matrices

The port count dictates the number of parameter columns per frequency line. A 2-port file has 2² = 4 complex parameters per row (S11, S21, S12, S22), while a 4-port file has 16—often split across multiple lines per frequency point for readability.

Touchstone File Syntax Explained

Comment Lines

Any line beginning with ! is a comment. Use comments to record the DUT description, measurement date, calibration type and reference plane location. Good metadata here saves hours of confusion later, especially when sharing files as part of an RF documentation package.

The Option Line

Exactly one option line must appear before the data, starting with #. Its fields, in order:

  1. Frequency unit — HZ, KHZ, MHZ or GHZ (default: GHZ).
  2. Parameter type — S, Y, Z, H or G (default: S).
  3. Format — MA (magnitude/angle), DB (dB/angle) or RI (real/imaginary). Default: MA.
  4. R followed by the reference impedance in ohms (default: 50).

A typical option line looks like:

# GHZ S DB R 50

This means frequencies in GHz, S-parameters in dB-angle format, referenced to 50 Ω. Omitting the option line forces the parser to assume all defaults, which is legal but fragile—always include it explicitly.

Data Lines

Each data line starts with the frequency value, followed by parameter pairs. For a 2-port file in DB format:

! freq dB(S11) ang(S11) dB(S21) ang(S21) dB(S12) ang(S12) dB(S22) ang(S22)
1.000 -25.3 -12.4 -0.15 -8.7 -0.16 -8.5 -24.8 -11.9

Frequencies must be in ascending order with no duplicates. Violating this causes silent interpolation errors in most simulators.

Touchstone Version 2.0 Keywords

Version 2.0 added bracketed keywords that sit between the option line and the data:

  • [Version] 2.0 — declares the file version.
  • [Number of Ports] — removes ambiguity for high port counts.
  • [Number of Frequencies] — lets the parser pre-allocate memory.
  • [Reference] — per-port reference impedances (critical for mixed-impedance networks, e.g. 50 Ω input / 75 Ω output).
  • [Network Data] and [End] — bracket the numeric block.

Most EDA tools—including those used in ADS Momentum workflows and HFSS simulation setups—now accept version 2.0, but some legacy code still chokes on the keywords. When distributing files externally, include a version 1.0 fallback unless you confirm the receiver’s tool chain.

Reading and Writing Touchstone Files in Practice

Exporting from a VNA

Every modern vector network analyzer can save .s2p directly after calibration. Before exporting, verify:

  • The calibration reference plane matches the DUT boundary you intend. If you need to shift it, apply de-embedding techniques (TRL, SOLT or 2x-Thru) before saving.
  • The frequency list covers the band of interest with enough points—at least 201 for narrowband filters, 801+ for broadband channels.
  • The format is set to the convention your downstream tool expects; RI is the safest for numerical precision.

Importing into Simulators

In Keysight ADS, Ansys HFSS, CST and KiCad RF design flows, S-parameter blocks or n-port components accept a Touchstone path. The simulator interpolates between data points, so sparse data at critical frequencies (filter edges, resonances) causes visible artifacts. If your simulation frequency range extends beyond the file’s range, the tool either extrapolates (risky) or errors out—check the log.

Scripting with Python

The open-source library scikit-rf (skrf) parses and manipulates Touchstone files in a few lines. It handles both version 1.0 and 2.0, supports cascading, de-embedding and format conversion, and writes clean output files. For batch validation of dozens of vendor-supplied models, a short Python script beats manual inspection every time.

Common Touchstone File Errors and How to Fix Them

Error Symptom Fix
Non-ascending frequencies Interpolation spikes or NaN Sort and remove duplicates
Wrong column count Parser reads wrong parameter into wrong S-index Verify n² pairs per frequency
Mixed tabs and spaces Some parsers split incorrectly Normalize to single-space delimiters
Missing option line Tool assumes MA format when data is DB Always write the # line explicitly
Passive violation (|S| > 0 dB) Simulation convergence failure Enforce passivity; most solvers have a passivity-enforcement option
Causality violation Time-domain ringing, non-physical transients Apply Hilbert-transform check or use causal fitting tools
UTF-8 BOM or Windows line endings First comment line misread Save as plain ASCII, LF line endings

Passivity and causality checks matter most for high-frequency and high-speed designs where channel models feed time-domain simulators. A non-passive S-parameter model can make a SPICE-like solver inject energy that does not exist, producing wildly optimistic eye diagrams.

Validating Your Component Placement Data Alongside S-Parameters

Text editor displaying Touchstone S2P file data in an RF lab setting

Touchstone files describe electrical behavior, but they must align with the physical layout. When you place an RF component whose behavior is defined by an .s2p model, the XY coordinates and rotation in your pick-and-place (CPL) file determine whether the port mapping matches reality. A 180° rotation on a directional coupler, for example, swaps the coupled and through ports—your simulation matches, but the board does not.

Use the validator below to cross-check your CPL/XY centroid file for formatting errors, missing references and coordinate sanity before sending the design to fabrication. Enter your CPL data and review the flagged entries.

Loading CPL XY Validation…

After running the check, pay special attention to components whose Touchstone models are orientation-sensitive: couplers, baluns, asymmetric filters and multi-section power dividers. A flagged coordinate offset of even 5 mil (0.127 mm) on a 0201 component at millimeter-wave frequencies can shift the reference plane enough to invalidate your carefully calibrated .s2p data. Cross-reference any warnings with your EDA tool’s 3-D view before generating final manufacturing files—and consider requesting a Gerber and placement file review for an independent check.

S2P vs S4P: When to Use Which

S2P (2-Port)

Use .s2p for any single-ended, two-terminal-pair device: a filter, an amplifier, a length of transmission line, a single-ended connector. Two-port data is straightforward to cascade (T-parameter conversion) and universally supported.

S4P (4-Port)

Use .s4p for differential or coupled structures: a differential pair on a PCB, a balun, a common-mode choke, a differential connector. The 4-port matrix contains all single-ended S-parameters; your simulator converts them to mixed-mode (Sdd, Scc, Sdc, Scd) for differential analysis. Getting the port numbering right is critical—the IEEE standard port-ordering convention places ports 1 and 3 on the input side and ports 2 and 4 on the output side, but not every vendor follows it. Always check the comment header or the vendor’s documentation.

Best Practices for Managing Touchstone Files

  • Version-control them. Store .snp files in Git alongside schematics. They are plain text and diff cleanly.
  • Name files descriptively: BPF_2400MHz_SAW_Murata_SAFFB2G14FA0F0A_v1.s2p beats filter.s2p.
  • Record calibration metadata in comment lines: cal kit, cal type, IF bandwidth, averaging, temperature.
  • Validate passivity and causality before importing into time-domain or co-simulation. Keysight’s Causal Fitting tool in ADS handles this automatically.
  • Keep frequency range wider than needed. A model from 10 MHz to 20 GHz is more reusable than one from 2.4 to 2.5 GHz, even if today’s design only needs the ISM band.
  • Distribute version 1.0 externally unless you have confirmed version 2.0 support on the receiving end.

Touchstone Files in the Broader RF Design Flow

Touchstone data feeds into every stage: initial component selection based on Q, SRF and package parasitics, schematic simulation, layout-level EM extraction, and post-fabrication correlation. When measured data diverges from the model, the Touchstone file is the first thing to re-examine—check the reference plane, the port impedance and the frequency range before suspecting the PCB itself.

Frequently Asked Questions

Can I open a Touchstone file in a text editor?

Yes. Touchstone files are plain ASCII. Any text editor (Notepad++, VS Code, vim) works. For plotting, use scikit-rf in Python or the built-in data viewer in your EDA tool.

What is the maximum number of ports a Touchstone file supports?

Version 1.0 supports up to 99 ports (limited by the two-digit extension convention, e.g. .s99p). Version 2.0 removes this limit by declaring the port count inside the file with the [Number of Ports] keyword.

Does the Touchstone format store noise parameters?

Version 1.0 appends noise data after the S-parameter block, using a specific five-column format (Fmin, Γopt magnitude, Γopt angle, Rn/Z0). Version 2.0 formalizes this with a [Noise Data] keyword. Not all tools read the noise section automatically—verify in your simulator’s documentation.

How do I convert between MA, DB and RI formats?

The conversion is purely mathematical. MA to RI: real = mag × cos(angle), imag = mag × sin(angle). DB to MA: mag = 10^(dB/20). Most tools handle this on import, but if you need to batch-convert files, a three-line Python script with NumPy or scikit-rf is the fastest path.

Why does my simulation show gain greater than 0 dB for a passive component?

The Touchstone data violates passivity—likely due to calibration error, noise floor issues at low signal levels, or a corrupted file. Enforce passivity in your simulator’s S-parameter checker or re-measure with tighter calibration and averaging.

Ready for a quotation?

Send your requirements for a material, stackup and manufacturing review. Price and schedule are confirmed for your project.

Upload Gerber