- 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:
@@ -4,16 +4,16 @@ use IEEE.STD_LOGIC_1164.ALL;
|
|||||||
use ieee.numeric_std.all;
|
use ieee.numeric_std.all;
|
||||||
use IEEE.MATH_REAL.ALL;
|
use IEEE.MATH_REAL.ALL;
|
||||||
|
|
||||||
|
library work;
|
||||||
|
use work.fixed_util_pkg.all;
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
package filter_pkg is
|
package filter_pkg is
|
||||||
|
|
||||||
constant pi : real := 3.141592653589793e+000;
|
function FilterCoef_Lowpass (N : positive; omega, gain : real) return real_array_t;
|
||||||
type real_array_t is array (natural range <>) of real;
|
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_Lowpass (N : positive; omega, amp : real) return real_array_t;
|
function FilterCoef_Delta (N:positive; delay:natural; gain: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 Window_Hamming (x : real_array_t) 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_VonHann (x : real_array_t) return real_array_t;
|
||||||
function Window_Blackman (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;
|
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);
|
variable lp : real_array_t(0 to N-1);
|
||||||
begin
|
begin
|
||||||
lp := Prototype_Lowpass(N, omega);
|
lp := Prototype_Lowpass(N, omega);
|
||||||
|
|
||||||
return Window_VonHann(FilterScale(lp, amp/FilterEnergy(lp)));
|
return Window_VonHann(FilterScale(lp, gain/FilterEnergy(lp)));
|
||||||
|
|
||||||
end FilterCoef_Lowpass;
|
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 lp, res : real_array_t(0 to N-1);
|
||||||
variable phi : real := 0.0;
|
variable phi : real := 0.0;
|
||||||
variable dphi : real := pi;
|
variable dphi : real := pi;
|
||||||
@@ -77,12 +77,12 @@ package body filter_pkg is
|
|||||||
phi := phi + dphi;
|
phi := phi + dphi;
|
||||||
end loop;
|
end loop;
|
||||||
|
|
||||||
return Window_VonHann(FilterScale(res, amp/FilterEnergy(lp)));
|
return Window_VonHann(FilterScale(res, gain/FilterEnergy(lp)));
|
||||||
|
|
||||||
end FilterCoef_Highpass;
|
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 lp, res, mean, sum : real_array_t(0 to N-1);
|
||||||
variable phi : real := 0.0;
|
variable phi : real := 0.0;
|
||||||
variable dphi : real := 2.0*pi*omega_m;
|
variable dphi : real := 2.0*pi*omega_m;
|
||||||
@@ -94,18 +94,18 @@ package body filter_pkg is
|
|||||||
phi := phi + dphi;
|
phi := phi + dphi;
|
||||||
end loop;
|
end loop;
|
||||||
|
|
||||||
return Window_VonHann(FilterScale(res, amp/FilterEnergy(lp)));
|
return Window_VonHann(FilterScale(res, gain/FilterEnergy(lp)));
|
||||||
|
|
||||||
end FilterCoef_Bandpass;
|
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);
|
variable res : real_array_t(0 to N-1);
|
||||||
begin
|
begin
|
||||||
for i in 0 to N-1 loop
|
for i in 0 to N-1 loop
|
||||||
res(i) := 0.0;
|
res(i) := 0.0;
|
||||||
end loop;
|
end loop;
|
||||||
res(delay) := amp;
|
res(delay) := gain;
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user