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

Subversion Repositories cordic

[/] [cordic/] [trunk/] [rect2polar/] [r2p_cordic.vhd] - Blame information for rev 6

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 6 rherveille
--
2
--      VHDL implementation of cordic algorithm
3
--
4
-- File: cordic.vhd
5
-- author: Richard Herveille
6
-- rev. 1.0 initial release
7
-- rev. 1.1 changed CordicPipe component declaration, Xilinx WebPack issue
8
-- rev. 1.2 Revised entire core. Made is simpler and easier to understand.
9
 
10
library ieee;
11
use ieee.std_logic_1164.all;
12
use ieee.std_logic_arith.all;
13
 
14
entity r2p_cordic is
15
        generic(
16
                PIPELINE      : integer := 15;
17
                WIDTH         : integer := 16;
18
                EXT_PRECISION : integer := 4
19
        );
20
        port(
21
                clk     : in std_logic;
22
                ena : in std_logic;
23
 
24
                Xi : in signed(WIDTH-1 downto 0);
25
                Yi : in signed(WIDTH-1 downto 0);
26
                Zi : in signed(19 downto 0) := (others => '0');
27
 
28
                Xo : out signed(WIDTH + EXT_PRECISION -1 downto 0);
29
                Zo : out signed(19 downto 0)
30
        );
31
end r2p_cordic;
32
 
33
 
34
architecture dataflow of r2p_cordic is
35
 
36
        --
37
        --      TYPE defenitions
38
        --
39
        type XYVector is array(PIPELINE downto 0) of signed(WIDTH + EXT_PRECISION -1 downto 0);
40
        type ZVector is array(PIPELINE downto 0) of signed(19 downto 0);
41
 
42
        --
43
        --      COMPONENT declarations
44
        --
45
        component r2p_CordicPipe
46
        generic(
47
                WIDTH   : natural := 16;
48
                PIPEID  : natural := 1
49
        );
50
        port(
51
                clk             : in std_logic;
52
                ena             : in std_logic;
53
 
54
                Xi              : in signed(WIDTH -1 downto 0);
55
                Yi              : in signed(WIDTH -1 downto 0);
56
                Zi              : in signed(19 downto 0);
57
 
58
                Xo              : out signed(WIDTH -1 downto 0);
59
                Yo              : out signed(WIDTH -1 downto 0);
60
                Zo              : out signed(19 downto 0)
61
        );
62
        end component r2p_CordicPipe;
63
 
64
        --
65
        --      SIGNALS
66
        --
67
        signal X, Y     : XYVector;
68
        signal Z        : ZVector;
69
 
70
        --
71
        --      ACHITECTURE BODY
72
        --
73
begin
74
        -- fill first nodes
75
 
76
        X(0)(WIDTH + EXT_PRECISION -1 downto EXT_PRECISION) <= Xi;   -- fill MSBs with input data
77
        X(0)(EXT_PRECISION -1 downto 0) <= (others => '0');          -- fill LSBs with '0'
78
 
79
        Y(0)(WIDTH + EXT_PRECISION -1 downto EXT_PRECISION) <= Yi;   -- fill MSBs with input data
80
        Y(0)(EXT_PRECISION -1 downto 0) <= (others => '0');          -- fill LSBs with '0'
81
 
82
        Z(0) <= Zi;
83
 
84
        --
85
        -- generate pipeline
86
        --
87
        gen_pipe:
88
        for n in 1 to PIPELINE generate
89
                Pipe: r2p_CordicPipe
90
                        generic map(WIDTH => WIDTH+EXT_PRECISION, PIPEID => n -1)
91
                        port map ( clk, ena, X(n-1), Y(n-1), Z(n-1), X(n), Y(n), Z(n) );
92
        end generate gen_pipe;
93
 
94
        --
95
        -- assign outputs
96
        --
97
        Xo <= X(PIPELINE);
98
        Zo <= Z(PIPELINE);
99
end dataflow;
100
 

powered by: WebSVN 2.1.0

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