I am trying to make a synthesizable filter in verilog. I have the fixed-point filter coefficients in a text file. I am looking for an elegant and scalable way to pass on these filter coefficients. The filter will not be a simple beast: it will contain multiple sub-modules, and each of which may need a single co-efficient.
Since the filter coefficients will be constant, I would like them to be hardcoded, i.e., not consume any registers in implementation.
I have a few options/wishes below, along with their possible downsides:
- Use
readmemhor some similar trick to read the coefficients into a memory (reg [15:0] coeff [0:1023]) in the enclosing module, and pass on the coefficients from memory to FIR stages using a generate block. It should look something like:
generate
for (i = 0; i < 3 ; i = i + 1) begin: k
filter_stage(input[k], coeff[k], output[k]);
end
endgenerate
The downside is that the memory must be in the module that encloses the filter stages, otherwise I will have to go through portlist hell.
Use systemverilog packed arrays as module ports. The downside is that systemverilog support for some synthesis tools is sub-optimal.
This is a wish: Some sort of global lookup structure which is accessible to each module, so I don't have to manually wrap modules and adjust portlists just to pass coefficients to the right place.
I would want to know if option 3 is at all possible. If not, what else could I do?
Thanks.