PDA

View Full Version : FIR filter generic


Zorjak
10-20-2006, 12:25 AM
Hi.
I am trying to write generic VHDL code for FIR filter. generic
parametars should be word_length, filter_order. Can anybody help me
how to input filter coeficients. I tought something like, read
coeficitients from file and write it in some LUT table. Could it be
done (or something similar)?

Thanks for help

Jiri Plasil
10-26-2006, 12:37 AM
Zorjak napsal(a):
> Hi.
> I am trying to write generic VHDL code for FIR filter. generic
> parametars should be word_length, filter_order. Can anybody help me
> how to input filter coeficients. I tought something like, read
> coeficitients from file and write it in some LUT table. Could it be
> done (or something similar)?
>
> Thanks for help
>
You can use e.g. std.textio.all package. The coeffs can be stored in the
regular text file. In case std.textio.all the content of the file is
binary string like

-- file.dat
0010000
0010001
....

--

(there is also possibility to use hex representation but different
package has to be used - from IEEE....)

Then just define ROM (distributed or block RAM) by array statement. E. g.
TYPE ROM IS ARRAY (N_COEFF - 1 DOWNTO 0) OF SIGNED(N_BITS - 1 DOWNTO 0);

Define function "init_function" to be able read data from file by means
of "readline" and "read" statement from textio package.

And finally initiate e. g. constant of coeffs.
CONSTANT coeff : ROM := init_function("file.dat");

It works in XST. I don't have any experience with Quartus. Check in the
Quartus documentation how is possible define initial value of registers
an memories.