[[TOC]]
The core tasks of any LLRF controls are:
- RX: Measure RF signal:
- Frequency conversion to base-band;
- Diagnostics and record waveforms;
- Control:
- Feedback control
- Feed-forward control
- System identification
- Diagnostics and record waveforms;
- TX: Drive RF signal:
- Frequency conversion from base-band;
- Diagnostics and record waveforms;
- Trigger and interlocks
These tasks are abstracted in the following diagram, which highlights the core elements of each building blocks. The same concept and architecture applies to other platforms such as the [RFSoC based LLRF System design at ALS][https://arxiv.org/abs/2510.13192].
As part of the full-stack open source firmware development in Berkeley Lab, we leverage a collection of open source tools including:
- Icarus Verilog: tested version v12.0.
- Verilator: tested version 5.038.
- cocotb: tested version 2.0.1.
- yosys
and Jupyter notebooks for demonstration and documentation.
-
For
condausers, a python virtual environment can be created as:conda create -n uspas_llrf python=3.13 conda activate uspas_llrf pip install -e . -
All tools are native to Debian Trixie, where we used it in the
gitlabContinuous Integration, as defined .gitlab-ci.yml, including steps of:- Coding style sanity checking using
flake8; cocotbLLRF DSP behavioral verification;- Clock domain crossing validation;
- Bit-stream synthesize for all supported variants of applications;
- Hardware in-the-loop testing;
- Coding style sanity checking using
The following of pre-defined LLRF applications are supported, and their frequency settings are described in README.md.
USPAS: For USPAS LLRF class taught in 2023.ALSU: For LBNL ALS-U AR LLRF system.LEMP: SLAC Linac Electronics Modernization ProjectAWA: Argonne AWA facility
Detailed description of settings:
- LLRF DSP: All configurations are contained in uspas_llrf/settings.json.
- Board Support:
For each application, customized hardware settings and LLRF configurations can be found in
soc/<design>/(for example soc/uspas), where each application's configuration files for FPGA carrier and digitizer (init_marble.c,init_zest.c) are located.
A RISC-V soft core PicoRV32 is used for peripheral control, booting and diagnostics. We leverage the cross-compiler tool and common modules described in Berkeley Lab's Bedrock repository.
The design can be found in soc/common, where:
- Open source RTL simulation: See soc/common/sim, for the booting process, using purely icarus verilog.
- Full RTL simulation:
See soc/common/top_sim. This simulation process requires Xilinx vivado command tools like
xvlogandxelab, for building and execution respectively. This allows the use of UNISIM models provided by vivado's installation package, for a complete behavioral verification of Xilinx primitives including XADC, ISERDES, etc, which is needed for the development of board support package with LVDS digitizer interface. - Hardware test: See soc/common/synth, where two functions are implemented:
- Synthesis: A minimal structured bitstream file containing only the soft core and essential peripherals.
- Boot-loading: The CPU program memory in the deployed production bitstream can be updated using a boot-loading process thanks to a built-in bootloader. This is a well known technique in embedded system designs, and provides flexible and quick iterations for development / troubleshooting. Details and examples can be found in soc/common/synth/README.md.
We use LBNL Bedrock's Makefile based building system to find dependencies and synthesize the bitstream file in top/<design>/ (for example top/uspas), with shared rules and sources in top/common. The top level RTL marble_zest_top.v assembles the soft core, board support package and LLRF DSP together.
FPGA carrier (Marble)
See marble_bsp/marble_bsp.v, which features:
- LBNL local bus control interface;
- LBNL Gigabit Ethernet UDP engine (Packet Badger);
- LBNL 8b10b MRF timing event receiver (EVR);
- LBNL Marble micro-controller (MMC) mail-box interface;
- External trigger logic;
Digitizer (Zest)
See bedrock/board_support/zest_soc.
As shown in the following diagram of the digitizer (Zest) board support, the clock distribution chip LMK01801 receives an external reference clock, and the outputs of two divider groups drives ADC AD9563 and DAC AD9781 respectively, where the DAC sampling clock is double of the ADC sampling clock, which is the same as the DSP clock.
A collection of LLRF DSP numerical models can be found in uspas_llrf/model/llrf_dsp.py, which is shared among all simulations.
The complete feedback controller is modeled, and it can be used for cocotb simulation with cavity emulators, whose parameters are defined in uspas_llrf/model/cavity.json.
The detailed cavity model co-simulation with discrete signal process is explained in doc/lti.ipynb.
There are two conventions for IQ decomposition of a RF signal
-
Positive carrier frequency:
As described in Wikipedia,
$$ \begin{align*} y(t) &= (I + jQ) \cdot e^{j\omega t} \ \Re(y(t)) &= I\cos(\omega t) - Q\sin(\omega t) \end{align*} $$
This convention is used in this repository.
-
Negative carrier frequency:
$$ \begin{align*} y(t) &= (I + jQ) \cdot e^{j-\omega t} \ \Re(y(t)) &= I\cos(\omega t) + Q\sin(\omega t) \end{align*} $$
This convention is used in
bedrock/dspRTL modules.
Also known as NCO, it is used to generate a pair of sinusoidal signals at a single frequency, with a known starting phase. The DSP implementation is shown in the following figure. It is consisted of a phase accumulator and a CORDIC for conversion from Polar to Rectangular coordinate.
-
RTL implementation
See llrf_dsp/dds.v.
-
Simulation
See llrf_dsp/tests/dds.
For high precision digitization, Non-IQ direct digital down-conversion is used to avoid aliasing.
With the normalized ADC IF frequency
Solve
-
RTL implementation
RTL implementation is in
noniq_ddc.v, where a serialized stream of IQ data is generated, with a gain of$\sin(\omega_d)$ .An interpolation module
fiq_interp.vis used to convert to parallel I and Q sample streams. A DC-blocking modulefwashout.vis inserted before thenoniq_ddc.v. The full DDC is packaged inddc.v. -
Simulation
See llrf_dsp/tests/ddc.
A generic digital up-conversion scheme is implemented, in the dac_clk domain.
With the normalized DAC IF frequency
Equation in matrix form:
To avoid aliasing, condition
When operating in the under-sampling scheme, the signal location at the first Nyquist zone must be calculated to derive the effective NCO frequency value.
The following figure illustrates two cases of modulation at carrier frequency
-
First Nyquist zone:
$0 < f_c < \frac{f_s}{2}$ , see case (b). -
Second Nyquist zone:
$\frac{f_s}{2} < f_c < f_s$ , see case (c). The NCO frequency is set to be$-(f_s - f_c)$ or$-f_c$ . This flip of sign is known as the spectral inversion due to frequency folding around the Nyquist frequency. -
RTL implementation
In practice, this spectral inversion is implemented by simply flipping the sign of the
$\sin(\omega n + \theta)$ for the LO to rotate in a counter clock wise direction.Many applications like LEMP and PIP-II LLRF use single-side-band modulation for analog up conversion from IF to RF. When this modulation is configured as the lower-side band modulation, it will result in a phase sign flip between IF and RF. This can be compensated by an additional register
tx_afe_spectral_flip. To gurantee the correct phase sign including both digital and analog upconversion, the combined spectral flipping is applied by an XOR between the reigisterduc_spectral_flip(digital) andtx_afe_spectral_flip(analog). -
Simulation
See llrf_dsp/tests/duc.
This approach is consistent with the NCO Modulator in many RF-DACs such as the AD9174 (Figure 79), and the AMD RFSoC with its NCO Setting, where a standalone NCO with configurable frequency and phase is instantiated, allowing 1st or 2nd Nyquist zone modulation. For 2nd Nyquist zone operation, most DACs has a Mix-Mode available to increase the amplitude response.
As a classical PI controller, it is designed to operate in base band with a single, complex input and output signal. There are two parallel PI controllers for amplitude and phase control, respectively. The phase wrapping is taken care of in the difference calculation. A pair of CORDIC are used to convert the complex signal to between rectangular and polar representation, where phase offsets can be added optionally.
-
RTL implementation
See llrf_dsp/dsp_core.v, as shown in the following diagram:
-
Simulation
cocotbtests will go through all test cases for various frequency settings, each has a test of RX, open loop and close loop responses. The results are integrated as part of the gitlab Continuous Integration, where the configuration can be found at .gitlab-ci.cml.
Three functions are integrated in the llrf_dsp/cic_waves.v:
- Dynamic waveform with a run-time configurable CIC filter and channel selector. The decimation factor is the production of
cic_base_periodandwave_samp_perregisters. The CIC filter response and calibration factors are calculated at theCICWaveRecorderclass inllrf_dsp.py. - A circular buffer that captures the CIC waveform, associated with diagnostic data including minimum and maximum value of each channel, 64 bit timestamp and fault status. Trigger logic, pre and post trigger buffer, fault freezing features are included.
- Sharing the same integrator, a fixed decimation filtered datastream of all channels are generated for the use of fast interlock purpose.
-
RTL implementation
Putting things together, we can form a complete chain of digital frequency conversion with two independent feedback control loops with flexible ADC / DAC channel mapping, with independent ADC / DAC IF frequencies.
-
Simulation
See llrf_dsp/tests/llrf_shell.
A complete instantiation of
llrf_shell.vand its pre-processed application settings is tested undercocotbverification through the LBNL Local Bus control interface, which include:- A test signal driving an ADC channel with known frequency, amplitude and phase, for testing RX path including down-conversion;
- A looped-back signal from one DAC channel to an ADC channel, for testing TX path including up-conversion;
- A looped-back signal from the other DAC channel to an ADC channel, for testing feedback loop settings and closed-loop response;
- CIC filtered waveform acquisition for multi-channel signals including 2 DACs and 10 ADCs, with configurable decimation factors;
- Wide bandwidth IQ waveform acquisition for each DAC and ADC base-band signal with sample-to-sample resolution;
- Fast interlock protection logic and RF permit latching;
- Trigger logic;
-
Calibration
The numerical DSP transfer function of each building element in
llrf_shell.vare modeled in uspas_llrf/model/llrf_dsp.py.The DSP models are used in both
cocotbsimulaiton, and the Python driver in uspas_llrf//app, where the calibration factors are illustrated in the following diagram:
An example python class for packaging the LLRF application can be found in uspas_llrf//app, where a few Jupyter notebook examples are provided as reference use cases.
See LBNL FEED.