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

Subversion Repositories dct_idct

[/] [dct_idct/] [trunk/] [dct/] [Bench/] [test_dct.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 unicore
---------------------------------------------------------------------
2
----                                                             ----
3
----  DCT IP core                                                ----
4
----                                                             ----
5
----  Authors: Anatoliy Sergienko, Volodya Lepeha                ----
6
----  Company: Unicore Systems http://unicore.co.ua              ----
7
----                                                             ----
8
----  Downloaded from: http://www.opencores.org                  ----
9
----                                                             ----
10
---------------------------------------------------------------------
11
----                                                             ----
12
---- Copyright (C) 2006-2010 Unicore Systems LTD                 ----
13
---- www.unicore.co.ua                                           ----
14
---- o.uzenkov@unicore.co.ua                                     ----
15
----                                                             ----
16
---- This source file may be used and distributed without        ----
17
---- restriction provided that this copyright statement is not   ----
18
---- removed from the file and that any derivative work contains ----
19
---- the original copyright notice and the associated disclaimer.----
20
----                                                             ----
21
---- THIS SOFTWARE IS PROVIDED "AS IS"                           ----
22
---- AND ANY EXPRESSED OR IMPLIED WARRANTIES,                    ----
23
---- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED                  ----
24
---- WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT              ----
25
---- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.        ----
26
---- IN NO EVENT SHALL THE UNICORE SYSTEMS OR ITS                ----
27
---- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,            ----
28
---- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL            ----
29
---- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT         ----
30
---- OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,               ----
31
---- DATA, OR PROFITS; OR BUSINESS INTERRUPTION)                 ----
32
---- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,              ----
33
---- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT              ----
34
---- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING                 ----
35
---- IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,                 ----
36
---- EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.          ----
37
----                                                             ----
38
---------------------------------------------------------------------
39
 
40
library IEEE;
41
use IEEE.std_logic_1164.all;
42
use IEEE.std_logic_arith.all;
43
use IEEE.math_real.all;
44
 
45
entity TEST_DCT is
46
        generic( SIGNED_DATA : integer:= 1;   --  input data - 0 - unsigned, 1 - signed
47
        RANDOM:integer:=0;                                --1 - random test data         ; 0 - predefined   
48
        scale_out:integer:=0      );
49
 
50
end TEST_DCT;
51
 
52
 
53
 
54
architecture TEST_DCT of TEST_DCT is
55
 
56
        signal DATAIN : STD_LOGIC_VECTOR (7 downto 0);
57
        signal DCT,dct1 : STD_LOGIC_VECTOR (11 downto 0);
58
        signal DCTi : STD_LOGIC_VECTOR (11 downto 0);
59
        signal DCTRES : integer;
60
        signal DCTRES_STD : integer;
61
        signal DCT_STD : STD_LOGIC_VECTOR (11 downto 0);
62
        signal ERROR : integer;
63
        signal QUADMEAN : REAL;
64
        signal READY,ready1 : STD_LOGIC;
65
        signal READY_STD : STD_LOGIC;
66
        signal START,EN : STD_LOGIC;
67
        signal CLK,clk1 : STD_LOGIC;
68
        signal RST : STD_LOGIC;
69
 
70
        signal r,rb,max, serror1,       num,num1, serror : integer;
71
 
72
 
73
        component  DCT_AAN is
74
                generic(
75
                        d_signed:integer:=1;    --1 input data signed; 0 - unsigned, and for compression 1/2 is subtracted
76
                        scale_out:integer:=1);             -- 1 output data are scaled; 0 - genuine DCT 
77
                port(
78
                        CLK : in STD_LOGIC;
79
                        RST : in STD_LOGIC;
80
                        START: in STD_LOGIC;         -- after this impulse the 0-th datum is sampled
81
                        EN: in STD_LOGIC;                    -- operation enable to slow-down the calculations
82
                        DATA_IN : in STD_LOGIC_VECTOR(7 downto 0);
83
                        RDY : out STD_LOGIC;
84
                        DATA_OUT : out STD_LOGIC_VECTOR(11 downto 0)
85
                        );
86
        end component;
87
 
88
        component DCT_BEH
89
                generic(  SIGNED_DATA: integer);
90
                port (
91
                        CLK : in STD_LOGIC;
92
                        DATAIN : in STD_LOGIC_VECTOR (7 downto 0);
93
                        RST : in STD_LOGIC;
94
                        EN: in STD_LOGIC;
95
                        START : in STD_LOGIC;
96
                        DATAOUT : out STD_LOGIC_VECTOR (11 downto 0);
97
                        READY : out STD_LOGIC := '0'
98
                        );
99
        end component;
100
 
101
        component BMP_GENERATOR
102
                generic(  SIGNED_DATA : integer:= 0;   --  input data - 0 - unsigned, 1 - signed
103
        RANDOM:integer:=1 );
104
                port (
105
                        CLK : in STD_LOGIC;
106
                        RST : in STD_LOGIC;
107
                        DATA : out STD_LOGIC_VECTOR (7 downto 0);
108
                        START : out STD_LOGIC
109
                        );
110
        end component;
111
 
112
 
113
 
114
begin
115
 
116
        process begin CLK<='0'; wait for 5ns;CLK<='1'; wait for 5ns;
117
        end process;
118
        process begin RST<='1'; wait for 50ns;RST<='0'; wait;
119
        end process;
120
 
121
        en <= '1';
122
        clk1 <= clk;
123
 
124
        U1 : BMP_GENERATOR
125
        generic map( SIGNED_DATA,    --  input data - 0 - unsigned, 1 - signed
126
        RANDOM)
127
        port map(
128
                CLK => CLK,
129
                DATA => DATAIN,
130
                RST => RST,
131
                START => START
132
                );
133
 
134
        U2 : DCT_AAN
135
        generic map( d_SIGNED => SIGNED_DATA, scale_out =>scale_out )
136
        port map(
137
                CLK => CLK1,
138
                DATA_IN => DATAIN,
139
                EN => EN,
140
                DATA_OUT => DCT,
141
                RDY => READY,
142
                RST => RST,
143
                START => START
144
                );
145
 
146
 
147
        U3 : DCT_BEH
148
        generic map( SIGNED_DATA => SIGNED_DATA)
149
        port map(
150
                CLK => CLK,
151
                DATAIN => DATAIN,
152
                DATAOUT => DCT_STD,
153
                EN => EN,
154
                READY => READY_STD,
155
                RST => RST,
156
                START => START
157
                );
158
 
159
 
160
 
161
        r<=CONV_INTEGER(SIGNED(DCT));
162
        rb<=CONV_INTEGER(SIGNED(DCT_STD));
163
        ERROR <= r - rb;
164
 
165
        ERROR_CALC:process(start,error,  READY_STD,clk)
166
                variable SUMERROR:integer;
167
                variable start_acc:boolean:=false;
168
        begin
169
                if start = '1' or RST='1' then
170
                        max <= 0;  serror1 <= 0;  num <= 0;     serror <= 0;
171
                        QUADMEAN<=0.0;   SUMERROR:=0;
172
                        start_acc:=false;
173
                end if;
174
                if READY='1' then
175
                        start_acc:=true;
176
                end if;
177
                if READY_STD = '0' and READY_STD'event then
178
                        num <= num + 1;
179
                        serror <= 0;
180
                        serror1 <= serror;
181
                        if start_acc then
182
                                SUMERROR:=serror;                -- SUMERROR  + 
183
                        end if;
184
                        if num>0 then
185
                                QUADMEAN<=SQRT(REAL(SUMERROR)/(64.0*REAL(num)));
186
                        end if;
187
                        if max <  serror                then
188
                                max <= serror;
189
                                num1 <= num;
190
                        end if;
191
                end if;
192
                if clk = '1' and clk'event  and start_acc then
193
                        serror <= serror + (error * error);             --
194
                end if;
195
 
196
        end process;
197
 
198
 
199
end TEST_DCT;

powered by: WebSVN 2.1.0

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