This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Generate HDL Code for Filter System Objects

You can generate HDL code for a supported filter System object™ by using the Filter Builder app, the Generate HDL dialog box, or by calling the generatehdl function. You can also explore filter architectures and generate test bench stimulus for a filter System object by using the hdlfilterserialinfo, hdlfilterdainfo, and generatetbstimulus functions. In either cases, you must specify a fixed-point data type for the System object. The HDL code generation tool quantizes the input signal to this data type.

Using Filter Builder

Open the Filter Builder app by calling the filterBuilder function, then set the following options.

  • On the Main tab, select Use a System object to implement filter.

  • On the Data Types tab, set Arithmetic to Fixed point and select the internal fixed-point data types.

  • On the Code Generation tab, click Generate HDL to set HDL code generation options and generate code.

Using Generate HDL Dialog Box

Open the Generate HDL dialog box by calling the fdhdltool function. When calling the function with a System object, specify the input data type as a numerictype object. Create this object by calling numerictype(s,w,f), where s is 1 for signed and 0 for unsigned, w is the word length in bits, and f is the number of fractional bits. In the following example, the call to numerictype(1,8,7) specifies a signed 8-bit number with 7 fractional bits.

filt =  dsp.BiquadFilter;
fdhdltool(filt,numerictype(1,8,7));
When the dialog box opens, you can set HDL code generation options and generate code for the System object.

At the Command Line

When calling the generatehdl function with a System object, specify the input data type as a Name,Value pair argument using the InputDataType property. Specify the property value as a numerictype object. For example:

filt =  dsp.BiquadFilter;
generatehdl(filt,'Name','HDLButter', ...
    'InputDataType',numerictype(1,8,7));
When calling generatehdl, you can set additional HDL code generation properties using Name,Value pair arguments. For example:

coeffs = fir1(22,0.45);
firfilt = dsp.FIRFilter('Numerator',coeffs, ...
    'Structure','Direct form antisymmetric');
generatehdl(firfilt,'InputDataType',numerictype(1,16,15), ...
    'SerialPartition',[7 4],'CoefficientMemory','DualPortRAMs', ...
    'CoefficientSource','ProcessorInterface');

See Also

| | |

Related Topics