Main Content

Implement FFT Algorithm for FPGA

此示例显示了如何使用DSP HDL Toolbox™块实现了针对硬件的FFT。

信号处理功能和DSP System Toolbox的块提供基于框架的浮点算法,并可以用作硬件设计的行为参考。但是,有效的硬件设计必须使用流数据界面和固定点数据类型。硬件设计通常还需要控制信号,例如valid,,,,reset,,,,andbackpressure

这blocks in DSP HDL Toolbox libraries provide hardware-optimized algorithms that model streaming data interfaces, hardware latency, and control signals in Simulink®. The blocks can process a number of samples in parallel to achieve high throughput such as gigasample-per-second (GSPS) rates. You can change the block parameters to explore different hardware implementations. These blocks support HDL code generation and deployment to FPGAs with HDL Coder™.

This example introduces the hardware-friendly streaming data interface and control signals used by DSP HDL Toolbox blocks, and shows how to use the two hardware architectures provided by the FFT block. Then, it shows how to generate HDL code for your design.

这DSP HDL工具箱FFT block provides two architectures optimized for different use cases. You can set the建筑学parameter on the block to one of these options.

  • Streaming Radix 2^2— Use this option for high throughput applications. The architecture achieves gigasamples per second (GSPS) when you use vector input.

  • Burst Radix 2- 用于低区域应用程序。该建筑仅使用一只复杂的蝴蝶。

This example includes two models, which show how to use the streaming and burst architectures of the FFT block. The streaming model shows how to use the input and outputvalid控制信号以独立于时钟速率建模数据速率。爆发模型显示了如何使用validcontrol signal to model bursty data streams and how to use aready指示算法何时可以并且不能接受新的数据示例的信号。

流radix 2^2架构

现代ADC能够以每秒多达几个Gigasples的样本速率进行采样信号。但是,最快的FPGA的时钟速度降低了此样本率。FPGA通常以数百MHz运行。在FPGA上执行GSP的一种方法是同时以低得多的时钟速率处理多个样本。许多现代FPGA支持JESD204B万博1manbetx标准接口,该界面以GHz时钟速率接受标量输入,并以较低的时钟速率生产样品向量。因此,现代信号处理需要矢量处理。

Streaming Radix 2^2架构旨在支持高通量应用程序。万博1manbetx此示例模型使用输入向量大小为8,建筑学FFT块的参数设置为Streaming Radix 2^2。有关定时图,支持功能和FPGA资源使用情况,万博1manbetx请参见FFT

modelName ='ffthdloptimizedExample_streaming';Open_System(modelName);

INITFCN回调函数(模型属性>回调> INITFCN)设置模型的参数。在此示例中,参数控制FFT的大小和输入数据特征。

fftlength = 512;

输入数据是两个正弦波,200 kHz和250 kHz,每个都以1*2e6 Hz采样。输入矢量大小为8个样本。

FrameSize = 8; Fs = 1*2e6;

To demonstrate the use of avalid对于非连续输入数据的控制信号,此示例应用了每个其他周期的有效输入。

ValidPattern = [1,0];

Open the Spectrum Viewer and run the example model.

open_system('FFTHDLOptimizedExample_Streaming/Spectrum Viewer/Power Spectrum viewer');set_param(modelname,“仿真”,,,,'start'

使用逻辑分析仪查看该输入和输出信号FFT Streaming子系统。这waveform shows that the input valid signal is high every second cycle, and that there is some latency before the block returns the first valid output sample. The block mask displays the latency from the first valid input to the first valid output, assuming no gaps in input valid samples. In this case, the actual latency is longer than the displayed latency because of the gaps in the input stream. The block returns the output data with no gaps in the valid samples.

Burst Radix 2 (Minimum Resource) Architecture

使用Burst Radix 2architecture for applications with limited FPGA resources, especially when the FFT length is large. This architecture uses only one complex butterfly to calculate the FFT. In this model, the建筑学FFT块的参数设置为Burst Radix 2

选择此架构时,该块具有输出控制信号,ready,,,,that indicates when the block can accept new input data. The block sets thereadysignal to 1 (true)当它可以接受数据并一旦将整个FFT帧保存到内存中,就可以开始处理。处理时,块不能接受数据,因此块设置了readysignal to 0 (错误的)。您只必须在ready信号为1。块忽略了当ready信号为0。

有关定时图,支持功能和FPGA资源使用情况,万博1manbetx请参见FFT

modelName ='FFTHDLOptimizedExample_Burst';Open_System(modelName);

INITFCN回调函数(模型属性>回调> INITFCN)设置模型的参数。在此示例中,参数控制FFT的大小和输入数据特征。

fftlength = 512;

输入数据是两个正弦波,200 kHz和250 kHz,每个都以1*2e6 Hz采样。Data is valid every cycle.

Fs = 1*2e6; ValidPattern = 1;

Open the Spectrum Viewer and run the example model.

open_system('ffthdloptimizedexample_burst/spectrum查看器/电源频谱查看器');set_param(modelname,“仿真”,,,,'start'

使用逻辑分析仪查看该输入和输出信号FFT Burst子系统。波形显示输入数据以有效的样本爆发而到达,并且在块返回有效的输出样本之前存在一些延迟。波形中的延迟与块蒙版上显示的延迟匹配。该块还返回输出ready信号表示何时有空间开始接受下一个输入数据。为了确保在块设置块之前不要应用下一个输入数据ready信号到1(true),模型使用Ready信号作为输入数据生成的启用信号。

生成HDL代码和测试工作台

You must have the HDL Coder product to generate HDL code for this example. Your model must have a subsystem that is targeted for HDL code generation.

Choose one of the models to generate HDL code and test bench for the FFT subsystem.

SystemName ='ffthdloptimizedexample_burst/fft爆发';

or

SystemName ='FFTHDLOptimizedExample_Streaming/FFT Streaming';

这n, use this command to generate HDL code for that subsystem. The generated code can be used for any FPGA or ASIC target.

makehdl(systemname);

Use this command to generate a test bench that compares the results of an HDL simulation against the Simulink simulation behavior.

makehdltb(systemName);

也可以看看

|

相关示例

更多关于