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)?
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:
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.
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.
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....)
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.
ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here.
All logos and trade names are the property of their respective owners.