Files
vhdl/projects/ac97_Controller/src/syn_fir_lowpass.vhd.bak
T
jens 67d79572d7 - added ac97 Controller
git-svn-id: http://moon:8086/svn/vhdl/trunk@1411 cc03376c-175c-47c8-b038-4cd826a8556b
2021-03-21 09:07:16 +00:00

192 lines
4.8 KiB
Plaintext

--------------------------------------------------------------------------------
-- Company:
-- Engineer:
--
-- Create Date: 17:16:42 13.05.2007
-- Design Name: tb_nco
-- Module Name: tb_nco.vhd
-- Project Name: nco
-- Target Device:
-- Tool versions:
-- Description:
--
--------------------------------------------------------------------------------
LIBRARY ieee;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.MATH_REAL.ALL;
USE ieee.numeric_std.ALL;
use std.textio.all; -- Imports the standard textio package.
library ieee_proposed;
use ieee_proposed.math_utility_pkg.all;
use ieee_proposed.fixed_pkg.all;
library work;
use work.fixed_util_pkg.all;
use work.filter_pkg.all;
use work.fir_stage_pkg.all;
use work.fir_iterative_pkg.all;
ENTITY syn_fir_lowpass IS
Generic (
ntaps : integer := 63;
nbits_in : integer := 24;
nbits_in_frac : integer := 22;
nbits_stages : integer := 36;
nbits_stages_frac : integer := 34;
nbits_out : integer := 32;
nbits_out_frac : integer := 31;
fir_mode : fir_iterative_mode_t := symmetric;
rounding : boolean := false;
saturating : boolean := false
);
PORT(
rst : in std_logic;
clk : in std_logic;
ready_i : out std_logic;
x_valid_i : in std_logic;
x_din_i : in signed(nbits_in-1 downto 0);
y_valid_i : out std_logic;
y_dout_i : out signed(nbits_out-1 downto 0);
ready_q : out std_logic;
x_valid_q : in std_logic;
x_din_q : in signed(nbits_in-1 downto 0);
y_valid_q : out std_logic;
y_dout_q : out signed(nbits_out-1 downto 0)
);
END syn_fir_lowpass;
ARCHITECTURE behavior OF syn_fir_lowpass IS
-- Lowpass parameter
constant fa : real := 48000.0;
constant f : real := 10000.0;
constant amp : real := 1.0;
constant omega : real := f/fa;
-- Component Declaration for the Unit Under Test (UUT)
COMPONENT fir_iterative
GENERIC
(
ntaps : integer;
nbits_in : integer;
nbits_in_frac : integer;
nbits_stages : integer;
nbits_stages_frac : integer;
nbits_out : integer;
nbits_out_frac : integer;
fir_mode : fir_iterative_mode_t;
rounding : boolean;
saturating : boolean
);
PORT
(
srst : in std_logic;
clk : in std_logic;
h_din : in sfixed;
h_addr_out : out integer;
ready : out std_logic;
x_valid : in std_logic;
x_din : in sfixed;
y_dout_valid : out std_logic;
y_dout : out sfixed
);
END COMPONENT;
type h_mem_t is array (0 to ntaps-1) of sfixed(shi(nbits_stages, nbits_stages_frac) downto slo(nbits_stages, nbits_stages_frac));
function to_h_mem(coef_real : real_array_t; ntaps : integer; proto : sfixed) return h_mem_t is
variable res : h_mem_t;
begin
for i in 0 to ntaps-1 loop
res(i) := to_sfixed(coef_real(i), proto, fixed_wrap, fixed_round);
end loop;
return res;
end to_h_mem;
constant ntaps_needed : integer := ntaps_addr(ntaps, fir_mode);
--Outputs
SIGNAL h_i, h_q : sfixed(shi(nbits_stages, nbits_stages_frac) downto slo(nbits_stages, nbits_stages_frac));
SIGNAL x_i, x_q : sfixed(shi(nbits_in, nbits_in_frac) downto slo(nbits_in, nbits_in_frac));
SIGNAL y_i, y_q : sfixed(shi(nbits_out, nbits_out_frac) downto slo(nbits_out, nbits_out_frac));
SIGNAL h_addr_i, h_addr_q : integer;
-- ROM
CONSTANT coeffs : real_array_t(0 to ntaps_needed-1) := FilterCoef_Lowpass(ntaps, omega, amp)(0 to ntaps_needed-1);
CONSTANT h_mem : h_mem_t := to_h_mem(coeffs, ntaps_needed, h_i);
BEGIN
-- Instantiate the Unit Under Test (UUT)
inst_fir_iterative_i: fir_iterative
GENERIC MAP
(
ntaps => ntaps,
nbits_in => nbits_in,
nbits_in_frac => nbits_in_frac,
nbits_out => nbits_out,
nbits_out_frac => nbits_out_frac,
nbits_stages => nbits_stages,
nbits_stages_frac => nbits_stages_frac,
fir_mode => fir_mode,
rounding => rounding,
saturating => saturating
)
PORT MAP
(
srst => rst,
clk => clk,
h_din => h_i,
h_addr_out => h_addr_i,
ready => ready_i,
x_valid => x_valid_i,
x_din => x_i,
y_dout_valid => y_valid_i,
y_dout => y_i
);
inst_fir_iterative_q: fir_iterative
GENERIC MAP
(
ntaps => ntaps,
nbits_in => nbits_in,
nbits_in_frac => nbits_in_frac,
nbits_out => nbits_out,
nbits_out_frac => nbits_out_frac,
nbits_stages => nbits_stages,
nbits_stages_frac => nbits_stages_frac,
fir_mode => fir_mode,
rounding => rounding,
saturating => saturating
)
PORT MAP
(
srst => rst,
clk => clk,
h_din => h_q,
h_addr_out => h_addr_q,
ready => ready_q,
x_valid => x_valid_q,
x_din => x_q,
y_dout_valid => y_valid_Q,
y_dout => y_q
);
x_i <= sfixed(x_din_i);
y_dout_i <= signed(y_i);
x_q <= sfixed(x_din_q);
y_dout_q <= signed(y_q);
process(clk)
begin
if rising_edge(clk) then
h_i <= h_mem(to_integer(h_addr_i));
h_q <= h_mem(to_integer(h_addr_q));
end if;
end process;
END;