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

Subversion Repositories iqcorrection

[/] [iqcorrection/] [trunk/] [IQGainPhaseCorrection_testbench_create.vhd] - Blame information for rev 39

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 39 Abraxas3d
library ieee;
2
use ieee.std_logic_1164.all;
3
use ieee.math_real.all;
4
use ieee.numeric_std.all;
5
use work.normal_distribution_random_noise.all;
6
use work.create_sample.all;
7
 
8
entity IQGainPhaseCorrection_testbench is
9
end entity;
10
 
11
 
12
 
13
 
14
 
15
--The create architecture creates I and Q samples programmatically
16
--using trigonometric identities. It's supported by two packages, 
17
--normal_distribution_random_noise and create_sample. create_sample
18
--needs normal_distribution_random_noise in order to add normally
19
--distributed noise to the sample. 
20
 
21
architecture IQGainPhaseCorrection_testbench_create of IQGainPhaseCorrection_testbench is
22
 
23
--declare the DUT as a component.
24
component IQGainPhaseCorrection is
25
        generic(width :natural);
26
        port(
27
        clk                             :in std_logic;
28
        x1                              :in signed(width downto 0);
29
        y1                              :in signed(width downto 0);
30
        gain_error              :out signed(width downto 0);
31
        gain_lock               :out bit;
32
        phase_error             :out signed(width downto 0);
33
        phase_lock              :out bit;
34
        corrected_x1    :out signed(width downto 0);
35
        corrected_y1    :out signed(width downto 0)
36
        );
37
        end component;
38
 
39
--provide signals to run the DUT.
40
signal clk_tb                   : std_logic := '0';
41
signal clk_tb_delayed   : std_logic     := '0';
42
signal x1_tb                    : signed(31 downto 0);
43
signal y1_tb                    : signed(31 downto 0);
44
signal gain_error_tb    : signed(31 downto 0);
45
signal gain_lock_tb             : bit;
46
signal phase_error_tb   : signed(31 downto 0);
47
signal phase_lock_tb    : bit;
48
signal corrected_x1_tb  : signed(31 downto 0);
49
signal corrected_y1_tb  : signed(31 downto 0);
50
 
51
begin
52
 
53
        --connect the testbench signal to the component
54
        DUT:IQGainPhaseCorrection
55
        generic map(
56
        width => 31
57
        )
58
        port map(
59
        clk => clk_tb_delayed,
60
        x1 => x1_tb,
61
        y1 => y1_tb,
62
        gain_error => gain_error_tb,
63
        gain_lock => gain_lock_tb,
64
        phase_error => phase_error_tb,
65
        phase_lock => phase_lock_tb,
66
        corrected_x1 => corrected_x1_tb,
67
        corrected_y1 => corrected_y1_tb
68
        );
69
 
70
 
71
--create I and Q. MTreseler says, "sin in vhdl I use use ieee.math_real.all and cast to integer."
72
 
73
CREATE_I_Q_SAMPLES: process (clk_tb) is
74
--for both I and Q
75
variable n_dat : integer := 0;
76
variable freq : real := 0.03; --relative frequency
77
variable sgma : real :=0.01; --sigma of noise
78
variable amplitude : real := 1.0; --amplitude
79
--for Q
80
variable e1 : real := 0.1; --gain error
81
variable a1 : real := (10.0*math_pi)/180.0; --phase error of 10 degrees
82
 
83
begin
84
        if (clk_tb'event and clk_tb = '1') then
85
                x1_tb <= create_I_sample(n_dat, freq, sgma, amplitude, 31);
86
                y1_tb <= create_Q_sample(n_dat, freq, sgma, amplitude, 31, e1, a1);
87
                n_dat := n_dat + 1;
88
        end if;
89
end process CREATE_I_Q_SAMPLES;
90
 
91
 
92
 
93
DRIVE_CLOCK:process
94
begin
95
        wait for 50 ns;
96
        clk_tb <= not clk_tb;
97
        clk_tb_delayed <= not clk_tb_delayed after 1 ns;
98
end process;
99
 
100
end IQGainPhaseCorrection_testbench_create;
101
 
102
 
103
 
104
 
105
 
106
 

powered by: WebSVN 2.1.0

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