Files
vhdl/lib/ac97_ctrl/src/tb_ac_in.vhd
T
jens 5091040c1d - Intital revision
git-svn-id: http://moon:8086/svn/vhdl/trunk@133 cc03376c-175c-47c8-b038-4cd826a8556b
2008-11-01 21:48:26 +00:00

204 lines
5.0 KiB
VHDL

--------------------------------------------------------------------------------
-- Company:
-- Engineer:
--
-- Create Date: 17:33:47 06/05/2007
-- Design Name: eval_ac
-- Module Name: E:/work/VHDL/eval_ac/tb_eval_ac.vhd
-- Project Name: ac_out
-- Target Device:
-- Tool versions:
-- Description:
--
-- VHDL Test Bench Created by ISE for module: ac_out
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
-- Notes:
-- This testbench has been automatically generated using types std_logic and
-- std_logic_vector for the ports of the unit under test. Xilinx recommends
-- that these types always be used for the top-level I/O of a design in order
-- to guarantee that the testbench will bind correctly to the post-implementation
-- simulation model.
--------------------------------------------------------------------------------
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.numeric_std.ALL;
ENTITY tb_ac_in IS
END tb_ac_in;
ARCHITECTURE behavior OF tb_ac_in IS
-- Component Declaration for the Unit Under Test (UUT)
COMPONENT ac_in
Port (
rst : in std_logic;
clk : in std_logic;
sync_frame : out std_logic;
sync_status : out std_logic;
slot_valid : out unsigned(0 to 12);
stat_addr : out unsigned (19 downto 0);
stat_data : out unsigned (19 downto 0);
pcm_out_addr : in unsigned (3 downto 0);
pcm_out_data : out unsigned (19 downto 0);
ac_reset : in std_logic;
ac_bit_clk : in std_logic;
ac_sdata_in : in std_logic;
ac_ssync : in std_logic
);
END COMPONENT;
COMPONENT ac_out
PORT(
rst : in std_logic;
clk : in std_logic;
sync_tx : out std_logic;
cmd_addr : in unsigned(19 downto 0);
cmd_data : in unsigned(19 downto 0);
cmd_we : in std_logic;
pcm_in_addr : in unsigned(3 downto 0);
pcm_in_data : in unsigned(19 downto 0);
pcm_in_we : in std_logic;
ac_bit_clk : in std_logic;
ac_reset : in std_logic;
ac_sdata_out : out std_logic;
ac_ssync : out std_logic
);
END COMPONENT;
constant SYS_CLK_PERIOD : time := 10 ns;
constant BIT_CLK_PERIOD : time := 81.38 ns;
--Inputs
SIGNAL rst : std_logic := '1';
SIGNAL clk : std_logic := '0';
SIGNAL cmd_we : std_logic := '0';
SIGNAL pcm_in_we : std_logic := '0';
SIGNAL ac_bit_clk : std_logic := '0';
SIGNAL cmd_addr : unsigned(19 downto 0) := (others=>'0');
SIGNAL cmd_data : unsigned(19 downto 0) := (others=>'0');
SIGNAL pcm_in_addr : unsigned(3 downto 0) := "0011";
SIGNAL pcm_in_data : unsigned(19 downto 0) := (others=>'0');
SIGNAL ac_sdata_in : std_logic;
SIGNAL pcm_out_addr : unsigned(3 downto 0) := "0101";
SIGNAL ac_reset : std_logic := '1';
--Outputs
SIGNAL sync_frame : std_logic;
SIGNAL sync_status : std_logic;
SIGNAL sync_tx : std_logic;
SIGNAL ac_sdata_out : std_logic;
SIGNAL ac_ssync : std_logic;
SIGNAL stat_addr : unsigned(19 downto 0);
SIGNAL stat_data : unsigned(19 downto 0);
SIGNAL stat_valid : std_logic;
SIGNAL pcm_out_data : unsigned(19 downto 0);
SIGNAL pcm_out_valid : std_logic;
SIGNAL pcm_out_avail : std_logic;
BEGIN
-- Instantiate the Unit Under Test (UUT)
uut: ac_in PORT MAP(
rst => rst,
clk => clk,
sync_frame => sync_frame,
sync_status => sync_status,
stat_addr => stat_addr,
stat_data => stat_data,
pcm_out_addr => pcm_out_addr,
pcm_out_data => pcm_out_data,
ac_reset => ac_reset,
ac_bit_clk => ac_bit_clk,
ac_sdata_in => ac_sdata_in,
ac_ssync => ac_ssync
);
inst_ac_out: ac_out PORT MAP(
rst => rst,
clk => clk,
sync_tx => sync_tx,
cmd_addr => cmd_addr,
cmd_data => cmd_data,
cmd_we => cmd_we,
pcm_in_addr => pcm_in_addr,
pcm_in_data => pcm_in_data,
pcm_in_we => pcm_in_we,
ac_reset => ac_reset,
ac_bit_clk => ac_bit_clk,
ac_sdata_out => ac_sdata_out,
ac_ssync => ac_ssync
);
ac_sdata_in <= ac_sdata_out;
sys_clk_gen :
PROCESS
BEGIN
wait for SYS_CLK_PERIOD;
clk <= not clk;
END PROCESS;
bit_clk_gen :
PROCESS
BEGIN
wait for BIT_CLK_PERIOD;
ac_bit_clk <= not ac_bit_clk;
END PROCESS;
tb_out : PROCESS
BEGIN
-- Wait 100 ns for global reset to finish
wait for 100*SYS_CLK_PERIOD;
rst <= '0';
wait for 100*SYS_CLK_PERIOD;
ac_reset <= '0';
wait until rising_edge(clk) and sync_tx = '1';
wait for 100*SYS_CLK_PERIOD;
cmd_data <= X"12340";
cmd_addr <= X"8B930";
wait until rising_edge(clk);
cmd_we <= '1';
wait until rising_edge(clk);
cmd_we <= '0';
for k in 1 to 10 loop
pcm_in_we <= '0';
wait until rising_edge(clk) and sync_tx = '1';
wait for 100*SYS_CLK_PERIOD;
for i in 3 to 12 loop
pcm_in_addr <= to_unsigned(i, 4);
pcm_in_data <= to_unsigned(2048*k + integer(i), 20);
pcm_in_we <= '1';
wait until rising_edge(clk);
end loop;
end loop;
pcm_in_we <= '0';
-- Place stimulus here
wait; -- will wait forever
END PROCESS;
tb_in : PROCESS(clk, pcm_out_addr, sync_status)
BEGIN
if rising_edge(clk) then
if sync_status = '1' then
pcm_out_addr <= "0011";
elsif pcm_out_addr /= "1100" then
pcm_out_addr <= pcm_out_addr + 1;
end if;
end if;
END PROCESS;
END;