Home / Resources / How to observe crosstalk between systems through simulation
Introduction
In electronics, crosstalk is any phenomenon by which a signal transmitted on one circuit or channel of a transmission system creates an undesired effect in another circuit or channel. Crosstalk is usually caused by undesired capacitive, inductive, or conductive coupling from one circuit or channel to another.
Ngspice is an open-source mixed-level/mixed-signal electronic circuit simulator. It is a successor of the latest stable release of Berkeley SPICE, version 3f.5, which was released in 1993. A small group of maintainers and the user community contribute to the ngspice project by providing new features, enhancements and bug fixes.
gnuplot is a command-line and GUI program that can generate two- and three-dimensional plots of functions, data, and data fits. It can produce output directly on screen, or in many formats of graphics files. It is also capable of producing LaTeX code that can be included directly in LaTeX documents, making use of LaTeX's fonts and powerful formula notation abilities.
Spice
Let's imagine that we have a first device that conducts a modulation of some useful signals. A quick solution to simulate this is a Pulse-Width Modulation (PWM) with a ramp at the carrier frequency:
- if the input signal is above the ramp, then we have 1
- if the input signal is bellow the ramp, then we have 0
The load affects the crosstalk so me must add something ; for instance, a low pass filter.
** input signal of device 1: sine wave between 0.05 and 0.95
VIN IN 0 SIN(0.5 0.45 100K 0 0 0)
** device 1 PWM carrier: repeat the whole sequence for the ramp between 0 and 1
.PARAM RAMP_PERIOD='1/1Meg'
VRAMP RAMP 0 PWL(0 0 'RAMP_PERIOD' 1) R=0
** device 1 PWM signal: modulation of the input signal
BDATA DATA 0 V='V(IN) > V(RAMP) ? 0.5 : -0.5'
** load of device 1: low pass filter at 1/(2*pi*R*C) [Hz]
VMEAS DATA MEAS DC(0) ; * to measure the output current
RLOAD MEAS OUT1 R=1k
CLOAD OUT1 0 C=1n
Now let's imagine that a second device is implemented on the same System on Chip (SoC) and shares the same power supply. The common resistor produces a drop on the power supply.
If the second device sends some data to the outside world after an other modulation, then the residual signal (present on the power supply) is sent as well. This can be observed with a simple clock at the carrier frequency and by using the same power supply.
** convert output current to a residual voltage on power supply:
.PARAM RPOWER=2
BVDD VDD 0 V='1 - RPOWER*I(VMEAS)'
** somewhere else in the same SoC, we have a device 2 using the same power
** supply with no signal:
.PARAM CLK_PERIOD='1/2.5Meg'
VCLK2 CLK2 0 PULSE(0 1 1ns 1ns 1ns 'CLK_PERIOD/2' 'CLK_PERIOD')
BOUT2 OUT2 0 V='V(CLK2) > 0.5 ? V(VDD) : 0'
.TRAN '0.01*CLK_PERIOD' 1m
Gnuplot
A fast Fourier transform (FFT) on the output of the second device allows to observe the crosstalk. Although, a zoom is needed to observe the data linearly on each side of the carrier. Gnuplot allows to trace the data that ngspice outputs.
Fs=1e6 # sampling frequency
Fd=100e3 # data signal frequency
set xlabel "Hz"
set grid
set xtics 100e3
set terminal postscript eps color size 10,4
set out "fft_out2.eps"
set multiplot layout 1,3 title "FFT of output 2"
set xrange [2*Fd/10 : 2*Fd]
set yrange [-160:10]
set size 0.25,0.98
plot 'fft_out2.data' with lines lw 2 lc 3 title "dB(V(OUT2))"
set xrange [Fs - 2*Fd : Fs + 2*Fd]
set yrange [] writeback
set size 0.5,0.98
set origin 0.25,0
plot 'fft_out2.data' with lines lw 2 lc 3 title "dB(V(OUT2))"
set xrange [2*Fs - 2*Fd : 2*Fs]
set yrange [] writeback
set size 0.25,0.98
set origin 0.75,0
plot 'fft_out2.data' with lines lw 2 lc 3 title "dB(V(OUT2))"
unset multiplot
Makefile
Now, we must run the simulation with Ngspice and ask gnuplot to plot our
data into a file.
Let's imagine that our Spice source is written in a file called testbench.cir
and that our gnuplot script is called zoom.plt
.
Here is a Makefile that provides the recipe (make sure to indent with tabulations):
all: fft_out1.eps fft_out2.eps
fft_out1.eps fft_out2.eps: zoom.plt fft_out1.data fft_out2.data
gnuplot $<
fft_out1.data fft_out2.data: testbench.cir
ngspice $^
clean:
$(RM) fft_out1.data fft_out1.plt fft_out1.eps
$(RM) fft_out2.data fft_out2.plt fft_out2.eps
Associated resources
Here is an archive which contains the discussed example and its Makefile.