Forum Discussion
JC_FPGA
New Contributor
5 years agoThere's a long standing bug in the FIR filter read-back code. The read signal is messed up. I've attached a python script that will fix the code. You have to re-run the script each time the FIR is regenerated by Quartus. You can place the following in a batch file or shell script to make life easier.
python3 fir_filter_read_coeff_fix.py YOUR_PROJECT_DIR/interpolator/interpolator_0002.vhd
python3 fir_filter_read_coeff_fix.py YOUR_PROJECT_DIR/interpolator_sim/interpolator.vhdReplace YOUR_PROJECT_DIR with your required path and replace "interpolator" with whatever you named your filter. The main thing is that you have to fix both the implementation and the simulation versions of the filter.
Python script:
################################################################################
#
# Python3 script to fix bug in Intel/Altera FIR generator code
#
# Created: 2018-08-16
# Author: Jim Cox
################################################################################
# This script is meant to be used as a post-processing step after creating a
# FIR filter using the Quartus tools. The read signal for the coefficients
# is not connected properly to the lower level module.
import re
import sys
if (len(sys.argv) != 2):
sys.exit("\nUsage: fir_filter_read_coeff_fix.py my_file.vhd\n")
### Lines to delete
###
### signal coeff_in_read_sig : std_logic;
###
### coeff_in_read_sig <= not(coeff_in_we(0));
###
### Line to modify
###
### busIn_read => coeff_in_read_sig,
#################################################################
# Input file
my_file = open(sys.argv[1], "rt+")
my_file_list = my_file.readlines()
# Move back to the begining of the file
my_file.seek(0)
for line_of_code in my_file_list:
if (re.search('^\W+signal coeff_in_read_sig : std_logic;', line_of_code)):
continue
if (re.search('^\W+coeff_in_read_sig <= not\(coeff_in_we\(0\)\);', line_of_code)):
continue
if (re.search('^\W+busIn_read => coeff_in_read_sig,', line_of_code)):
print(" busIn_read => coeff_in_read,", file=my_file)
print("File has been updated\n")
continue
print(line_of_code, end='', file=my_file)
my_file.truncate()
my_file.close()