JuliaComputing / xtrx_julia

XTRX LiteX/LitePCIe based design for Julia Computing
BSD 2-Clause "Simplified" License
1 stars 0 forks source link

Spiking signal issues #41

Open staticfloat opened 1 year ago

staticfloat commented 1 year ago

When capturing signals using the TBB loopback, we found that there is a regular spiking pattern that tends to happen near signal zero-crossings. In this figure, the blue line represents what was transmitted, and the orange/green lines represent what is received:

image

Note the regular pattern of the spikes, and how the spikes follow the curvature of the signal, almost like the signal is being bitshifted. I hypothesized that this might be a clocking issue, and so embarked on a combinatorial exploration of the various clocking options within the LMS, finding that if we inverted the RX LMLA and RX LMLB clocks (e.g. set CDSN_RXALML and CDSN_RXBLML) the spikes went away. Here's a zoomed out view, where we're transmitting a modulated sinusoid, showing timing behavior (don't worry that the transmitted signal ends, we're only plotting a single period of it):

image

This is a reasonable workaround, but I'm pretty sure it's just adding a little extra stability on top of an unsteady foundation. If we start to push other parameters of the system, we see similar issues appear elsewhere. If we increase CGEN frequency up to 400MHz (necessary for high-bandwidth (40MHz) captures), we get a host of bad behaviors, including spiking, and leakage from the real part to the imaginary part:

image

Even if we don't pass through the baseband, the digital loopback itself starts to break down at such a high CGEN frequency:

image

My main guess as to what's going on wrong here is that our estimate of our reference clock is off by a few percentage points, and when we feed this through the PLL, we get something that is wildly off of what we expect, and that screws up some clock propagation somewhere. However, this isn't really my domain of expertise, so I think we're going to need to call in an expert to truly get to the bottom of this.

enjoy-digital commented 1 year ago

The issue is probably related to a calibration of the FPGA <-> LMS7002M delays that would need to be done after setting up the CGEN (or a pre-defined table that would need to be generated/configured based on CGEN).

The FPGA has the possibility to adjust TX/RX delays (similarly to what you are doing with the clock inversion) and this has been tested from Python scripts with: https://github.com/enjoy-digital/xtrx_julia/blob/master/test/test_lms7002m_digital_interface.py

IIRC I set default values that were working correctly with the CGEN I tested, but the behavior is maybe different in your case.

In the short term, this could be useful to had the possibility to adjust these delays in your software and see if you find values that work correctly for the CGEN freqs you are currently using.

In the long term, it would be useful to implement a proper calibration:

This could be similar to AD9361's AN-1441: https://www.analog.com/media/en/technical-documentation/app-notes/an-1441.pdf

maleadt commented 1 year ago

Looking into this, I haven't found anything delay-related that changes this. First, I tried re-calibrating the TX/RX clock delays with the set-up from acquire_iq.jl using the standard CGEN (but with clock inversion disabled again), but it seems like most delays are just valid:

TX-RX Delay Scan...
TX / RX 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
00 |     -  -  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X
01 |     -  -  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X
02 |     -  -  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X
03 |     -  -  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X
04 |     -  -  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X
05 |     -  -  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X
06 |     -  -  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X
07 |     -  -  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X
08 |     -  -  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X
09 |     -  -  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X
10 |     -  -  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X
11 |     -  -  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X
12 |     -  -  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X
13 |     -  -  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X
14 |     -  -  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X
15 |     -  -  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X
16 |     -  -  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X
17 |     -  -  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X
18 |     -  -  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X
19 |     -  -  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X
20 |     -  -  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X
21 |     -  -  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X
22 |     -  -  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X
23 |     -  -  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X
24 |     -  -  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X
25 |     -  -  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X
26 |     -  -  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X
27 |     -  -  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X
28 |     -  -  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X
29 |     -  -  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X
30 |     -  -  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X
31 |     -  -  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X

So the default of 16/16 should work fine. I guess that's because the spikes aren't introduced when using the digital loopback?

Florent suggested trying to re-calibrate at a higher CGEN as to maybe fix that issue at least, but I cannot reproduce that issue. Using a master clock rate of 400e6, I'm getting:

$ julia --project acquire_iq.jl --digital-loopback
[INFO] CGEN tune 400.000000 MHz (fref=26.000000 MHz) begin
[DEBUG] Using: fdiv = 6, Ndiv = 92.307692, fvco = 2400.000000 MHz
[INFO] SXX tune 1575.000000 MHz (fref=26.000000 MHz) begin

data_re

TBB loopback looks reasonable too. @staticfloat was this on my rev4 you were doing these experiments? Any additional settings I'm missing?

maleadt commented 1 year ago

Changing delays does improve the issue with higher-frequency CGEN, albeit partially. See https://github.com/JuliaComputing/xtrx_julia/pull/44#issuecomment-1231957860