Displaying measurements and waveforms simultaneously in Xschem
Tools and resources
Displaying measurements and waveforms simultaneously in Xschem
Tools and resources
For this article, I am using the IIC-OSIC-TOOLS. In this development environment, Xschem and Ngspice are used. All examples are available on GitHub.
Introduction
When running simulations in Xschem, observing resulting waveforms gives us a good intuitive, visual grasp of the performance. However, we also have to rely on measurements as they give us a numerical insight into the circuit. We normally add measurements into the Ngspice runset and they are displayed post-simulation, like so:
...
MEAS TRAN t_pd_L2H TRIG V(v_i) VAL=0.9 RISE=1 TARG V(v_o) VAL=0.9 RISE=1
MEAS TRAN t_pd_H2L TRIG V(v_i) VAL=0.9 FALL=1 TARG V(v_o) VAL=0.9 FALL=1
...

This result display is neat and sufficient in a lot of cases. If there are any errors, they are displayed as well. However, running any kind of a sweep/Monte Carlo and the results will be displayed after each simulation run which is not sustainable for a long-term development process.
Goals
To implement a system where all the results are shown in the schematic screen in Xschem let’s first define what we want to implement:
- The simulation has defined measurements
- Simulation results (waveforms/measurements) are saved in their respective
.rawfiles - All waveform graphs and measurement tables are loaded simultaneously
Defining the simulation and measurements
To run a simulation we have to prepare a runset. Let’s start with a basic simulation setup:
.control
save all
tran 0.1p 3n
write xschem-meas-table-single.raw
.endc
Here, we define three things inside a .controlstatement: 1) We save all available waveforms; 2) We’re running a transient simulation where tstep = 0.1 ps and tstop = 3 ns; and 3) The results are saved into a file named xschem-meas-table-single.raw.
We can next define two measurements measuring rising/falling propagation delay:
.control
save all
tran 0.1p 3n
MEAS TRAN t_pd_L2H TRIG V(v_i) VAL=0.9 RISE=1 TARG V(v_o) VAL=0.9 RISE=1
MEAS TRAN t_pd_H2L TRIG V(v_i) VAL=0.9 FALL=1 TARG V(v_o) VAL=0.9 FALL=1
write xschem-meas-table-single.raw
.endc
This will give us the same result as shown in the introduction. The measurements will be displayed at the end of the simulation. However, the measurements will not be saved for later use.
Saving measurements in a separate file
To save the measurements in a separate file, we can define a new plot. Before calling the tran statement, we define a new plot (myplot) and populate it with unit-length vectors (in this case we’re only running a single simulation), one for each of the necessary measurements. Then, after the measurements are done, we assign the measured values to those vectors. In the end, we set types to those vectors (optional) and write them to a new file.
.control
save all
setplot new
set myplot=$curplot
let t_pd_l2h=vector(1)
let t_pd_h2l=vector(1)
tran 0.1p 3n
MEAS TRAN t_pd_L2H TRIG V(v_i) VAL=0.9 RISE=1 TARG V(v_o) VAL=0.9 RISE=1
MEAS TRAN t_pd_H2L TRIG V(v_i) VAL=0.9 FALL=1 TARG V(v_o) VAL=0.9 FALL=1
let {$myplot}.t_pd_l2h[0]=t_pd_l2h
let {$myplot}.t_pd_h2l[0]=t_pd_h2l
write xschem-meas-table-single.raw
setplot $myplot
settype time t_pd_l2h
settype time t_pd_h2l
write xschem-meas-table-single-meas.raw
.endc
To summarize the previous step, we can generalize the process:
.control
save ...
setplot new
set myplot=$curplot
let vector_meas = vector(1)
tran ...
MEAS tran meas_name ...
let {$myplot}.vector_meas[0] = meas_name
write file-name-waveforms.raw
setplot $myplot
write file-name-measurements.raw
.endc
For each new measurement, we need to:
- Define a vector
- Create a measurement
- Assign the measurement result to the vector
This will result in two generated files: 1) A waveform file with an x-axis as time (in case of an tran analysis); and 2) A list of measurement results.
After this process, it’s possible to see the measurements and the waveforms. But, they have to be separately loaded (as they are two separate files) and are not visible at the same time.
Displaying measurements and waveforms simultaneously
After the simulation has finished, we can load the waveforms as we normally do.

How do we also load the measurements? My personal preference for loading data is to tabulation.
Let’s add a table using a tclevalstatement:
tcleval([xschem raw read $netlist_dir/[file tail [file rootname [xschem get current_name]]]-meas.raw
set table "t_pd_l2h,t_pd_h2l"
foreach t_pd_l2h [xschem raw values t_pd_l2h] t_pd_h2l [xschem raw values t_pd_h2l] {
append table \\n [to_eng $t_pd_l2h] {,} [to_eng $t_pd_h2l]
}
xschem raw switch 0
return [tabulate $table ,]])
Note that, in the first line, we’re using a xschem raw read statement to load a custom .raw file. This is the same file we stored the measurements in the Ngspice runset. Next, we create a table, iterate over all available rows (in this case, it’s only one), and append the table. The result is the following:

We now have both waveforms and measurements available at the same time.
Displaying measurements from multiple iterations
If we want to add any kind of simulation iteration, the changes to the existing runset are minimal:
.control
save all
setseed 100
reset
let mc_points=10
let index=0
setplot new
set myplot=$curplot
let index_mc=vector(mc_points)
let t_pd_l2h=vector(mc_points)
let t_pd_h2l=vector(mc_points)
while index < mc_points
tran 0.1p 3n
MEAS TRAN t_pd_L2H TRIG V(v_i) VAL=0.9 RISE=1 TARG V(v_o) VAL=0.9 RISE=1
MEAS TRAN t_pd_H2L TRIG V(v_i) VAL=0.9 FALL=1 TARG V(v_o) VAL=0.9 FALL=1
let {$myplot}.index_mc[index]=index
let {$myplot}.t_pd_l2h[index]=t_pd_l2h
let {$myplot}.t_pd_h2l[index]=t_pd_h2l
write xschem-meas-table-mc.raw
set appendwrite
let index = index + 1
end
unset appendwrite
setplot $myplot
settype notype index_mc
settype time t_pd_l2h
settype time t_pd_h2l
write xschem-meas-table-mc-meas.raw
.endc
Here, we’ve added the loop to run a Monte Carlo analysis. In addition to that, we’ve had to change two things:
- Vector lengths are set to the total number of Monte Carlo points
- Measurement results are assigned by the index of the iteration (which is also saved (optional)
With this, we have the following result:

Conclusion
In this article, we’ve covered a methodology for saving measurements and displaying them alongside waveforms. This does not require any separate manual result loading and your results are available all at once.
If you have any comments, do not hesitate to let me know!
If this article has helped you, please consider supporting me with a coffee.

메타데이터
- post_id
- 2ae0c71ecfb0
- slug
- displaying-measurements-and-waveforms-simultaneously-in-xschem-2ae0c71ecfb0
- url
- https://medium.com/@f.hormot/displaying-measurements-and-waveforms-simultaneously-in-xschem-2ae0c71ecfb0
- canonical_url
- https://medium.com/@f.hormot/displaying-measurements-and-waveforms-simultaneously-in-xschem-2ae0c71ecfb0
- author_url
- https://medium.com/@f.hormot
- status
- ok
- fetched_at
- 2026-06-20 20:29:01