- moved real_array_t to fixed_util_pkg

git-svn-id: http://moon:8086/svn/vhdl/trunk@184 cc03376c-175c-47c8-b038-4cd826a8556b
This commit is contained in:
2009-01-02 16:20:21 +00:00
parent d7ed0a9fb0
commit 5f1b2738de
+15 -15
View File
@@ -4,16 +4,16 @@ use IEEE.STD_LOGIC_1164.ALL;
use ieee.numeric_std.all;
use IEEE.MATH_REAL.ALL;
library work;
use work.fixed_util_pkg.all;
-------------------------------------------------------------------------------
package filter_pkg is
constant pi : real := 3.141592653589793e+000;
type real_array_t is array (natural range <>) of real;
function FilterCoef_Lowpass (N : positive; omega, amp : real) return real_array_t;
function FilterCoef_Highpass (N : positive; omega, amp : real) return real_array_t;
function FilterCoef_Bandpass (N : positive; bw2, omega_m, amp : real) return real_array_t;
function FilterCoef_Delta (N:positive; delay:natural; amp:real) return real_array_t;
function FilterCoef_Lowpass (N : positive; omega, gain : real) return real_array_t;
function FilterCoef_Highpass (N : positive; omega, gain : real) return real_array_t;
function FilterCoef_Bandpass (N : positive; bw2, omega_m, gain : real) return real_array_t;
function FilterCoef_Delta (N:positive; delay:natural; gain:real) return real_array_t;
function Window_Hamming (x : real_array_t) return real_array_t;
function Window_VonHann (x : real_array_t) return real_array_t;
function Window_Blackman (x : real_array_t) return real_array_t;
@@ -55,17 +55,17 @@ package body filter_pkg is
end Prototype_Lowpass;
-------------------------------------------------------------------------------
function FilterCoef_Lowpass (N : positive; omega, amp : real) return real_array_t is
function FilterCoef_Lowpass (N : positive; omega, gain : real) return real_array_t is
variable lp : real_array_t(0 to N-1);
begin
lp := Prototype_Lowpass(N, omega);
return Window_VonHann(FilterScale(lp, amp/FilterEnergy(lp)));
return Window_VonHann(FilterScale(lp, gain/FilterEnergy(lp)));
end FilterCoef_Lowpass;
-------------------------------------------------------------------------------
function FilterCoef_Highpass (N : positive; omega, amp : real) return real_array_t is
function FilterCoef_Highpass (N : positive; omega, gain : real) return real_array_t is
variable lp, res : real_array_t(0 to N-1);
variable phi : real := 0.0;
variable dphi : real := pi;
@@ -77,12 +77,12 @@ package body filter_pkg is
phi := phi + dphi;
end loop;
return Window_VonHann(FilterScale(res, amp/FilterEnergy(lp)));
return Window_VonHann(FilterScale(res, gain/FilterEnergy(lp)));
end FilterCoef_Highpass;
-------------------------------------------------------------------------------
function FilterCoef_Bandpass (N : positive; bw2, omega_m, amp : real) return real_array_t is
function FilterCoef_Bandpass (N : positive; bw2, omega_m, gain : real) return real_array_t is
variable lp, res, mean, sum : real_array_t(0 to N-1);
variable phi : real := 0.0;
variable dphi : real := 2.0*pi*omega_m;
@@ -94,18 +94,18 @@ package body filter_pkg is
phi := phi + dphi;
end loop;
return Window_VonHann(FilterScale(res, amp/FilterEnergy(lp)));
return Window_VonHann(FilterScale(res, gain/FilterEnergy(lp)));
end FilterCoef_Bandpass;
-------------------------------------------------------------------------------
function FilterCoef_Delta (N:positive; delay:natural; amp:real) return real_array_t is
function FilterCoef_Delta (N:positive; delay:natural; gain:real) return real_array_t is
variable res : real_array_t(0 to N-1);
begin
for i in 0 to N-1 loop
res(i) := 0.0;
end loop;
res(delay) := amp;
res(delay) := gain;
return res;