Detailed instructions for use are in the User's Guide.
[. . . ] Filter Design HDL CoderTM 2 User's Guide
How to Contact The MathWorks
Web Newsgroup www. mathworks. com/contact_TS. html Technical Support
www. mathworks. com comp. soft-sys. matlab suggest@mathworks. com bugs@mathworks. com doc@mathworks. com service@mathworks. com info@mathworks. com
Product enhancement suggestions Bug reports Documentation error reports Order status, license renewals, passcodes Sales, pricing, and general information
508-647-7000 (Phone) 508-647-7001 (Fax) The MathWorks, Inc. 3 Apple Hill Drive Natick, MA 01760-2098
For contact information about worldwide offices, see the MathWorks Web site. Filter Design HDL CoderTM User's Guide © COPYRIGHT 20042010 by The MathWorks, Inc.
The software described in this document is furnished under a license agreement. The software may be used or copied only under the terms of the license agreement. [. . . ] This stimulus signal has the same duration as the filter's input signal, but changes at a slower rate. Each fractional delay value obtained from the vector is held for 10% of the total duration of the input signal before the next value is obtained. When you select this option, the User defined stimulus field is enabled. You can enter a call to any function that returns a vector in the User defined stimulus field. Alternatively, create the
-
-
3-109
3
Generating HDL Code for a Filter Design
vector as a workspace variable and enter the variable name, as shown in the following figure.
Farrow Filter Code Generation Mechanics
FDATool does not support design or import of Farrow filters. To generate HDL code for a Farrow filter, use one of the following methods: · Use the MATLAB command line to create a Farrow filter object and initiate code generation, and set Farrow-related properties, as in the examples shown in "Code Generation Properties for Farrow Filters" on page 3-105. · Use the MATLAB command line to create a Farrow filter object. For example, the following commands create a Farrow linear fractional delay filter object Hd and pass it in to fdhdltool:
D = . 3; Hd = dfilt. farrowlinearfd(D); Hd. arithmetic = 'fixed'; fdhdltool(Hd);
3-110
Generating Code for Single-Rate Farrow Filters
· Use filterbuilder to design a Farrow (fractional delay) filter object. Then, select the Code Generation pane of the filterbuilder dialog box (shown in the following figure). Click the Generate HDL button to open the Generate HDL dialog box, specify code generation options, and generate code.
Options Disabled for Farrow Filters
The coder disables some options or sets them to fixed default value when the Generate HDL dialog box opens with a Farrow filter. The coder sets this option to its default (Fully parallel) and disables it. The coder sets this option to its default (Single) and disables it.
3-111
3
Generating HDL Code for a Filter Design
Customizing the Test Bench
In this section. . . "Renaming the Test Bench" on page 3-112 "Specifying a Test Bench Type" on page 3-114 "Splitting Test Bench Code and Data into Separate Files" on page 3-115 "Configuring the Clock" on page 3-117 "Configuring Resets" on page 3-119 "Setting a Hold Time for Data Input Signals" on page 3-122 "Setting an Error Margin for Optimized Filter Code" on page 3-125 "Setting an Initial Value for Test Bench Inputs" on page 3-126 "Setting Test Bench Stimuli" on page 3-127 "Setting a Postfix for Reference Signal Names" on page 3-129 "Generating HDL Cosimulation Blocks for Use with HDL Simulators" on page 3-130 "Generating a Simulink Model for Cosimulation with an HDL Simulator" on page 3-133
Renaming the Test Bench
As discussed in "Customizing Reset Specifications" on page 3-33, the coder derives the name of the test bench file from the name of the quantized filter for which the HDL code is being generated and the postfix _tb. The file type extension depends on the type of test bench that is being generated. Defined by the Verilog file extension field in the General subpane of the Global Settings pane of the Generate HDL dialog box Defined by the VHDL file extension field in the Global Settings pane of the Generate HDL dialog box
VHDL file
3-112
Customizing the Test Bench
The file is placed in the folder defined by the Folder option in the Target pane of the Generate HDL dialog box. To specify a test bench name, enter the name in the Name field of the Test bench settings pane, as shown in the following figure.
3-113
3
Generating HDL Code for a Filter Design
Note If you enter a string that is a VHDL or Verilog reserved word, the coder appends the reserved word postfix to the string to form a valid identifier. Command Line Alternative: Use the generatetb function with the property TestBenchName to specify a name for your filter's test bench.
Specifying a Test Bench Type
The coder can generate two types of test benches: · A VHDL file that you can simulate in a simulator of choice · A Verilog file that you can simulate in a simulator of choice By default, the coder generates a single test bench file, containing all test bench helper functions, data, and test bench code. You can split these elements into separate files, as described in "Splitting Test Bench Code and Data into Separate Files" on page 3-115. Because of differences in representation of double-precision data in VHDL and Verilog, restrictions apply to the types of test benches that are interoperable. The following table shows valid and invalid test bench type and HDL combinations when code is generated for a double-precision filter. Test Bench Type Verilog VHDL VHDL Invalid Valid Verilog Valid Invalid
Note These restrictions do not apply for fixed-point filters.
3-114
Customizing the Test Bench
By default, the coder produces a VHDL or Verilog file, depending on your Language selection. Use the Test bench language pulldown menu in the Test bench generate output panel of the Generate HDL dialog box. [. . . ] Optionally, you can also specify that hdlgetserialpartition returns serial partition values and corresponding values of folding factor and number of multipliers to a cell array.
hdlgetserialpartition (Hd): for the filter object Hd, displays an
exhaustive table of serial partition values with corresponding values of folding factor and number of multipliers.
hdlgetserialpartition (Hd, 'FoldingFactor, ff): for the filter object Hd, displays the serial partition values and number of multipliers corresponding the folding factor ff. hdlgetserialpartition (Hd, 'Multipliers, nmults): for the filter object Hd, displays the serial partition values and folding factor corresponding to the number of multipliers nmults. hdlgetserialpartition (Hd, 'SerialPartition', [p1 p2. . . pN]):
for the filter object Hd, displays the folding factor and number of multipliers corresponding to the serial partition vector [p1p2. . . pN].
[sp, fold, nm] = hdlgetserialpartition(Hd): for the filter object Hd, returns an exhaustive table of serial partition values with corresponding values of folding factor and number of multipliers to a cell array. [sp, fold, nm] = hdlgetserialpartition(Hd, 'FoldingFactor, ff): for the filter object Hd, returns the serial partition values and number of multipliers corresponding to the folding factor ff to a cell array. [. . . ]