FIR filter generic

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
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

Re: FIR filter generic

Quoted text here. Click to load it

If it is synthesizable code, it can't go and read files.  What you can
do though is have a helper function that converts your coefficient file
into a VHDL package containing the coefficient constants.  Write that
package to a file, and then include that file with the rest of the
design when you compile the design.  The helper function can be
non-synthesizable VHDL, C, Matlab or any other programming language you
feel like using.  Alternatively, you can cut and paste your coefficients
into a VHDL package or directly into a constant array in your code.

You can also pass the coefficients into the entity through a generic by
defining an integer_array type in a top level package, referring to that
package in the library declarations, and then putting the int_array in
the generics like this:

    component matrix
        coefs: int_array:= (
        -62465, -8923, 24026, 39814, 41873, 33635, 18534,                 
0,-18534,-33636,-41873,-39813,-24025, 8925, 62468,
         48188, 27536, 10061));
        clk : in std_logic;

Leaving the integer array unconstrained allows you to put in an
arbitrary number of coefficients (must be more than 1).

Re: FIR filter generic

Quoted text here. Click to load it

Thanks for your answer Ray

I am using Altera Quartus|| software and I've seen there thet some
*.mif files are using for ram initialization so I thought could I do
something similar with my FIR filter. Can you help me with that helper
function if it isnt to much that I am asking. I am VHDL beginer and I
am not very familiar with it so any lkind of help would used me.

If is to much that I asking, sory.
Thanks again

Re: FIR filter generic
Quoted text here. Click to load it

The *.MIF files are tie-ins to the altera tools, and have nothing to do
with the VHDL.  You don't have the hooks you need to get inside the
place and route tools to bring in your own custom initialization.

The helper program I talked about just has to write out a text file
containing a VHDL package.  The package contains a constant containing
your coefficients.

Re: FIR filter generic

Quoted text here. Click to load it

I think I understand you. I'll try to do that

Thanks again, Ray

Re: FIR filter generic
Zorjak napsal(a):
Quoted text here. Click to load it
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


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

We've slightly trimmed the long signature. Click to see the full one.
Re: FIR filter generic
Quoted text here. Click to load it

It may work in some tools, but it isn't standard.  Generally speaking
file i/o is not currently allowed in synthesizable code.  It is allowed
in behavioral code (e.g. testbenches) that is not intended to be
synthesized, but I wasn't aware that any synthesizers supported file
i/o.   I've asked for years for support of file i/o and reals for
filling constants.  I think some are supporting reals in functions for
generating constants now.

Site Timeline