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

Subversion Repositories lp_iir_filter

[/] [lp_iir_filter/] [trunk/] [Testbench/] [IIR_LP_TB.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 unicore
---------------------------------------------------------------------
2
----                                                             ----
3
----  IIR Filter 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_arith.all;
42
use ieee.std_logic_signed.all;
43
use ieee.std_logic_1164.all;
44
use IEEE.MATH_REAL.all;
45
 
46
entity wave2x5_tb is
47
end wave2x5_tb;
48
 
49
architecture TB_ARCHITECTURE of wave2x5_tb is
50
        -- Component declaration of the tested unit
51
        component lpf3x8
52
                port(
53
                        CLK : in std_logic;
54
                        RST : in std_logic;
55
                        EF : in STD_LOGIC;
56
                        FREQ : in STD_LOGIC_VECTOR(11 downto 0);
57
                        DI : in std_logic_vector(15 downto 0);
58
                        DO : out std_logic_vector(15 downto 0) );
59
        end component;
60
 
61
        component FilterTB is
62
                generic(fsampl:integer := 2000;
63
                        fstrt: integer:=0;
64
                        deltaf:integer:=20;
65
                        maxdelay:integer:=100;
66
                        slowdown:integer:=3;
67
                        magnitude:real:=1000.0
68
                        );
69
                port(
70
                        CLK : in STD_LOGIC;
71
                        RST : in STD_LOGIC;
72
                        RERSP : in INTEGER;
73
                        IMRSP : in INTEGER;
74
                        REO : out INTEGER;
75
                        IMO : out INTEGER;
76
                        FREQ : out INTEGER;
77
                        MAGN:out INTEGER;
78
                        LOGMAGN:out REAL;
79
                        PHASE: out REAL ;
80
                        ENA: inout STD_LOGIC
81
                        );
82
        end component ;
83
 
84
        signal CLK : std_logic:='1';
85
        signal RST,ena,ef : std_logic;
86
        signal DI : std_logic_vector(15 downto 0);
87
        signal RNG : std_logic_vector(1 downto 0);
88
        signal Fre : std_logic_vector(7 downto 0);
89
        signal DO : std_logic_vector(15 downto 0);
90
        constant ze:std_logic_vector(15 downto 0):=(others=>'0');
91
        constant one:std_logic_vector(15 downto 0):=(15=>'0',14=>'0',others=>'1');
92
        signal rersp,imrsp,reo,imo,freq,magn:integer;
93
        signal reov,rerspv,imov,imrspv:std_logic_vector(15 downto 0);
94
        signal logmagn,phase,er:real;
95
        signal f:std_logic_vector(11 downto 0);
96
        signal nn:natural;
97
        signal n1,n2,n3:natural;
98
begin
99
        er<=sqrt((1.2*1.2+1.0+1.5*1.5+0.6*0.6+0.3*0.3)/5.0);
100
        rst<='1', '0' after 1 ns;
101
        CLK<=(not CLK) after 5 ns;      --and not rst
102
        DI<= ze, one after 10 ns, ze after 20 ns;
103
        ef<= '0', '1' after 25 ns, '0' after 55 ns;
104
        f<=X"a00";
105
        process(clk)
106
        variable s1,s2:integer:=33;
107
        variable u:real;
108
        begin
109
                UNIFORM(s1,s2,u);
110
                nn<=integer(u*3.0+0.5);
111
                if nn=1 then n1<=n1+1;
112
                        elsif nn=2 then n2<=n2+1;
113
                        elsif nn=3 then n3<=n3+1;
114
                                end if;
115
                end process;
116
 
117
        UUTr : LPF3x8
118
        port map (
119
                CLK => CLK,
120
                RST => RST,
121
                Ef=>ef,
122
                freq=>f,
123
                DI => reov,--DI,--  
124
                DO => rerspv
125
                );
126
        UUTi : Lpf3x8
127
        port map (
128
                CLK => CLK,
129
                RST => RST,
130
                Ef=>ef,
131
                freq=>f,
132
                DI => imov,
133
                DO => imrspv
134
                );
135
        rersp<=conv_integer(signed(rerspv));
136
        imrsp<=conv_integer(signed(imrspv));
137
        reov<=conv_std_logic_vector(reo,16);
138
        imov<=conv_std_logic_vector(imo,16);
139
 
140
        UTB: FilterTB generic map(fsampl=> 1000,
141
                fstrt=>00,
142
                deltaf=>2,
143
                maxdelay=>100,
144
                slowdown=>8,
145
                magnitude=>32767.0/1.0  )
146
        port map(CLK,RST,
147
                RERSP=>rersp,
148
                IMRSP=>imrsp,
149
                REO=>reo,
150
                IMO=>imo,
151
                FREQ=>freq,
152
                MAGN=>magn,
153
                LOGMAGN=>logmagn,
154
                PHASE=>phase,
155
                ENA=>ena
156
                );
157
 
158
 
159
 
160
end TB_ARCHITECTURE;
161
 

powered by: WebSVN 2.1.0

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