MATLAB Examples

Generate HDL Code for FFT HDL Optimized Block

The FFT and IFFT HDL Optimized blocks and system objects support simulation and HDL code generation for many applications. They provide two architectures optimized for different use cases:

  • Streaming Radix 2^2 - For high throughput applications. Achieves Gigasamples per second when you use vector input.
  • Burst Radix 2 - For low area applications. Uses only one complex butterfly.

This example includes two models that show how to use the streaming and burst architectures of the FFT HDL Optimized block, respectively.

Contents

Streaming Radix 2^2 Architecture

Modern ADCs are capable of sampling signals at sample rates up to several Gigasamples per second. However, clock speeds for the fastest FPGA fall short of this sample rate. FPGAs typically run at hundreds of MHz. One way to perform GSPS processing on an FPGA is to process multiple samples at the same time at a much lower clock rate. Many modern FPGAs support the JESD204B standard interface that accepts scalar input at GHz clock rate and produces a vector of samples at a lower clock rate. Therefore modern signal processing requires vector processing.

The Streaming Radix 2^2 architecture is designed to support the high throughput use case. This example model uses an input vector size of 8, and calculates the FFT using the Streaming Radix 2^2 architecture. See the FFT HDL Optimized documentation for timing diagram, supported features, and FPGA resource usage.

Open the example model:

modelname = 'FFTHDLOptimizedExample_Streaming';
open_system(modelname);

The InitFcn callback (Model Properties > Callbacks > InitFcn) sets parameters for the model. In this example, the parameters control the size of the FFT and the input data characteristics.

FFTLength  = 512;

The input data is two sine waves, 200 KHz and 250 KHz, each sampled at 1*2e6 Hz. The input vector size is 8 samples.

FrameSize    = 8;
Fs           = 1*2e6;

To demonstrate that data does not need to come continuously, this example applies valid input every other cycle.

ValidPattern = [1,0];

Visualize the result with the Spectrum Viewer.

open_system('FFTHDLOptimizedExample_Streaming/Spectrum Viewer/Power Spectrum viewer');

% Run the example model:
sim(modelname);

Burst Radix 2 (Minimum resource) Architecture

Use the Burst Radix 2 architecture for applications with limited FPGA resources, especially when the FFT length is big. This architecture uses only one complex butterfly to calculate the FFT. The design accepts data while ready is asserted, and starts processing once the whole FFT frame is saved into the memory. While processing, the design cannot accept data, so ready is de-asserted. See the FFT HDL Optimized documentation for timing diagram, supported features, and FPGA resource usage.

modelname = 'FFTHDLOptimizedExample_Burst';
open_system(modelname);

The InitFcn callback (Model Properties > Callbacks > InitFcn) sets parameters for the model. In this example, the parameters control the size of the FFT and the input data characteristics.

FFTLength  = 512;

The input data is two sine waves, 200 KHz and 250 KHz, each sampled at 1*2e6 Hz. Data is valid every cycle.

Fs           = 1*2e6;
ValidPattern = 1;

Visualize the result with the Spectrum Viewer.

open_system('FFTHDLOptimizedExample_Burst/Spectrum Viewer/Power Spectrum viewer');

% Run the example model:
sim(modelname);

Generate HDL Code and Test Bench

An HDL Coder™ license is required to generate HDL for this example.

Choose one of the models to generate HDL code and test bench:

    systemname = 'FFTHDLOptimizedExample_Burst/FFT HDL Optimized Burst';
or
    systemname = 'FFTHDLOptimizedExample_Streaming/FFT HDL Optimized Streaming';

Use a temporary directory for the generated files:

    workingdir = tempname;

You can run the following command to check for HDL code generation compatibility:

     checkhdl(systemname,'TargetDirectory',workingdir);

Run the following command to generate HDL code:

     makehdl(systemname,'TargetDirectory',workingdir);

Run the following command to generate the test bench:

     makehdltb(systemname,'TargetDirectory',workingdir);