|
|
-- VHDL Test Bench Created from source file arithmeticcoder.vhd -- 13:44:22 01/05/2005
|
-- VHDL Test Bench Created from source file arithmeticcoder.vhd -- 13:44:22 01/05/2005
|
--
|
--
|
-- Notes:
|
-- Notes:
|
-- This testbench has been automatically generated using types std_logic and
|
-- This testbench has been automatically generated using types std_logic and
|
-- std_logic_vector for the ports of the unit under test. Xilinx recommends
|
-- 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
|
-- 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
|
-- to guarantee that the testbench will bind correctly to the post-implementation
|
-- simulation model.
|
-- simulation model.
|
--
|
--
|
LIBRARY ieee;
|
LIBRARY ieee;
|
USE ieee.std_logic_1164.ALL;
|
USE ieee.std_logic_1164.ALL;
|
USE ieee.numeric_std.ALL;
|
USE ieee.numeric_std.ALL;
|
use IEEE.std_logic_textio.all;
|
use IEEE.std_logic_textio.all;
|
use ieee.std_logic_arith.all;
|
use ieee.std_logic_arith.all;
|
use ieee.std_logic_unsigned.all;
|
use ieee.std_logic_unsigned.all;
|
use STD.textio.all;
|
use STD.textio.all;
|
|
|
ENTITY arithmeticcoder_ArithmeticCoderTestbench_vhd_tb IS
|
ENTITY arithmeticcoder_ArithmeticCoderTestbench_vhd_tb IS
|
END arithmeticcoder_ArithmeticCoderTestbench_vhd_tb;
|
END arithmeticcoder_ArithmeticCoderTestbench_vhd_tb;
|
|
|
ARCHITECTURE behavior OF arithmeticcoder_ArithmeticCoderTestbench_vhd_tb IS
|
ARCHITECTURE behavior OF arithmeticcoder_ArithmeticCoderTestbench_vhd_tb IS
|
|
|
COMPONENT arithmeticcoder
|
COMPONENT arithmeticcoder
|
generic(
|
generic(
|
PROB : std_logic_vector (9 downto 0));
|
PROB : std_logic_vector (9 downto 0));
|
PORT(
|
PORT(
|
ENABLE : IN std_logic;
|
ENABLE : IN std_logic;
|
DATA_IN : IN std_logic;
|
DATA_IN : IN std_logic;
|
CONTEXT_ENABLE : in std_logic;
|
CONTEXT_ENABLE : in std_logic;
|
CONTEXT_IN : in std_logic_vector (5 downto 0);
|
CONTEXT_IN : in std_logic_vector (5 downto 0);
|
RESET : IN std_logic;
|
RESET : IN std_logic;
|
CLOCK : IN std_logic;
|
CLOCK : IN std_logic;
|
SENDING : OUT std_logic;
|
SENDING : OUT std_logic;
|
DATA_OUT : OUT std_logic
|
DATA_OUT : OUT std_logic
|
);
|
);
|
END COMPONENT;
|
END COMPONENT;
|
component ARITHMETICDECODER
|
component ARITHMETICDECODER
|
generic(
|
generic(
|
PROB : std_logic_vector (9 downto 0));
|
PROB : std_logic_vector (9 downto 0));
|
port (ENABLE : in std_logic;
|
port (ENABLE : in std_logic;
|
DATA_IN : in std_logic;
|
DATA_IN : in std_logic;
|
RESET : in std_logic;
|
RESET : in std_logic;
|
CLOCK : in std_logic;
|
CLOCK : in std_logic;
|
SENDING : out std_logic;
|
SENDING : out std_logic;
|
DATA_OUT : out std_logic);
|
DATA_OUT : out std_logic);
|
end component ARITHMETICDECODER;
|
end component ARITHMETICDECODER;
|
|
|
SIGNAL ENABLE : std_logic;
|
SIGNAL ENABLE : std_logic;
|
SIGNAL DATA_IN : std_logic := '0';
|
SIGNAL DATA_IN : std_logic := '0';
|
SIGNAL RESET : std_logic;
|
SIGNAL RESET : std_logic;
|
SIGNAL CLOCK : std_logic := '0';
|
SIGNAL CLOCK : std_logic := '0';
|
SIGNAL SENDING : std_logic;
|
SIGNAL SENDING : std_logic;
|
SIGNAL DATA_OUT : std_logic;
|
SIGNAL DATA_OUT : std_logic;
|
signal TRANSMIT : std_logic;
|
signal TRANSMIT : std_logic;
|
signal DATA_TRANSFER : std_logic;
|
signal DATA_TRANSFER : std_logic;
|
constant PERIOD : time := 10 ns;
|
constant PERIOD : time := 10 ns;
|
signal CONTEXT_ENABLE : std_logic;
|
signal CONTEXT_ENABLE : std_logic;
|
signal CONTEXT : std_logic_vector (5 downto 0) := "000000";
|
signal CONTEXT : std_logic_vector (5 downto 0) := "000000";
|
file TESTDATA : text is in "";
|
file TESTDATA : text is in "";
|
file RESULTS : text is out "results";
|
file RESULTS : text is out "results";
|
|
|
BEGIN
|
BEGIN
|
|
|
uut: arithmeticcoder
|
uut: arithmeticcoder
|
generic map(
|
generic map(
|
PROB => "1110010000")
|
PROB => "1110010000")
|
PORT MAP(
|
PORT MAP(
|
ENABLE => ENABLE,
|
ENABLE => ENABLE,
|
DATA_IN => DATA_IN,
|
DATA_IN => DATA_IN,
|
CONTEXT_ENABLE => CONTEXT_ENABLE,
|
CONTEXT_ENABLE => CONTEXT_ENABLE,
|
CONTEXT_IN => CONTEXT,
|
CONTEXT_IN => CONTEXT,
|
RESET => RESET,
|
RESET => RESET,
|
CLOCK => CLOCK,
|
CLOCK => CLOCK,
|
SENDING => TRANSMIT,
|
SENDING => TRANSMIT,
|
DATA_OUT => DATA_TRANSFER
|
DATA_OUT => DATA_TRANSFER
|
);
|
);
|
|
|
CLOCK <= not CLOCK after PERIOD/2;
|
CLOCK <= not CLOCK after PERIOD/2;
|
|
|
DECODER: ARITHMETICDECODER
|
DECODER: ARITHMETICDECODER
|
generic map(
|
generic map(
|
PROB => "1110010000")
|
PROB => "1110010000")
|
port map( ENABLE => TRANSMIT,
|
port map( ENABLE => TRANSMIT,
|
DATA_IN => DATA_TRANSFER,
|
DATA_IN => DATA_TRANSFER,
|
RESET => RESET,
|
RESET => RESET,
|
CLOCK => CLOCK,
|
CLOCK => CLOCK,
|
SENDING => SENDING,
|
SENDING => SENDING,
|
DATA_OUT => DATA_OUT);
|
DATA_OUT => DATA_OUT);
|
--*** Test Bench - User Defined Section ***
|
--*** Test Bench - User Defined Section ***
|
tb : PROCESS
|
tb : PROCESS
|
variable GETLINE : line;
|
variable GETLINE : line;
|
variable INDATA : std_logic;
|
variable INDATA : std_logic;
|
BEGIN
|
BEGIN
|
for COUNT in 0 to 4194307 loop
|
for COUNT in 0 to 4194307 loop
|
wait until CLOCK'event and CLOCK = '1';
|
wait until CLOCK'event and CLOCK = '1';
|
if COUNT = 0 then
|
if COUNT = 0 then
|
RESET <= '1';
|
RESET <= '1';
|
ENABLE <= '0';
|
ENABLE <= '0';
|
DATA_IN <= '0';
|
DATA_IN <= '0';
|
elsif COUNT = 1 then
|
elsif COUNT = 1 then
|
RESET <= '0';
|
RESET <= '0';
|
|
|
elsif (COUNT - 2) mod 4 = 0 then
|
elsif (COUNT - 2) mod 4 = 0 then
|
if (COUNT < 4194307) then
|
if (COUNT < 4194307) then
|
if (COUNT - 2) mod 128 = 0 then
|
if (COUNT - 2) mod 128 = 0 then
|
readline(TESTDATA,GETLINE);
|
readline(TESTDATA,GETLINE);
|
end if;
|
end if;
|
read(GETLINE,INDATA);
|
read(GETLINE,INDATA);
|
DATA_IN <= INDATA;
|
DATA_IN <= INDATA;
|
ENABLE <= '1';
|
ENABLE <= '1';
|
else
|
else
|
DATA_IN <= '1';
|
DATA_IN <= '1';
|
ENABLE <= '1';
|
ENABLE <= '1';
|
end if;
|
end if;
|
|
|
elsif COUNT < 4194307 then
|
elsif COUNT < 4194307 then
|
ENABLE <= '0';
|
ENABLE <= '0';
|
else
|
else
|
wait; -- will wait forever
|
wait; -- will wait forever
|
end if;
|
end if;
|
end loop;
|
end loop;
|
END PROCESS;
|
END PROCESS;
|
|
|
OUTPUT : process
|
OUTPUT : process
|
variable OUTLINE : line;
|
variable OUTLINE : line;
|
begin
|
begin
|
for WRITTEN in 0 to 1048576 loop
|
for WRITTEN in 0 to 1048576 loop
|
wait until CLOCK'event and CLOCK = '1' and SENDING = '1';
|
wait until CLOCK'event and CLOCK = '1' and SENDING = '1';
|
if WRITTEN = 1048576 then
|
if WRITTEN = 1048576 then
|
report "Process Complete" severity failure;
|
report "Process Complete" severity failure;
|
wait;
|
wait;
|
else
|
else
|
write(OUTLINE,DATA_OUT);
|
write(OUTLINE,DATA_OUT);
|
if (WRITTEN mod 32) = 31 then
|
if (WRITTEN mod 32) = 31 then
|
writeline(RESULTS,OUTLINE);
|
writeline(RESULTS,OUTLINE);
|
end if;
|
end if;
|
end loop;
|
end loop;
|
end process;
|
end process;
|
|
|
|
|
-- *** End Test Bench - User Defined Section ***
|
-- *** End Test Bench - User Defined Section ***
|
|
|
COUNT_BITS: process (CLOCK, TRANSMIT)
|
COUNT_BITS: process (CLOCK, TRANSMIT)
|
variable BITS_SENT : integer range 0 to 1048576 := 0;
|
variable BITS_SENT : integer range 0 to 1048576 := 0;
|
begin
|
begin
|
if (CLOCK'event and CLOCK='1' and TRANSMIT='1') then
|
if (CLOCK'event and CLOCK='1' and TRANSMIT='1') then
|
BITS_SENT := BITS_SENT+1;
|
BITS_SENT := BITS_SENT+1;
|
end if;
|
end if;
|
end process;
|
end process;
|
END;
|
END;
|
|
|