《cordic算法vhdl实现》由会员分享,可在线阅读,更多相关《cordic算法vhdl实现(5页珍藏版)》请在金锄头文库上搜索。
1、LIBRARY ieee;USE ieee.std_logic_1164.all;USE ieee.std_logic_arith.all;USE ieee.STD_LOGIC_UNSIGNED.all;ENTITY cordicCOS_SIN ISPORT(clk :IN std_logic;deg_in :IN std_logic_vector (13 downto 0);cos :OUT std_logic_vector(15 downto 0);sin :OUT std_logic_vector(15 downto 0);END cordicCOS_SIN;architecture r
2、lt_cordicCOS_SIN of cordicCOS_SIN isconstant c1:std_logic_vector(13 downto 0):=CONV_STD_LOGIC_VECTOR(4096,14);constant c2:std_logic_vector(13 downto 0):=CONV_STD_LOGIC_VECTOR(2048,14);constant c3:std_logic_vector(13 downto 0):=CONV_STD_LOGIC_VECTOR(1209,14); -arctan(1/2)constant c4:std_logic_vector(
3、13 downto 0):=CONV_STD_LOGIC_VECTOR(639,14); -arctan(1/4)-constant x0:std_logic_vector(15 downto 0):=CONV_STD_LOGIC_VECTOR(19895,16);signal x0 :std_logic_vector(15 downto 0);signal y1,x1 :std_logic_vector(15 downto 0);signal y2,x2:std_logic_vector(15 downto 0);signal y3,x3:std_logic_vector(17 downto
4、 0);signal y4,x4:std_logic_vector(19 downto 0);signal p1,p2,p3,p4 :std_logic_vector(13 downto 0);beginx0 = conv_std_logic_vector(26980,16);-step 1-process(clk)begin if rising_edge(clk) then if deg_in(13) =1 then y1 = x0000 -x0;else y1 = x0;end if;end if;end process;process(clk)begin if rising_edge(c
5、lk) then x1 0); end if;end process;process(clk)begin if rising_edge(clk) then if deg_in(13) =1 then p1 = deg_in + c1;else p1 = deg_in - c1;end if;end if;end process;-step 2-process(clk)begin if rising_edge(clk) then if p1(13) =1 then y2 = y1 - x1;else y2 = y1 + x1;end if;end if;end process;process(c
6、lk)begin if rising_edge(clk) then if p1(13) =1 then x2 = x1 + y1;else x2 = x1 - y1;end if; end if;end process;process(clk)begin if rising_edge(clk) then if p1(13) =1 then p2 = p1 + c2;else p2 = p1 - c2;end if;end if;end process;-step 3-process(clk)begin if rising_edge(clk) then if p2(13) =1 then y3
7、= (y2(15) & y2 &0) -(x2(15) & x2(15) & x2);else y3 = (y2(15) & y2 &0) + (x2(15) & x2(15) & x2);end if;end if;end process;process(clk)begin if rising_edge(clk) then if p2(13) =1 then x3 = (x2(15) & x2 & 0) + (y2(15) & y2(15) & y2 );else x3 = (x2(15) & x2 & 0) - (y2(15) & y2(15) & y2 );end if; end if;
8、end process;process(clk)begin if rising_edge(clk) then if p2(13) =1 then p3 = p2 + c3;else p3 = p2 - c3;end if;end if;end process;-step 4-process(clk)begin if rising_edge(clk) then if p3(13) =1 then y4 = (y3 & 00) -(x3(17) & x3(17) & x3);else y4 = (y3 & 00) +(x3(17) & x3(17) & x3);end if;end if;end
9、process;process(clk)begin if rising_edge(clk) then if p3(13) =1 then x4 = (x3 & 00) + (y3(17) & y3(17) & y3 );else x4 = (x3 & 00) - (y3(17) & y3(17) & y3 );end if; end if;end process;process(clk)begin if rising_edge(clk) then if p3(13) =1 then p4 = p3 + c4;else p4 = p3 - c4;end if;end if;end process;cos=x4(19 downto 4);sin=y4(19 downto 4);end rlt_cordicCOS_SIN;