| Filter Design HDL Coder™ | ![]() |
generatetb(Hd, 'TbType')
generatetb(Hd 'TbType', 'PropertyName',
'PropertyValue',...)
generatetb(Hd)
generatetb(Hd, 'PropertyName', 'PropertyValue',...)
generatetb(Hd, 'TbType') generates a HDL test bench of a specified type to verify the HDL code generated for the quantized filter identified by Hd. The argument Hd must be a handle to a filter object. The value that you specify for 'TbType' identifies the type of test bench to be generated and can be one of the values shown in the following table (or a cell array that contains one or more of these values).
If you do not specify the 'TbType' argument, the test bench type defaults to the current setting of the TargetLanguage property ('VHDL' or 'Verilog').
| Specify... | To Generate a Test Bench Consisting of... |
|---|---|
| 'Verilog' | Verilog code |
| 'VHDL' | VHDL code |
| 'ModelSim' | The'Modelsim' test bench type argument is deprecated in the current release and will not be supported in future releases. If you specify this option, a warning message is displayed. If your scripts use the 'Modelsim' option, you should remove it. It is recommended that you use the default test bench type instead. |
The generated test bench applies input stimuli based on the setting of the properties TestBenchStimulus and TestBenchUserStimulus. By default, TestBenchStimulus specifies impulse, step, ramp, chirp, and noise stimuli for FIR, FIRT, Symmetric FIR, and Antisymmetric FIR filters and step, ramp, and chirp stimuli for all other filters.
The function uses default settings for other properties that determine test bench characteristics. By default the function does the following.
Places the generated test bench file in the target directory hdlsrc under your current working directory with the name Hd_tb and a file type extension that is based on the type of test bench you are generating.
| If the Test Bench Is a... | The Extension Is... |
|---|---|
| Verilog file | Defined by the property VerilogFileExtension |
| VHDL file | Defined by the property VHDLFileExtension |
Generates script files for third-party EDA tools. Where Hd is the name of the specified filter object, the following script files are generated:
Hd_tb_compile.do :Mentor Graphics® ModelSim® compilation script. This script contains commands to compile the generated filter and test bench code.
Hd_tb_sim.do: Mentor Graphics ModelSim simulation script. This script contains commands to run a simulation of the generated filter and test bench code.
Forces clock, clock enable, and reset input signals.
Forces clock enable and reset input to active high.
Drives the clock input signal high (1) for 5 nanoseconds and low (0) for 5 nanoseconds.
Forces reset signals.
Applies a hold time of 2 nanoseconds to filter reset and data input signals.
For HDL test benches, applies an error margin of 4 bits.
Places generated files in the target directory hdlsrc and names the files as follows:
| File | Name |
|---|---|
| Verilog source | Hd.v, where Hd is the name of the specified filter object |
| VHDL source | Hd.vhd, where Hd is the name of the specified filter object |
| VHDL package | Hd_pkg.vhd, where Hd is the name of the specified filter object |
Places generated files in a subdirectory name hdlsrc, under your current working directory.
Includes VHDL entity and architecture code in a single source file.
Uses an asynchronous reset when generating HDL code for registers.
Asserts the reset input signal high (1) to reset registers in the design.
Names the generated VHDL entity or Verilog module with the name of the filter.
Names the filter's HDL ports as follows:
| HDL Port | Name |
|---|---|
| Input | filter_in |
| Output | filter_out |
| Clock input | clk |
| Clock enable input | clk_enable |
| Reset input | reset |
Sets the data type for clock input, clock enable input, and reset ports to STD_LOGIC and data input and output ports to VHDL type STD_LOGIC_VECTOR or Verilog type wire.
Names coefficients as follows:
| For... | Names Coefficients... |
|---|---|
| FIR filters | coeffn, where n is the coefficient number, starting with 1 |
| IIR filters | coeff_xm_sectionn, where x is a or b, m is the coefficient number, and n is the section number |
When declaring signals of type REAL, initializes the signal with a value of 0.0.
Places VHDL configurations in any file that instantiates a component.
Appends _rsvd to names that are VHDL or Verilog reserved words.
Uses a type safe representation when concatenating zeros: '0' & '0'...
Applies the statement IF clock'event AND clock='1' THEN to check for clock events.
Allows scale values to be up to 3 bits smaller than filter input values.
Adds an extra input register and an extra output register to the filter.
Appends _process to process names.
When creating labels for VHDL GENERATE statements:
Appends _gen to section and block names.
Names output assignment blocks with the string outputgen
Generates HDL code that is bit-true to the original filter function and is not optimized for performance or space requirements.
Applies a linear final summation to FIR filters. This is the form of summation explained in most DSP text books.
Enables multiplier operations for a filter, as opposed to replacing them with additions of partial products.
generatetb(Hd 'TbType', 'PropertyName', 'PropertyValue',...) generates a HDL test bench of a specified type to verify the HDL code generated for the quantized filter identified by Hd, using the specified property name and property value pair settings. You can specify the function with one or more of the property name and property value pairs described in Properties Reference and Properties — Alphabetical List.
generatetb(Hd) generates a HDL test bench to verify the HDL code generated for the quantized filter identified by Hd. . The 'TbType' argument is omitted, and the test bench type defaults to the current setting of the TargetLanguage property ('VHDL' or 'Verilog').
generatetb(Hd, 'PropertyName', 'PropertyValue',...) generates a HDL test bench to verify the HDL code generated for the quantized filter identified by Hd, using the specified property name and property value pair settings. The 'TbType' argument is omitted, and the test bench type defaults to the current setting of the TargetLanguage property ('VHDL' or 'Verilog').
You can specify the function with one or more of the property name and property value pairs described in Properties Reference and Properties — Alphabetical List.
Design a filter. The call to fdesign in the following command line sequence designs a minimum order lowpass filter with a normalized passband frequency of 0.2, a stopband frequency of 0.22, a passband ripple of 1 dB, and a stopband attenuation of 60 dB.
Construct a filter object. The call to design constructs the FIR equiripple filter object Hd.
Set the filter arithmetic. The arithmetic assignment statement sets the filter arithmetic to fixed-point arithmetic.
Generate VHDL code for the filter. The call to generatehdl generates VHDL code for the filter Hd. The function names the file MyFilter.vhd and places it in the default target directory hdlsrc.
Generate a test bench for the filter. The call to generatetb generates a VHDL test bench for the filter Hd named MyFilterTB.vhd and places the generated test bench file in the default target directory hdlsrc.
d = fdesign.lowpass('Fp,Fst,Ap,Ast',0.2, 0.22, 1, 60);
Hd = design(d, 'equiripple'); % Create FIR equiripple filter
Hd.arithmetic='fixed'; %Quantized filter with default settings
generatehdl(Hd, 'Name', 'MyFilter'); %Generate filter's VHDL code
generatetb(Hd, 'VHDL', 'TestBenchName', 'MyFilterTB');
generatetbstimulus, generatehdl
![]() | generatehdl | generatetbstimulus | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |