generating hdl code
once your filter design and hdl settings are ready, generate hdl code for your design.
applying your settings
when you generate hdl, either from the ui or the command line, the coder
applies code generation option settings that you have edited
generates hdl code and other requested files, such as a test bench.
tip
to preserve your coder settings, use the generate matlab code option, as described in . generate matlab code is available only in the ui. the function does not have an equivalent property.
generating hdl code from the ui
this section assumes that you have opened the generate hdl tool. see .
to initiate hdl code generation for a filter and its test bench from the ui, click generate on the generate hdl tool. as code generation proceeds, a sequence of messages similar to the following appears in the matlab® command window:
### starting vhdl code generation process for filter: iir ### generating: d:\hdlfilter_tutorials\hdlsrc\iir.vhd ### starting generation of iir vhdl entity ### starting generation of iir vhdl architecture ### first-order section, # 1 ### second-order section, # 2 ### second-order section, # 3 ### hdl latency is 3 samples ### successful completion of vhdl code generation process for filter: iir ### starting generation of vhdl test bench ### generating input stimulus ### done generating input stimulus; length 2172 samples. ### generating: d:\hdlfilter_tutorials\hdlsrc\iir_tb.vhd ### please wait ....... ### done generating vhdl test bench.
the messages include hyperlinks to the generated code and test bench files. click these hyperlinks to open the code files in the matlab editor.
generate hdl from the command prompt
design a filter.
d = fdesign.lowpass('fp,fst,ap,ast',0.2,0.22,1,60)
d = lowpass with properties: response: 'lowpass' specification: 'fp,fst,ap,ast' description: {4x1 cell} normalizedfrequency: 1 fpass: 0.2000 fstop: 0.2200 apass: 1 astop: 60
hd = design(d,'equiripple','filterstructure','dfsymfir','systemobject',true)
hd = dsp.firfilter with properties: structure: 'direct form symmetric' numeratorsource: 'property' numerator: [-0.0011 -0.0017 -0.0025 -0.0031 -0.0031 -0.0024 -9.7703e-04 0.0010 0.0031 0.0049 0.0059 0.0057 0.0046 0.0029 9.8747e-04 -3.9494e-04 -8.8308e-04 -3.8937e-04 8.1727e-04 0.0022 0.0032 0.0033 0.0025 9.6853e-04 -6.5050e-04 ... ] initialconditions: 0 show all properties
to generate hdl code for the filter and its test bench from the command line, use the generatehdl
function. when you call the generatehdl
function, specify the filter name and (optionally) desired property name and property value pairs. when the filter is a system object™, you must specify the input data type property.
as code generation proceeds, a sequence of messages appears in the matlab command window. the messages include hyperlinks to the generated code and test bench files. click these hyperlinks to open the code files in the matlab editor.
generatehdl(hd,'inputdatatype',numerictype(1,16,15),'name','myfilter',... 'targetlanguage','verilog','generatehdltestbench', 'on')
### starting verilog code generation process for filter: myfilter ### generating: /tmp/bdoc23a_2213998_478575/tpadc45a61/hdlfilter-ex97122369/hdlsrc/myfilter.v ### starting generation of myfilter verilog module ### starting generation of myfilter verilog module body ### successful completion of verilog code generation process for filter: myfilter ### hdl latency is 2 samples ### starting generation of verilog test bench. ### generating input stimulus ### done generating input stimulus; length 4486 samples. ### generating test bench: /tmp/bdoc23a_2213998_478575/tpadc45a61/hdlfilter-ex97122369/hdlsrc/myfilter_tb.v ### creating stimulus vectors ... ### done generating verilog test bench.