FIR Filter Design in Arria V/Cyclone V DSP Block Using VHDL Inferring

cancel
Showing results for 
Search instead for 
Did you mean: 
363 Discussions

FIR Filter Design in Arria V/Cyclone V DSP Block Using VHDL Inferring

FIR Filter Design in Arria V/Cyclone V DSP Block Using VHDL Inferring


Introduction

Altera’s 28-nm DSP architecture includes a host of features for optimizing FIR filter implementations:

  • Hard, built-in pre-adders can be used when implementing symmetric filters to cut multiplier usage by half.
  • Internal co-efficient register storage allows the designer to store the filter coefficients inside the DSP block, which not only saves registers and memory but allows for faster fMAX because coefficients do not have to be routed from the logic.
  • Distributed output adder, output register and cascade path for implementing systolic FIR filters.

This document demonstrates how these important features can be inferred by Quartus II from VHDL when designing filters. Four FIR filters are featured in this section, including multichannel interpolation, multichannel decimation, single rate multichannel systolic symmetric design and single channel single rate systolic symmetric design.The filter requirements as well as demonstrated DSP Block features are given in Table 1. The inferring codes can be downloaded here.

 a/a6/A5c5-table-1.jpg ( A5c5-table-1.jpg - click here to view image )


Features

The filters included in this package have the following features:

  1. All FPGA modules are inferred without invoking MegaFunctions. Modules inferred include DSP Blocks, parallel adders and memory based shift tap registers.
  2. Fully parameterized design, allowing the same template to be used for other bit width, filter size, number of channels, filter length, filter coefficients, sample rate and FPGA clock rate. Due to the time limit, the template is only tested again the parameters listed in the filter requirement in Table 1.


Contents

Each filter type has the following deliverables:

  1. Source code in VHDL.
  2. Test bench.
  3.  Input test data. Only sine wave is tested.
  4. Tcl scripts for running Modelsim simulation.
  5. Quartus project file.


Functional Description

VHDL Coding Style

RTL inferring is focused on the functionality of DSP block as shown in Table 1. This project also uses arrays and multi-dimensional arrays to make the design more compact, more readable and more manageable. This requires customized definition of data types, as VHDL is strong typed. At various places type conversion may be needed.For all four FIR designs, a package definition file is included that defined necessary data types. The dimensions of all the array types are fully parameterized.


Interface

All four filters in this example have the following interface signals:

8/85/Dsp-block-vhdl-inferring-a5c5-figure-1.jpg ( Dsp-block-vhdl-inferring-a5c5-figure-1.jpg - click here to view image )

The following table lists the interface signals.

6/63/Dsp-block-vhdl-inferring-a5c5-table-2.jpg ( Dsp-block-vhdl-inferring-a5c5-table-2.jpg - click here to view image )



Input Data Format

The multiple channel input data follows the protocol used in Altera FIR Compiler II. That is, an aggregate of valid channel data followed by don’t care samples. Suppose we have four valid channels in the interpolation filter case. The interpolation rate is four. This implies every 16 clock cycles there is one valid data for each input channel. The multiple channels of data take the following format at the input to the FIR: 

6/60/Dsp-block-vhdl-inferring-a5c5-figure-2.jpg ( Dsp-block-vhdl-inferring-a5c5-figure-2.jpg - click here to view image )

where <X> marks a don’t care sample. Alternatively, the input data could take the following more symmetrical format

9/9e/Dsp-block-vhdl-inferring-a5c5-figure-3.jpg ( Dsp-block-vhdl-inferring-a5c5-figure-3.jpg - click here to view image )


The format in Figure 2 is more general and is the adopted format in this design. It requires a slightly more complex structure on data delay taps in interpolation filters, but can be easily modified to support the format in Figure 3. Decimation and single rate multi-channel filter types can support both input data formats since there are only multi-channel signals without any <X> inserted. The single rate single channel can also support both since there are only signal channel signals without any <X> inserted.


Parameters

The filters are fully parameterized with the key parameters listed below. Please refer to the source code especially the package definition file for a complete collection of parameters.

2/20/Dsp-block-vhdl-inferring-a5c5-table-3.jpg ( Dsp-block-vhdl-inferring-a5c5-table-3.jpg - click here to view image )


Multichannel Interpolation Filter

The interpolation filter is implemented as a polyphase decomposed direct form FIR filter. The polyphase decomposition on interpolation filters can be viewed as commutator samples the output of M parallel sub-filter paths, where M is the interpolation rate.

9/93/Dsp-block-vhdl-inferring-a5c5-figure-4.jpg ( Dsp-block-vhdl-inferring-a5c5-figure-4.jpg - click here to view image )

By polyphase decomposition and running FPGA at least M times faster than the input sample rate, we can reuse the multipliers on each polyphase sub-filter path. As a result, the number of multipliers required to run the FIR engine is reduced by M-fold from the total filter size. For multi-channel interpolation FIR filter, the FPGA must run at least M* num_chan_c times faster than the input sample rate. In the following description, rate_c is used to present interpolation rate (M).

Figure 5 shows the architecture of 8 tap direct form multi-channel interpolation FIR filter. It can be easily extended to other taps. Zc means delaying c cycles. c is equal to rate_c* num_chan_c.

1/17/Dsp-block-vhdl-inferring-a5c5-figure-5.jpg ( Dsp-block-vhdl-inferring-a5c5-figure-5.jpg - click here to view image )

Alternatively, you can implement the polyphase FIR in systolic mode, utilizing the chain-out data path available arria-v or cyclone-v DSP blocks. Systolic mode will be discussed in more details later.

In the inferring code, the interpolating rate is 4, the channel number is 4 and the tap number is 32. The filter coefficients are stored internally in DSP blocks. Each DSP block stores 4 different coefficients, corresponding to 4 polyphase components. A select signal controls both the data MUX and coefficient selection, so that coefficients and channel data are properly aligned. The outputs of the multipliers are grouped into pairs of 2 signals, so that we can use the sum of two mode of the DSP block. The sum of two modes allows the output of the first DSP block to be sourced into the second DSP block through the chain-out adder path. The outputs from every other DSP blocks are then collected to perform the final summation. Therefore we need a 16-port pipelined adder to perform the final summation.

As we will show shortly, to infer the tap delay line implementation, a few parameters are needed:

1/19/Dsp-block-vhdl-inferring-a5c5-table-4.jpg ( Dsp-block-vhdl-inferring-a5c5-table-4.jpg - click here to view image )

Given the filter requirement in Table 1, we have the following parameters for the interpolation filter:

1/13/Dsp-block-vhdl-inferring-a5c5-table-5.jpg ( Dsp-block-vhdl-inferring-a5c5-table-5.jpg - click here to view image )

VHDL Inferring Code

From Figure 5 we know that the VHDL consists of three parts: shift register chain, DSP block instances and adder chain. The adder chain is implemented by the parallel_add block in Megafunctions/LPM. So only the code of shift register chain and DSP block instances are introduced here.


Inferring altshift_taps MegaFunction

Altshift_taps MegaFunction creates a shift register chain with equally spaced taps in RAM. Details on inferring altshift_taps can be found in Quartus II Handbook, Recommended HDL Coding Styles.

4/48/Dsp-block-vhdl-inferring-a5c5-figure-6.jpg ( Dsp-block-vhdl-inferring-a5c5-figure-6.jpg - click here to view image )


DSP blocks inferring code

There are two kinds of DSP blocks as shown in Figure 5. The functionality of DSP block and the corresponding inferring code are shown in Figure 7 and Figure 8.

8/8b/Dsp-block-vhdl-inferring-a5c5-figure-7.jpg ( Dsp-block-vhdl-inferring-a5c5-figure-7.jpg - click here to view image )

7/7b/Dsp-block-vhdl-inferring-a5c5-figure-8.jpg ( Dsp-block-vhdl-inferring-a5c5-figure-8.jpg - click here to view image )


Compilation

The DSP block usage summary is shown in Figure 9. The number of DSP blocks and the used features match that described in Table 1.

b/b5/Dsp-block-vhdl-inferring-a5c5-figure-9.jpg ( Dsp-block-vhdl-inferring-a5c5-figure-9.jpg - click here to view image )


Multichannel Decimation Filter

The decimation filter is implemented as a polyphase decomposed direct form FIR filter. The polyphase decomposition on decimation filters can be viewed as commutator delivers input samples sequentially to M parallel sub-filter paths, where M is the decimation rate.

8/88/Dsp-block-vhdl-inferring-a5c5-figure-10.jpg ( Dsp-block-vhdl-inferring-a5c5-figure-10.jpg - click here to view image )

By polyphase decomposition and running FPGA at least M times faster than the input sample rate, we can reuse the multipliers on each polyphase sub-filter path. As a result, the number of multipliers required to run the FIR engine is reduced by M-fold from the total filter size. For multi-channel decimation FIR filter, the FPGA must run at least M* num_chan_c times faster than the input sample rate. In the following description, rate_c is used to present interpolation rate (M).


Note that the input is delivered to the last polyphase of the filter first.Figure 5 shows the architecture of 8 tap direct form multi-channel interpolation FIR filter. It can be easily extended to other taps. Zc means delaying c cycles. c is equal to rate_c* num_chan_c.


Figure 10 shows the architecture of 8 tap direct form multi-channel decimation FIR filter. Similar to the interpolation FIR, the filter coefficients are stored internally in DSP blocks. The tap number is also 32. Each DSP block stores 4 different coefficients, corresponding to 4 polyphase components. A select signal controls coefficient selection. We don’t need the MUX along the tap delay line. The output signal follows the format shown in Figure 2, thus output valid signal is periodically deasserted. The outputs of the multipliers are grouped into pairs of 2 signals, so that we can use the sum of two modes of the DSP block. The sum of two modes allows the output of the first DSP block to the sourced into the second DSP block through the chain-out adder path. The outputs from every other DSP blocks are then collected to perform the final summation. Therefore we need a 16-port pipelined adder to perform the final summation. An accumulator supporting multiple channels completes the final stage of the decimation filter. The DSP block internal accumulator could not be used in this example because the delay is more than 1 cycle due to multi-channel requirement. However in a single channel decimation FIR, you might be able to use the DSP block internal accumulator to further speed up your design.

5/58/Dsp-block-vhdl-inferring-a5c5-figure-11.jpg ( Dsp-block-vhdl-inferring-a5c5-figure-11.jpg - click here to view image )

Given the filter requirement in Table 1, we have the following parameters for the decimation filter:

8/8a/Dsp-block-vhdl-inferring-a5c5-table-6.jpg ( Dsp-block-vhdl-inferring-a5c5-table-6.jpg - click here to view image )



VHDL Inferring Code

The inferring part of the decimation FIR is very similar to the interpolation FIR. Please refer to the interpolation FIR section for details.


Compilation

The compiling result of DSP block usage is the same as that of the interpolation FIR. Please refer to the interpolation FIR section for details.


Multi-channel Single Rate Systolic FIR with Symmetric Coefficients

For a single rate FIR, the systolic structure utilizes the chain out data path inside the DSP blocks and can therefore speed up the FIR quite significantly. If the filter has symmetric coefficients, we can reduce the multiplier count by bending the tap delay line and pre-adding input data in pairs. 

1/1e/Dsp-block-vhdl-inferring-a5c5-figure-12.jpg ( Dsp-block-vhdl-inferring-a5c5-figure-12.jpg - click here to view image )


Figure 12 shows the architecture example of 16 tap multi-channel systolic symmetric FIR. This architecture can be easily extended to other taps. Parameter c in reflects the time division multiplexing (TDM) factor of a multi-channel FIR filter. It is the ratio of FPGA clock rate over input data sample rate, assuming all channels are of the same sample rate. The number of channels supported in your design should not exceed c. When c becomes 1, it reduces to a single channel FIR, which will be discussed in more details in the next section.

As shown in Figure 12, the output of DSP block is fed to the chain-in of next DSP block. Due to the additional pipeline on the chain out adder path, the tap delay line depth changes after it bends. The tap delay line needs to be implemented in on-chip RAM.

The inferring example of VHDL code has the following parameters:

5/57/Dsp-block-vhdl-inferring-a5c5-table-7.jpg ( Dsp-block-vhdl-inferring-a5c5-table-7.jpg - click here to view image )


VHDL Inferring Code

From Figure 12 we know that the VHDL consists of two parts: tap delay line and DSP block instances.The tap delay line can be inferred in a similar manner as in the interpolation filter case. Please refer to Figure 6 for details. Be mindful that the forward, backward and folding point taps have different depth. As a result three separate shift registers are instantiated and concatenated together.

DSP blocks inferring code

There are two kinds of DSP blocks as shown in Figure 12. The functionality of DSP block and the corresponding inferring code are shown Figure 13 and Figure 14. The final data output is directly from the last DSP block chain out adder output.

2/2d/Dsp-block-vhdl-inferring-a5c5-figure-13.jpg ( Dsp-block-vhdl-inferring-a5c5-figure-13.jpg - click here to view image )

6/6a/Dsp-block-vhdl-inferring-a5c5-figure-14.jpg ( Dsp-block-vhdl-inferring-a5c5-figure-14.jpg - click here to view image )


Compilation

The DSP block usage summary is shown in Figure 15. The number of DSP blocks and the used features match that described in Table 1.

c/c5/Dsp-block-vhdl-inferring-a5c5-figure-15.jpg ( Dsp-block-vhdl-inferring-a5c5-figure-15.jpg - click here to view image )


Single-channel Single Rate Systolic FIR with Symmetric Coefficients

For a single rate FIR, the systolic structure utilizes the chain out data path inside the DSP blocks and can therefore speed up the FIR quite significantly. If the filter has symmetric coefficients, we can reduce the multiplier count by bending the tap delay line and pre-adding input data in pairs.

It is the same structure as the multiple channel systolic FIR, with the tap delay line having exactly two delays between taps. That is, the c parameter in Table 6 becomes 1. We can use the DSP block scanout register as the additional pipeline register required in the systolic FIR. Scanout register is designed to balance out the chain out register. 

3/34/Dsp-block-vhdl-inferring-a5c5-table-8.jpg ( Dsp-block-vhdl-inferring-a5c5-table-8.jpg - click here to view image )

6/6f/Dsp-block-vhdl-inferring-a5c5-figure-16.jpg ( Dsp-block-vhdl-inferring-a5c5-figure-16.jpg - click here to view image ) 

If you do not rely on the symmetric coefficients property or use pre-adder, a single channel systolic FIR can potentially be mapped entirely inside DSP blocks. The tap delay lines are implemented using input pipeline registers inside the DSP blocks. This will further speed up the performance of the FIR.

Similar to the multiple channel systolic FIR, the multipliers and chain out adders are also mapped completely inside the DSP blocks, resulting in a very high speed FIR structure.


VHDL Inferencing Code

The only difference from the multiple channel systolic FIR design is how tap delay line is implemented. Instead of inferring altshift_taps MegaFunction, you should use simple two-cycle-delay registers to realize the tap delay line.

The preadders and chain out adders can be inferred in the same manner as the multi-channel systolic FIR. Be mindful to use the correct chain out data width is the key for inference.


Compilation

The compiling result of DSP block usage is the same as that of the multi-channel single rate systolic symmetric FIR. Please refer to the multi-channel single rate systolic symmetric FIR section for details.


Conclusion


This document describes the key VHDL inference elements to optimally design FIR inside Arria V/Cyclone V DSP blocks. Although VHDL coding styles may vary, simple guidelines are provided to highlight necessary steps for successful inference by the Quartus II software

Attachments
Version history
Last update:
‎06-26-2019 11:48 PM
Updated by:
Contributors