OpenCores
URL https://opencores.org/ocsvn/dirac/dirac/trunk

Subversion Repositories dirac

[/] [dirac/] [tags/] [dirac_0_0_1_0/] [src/] [testbench/] [ArithmeticCoderTestbench.vhd] - Blame information for rev 14

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 petebleack
 
2
-- VHDL Test Bench Created from source file arithmeticcoder.vhd -- 13:44:22 01/05/2005
3
--
4
-- Notes: 
5
-- This testbench has been automatically generated using types std_logic and
6
-- std_logic_vector for the ports of the unit under test.  Xilinx recommends 
7
-- that these types always be used for the top-level I/O of a design in order 
8
-- to guarantee that the testbench will bind correctly to the post-implementation 
9
-- simulation model.
10
--
11
LIBRARY ieee;
12
USE ieee.std_logic_1164.ALL;
13
USE ieee.numeric_std.ALL;
14
use IEEE.std_logic_textio.all;
15
use ieee.std_logic_arith.all;
16
use ieee.std_logic_unsigned.all;
17
use STD.textio.all;
18
 
19
ENTITY arithmeticcoder_ArithmeticCoderTestbench_vhd_tb IS
20
END arithmeticcoder_ArithmeticCoderTestbench_vhd_tb;
21
 
22
ARCHITECTURE behavior OF arithmeticcoder_ArithmeticCoderTestbench_vhd_tb IS
23
 
24
        COMPONENT arithmeticcoder
25
                generic(
26
        PROB :  std_logic_vector (9 downto 0));
27
        PORT(
28
                ENABLE : IN std_logic;
29
                DATA_IN : IN std_logic;
30
                CONTEXT_ENABLE : in std_logic;
31
                CONTEXT_IN : in std_logic_vector (5 downto 0);
32
                RESET : IN std_logic;
33
                CLOCK : IN std_logic;
34
                SENDING : OUT std_logic;
35
                DATA_OUT : OUT std_logic
36
                );
37
        END COMPONENT;
38
        component ARITHMETICDECODER
39
        generic(
40
        PROB :  std_logic_vector (9 downto 0));
41
        port (ENABLE : in std_logic;
42
           DATA_IN : in std_logic;
43
           RESET : in std_logic;
44
           CLOCK : in std_logic;
45
           SENDING : out std_logic;
46
           DATA_OUT : out std_logic);
47
        end component ARITHMETICDECODER;
48
 
49
        SIGNAL ENABLE :  std_logic;
50
        SIGNAL DATA_IN :  std_logic := '0';
51
        SIGNAL RESET :  std_logic;
52
        SIGNAL CLOCK :  std_logic := '0';
53
        SIGNAL SENDING :  std_logic;
54
        SIGNAL DATA_OUT :  std_logic;
55
        signal TRANSMIT :       std_logic;
56
        signal DATA_TRANSFER :  std_logic;
57
        constant PERIOD : time := 10 ns;
58
        signal CONTEXT_ENABLE : std_logic;
59
        signal CONTEXT : std_logic_vector (5 downto 0) := "000000";
60
        file TESTDATA : text is in "";
61
        file RESULTS :  text is out "results";
62
 
63
BEGIN
64
 
65
        uut: arithmeticcoder
66
        generic map(
67
        PROB => "1110010000")
68
        PORT MAP(
69
                ENABLE => ENABLE,
70
                DATA_IN => DATA_IN,
71
                CONTEXT_ENABLE => CONTEXT_ENABLE,
72
                CONTEXT_IN => CONTEXT,
73
                RESET => RESET,
74
                CLOCK => CLOCK,
75
                SENDING => TRANSMIT,
76
                DATA_OUT => DATA_TRANSFER
77
        );
78
 
79
        CLOCK <= not CLOCK after PERIOD/2;
80
 
81
        DECODER:        ARITHMETICDECODER
82
        generic map(
83
        PROB => "1110010000")
84
        port map(       ENABLE => TRANSMIT,
85
        DATA_IN => DATA_TRANSFER,
86
        RESET => RESET,
87
        CLOCK => CLOCK,
88
        SENDING => SENDING,
89
        DATA_OUT => DATA_OUT);
90
 --*** Test Bench - User Defined Section ***
91
   tb : PROCESS
92
        variable GETLINE : line;
93
        variable INDATA : std_logic;
94
   BEGIN
95
                for COUNT in 0 to 4194307 loop
96
                wait until CLOCK'event and CLOCK = '1';
97
                if COUNT = 0 then
98
                        RESET <= '1';
99
                        ENABLE <= '0';
100
                        DATA_IN <= '0';
101
                elsif COUNT = 1 then
102
                        RESET <= '0';
103
 
104
                elsif   (COUNT - 2) mod 4 = 0 then
105
                        if (COUNT < 4194307) then
106
                                if (COUNT - 2)  mod 128 = 0 then
107
                                        readline(TESTDATA,GETLINE);
108
                                end if;
109
                                read(GETLINE,INDATA);
110
                                DATA_IN <= INDATA;
111
                                ENABLE <= '1';
112
                        else
113
                                DATA_IN <= '1';
114
                                ENABLE <= '1';
115
                        end if;
116
 
117
                elsif COUNT < 4194307 then
118
                        ENABLE <= '0';
119
                else
120
        wait; -- will wait forever
121
        end if;
122
                end loop;
123
   END PROCESS;
124
 
125
        OUTPUT :        process
126
        variable OUTLINE :      line;
127
        begin
128
        for WRITTEN in 0 to 1048576 loop
129
                wait until CLOCK'event and CLOCK = '1' and SENDING = '1';
130
                if WRITTEN = 1048576 then
131
                        report "Process Complete" severity failure;
132
                        wait;
133
                else
134
                        write(OUTLINE,DATA_OUT);
135
                        if (WRITTEN mod 32) = 31 then
136
                                writeline(RESULTS,OUTLINE);
137
                        end if;
138
        end loop;
139
        end process;
140
 
141
 
142
-- *** End Test Bench - User Defined Section ***
143
 
144
COUNT_BITS: process (CLOCK, TRANSMIT)
145
        variable BITS_SENT : integer range 0 to 1048576 := 0;
146
        begin
147
        if (CLOCK'event and CLOCK='1' and TRANSMIT='1') then
148
        BITS_SENT := BITS_SENT+1;
149
        end if;
150
        end process;
151
END;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.