Main Content

Generate HDL Code for Filter System Objects

You can generate HDL code for a supported filter System object™ by using theFilter Builderapp, the Generate HDL dialog box, or by calling thegeneratehdlfunction. You can also explore filter architectures and generate test bench stimulus for a filter System object by using thehdlfilterserialinfo,hdlfilterdainfo, andgeneratetbstimulusfunctions. 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 theFilter Builderapp by calling thefilterBuilderfunction, then set the following options.

  • On theMaintab, selectUse a System object to implement filter.

  • On theData Typestab, setArithmetictoFixed pointand select the internal fixed-point data types.

  • On theCode Generationtab, clickGenerate HDLto set HDL code generation options and generate code.

Using Generate HDL Dialog Box

Open the Generate HDL dialog box by calling thefdhdltoolfunction. When calling the function with a System object, specify the input data type as anumerictype对象。Create this object by callingnumerictype(s,w,f), wheresis 1 for signed and 0 for unsigned,wis the word length in bits, andfis the number of fractional bits. In the following example, the call tonumerictype(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 thegeneratehdlfunction with a System object, specify the input data type as aName,Valuepair argument using theInputDataTypeproperty. Specify the property value as anumerictype对象。例如:

filt = dsp.BiquadFilter; generatehdl(filt,'Name','HDLButter',...'InputDataType',numerictype(1,8,7));
When callinggeneratehdl, you can set additional HDL code generation properties usingName,Valuepair 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