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

Subversion Repositories iqcorrection

[/] [iqcorrection/] [trunk/] [IQGainPhaseCorrection_arch_signed.vhd] - Blame information for rev 36

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 36 Abraxas3d
library ieee;
2
use ieee.std_logic_1164.all;
3
use ieee.numeric_std.all;
4
 
5
 
6
 
7
architecture IQGainPhaseCorrection_signed of IQGainPhaseCorrection is
8
 
9
        --signal declarations
10
 
11
        --phase error estimate accumulator
12
        signal reg_1:signed(width-1 downto 0) := (others => '0');
13
 
14
        --gain error estimate accumulator
15
        signal reg_2:signed(width-1 downto 0) := (0 => '1', others => '0');
16
 
17
        --Phase Offset Adjustment Applied to y1
18
        signal y2:signed(width-1 downto 0) := (others => '0');
19
 
20
        --Gain and Phase Adjustment Applied     to y1
21
        signal y3:signed(2*width-1 downto 0) := (others => '0');
22
 
23
        signal x1y2:signed(2*width-1 downto 0):= (others => '0');
24
        signal mu_1:signed(width-1 downto 0):= (others => '0');
25
        signal x1x1y3y3:signed(width-1 downto 0):= (others => '0');
26
        signal mu_2:signed(width-1 downto 0):= (others => '0');
27
 
28
        signal reg_1x1:signed(2*width-1 downto 0):= (others => '0');
29
 
30
        signal y3y3: signed(4*width-1 downto 0):= (others => '0');
31
        signal x1x1: signed(2*width-1 downto 0):= (others => '0');
32
 
33
begin
34
 
35
    correction : process (clk) is
36
                begin
37
 
38
                if clk'event and clk = '1' then
39
 
40
                --phase error estimate, step size set to 0.000244
41
                --which is achieved with an arithmetic shift right by 12.
42
 
43
                --multiply current I sample by phase error estimate.
44
                reg_1x1 <= reg_1 * x1; --clock 0   
45
 
46
                --Our phase-adjusted Q vector
47
                --is our current Q vector minus 
48
                --a tiny bit of I vector. 
49
                y2 <= y1 - reg_1x1(2*width-1 downto width); --clock 1
50
 
51
                --Multiply our current I vector
52
                --by our phase adjusted Q vector.
53
                x1y2 <= x1 * y2; --clock 2
54
 
55
                --Multiply this result by 0.000244. 
56
                --This applies the step size.
57
                mu_1 <= shift_right(x1y2(2*width-1 downto width),12);     --clock 3
58
 
59
                --Update the phase error estimate.
60
                reg_1 <= reg_1 + mu_1;   --clock 4
61
 
62
                --Output phase error estimate.
63
                phase_error <= reg_1;  --update phase error estimate.    --clock 5
64
 
65
 
66
                --gain error estimate, step size set to 0.000122
67
                --which is achieved with a shift right by 13.
68
                y3 <= y2 * reg_2;          --clock 0       
69
                x1x1 <= x1 * x1;         --clock 0        
70
                y3y3 <= y3 * y3;  --clock 1               
71
 
72
                x1x1y3y3 <= (x1x1(2*width-1 downto width)) - (y3y3(4*width-1 downto 3*width));   --clock 2
73
                mu_2 <= shift_right(x1x1y3y3, 13);       --clock 3
74
                reg_2 <= reg_2 + mu_2;   --clock 4
75
                gain_error <= reg_2;   --update gain error estimate.  --clock 5
76
 
77
                end if;
78
 
79
        end process;
80
 
81
end IQGainPhaseCorrection_signed;

powered by: WebSVN 2.1.0

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