Products & Services Solutions Academia Support User Community Company

Learn more about Filter Design HDL Coder   

Speed vs. Area Optimizations for FIR Filters

Overview of Speed vs. Area Optimizations

The coder provides options that extend your control over speed vs. area tradeoffs in the realization of FIR filter designs. To achieve the desired tradeoff, you can either specify a fully parallel architecture for generated HDL filter code, or choose one of several serial architectures. Supported architectures are described in Parallel and Serial Architectures.

The full range of parallel and serial architecture options is supported by properties passed in to the generatehdl command, as described in Specifying Speed vs. Area Tradeoffs via generatehdl Properties.

Alternatively, you can use the Architecture pop-up menu on the Generate HDL dialog box to choose parallel and serial architecture options, as described in Selecting Parallel and Serial Architectures in the Generate HDL Dialog Box.

The following table summarizes the filter types that are available for parallel and serial architecture choices.

ArchitectureAvailable for Filter Types...
Fully parallel (default)All filter types that are supported for HDL code generation
Fully serial
  • dfilt.dffir

  • dfilt.dfsymfir

  • dfilt.dfasymfir

  • mfilt.firdecim

  • mfilt.firinterp

Partly serial
  • dfilt.dffir

  • dfilt.dfsymfir

  • dfilt.dfasymfir

Cascade serial
  • dfilt.dffir

  • dfilt.dfsymfir

  • dfilt.dfasymfir

Parallel and Serial Architectures

Fully Parallel Architecture

This is the default option. A fully parallel architecture uses a dedicated multiplier and adder for each filter tap; all taps execute in parallel. A fully parallel architecture is optimal for speed. However, it requires more multipliers and adders than a serial architecture, and therefore consumes more chip area.

Serial Architectures

Serial architectures reuse hardware resources in time, saving chip area. The coder provides a range of serial architecture options, summarized below. All of these architectures have a latency of one clock period (see Latency in Serial Architectures).

The available serial architecture options are

Latency in Serial Architectures

Serialization of a filter increases the total latency of the design by one clock cycle. The serial architectures use an accumulator (an adder with a register) to sequentially add the products. An additional final register is used to store the summed result of all the serial partitions. An extra clock cycle is required for the operation.

Holding Input Data in a Valid State

In serial filters, data can be delivered to the outputs N cycles (N >= 2) later than the inputs. You can use the Hold input data between samples test bench option (or the HoldInputDataBetweenSamples CLI property) to determine how long (in terms of clock cycles) input data values are held in a valid state, as follows:

The following figure shows the Test Bench pane of the Generate HDL dialog box with Hold input data between samples set to its default setting.

See also HoldInputDataBetweenSamples.

Specifying Speed vs. Area Tradeoffs via generatehdl Properties

By default, generatehdl generates filter code using a fully parallel architecture. If you want to generate FIR filter code with a fully parallel architecture, you do not need to specify this explicitly.

Two properties are provided to specify serial architecture options when generating code via generatehdl:

The table below summarizes how to set these properties to generate the desired architecture. The table is followed by several examples.

To Generate This
Architecture...
Set SerialPartition to...Set ReuseAccum to...
Fully parallelOmit this propertyOmit this property
Fully serialN, where N is the length of the filterNot specified, or 'off'
Partly serial[p1 p2 p3...pN] : a vector of integers having N elements, where N is the number of serial partitions. Each element of the vector specifies the length of the corresponding partition. The sum of the vector elements must be equal to the length of the filter. When you define the partitioning for a partly serial architecture, consider the following:
  • We recommend that the filter length should be divided as uniformly as possible into a vector of length equal to the number of multipliers intended. For example, if your design requires a filter of length 9 with 2 multipliers, the recommended partition is [5 4]. If your design requires 3 multipliers, the recommended partition is[3 3 3] rather than some less uniform division such as [1 4 4] or [3 4 2].

  • If your design is constrained by the need to compute each output value (corresponding to each input value) in an exact number N of clock cycles, use N as the largest partition size and partition the other elements as uniformly as possible. For example, if the filter length is 9 and your design requires exactly 4 cycles to compute the output, define the partition as [4 3 2]. This partition executes in 4 clock cycles, at the cost of 3 multipliers.

'off'
Cascade-serial with explicitly specified partitioning[p1 p2 p3...pN]: a vector of integers having N elements, where N is the number of serial partitions. Each element of the vector specifies the length of the corresponding partition. The sum of the vector elements must be equal to the length of the filter. The values of the vector elements must be in descending order, except that the last two element must be equal. For example, for a filter of length 9, partitions such as[5 4] or [4 3 2] would be legal, but the partitions [3 3 3] or [3 2 4] would raise an error at code generation time. 'on'
Cascade-serial with automatically optimized partitioningOmit this property'on'

Specifying Parallel and Serial FIR Architectures in generatehdl

The following examples show the use of the 'SerialPartition' and 'ResuseAccum' properties in generating code with the generatehdl function. All examples assume that a direct-form FIR filter has been created in the workspace as follows:

Hd = design(fdesign.lowpass('N,Fc',8,.4));
Hd.arithmetic = 'fixed';

In this example, a fully parallel architecture is generated (by default).

generatehdl(Hd, 'Name','FullyParallel');
### Starting VHDL code generation process for filter: FullyParallel
### Generating: D:\Work\test\hdlsrc\FullyParallel.vhd
### Starting generation of FullyParallel VHDL entity
### Starting generation of FullyParallel VHDL architecture
### HDL latency is 2 samples
### Successful completion of VHDL code generation process for filter: FullyParallel

In this example, a fully serial architecture is generated. Notice that the system clock rate is nine times the filter's sample rate. Also, the HDL latency reported is one sample greater than in the previous (parallel) example.

generatehdl(Hd,'SerialPartition',9, 'Name','FullySerial')
### Starting VHDL code generation process for filter: FullySerial
### Generating: D:\Work\test\hdlsrc\FullySerial.vhd
### Starting generation of FullySerial VHDL entity
### Starting generation of FullySerial VHDL architecture
### Clock rate is 9 times the input sample rate for this architecture.
### HDL latency is 3 samples
### Successful completion of VHDL code generation process for filter: FullySerial

In this example, a partly serial architecture with three equal partitions is generated.

generatehdl(Hd,'SerialPartition',[3 3 3], 'Name', 'PartlySerial')
### Starting VHDL code generation process for filter: PartlySerial
### Generating: D:\Work\test\hdlsrc\PartlySerial.vhd
### Starting generation of PartlySerial VHDL entity
### Starting generation of PartlySerial VHDL architecture
### Clock rate is 3 times the input sample rate for this architecture.
### HDL latency is 2 samples
### Successful completion of VHDL code generation process for filter: PartlySerial

In this example, a cascade-serial architecture with three partitions is generated. The partitions are entered in descending order of size. Note that the clock rate is higher than that in the previous (partly serial without accumulator reuse) example.

generatehdl(Hd,'SerialPartition',[4 3 2], 'ReuseAccum', 'on','Name','CascadeSerial')
### Starting VHDL code generation process for filter: CascadeSerial
### Generating: D:\Work\test\hdlsrc\CascadeSerial.vhd
### Starting generation of CascadeSerial VHDL entity
### Starting generation of CascadeSerial VHDL architecture
### Clock rate is 5 times the input sample rate for this architecture.
### HDL latency is 3 samples
### Successful completion of VHDL code generation process for filter: CascadeSerial

In this example, a cascade-serial architecture is generated, with the partitioning automatically determined by the coder .

generatehdl(Hd,'ReuseAccum','on', 'Name','CascadeSerial')
### Starting VHDL code generation process for filter: CascadeSerial
### Generating: D:\Work\test\hdlsrc\CascadeSerial.vhd
### Starting generation of CascadeSerial VHDL entity
### Starting generation of CascadeSerial VHDL architecture
### Clock rate is 5 times the input sample rate for this architecture.
### Serial partition # 1 has 4 inputs.
### Serial partition # 2 has 3 inputs.
### Serial partition # 3 has 2 inputs.
### HDL latency is 3 samples
### Successful completion of VHDL code generation process for filter: CascadeSerial

Selecting Parallel and Serial Architectures in the Generate HDL Dialog Box

The Architecture pop-up menu, located on the Generate HDL dialog box, lets you select parallel and serial architecture options corresponding to those described in Parallel and Serial Architectures. These options are

The following figure shows the default (Fully parallel) architecture setting. .

Specifying Partitions for Partly Serial and Cascade Serial Architectures

When you select the Partly serial or Cascade serial option, the Generate HDL dialog box displays the Serial Partition field (shown in the following figure).

The Serial Partition field lets you enter a vector of integers specifying the number and size of the partitions, as described in Specifying Speed vs. Area Tradeoffs via generatehdl Properties.

By default, Serial Partition divides the filter into two partitions. For example, the preceding figure shows the default partition (5 4) for a filter with 9 taps.

Interactions Between Architecture Options and Other HDL Options

Selection of some Architecture menu options may change or disable other options, as described below.

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS