FPGA Design

This section focuses on the practical implementation of Digital Signal Processing (DSP) algorithms on FPGAs. We explore advanced techniques using both VHDL for RTL design and AMD Vitis for High-Level Synthesis (HLS). Our content highlights strategies to optimize throughput and minimize latency, providing technical solutions for modern FPGA design challenges. We hope these insights support your development journey and help you master complex silicon optimization.

  • Hardware-Verified Radar Processing on Zynq (Part 2: FPGA Architecture, Folding & Timing Closure)

    Hardware-Verified Radar Processing on Zynq (Part 2: FPGA Architecture, Folding & Timing Closure)

    In Part 1, we established the theoretical foundations of our radar processing chain—covering complex I/O baseband modeling, LFM chirp generation, and a rigorous mathematical breakdown of pulse compression and coherent integration processing gains.

    In this second and final post, we transition directly from GNU Octave algorithmic models to high-performance VHDL implementation on an AMD/Xilinx Zynq-7000 (xc7z020clg400-1) FPGA, examining time-division folded FIRs, complex convolution, Standard FIFO latency tuning, and 250 MHz timing closure.

    1. Quad-Channel Folded FIR Architecture

    Implementing a 50-tap symmetric finite impulse response (FIR) filter across four parallel channels for complex cross-correlation ($II, IQ, QQ, QI$) can quickly exhaust available digital signal processing resources if instantiated directly.

    To achieve high throughput while maintaining low resource utilization, the architecture employs 5x time-division folding (DSP_FOLD_STAGES_C = 5) leveraging the internal pre-adder and cascade features of the DSP48E1 primitive slice.

    • Symmetric Folding: By exploiting filter symmetry, each 50-tap filter processes two symmetric data taps per clock cycle across folded stages.
    • Resource Efficiency: The entire quad-channel complex matched filter engine consumes only 20 DSP48E1 slices (10% utilization on the XC7Z020), leaving ample programmable fabric for downstream integration and control logic.

    2. Complex Convolution & Convergent Rounding

    The quad-channel architecture computes the full complex cross-product between the incoming digitized radar echo ($I_{\text{rx}} + jQ_{\text{rx}}$) and the reference chirp ($I_{\text{tx}} – jQ_{\text{tx}}$):

    $$\text{Real Output} = \text{II} – \text{QQ} = (I_{\text{rx}}I_{\text{tx}} + Q_{\text{rx}}Q_{\text{tx}})$$

    $$\text{Imaginary Output} = \text{IQ} + \text{QI} = (Q_{\text{rx}}I_{\text{tx}} – I_{\text{rx}}Q_{\text{tx}})$$

    Bit-Growth & Convergent Rounding

    Internal multiplication and summation within the DSP48E1 slices result in a 32-bit word width. To downsize the stream back to 16-bit word lengths (ADC_BIT_RES_C = 16) without introducing systematic DC offsets, the design implements convergent rounding (round-to-nearest-even arithmetic) via a custom conv_round function before truncating the lower bits.

    Two channel FIR filter used as match filter

    Figure 1: Simulation waveform displaying the complex I/O matched filter output streaming through the folded DSP architecture.

    As demonstrated in the simulation waveform above, the raw noisy input pulses are successfully processed through the folded matched filter stages, eliminating background noise and yielding a clean, high-fidelity pulse compression response.

    3. Standard FIFO Latency Tuning & Data Alignment

    Managing clock-domain crossings (CDC) between the high-speed 250 MHz DSP clock domain and system interfaces requires careful FIFO selection.

    Transitioning to a Standard FIFO

    While First Word Fall Through (FWFT) FIFOs make data immediately available on dout, migrating to a Standard FIFO introduced a deterministic 1-clock-cycle read latency after asserting the read enable (rd_en).

    Resolving the Pipeline Shift

    1. Initial Zero Padding: When switching to a Standard FIFO, the initial read cycle produced a leading zero in the convolution stream (conv_ctr_s).
    2. Internal Threshold Adjustment: Rather than adding external input registers that would disturb high-fanout control routing, we adjusted the internal validation threshold (conv_ctr_v trigger condition) inside complex_convolution.vhd to absorb the 1-cycle read latency natively.
    3. Deterministic Peak Lock: This alignment eliminated leading-edge jitter and locked the final peak detection index precisely onto target bin 2333 ($R = 6999\text{ m}$), matching parity with our Octave golden reference model.

    4. 250 MHz Timing Closure & Vivado Implementation

    At 250 MHz, maintaining setup and hold timing across high-fanout control buses (cyc_ctr_s, clk_ena_i) across 20 distributed DSP slices presents a critical engineering challenge.

    • Implementation Strategy: Configuring the Vivado project generation script (range_detector.tcl) to enforce the Performance_NetDelay_high implementation strategy optimized place-and-route slack.
    • Timing Results: The final implementation achieved zero timing violations with a comfortable positive Worst Negative Slack (WNS) of ~0.158 ns at 250 MHz.

    The complete design operates efficiently within tight programmable logic bounds:

    Final resource usage of Correlation

    5. CORDIC Vectoring & Final Peak Detection

    Following 8-pulse coherent integration (which yields a theoretical 9.03 dB SNR boost), the Cartesian coordinate outputs ($I, Q$) are converted into polar magnitude and phase representations using a pipelined CORDIC IP core (IQ2Vector.xci).

    The peak search engine (peak_search_proc) monitors the absolute magnitude stream, identifying the absolute maximum value and latching the corresponding range bin.

    compatibility of VHDL simulation results with the Octave script result

    Figure 2: Final hardware peak detection output compared against the Octave simulation model.

    As illustrated in the final simulation waveform above, the hardware output perfectly mirrors the theoretical peak profile generated in our initial Octave script.

    Conclusion

    By bridging rigorous mathematical modeling in Octave with cycle-accurate VHDL implementation, folded DSP48E1 arithmetic, and aggressive Vivado timing closure, we have successfully deployed a production-grade radar signal processing chain on Zynq-7000 silicon.

    All VHDL source files, testbenches, IP configuration scripts (range_detector.tcl), and simulation assets are fully verified and available in the GitHub Repository.

  • FPGA radar correlator on Zynq: From Mathematical Modeling to FPGA Implementation (Part 1)

    FPGA radar correlator on Zynq: From Mathematical Modeling to FPGA Implementation (Part 1)

    Introduction

    Designing real-time digital signal processing (DSP) pipelines on embedded FPGA hardware requires bridging theoretical signal processing and hardware execution. Before writing VHDL RTL, establishing a bit-true algorithmic model in MATLAB/Octave or Python is essential.

    This post builds the theoretical foundation of our radar pipeline—covering complex I/O baseband representation, Linear Frequency Modulated (LFM) chirps, matched filtering, and a rigorous mathematical breakdown of Processing Gain.


    1. Complex Baseband Representation (I & Q Modeling)

    In modern digital radar systems, radio frequency (RF) signals are rarely processed directly at carrier frequencies due to sampling rate limitations and ADC bandwidth constraints. Instead, the signal is downconverted to a complex baseband representation consisting of In-phase ($I$) and Quadrature ($Q$) channels:
    $$s(t) = I(t) + jQ(t)$$

    • Why I/Q? A real-valued sinusoidal signal splits its spectral energy equally between positive and negative frequencies ($f_c$ and $-f_c$), leading to spectral ambiguity. By sampling the signal with two phase-orthogonal local oscillator references ($0^\circ$ for $I$ and $-90^\circ$ for $Q$), we form a complex analytic signal.
    • Preserving Phase & Frequency Shift: This complex representation allows the digital signal processor to unambiguously distinguish between positive and negative Doppler frequency shifts (target approaching vs. receding) and preserves instantaneous phase for precise matched filtering.

    2. LFM Chirps, Matched Filtering & Simulation Visuals

    To achieve high range resolution without requiring impractically high peak transmission power, pulsed radars transmit wideband modulated waveforms—most commonly Linear Frequency Modulated (LFM) chirps. An LFM chirp sweeps its instantaneous frequency linearly across a bandwidth $B_{\text{chirp}}$ over a pulse duration $T$:

    $$s(t) = \text{rect}\left(\frac{t}{T}\right) \exp\left(j \pi k t^2\right)$$

    where $k = \frac{B_{\text{chirp}}}{T}$ is the frequency modulation slope rate, and $t$ is centered symmetrically across the pulse duration interval $\left[-\frac{T}{2}, \frac{T}{2}\right]$.

    According to matched filter theory, the optimal linear filter maximizing output Signal-to-Noise Ratio (SNR) in white Gaussian noise has an impulse response that is the time-reversed, complex conjugate of the transmitted signal:
    $$h(t) = s^*(T – t)$$

    In digital hardware, complex cross-correlation expands into four parallel real convolutions:
    $$(I_{rx} + jQ_{rx}) * (I_{tx} – jQ_{tx}) = (I_{rx}I_{tx} + Q_{rx}Q_{tx}) + j(Q_{rx}I_{tx} – I_{rx}Q_{tx})$$

    3. Noise Modeling & Thermal/Ripple Breakdown

    Before generating the received signal, realistic environmental and system noise components are modeled:

    • Thermal Noise Power ($N_{\text{thermal}}$): Calculated using Boltzmann’s constant ($k = 1.38 \times 10^{-23}\text{ J/K}$), standard temperature ($T_0 = 290\text{ K}$), receiver matched filter bandwidth ($B = 1/T = 1\text{ MHz}$), Noise Figure ($F = 2$), and system losses ($L = 5$):$$N_{\text{thermal}} = k \cdot T_0 \cdot B \cdot F \cdot L$$
    • Power Supply Ripple Noise: Modeled as a sinusoidal interference component at $f_{\text{ripple}} = 120\text{ Hz}$ with an RMS voltage of $V_{\text{ripple\_rms}} = 5 \times 10^{-7}\text{ V}$ across a $50\,\Omega$ reference impedance ($R_{\text{ref}}$):$$P_{\text{ripple}} = \frac{V_{\text{ripple\_rms}}^2}{R_{\text{ref}}}$$
    • AWGN Addition: Complex Additive White Gaussian Noise ($\sigma_{n\_thermal} = \sqrt{N_{\text{thermal}}/2}$) is combined with the ripple interference across the full streaming matrix to simulate a received signal entirely buried beneath the noise floor.
    Comparison of transmitted LFM chirp signal, clean reflected received signal, and noise-corrupted received signal.

    Figure 1: Comparison of the transmitted reference chirp, a clean simulated received echo, and the noise-corrupted received signal ($r(t)$). As illustrated above, single-pulse received echoes are heavily buried beneath thermal noise, rendering raw threshold detection entirely impossible prior to pulse compression.


    3. Comprehensive Processing Gain Breakdown

    Total processing gain ($G_{\text{total}}$) is achieved through two distinct mechanisms:

    • Pulse Compression Gain ($G_{\text{PC}}$): Governed by the Time-Bandwidth Product ($BT = 20$):

    $$BT = (20 \times 10^6\text{ Hz}) \times (1 \times 10^{-6}\text{ s}) = 20$$

    $$G_{\text{PC(dB)}} = 10 \log_{10}(20) \approx 13.01\text{ dB}$$

    (Note: In discrete implementation with $N = 50$ tap coefficients, discrete matched filter gain is $10 \log_{10}(50) \approx 16.99\text{ dB}$)

    • Coherent Integration Gain ($G_{\text{coh}}$): Integrating $N_p = 8$ successive PRIs yields:

    $$G_{\text{coh(dB)}} = 10 \log_{10}(8) \approx 9.03\text{ dB}$$

    • Total System Gain:

    $$G_{\text{total(dB)}} = 16.99\text{ dB} + 9.03\text{ dB} = 26.02\text{ dB}$$


    4. Radar Range Equation & Octave Simulation Results

    Propagation physics are modeled via the radar range equation, where received power $P_r$ drops off inversely with the fourth power of target range $R$:
    $$P_r = \frac{P_t G^2 \lambda^2 \sigma}{(4\pi)^3 R^4 \cdot L}$$

    In our simulation framework (Correlation.m), the target is placed at sample index 2333, corresponding to a two-way propagation distance of:
    $$R = \frac{c \cdot \tau_{\text{prop}}}{2} \approx 6999\text{ meters}$$

    Final matched filter correlation output showing a distinct peak indicating the target range bin location.

    Figure 2: Octave simulation output showing the absolute magnitude of the matched filter response after 8-pulse coherent integration. The noise floor is suppressed, resulting in a sharp, unambiguous detection peak precisely at sample index 2333.


    Summary & Next Steps

    By establishing the mathematical framework—spanning complex I/Q baseband conversion, LFM chirp compression, and quantitative processing gain calculations—we generate our bit-true golden reference dataset (golden_ref_vector.dat).

    In the upcoming hardware implementation post, we transition directly from these Octave models to cycle-accurate VHDL on the Zynq-7000 FPGA, examining time-division folded FIRs, FIFO latency management, and 250 MHz timing closure.


    GitHub Repository:

    This Link – Stores GNU Octave simulation scripts and VHDL implementation files.

    References

    1. Radar Tutorial: Comprehensive theoretical foundations on pulse compression, matched filtering, and radar range equations. Available at radartutorial.eu.
    2. Skolnik, Merrill I. Introduction to Radar Systems, 3rd Edition, McGraw-Hill.
  • FIR Filter Implementation on FPGA Using Vitis HLS: Step-by-Step DSP IP Core Design

    FIR Filter Implementation on FPGA Using Vitis HLS: Step-by-Step DSP IP Core Design

    This FIR filter FPGA Vitis HLS implementation generates an optimized DSP IP core for real-time signal processing.

    Finite Impulse Response (FIR) filters are among the most widely used components in digital signal processing (DSP). They are essential in applications such as wireless communications, audio processing, radar systems, and FPGA-based real-time filtering.

    In this tutorial, we demonstrate how to implement a low-pass FIR filter on FPGA using AMD Vitis High-Level Synthesis (Vitis HLS) and deploy it as an optimized IP core.


    Project Overview: FIR Filter Design Using Vitis HLS

    The goal of this project is to:

    • Design an FIR filter in MATLAB
    • Implement the filter in C++
    • Synthesize the design into RTL using Vitis HLS
    • Export an FPGA-ready IP core
    • Verify performance through simulation and FFT analysis

    This workflow is widely used in FPGA-based DSP development.


    Step 1: FIR Filter Design in MATLAB

    We began by designing the FIR filter using MATLAB FDATool with the following specifications:

    • Filter Type: Low-pass FIR filter
    • Cutoff Frequency: ~2 MHz
    • Stop-band Attenuation: ~68 dB
    • Coefficient Format: 16-bit signed integers

    The coefficients were exported from MATLAB for use in the hardware implementation.


    Step 2: FIR Filter Reference Model in C++

    Next, we developed a C++ reference model to validate the filter behavior and generate golden simulation results.

    The software model served as:

    • A functional baseline
    • A reference output for RTL co-simulation
    • A verification tool during HLS development

    Step 3: Vitis HLS Workflow for FPGA Implementation

    The complete Vitis HLS design flow included:

    1. C Simulation
    2. High-Level Synthesis (RTL generation)
    3. RTL Co-Simulation
    4. IP Export for FPGA integration

    Vitis HLS successfully converted the FIR algorithm into a synthesizable IP core.


    Step 4: Performance Optimization Techniques in Vitis HLS

    In this FIR filter FPGA Vitis HLS design, loop pipelining and coefficient symmetry were applied to improve throughput.

    Symmetric Coefficient Optimization

    Since FIR filters often have symmetric coefficients, we leveraged symmetry to reduce the number of multiplications, cutting logic resource usage almost in half.

    Array Partitioning

    We applied the array_partition directive to enable parallel access to coefficient and delay-line arrays.

    function Pipelining

    Pipeline directives were added to the top function to maximize throughput.

    As a result, the design achieved:

    • One output sample per clock cycle

    Step 5: Testbench Input Signal and FFT Analysis

    To validate the FIR filter, the input signal consisted of:

    • A 1 MHz sinewave in the passband
    • A 6 MHz sinewave acting as high-frequency noise

    Input Signal

    Input test signal waveform with 1 MHz tone and 6 MHz noise

    FFT of Input Signal

    FFT spectrum of input signal before FIR filtering

    Step 6: FPGA Simulation Results Using XSim

    After exporting the FIR IP core, we integrated it into a Vitis FPGA project and simulated it using XSim.

    Time-Domain Output

    The simulation waveform confirmed that the noise component was significantly reduced.

    XSim simulation showing FIR filter input and output signals

    Frequency-Domain Output

    The FFT of the output showed strong attenuation of the unwanted 6 MHz signal.

    FFT spectrum after FIR filter showing 68 dB noise attenuation

    By measuring the FFT bin difference, we achieved:

    • ~68 dB stop-band attenuation, matching the MATLAB design target.

    Step 7: Simplifying and Optimizing the IP Interface

    In addition to datapath optimizations, improving the IP interface structure is an important step toward building a more professional and reusable FPGA core.

    In this stage, we applied optimizations to both the coefficient interface and the signal input/output ports.


    Reducing Excessive Array Ports

    When using array_partition, Vitis HLS may generate a separate 16-bit input port for every FIR tap. In our case, this resulted in 54 individual coefficient ports, which significantly increased interface complexity.

    Since the FIR coefficients are constant, a better approach is to define them as global compile-time constants rather than passing them as input arguments. This eliminates unnecessary ports and slightly reduces overall logic utilization.

    FIR low-pass filter FPGA IP core design using Vitis HLS and DSP optimization

    Using Modern AXI-Stream Interfaces

    In many FPGA-based DSP systems, AXI-Stream interfaces are preferred because they simplify integration with the rest of the design pipeline.

    To improve compatibility and system-level usability, we modified the function arguments so that Vitis HLS could automatically infer AXI-Stream input and output interfaces. This makes the generated IP core easier to connect to other processing blocks in a complete FPGA signal chain.


    Frequently Asked Questions (FAQ)

    What is an FIR filter in digital signal processing?

    An FIR (Finite Impulse Response) filter is a digital filter commonly used in DSP because it is stable, provides linear-phase response, and is well suited for FPGA implementation.


    Why use Vitis HLS for FIR filter implementation?

    Vitis HLS allows designers to implement FIR filters using C/C++ instead of writing RTL manually, enabling faster development and optimized FPGA IP generation.


    What optimizations improve FIR filter performance in HLS?

    Common techniques include loop pipelining, array partitioning, coefficient symmetry, and resource sharing to achieve high throughput.


    How do you verify FIR filter FPGA output?

    Verification is typically done through C simulation, RTL co-simulation, XSim waveform analysis, and FFT-based frequency-domain validation.


    Conclusion: FIR Filter IP Core Generation with Vitis HLS

    This FIR filter FPGA Vitis HLS workflow demonstrates how DSP algorithms can be deployed efficiently as FPGA IP cores.

    With proper optimization, we achieved:

    • One sample per clock throughput
    • Efficient FPGA resource usage
    • Accurate stop-band attenuation performance

    Source Code on GitHub

    The full project source code is available here:

    👉 FIR Filter Vitis HLS Project Repository
    FIR filter repo

    For more FPGA projects, visit my Blog Homepage.