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

Subversion Repositories cordic

[/] [cordic/] [trunk/] [rect2polar/] [r2p_pre.vhd] - Blame information for rev 12

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 6 rherveille
--
2
-- r2p_pre.vhd
3
--
4
-- Cordic pre-processing block
5
--
6
--
7
-- step 1:      determine quadrant and generate absolute value of X and Y
8
--              Q1: Xnegative
9
--              Q2: Ynegative
10
--
11
-- step 2:      swap X and Y values if Y>X
12
--              Q3: swapped (Y > X)
13
--
14
-- Rev. 1.1  June 4th, 2001. Richard Herveille. Revised entire core.
15
--
16
 
17
library ieee;
18
use ieee.std_logic_1164.all;
19
use ieee.std_logic_arith.all;
20
 
21
entity r2p_pre is
22
        port(
23
                clk     : in std_logic;
24
                ena     : in std_logic;
25
 
26
                Xi      : in signed(15 downto 0);
27
                Yi      : in signed(15 downto 0);
28
 
29
                Xo      : out unsigned(14 downto 0);
30
                Yo      : out unsigned(14 downto 0);
31
                Q       : out std_logic_vector(2 downto 0));
32
end entity r2p_pre;
33
 
34
architecture dataflow of r2p_pre is
35
        signal Xint1, Yint1             : unsigned(14 downto 0);
36
        signal Xneg, Yneg, swap : std_logic;
37
 
38
begin
39
        --
40
        -- step 1: Determine absolute value of X and Y, set Xneg and Yneg
41
        --         Loose the sign-bit.
42
        Step1: process(clk, Xi, Yi)
43
        begin
44
                if (clk'event and clk = '1') then
45
                        if (ena = '1') then
46
                                Xint1 <= conv_unsigned(abs(Xi), 15);
47
                                Xneg <= Xi(Xi'left);
48
 
49
                                Yint1 <= conv_unsigned(abs(Yi), 15);
50
                                Yneg <= Yi(Yi'left);
51
                        end if;
52
                end if;
53
        end process Step1;
54
 
55
        --
56
        -- step 2: Swap X and Y if Y>X
57
        --
58
        Step2: process(clk, Xint1, Yint1)
59
                variable Xint2, Yint2   : unsigned(14 downto 0);
60
        begin
61
                if (Yint1 > Xint1) then
62
                        swap <= '1';
63
                        Xint2 := Yint1;
64
                        Yint2 := Xint1;
65
                else
66
                        swap <= '0';
67
                        Xint2 := Xint1;
68
                        Yint2 := Yint1;
69
                end if;
70
 
71
                if(clk'event and clk = '1') then
72
                        if (ena = '1') then
73
                                Xo <= Xint2;
74
                                Yo <= Yint2;
75
 
76
                                Q <= (Yneg, Xneg, swap);
77
                        end if;
78
                end if;
79
                end process Step2;
80
 
81
end architecture dataflow;
82
 
83
 

powered by: WebSVN 2.1.0

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