Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as VHDL by cordic ( 15 years ago )
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
use IEEE.NUMERIC_STD.ALL;
---- Uncomment the following library declaration if instantiating
---- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity CordicRtl is
Port ( x : in real; --in signed(15 downto 0);
clk : in real; --in std_ulogic;
arcsin : out real--out signed(15 downto 0));
);
end CordicRtl;
architecture Behavioral of CordicRtl is
function ArcTan(x: natural) return real is --Tan^-1(2^-i), dove i va da 0 a 6
variable risultato : real;
begin
case x is
when 0 => risultato := 45.00;--10#45#;--2#0000000000101101#;--45;
when 1 => risultato := 26.56;--10#26#;--2#0000000000011010#;--26,56505118;
when 2 => risultato := 14.03;--10#14#;--2#0000000000001110#;--14,03624347;
when 3 => risultato := 7.12;--10#7#;--2#0000000000000111#;--7,125016349;
when 4 => risultato := 3.57;--10#3#;--2#0000000000000011#;--3,576364375;
when 5 => risultato := 1.78;--10#1#;--2#0000000000000001#;--1,789910608;
when 6 => risultato := 0.89;--10#0#;--2#0000000000000000#;--0,89517371;
when others => risultato := 0.0;--10#0#;--2#0000000000000000#;--0;
end case;
return risultato;
end function ArcTan;
begin
main: process(x,clk) is
constant An: real := 1.647;
--variable X, Y, Z, c : real;
type XYVector is array(15 downto 0) of real;--signed(15 downto 0);
variable X,Y,Z,c : XYVector;
begin
--case clk is
--when 0 =>
--if clk = 0 then
--c := x * An;
--X := 1.0;
--Y := 0.0;
--end if;
--else if (clk := 1) Z := 0.0;
--converti x in real
c(0) := 0.0; --x*An
X(0) := 1.0;
Y(0) := 0.0;
Z(0) := 0.0;
for i in 6 downto 0 loop
--variable x :natural;
case x is
when 1 =>--x :=
c(i+1) := x * An;
X(i+1) := X(i) - SHL(Y(i), "10"); --shift
Y(i+1) := Y(i) + SHL(X(i), "10");
Z(i+1) := Z(i) - SHL(ArcTan(x), "10");
when 2 =>
c(i+1) := x * An;
X(i+1) := X(i) - SHL(Y(i), "10"); --shift
Y(i+1) := Y(i) + SHL(X(i), "10");
Z(i+1) := Z(i) - SHL(ArcTan(x), "10");
when 3 =>
c(i+1) := x * An;
X(i+1) := X(i) - SHL(Y(i), "10"); --shift
Y(i+1) := Y(i) + SHL(X(i), "10");
Z(i+1) := Z(i) - SHL(ArcTan(x), "10");
when 4 =>
c(i+1) := x * An;
X(i+1) := X(i) - SHL(Y(i), "10"); --shift
Y(i+1) := Y(i) + SHL(X(i), "10");
Z(i+1) := Z(i) - SHL(ArcTan(x), "10");
when 5 =>
c(i+1) := x * An;
X(i+1) := X(i) - SHL(Y(i), "10"); --shift
Y(i+1) := Y(i) + SHL(X(i), "10");
Z(i+1) := Z(i) - SHL(ArcTan(x), "10");
end case;
end loop;
--case ruota of
--when x := 0 => --caso base
--c := x * An;
--X := 1.0;
--Y := 0.0;
--when x := 1 =>
--c := x * An;
--X := X
end Behavioral;
Revise this Paste