Write Xilinx COE file
coewrite(hd) writes a XILINX Distributed Arithmetic FIR filter coefficient .COE file which can be loaded into the XILINX CORE Generator. The coefficients are extracted from the fixed-point dfilt object hd. Your fixed-point filter must be a direct form FIR structure dfilt object with one section and whose Arithmetic property is set to fixed. You cannot export single-precision, double-precision, or floating-point filters as .coe files, nor multiple-section filters. To enable you to provide a name for the file, coewrite displays a dialog box where you fill in the file name. If you do not specify the name of the output file, the default file name is untitled.coe.
The coewrite function always generates the XILINX.COE file in your current folder. To use this function, you must have write permission in your current folder.
coewrite generates an ASCII text file that contains the filter coefficients in a format the XILINX CORE Generator can read and load. In this example, you create a 30th-order fixed-point filter and generate the .coe file that includes the filter coefficients as well as associated information about the filter.
b = firceqrip(30,0.4,[0.05 0.03]); hq = dfilt.dffir(b); set(hq,'arithmetic','fixed'); coewrite(hq,10,'mycoefile');
The coewrite function generates the output file, mycoefile.coe, in your current folder. The .coe file contains the radix, coefficient width, and filter coefficients. The file reports the filter coefficients in column-major order. The radix, coefficient width, and filter coefficients are the minimum set of data needed in a .coe file.