📄 fir filter.vhd
字号:
library maths;
library matrix;
library vfp;
library dsp;
architecture behavioural of FIR_32tap_8_8 is
use maths.maths_functions.all;
use matrix.matrix_class.all;
use vfp.generic_functions.all;
use vfp.generic_conversions.all;
use vfp.mixed_operators.all;
use vfp.twos_complement_types.all;
constant number_of_taps: integer := 32;
signal data_table: single_vector(number_of_taps-1 downto 0);
signal coefficient_table: single_vector(number_of_taps-1 downto 0);
begin
-- y <= sum_over (0, k-1, a((k-1)-i), b(i))
-- coefficient_table <= b;
fir_algorithm: process (clock)
variable data_out : single;
variable fir_result : single;
variable data_table_var: single_vector(number_of_taps-1 downto 0);
-- the coeff table assignment really ought to be handled at the entity interface
variable coefficient_table_var: single_vector(number_of_taps-1 downto 0);
variable tmp2 : single;
variable num_taps_minus_1 : integer;
variable y_result : twos_complement(20 downto 0);
begin
if posedge (clock) then
-- data_table_var := data_table(number_of_taps-1) & data_table(number_of_taps-
-- putting the coeff table in a loop like this allows dynamic coeff updating
for i in 0 to number_of_taps-1 loop
coefficient_table_var(i) := single(to_integer(b(i)))/127.0;
end loop;
data_table_var := data_table;
tmp2 := single(to_integer(to_twos_complement(a)));
data_table_var := shift_fifo (data_table_var, tmp2);
data_table <= data_table_var;
num_taps_minus_1 := number_of_taps-1;
fir_result := sum_of_products (
lower_limit => 0,
upper_limit => number_of_taps-1,
a_in => reverse_order(data_table_var),
b_in => coefficient_table_var
);
y_result := y_result = integer(fir_result);
y <= to_std_ulogic_vector(y_result);
end if;
end process;
end behavioural;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -