LLRFLibsPy Introduction#

LLRFLibsPy is a library of LLRF domain algorithms implemented in Python. It’s main purpose is to implement common LLRF algorithms benificial for the development of LLRF high-level applications, automation, and test software. Here we introduce the backgroud and motivation for this work.

Survey of Firmware/Software Libraries in LLRF Community#

After years’ development of digital LLRF systems, their architecture are now quite mature with similar patterns. Though pushing the RF field stability to extreme and applying advanced algorithms like modern control algorithms and machine learning are still guiding the R&D, standardization of the LLRF hardware, firmware and software has been started. DESY is in advance to standardize the LLRF hardware based on the MicroTCA platform. Some basic firmware/software libraries have been developed at DESY and PSI:

  • PSI Firmware/Software Libraries

    • psi_fix: bittrue implementations in VHDL (for synthesis) and Python (for fast simulations) of standard signal processing components.

    • psi_common: contains general VHDL code that is not very application specific and can be reused easily.

    • psi_tb: contains VHDL code that is useful for testbenches.

    • PsiSim: TCL framework allows easily creating regression tests using modelsim, VHDL and Vivado-Simulator.

    • LLRFLibs: LLRF algorithm library implemented in C language.

    • LLRFLibsPy: LLRF algorithm library implemented in Python (code of this website).

    • ooEpics: C++ framework for EPICS module development.

    • ooPye: Python framework for EPICS soft IOC development.

  • DESY Firmware/Software Libraries

    • FWK: a library for firmware framework.

    • ChimeraTK: a library for software framework

These libraries are used either to build the architecture, framework and infrastructure of the firmware/software or to implement domain algorithms related to LLRF and accelerator controls. To understand the motivations to develop these libraries, let us first have a look at the roles and locations of these libraries within the LLRF system.

Motivation for Libraries#

A general logical (functional) architecture of LLRF systems is depicted in Figure 1. Note that different implementations may map the functional blocks into different physical architecture. For example, the new SwissFEL X-band LLRF system combines the “LO & Clock Generator” and “RF Transceiver” into a single custom chassis, whereas DESY’s MicroTCA system has a separated box for “LO & Clock Generator” and implements the “RF Transceiver” into an RTM board.

Figure 1: A general functional architecture of a LLRF system

In Figure 1, the FPGA and CPU (a LLRF station may have multiple FPGAs and CPUs) are the digital processing units hosting the firmware and software entities. The logistical (functional) architecture of the firmware and software are depicted in Figure 2, including allocations into the FPGA and CPU. The firmware architecture are explained as follows:

  • We separate the “Platform Support Firmware Modules” and the “Application Firmware Modules”. These two parts can be developed by different teams since different domain knowledge is required. To implement the platform support modules, the developers need to know the detailed protocols and electronic characteristics to access the on-board hardware components, such as the ADCs, DACs, memories and data buses (e.g., PCI express). On the other hand, the application firmware requires domain knowledge for RF signal detection, filtering, feedback control, and so on.

  • The “Application Interface” of firmware should be designed as generic as possible to decouple the platform and application modules.

The following firmware libraries can be beneficial for LLRF firmware development:

  • Firmware Framework Library: Such a library helps construct the firmware project structure, simulate the firmware code, and automate the firmware synthesize. Of course, platform support modules for accessing widely used hardware components (e.g., popular ADC chips, DAC chips, PCI express driver) can also be compiled into the library.

  • Basic Firmware Library: This library collects firmware build-up components (e.g., FIFO, filters… as shown in the diagram) that can be used in any firmware implementation.

  • RF Control Firmware Library: This library aims at implementing generic high-level configurable LLRF control modules. These modules can be assembled and configured to derive a working LLRF controller quickly.

These libraries enables fast prototyping of LLRF controllers containing most fundamental features to satisfy most of the RF control requirements. The LLRF developer can make further development based on these libraries to include specific features for solving the particular RF control problems that they are facing.

The software architecture are explained as follows:

  • A layered architecture is constructed. The “OS & Drivers” layer is at the bottom that is platform specific. The “Platform Control Interface” is a wrapper to separate the platform and application software, which has the similar role as the “Application Interface” in the firmware.

  • The “Low-Level Applications” are usually soft real time for fast processing. In most LLRF systems, this layer is thin since most real-time functions can be implemented in the FPGA firmware, leaving this layer small only implementing necessary software-based real-time functions like data streaming, fast (complex) diagnostics/protection, and pulse-to-pulse feedback (for pulsed machine).

  • The “High-Level Applications” are non-real-time functions performing the automation of the operation of LLRF system. This part requires lots of LLRF domain knowledge (e.g., cavity model, control theory, signal processing theory, etc.) since the high-level applications need to interpret the raw results from FPGA to values with physical meanings.

The following Software libraries can be beneficial for LLRF software development:

  • Software Framework Library: The library defines a common software architecture and implements the infrastructures for multithreading, hardware access and network communication.

  • LLRF Algorithm Library (C/C++): This library implements RF control domain algorithms. If written in C/C++ languages, the library can be used in “Low-Level Applications” for fast processing.

  • LLRF Algorithm Library (Python): This library is suitable to implement “High-Level Applications”, including the RF test and conditioning automation software. Python is an excellent language for such applications. In addition to the same algorithms as in the C/C++ libraries, the Python library may also implement the features for noise analysis, feedback controller design, analysis and simulation. With such features, we can further reduce the reliance on Matlab for controller design.

Figure 2: A general functional architecture of the LLRF firmware and software and the libraries

This document describes the architecture, algorithms, and manual for the LLRFLibsPy library implemented at PSI.

Dependencies#

LLRFLibsPy depends on the following Python modules:

Installation#

To be documented …