Main Content

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 tool, 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 these 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

Open the Generate HDL tool 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 this example, the call to numerictype(1,8,7) specifies a signed 8-bit number with 7 fractional bits.

filt =  dsp.FIRFilter;
fdhdltool(filt,numerictype(1,8,7));
When the tool 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.FIRFilter;
generatehdl(filt,'Name','HDLFIR', ...
    '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