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

Subversion Repositories cordic

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 6 rherveille
--
2
-- file: r2p_corproc.vhd
3
--
4
-- XY to RA coordinate / rectangular to polar coordinates processor 
5
--
6
-- uses: r2p_pre.vhd, r2p_cordic.vhd, r2p_post.vhd
7
--
8
-- rev. 1.1 June 4th, 2001. Richard Herveille. Completely revised core.
9
--
10
 
11
library ieee;
12
use ieee.std_logic_1164.all;
13
use ieee.std_logic_arith.all;
14
 
15
entity r2p_corproc is
16
        port(
17
                clk     : in std_logic;
18
                ena     : in std_logic;
19
                Xin     : in signed(15 downto 0);
20
                Yin : in signed(15 downto 0);
21
 
22
                Rout    : out unsigned(19 downto 0);
23
                Aout    : out signed(19 downto 0)
24
        );
25
end entity r2p_corproc;
26
 
27
architecture dataflow of r2p_corproc is
28
        constant PipeLength : natural := 15;
29
 
30
        component r2p_pre is
31
        port(
32
                clk     : in std_logic;
33
                ena     : in std_logic;
34
                Xi      : in signed(15 downto 0);
35
                Yi      : in signed(15 downto 0);
36
 
37
                Xo      : out unsigned(14 downto 0);
38
                Yo      : out unsigned(14 downto 0);
39
                Q       : out std_logic_vector(2 downto 0)
40
        );
41
        end component r2p_pre;
42
 
43
        component r2p_cordic is
44
        generic(
45
                PIPELINE      : integer;
46
                WIDTH         : integer;
47
                EXT_PRECISION   : integer
48
        );
49
        port(
50
                clk     : in std_logic;
51
                ena     : in std_logic;
52
                Xi      : in signed(WIDTH-1 downto 0);
53
                Yi      : in signed(WIDTH-1 downto 0);
54
                Zi : in signed(19 downto 0) := (others => '0');
55
 
56
                Xo      : out signed(WIDTH + EXT_PRECISION -1 downto 0);
57
                Zo      : out signed(19 downto 0));
58
        end component r2p_cordic;
59
 
60
        component r2p_post is
61
        port(
62
                clk     : in std_logic;
63
                ena     : in std_logic;
64
 
65
                Ai      : in signed(19 downto 0);
66
                Ri      : in unsigned(19 downto 0);
67
                Q       : in std_logic_vector(2 downto 0);
68
 
69
                Ao      : out signed(19 downto 0);
70
                Ro      : out unsigned(19 downto 0));
71
        end component r2p_post;
72
 
73
        signal Xpre, Ypre : unsigned(15 downto 0);
74
        signal Acor, Rcor : signed(19 downto 0);
75
        signal Q, dQ : std_logic_vector(2 downto 0);
76
 
77
begin
78
 
79
        -- instantiate components
80
        u1:     r2p_pre port map(clk => clk, ena => ena, Xi => Xin, Yi => Yin, Xo => Xpre(14 downto 0), Yo => Ypre(14 downto 0), Q => Q);
81
        Xpre(15) <= '0';
82
        Ypre(15) <= '0';
83
 
84
        u2:     r2p_cordic
85
                        generic map(PIPELINE => PipeLength, WIDTH => 16, EXT_PRECISION => 4)
86
                        port map(clk => clk, ena => ena, Xi => signed(Xpre), Yi => signed(Ypre), Xo => Rcor, Zo => Acor);
87
 
88
        delay: block
89
                type delay_type is array(PipeLength -1 downto 0) of std_logic_vector(2 downto 0);
90
                signal delay_pipe :delay_type;
91
        begin
92
                process(clk, Q)
93
                begin
94
                        if (clk'event and clk = '1') then
95
                                if (ena = '1') then
96
                                        delay_pipe(0) <= Q;
97
                                        for n in 1 to PipeLength -1 loop
98
                                                delay_pipe(n) <= delay_pipe(n -1);
99
                                        end loop;
100
                                end if;
101
                        end if;
102
                end process;
103
                dQ <= delay_pipe(PipeLength -1);
104
        end block delay;
105
 
106
        u3:     r2p_post port map(clk => clk,  ena => ena, Ri => unsigned(Rcor), Ai => Acor, Q => dQ, Ao => Aout, Ro => Rout);
107
end architecture dataflow;

powered by: WebSVN 2.1.0

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