philrivers
Programmer
Hi, I imagine this is going to seem like a rookie mistake. i am doing some work on developing an algorithm the cod eof which i will post below. essentially it isnt finished so, but before i go further i would like to rectify the mistakes that are appearing with regards to the constants. "Numeric value exceeds INTEGER high" is appearing. how can I fix this
thanks
LIBRARY IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_misc.all;
use IEEE.std_logic_arith.all;
use IEEE.std_logic_unsigned.all;
ENTITY cordic IS
PORT (
clk : IN STD_LOGIC;
load: IN STD_LOGIC;
res : IN STD_LOGIC;
x_in, IN STD_LOGIC_VECTOR(15 downto 0);
y_in, IN STD_LOGIC_VECTOR(15 downto 0);
z_in: IN STD_LOGIC_VECTOR(15 downto 0);
x_out: OUT STD_LOGIC_VECTOR(15 downto 0);
y_out: OUT STD_LOGIC_VECTOR(15 downto 0);
END cordic;
ARCHITECTURE cordic_arch OF cordic IS
constant K : signed(31 down to 0) := SIGNED(To_StdLogicVector(100100001100100000101001100011)); -- .607252935
constant a : signed(31 down to 0) := SIGNED(To_StdLogicVector(111011100110101100101000000000)); -- 1.0
constant b : signed(31 down to 0) := SIGNED(To_StdLogicVector(11101110011010110010100000000)); -- .5
constant c : signed(31 down to 0) := SIGNED(To_StdLogicVector(1110111001101011001010000000)); -- .25
constant d : signed(31 down to 0) := SIGNED(To_StdLogicVector(111011100110101100101000000)); -- .125
constant e : signed(31 down to 0) := SIGNED(To_StdLogicVector(11101110011010110010100000)); -- .0625
constant f : signed(31 down to 0) := SIGNED(To_StdLogicVector(1110111001101011001010000)); -- .03125
constant g : signed(31 down to 0) := SIGNED(To_StdLogicVector(111011100110101100101000)); -- .015625
constant h : signed(31 down to 0) := SIGNED(To_StdLogicVector(11101110011010110010100)); -- .0078125
constant i : signed(31 down to 0) := SIGNED(To_StdLogicVector(1110111001101011001010)); -- .00390625
constant j : signed(31 down to 0) := SIGNED(To_StdLogicVector(111011100110101100101)); -- .001953125
constant k : signed(31 down to 0) := SIGNED(To_StdLogicVector(11101110011010110010)); --.0009765625
constant l : signed(31 down to 0) := SIGNED(To_StdLogicVector(1110111001101011001)); -- .00048828125
constant m : signed(31 down to 0) := SIGNED(To_StdLogicVector(111011100110101100)); --.000244140625
constant n : signed(31 down to 0) := SIGNED(To_StdLogicVector(11101110011010110)); --.0001220703125
constant o : signed(31 down to 0) := SIGNED(To_StdLogicVector(1110111001101011)); --.00006103515625
PROCESS(clk)
begin
if z_in := 0 then x_out := x_in and y_out := y_in,
end if;
if z_in := a then z1 := a , and x_out := x_in - y_in*1*a, and y_out := y_in + x_in*1*a;
elseif Z_in > a then z1 := a + b, and x1 := x_in - y_in*1*z1, and y1 := y_in + x_in*1*z1,
elseif Z_in < a then z1 := a - b, and x1 := x_in - y_in*1*z1, and y1 := y_in + x_in*1*z1,
end if;
if Z_in := z1 then x_out := x_in - y_in*1*z1, and y_out := y_in + x_in*1*z1,
elseif z_in > z1 then z2 := z1 + c, and x2 := x1 - y1*1*z2, and y2 := y1 + x1*1*z2,
elseif z_in < z1 then z2 := z1 - c, and x2 := x1 - y1*1*z2, and y2 := y1 + x1*1*z2,
endif;
if z_in := z2 then x_out := x1 - y1*1*z2, and y_out := y1 + x1*1*z2,
elseif z_in > z2 then z3 := z2 + d, and x3 := x2 - y2*1*z3, and y3 := y2 + x2*1*z3,
elseif z_in < z2 then z3 := z2 - d, and x3 := x2 - y2*1*z3, and y3 := y2 + x2*1*z3,
endif;
if z_in := z3 then x_out := x2 - y2*1*z3, and y_out := y2 + x2*1*z3,
if z_in > z3 then z4 := z3 + e, and x_out := x3 - y3*1*z4, and y_out := y3 + x3*1*z4,
elseif z_in < z3 then z4 := z3 - e, and x_out := x_in - y_in*1*z4, and y_out := y_in + x_in*1*z4,
endif;
if z_in := z4 then x_out :=
if z_in > z4 then z5 := z4 + f, and x_out := x_in - y_in*1*z5, and y_out := y_in + x_in*1*z5,
elseif z_in < z4 then z5 := z4 - f, and x_out := x_in - y_in*1*z5, and y_out := y_in + x_in*1*z5,
endif;
if z_in > z5 then z6 := z5 + g, and x_out := x_in - y_in*1*z6, and y_out := y_in + x_in*1*z6,
elseif z_in < z5 then z6 := z5 - g, and x_out := x_in - y_in*1*z6, and y_out := y_in + x_in*1*z6,
endif;
if z_in > z6 then z7 := z6 + h, and x_out := x_in - y_in*1*z7, and y_out := y_in + x_in*1*z7,
elseif z_in < z6 then z7 := z6 - h, and x_out := x_in - y_in*1*z7, and y_out := y_in + x_in*1*z7,
endif;
if z_in > z7 then z8 := z7 + i, and x_out := x_in - y_in*1*z8, and y_out := y_in + x_in*1*z8,
elseif z_in < z7 then z8 := z7 - i, and x_out := x_in - y_in*1*z8, and y_out := y_in + x_in*1*z8,
endif;
if z_in > z8 then z9 := z8 + j, and x_out := x_in - y_in*1*z9, and y_out := y_in + x_in*1*z9,
elseif z_in < z8 then z9 := z8 - j, and x_out := x_in - y_in*1*z9, and y_out := y_in + x_in*1*z9,
endif;
if z_in > z9 then z10 := z9 + k, and x_out := x_in - y_in*1*z10, and y_out := y_in + x_in*1*z10,
elseif z_in < z9 then z10 := z9 - k, and x_out := x_in - y_in*1*z10, and y_out := y_in + x_in*1*z10,
endif;
if z_in > z10 then z11 := z10 + l, and x_out := x_in - y_in*1*z11, and y_out := y_in + x_in*1*z11,
elseif z_in < z10 then z11 := z10 - l, and x_out := x_in - y_in*1*z11, and y_out := y_in + x_in*1*z11,
endif;
if z_in > z11 then z12 := z11 + m, and x_out := x_in - y_in*1*z12, and y_out := y_in + x_in*1*z12,
elseif z_in < z11 then z12 := z11 - m, and x_out := x_in - y_in*1*z12, and y_out := y_in + x_in*1*z12,
endif;
if z_in > z12 then z13 := z12 + n, and x_out := x_in - y_in*1*z13, and y_out := y_in + x_in*1*z13,
elseif z_in < z12 then z12 := z12 - n, and x_out := x_in - y_in*1*z13, and y_out := y_in + x_in*1*z13,
endif;
if z_in > z13 then z14 := z13 + o, and x_out := x_in - y_in*1*z14, and y_out := y_in + x_in*1*z14,
elseif z_in < z13 then z14 := z13 - o, and x_out := x_in - y_in*1*z14, and y_out := y_in + x_in*1*z14,
endif;
thanks
LIBRARY IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_misc.all;
use IEEE.std_logic_arith.all;
use IEEE.std_logic_unsigned.all;
ENTITY cordic IS
PORT (
clk : IN STD_LOGIC;
load: IN STD_LOGIC;
res : IN STD_LOGIC;
x_in, IN STD_LOGIC_VECTOR(15 downto 0);
y_in, IN STD_LOGIC_VECTOR(15 downto 0);
z_in: IN STD_LOGIC_VECTOR(15 downto 0);
x_out: OUT STD_LOGIC_VECTOR(15 downto 0);
y_out: OUT STD_LOGIC_VECTOR(15 downto 0);
END cordic;
ARCHITECTURE cordic_arch OF cordic IS
constant K : signed(31 down to 0) := SIGNED(To_StdLogicVector(100100001100100000101001100011)); -- .607252935
constant a : signed(31 down to 0) := SIGNED(To_StdLogicVector(111011100110101100101000000000)); -- 1.0
constant b : signed(31 down to 0) := SIGNED(To_StdLogicVector(11101110011010110010100000000)); -- .5
constant c : signed(31 down to 0) := SIGNED(To_StdLogicVector(1110111001101011001010000000)); -- .25
constant d : signed(31 down to 0) := SIGNED(To_StdLogicVector(111011100110101100101000000)); -- .125
constant e : signed(31 down to 0) := SIGNED(To_StdLogicVector(11101110011010110010100000)); -- .0625
constant f : signed(31 down to 0) := SIGNED(To_StdLogicVector(1110111001101011001010000)); -- .03125
constant g : signed(31 down to 0) := SIGNED(To_StdLogicVector(111011100110101100101000)); -- .015625
constant h : signed(31 down to 0) := SIGNED(To_StdLogicVector(11101110011010110010100)); -- .0078125
constant i : signed(31 down to 0) := SIGNED(To_StdLogicVector(1110111001101011001010)); -- .00390625
constant j : signed(31 down to 0) := SIGNED(To_StdLogicVector(111011100110101100101)); -- .001953125
constant k : signed(31 down to 0) := SIGNED(To_StdLogicVector(11101110011010110010)); --.0009765625
constant l : signed(31 down to 0) := SIGNED(To_StdLogicVector(1110111001101011001)); -- .00048828125
constant m : signed(31 down to 0) := SIGNED(To_StdLogicVector(111011100110101100)); --.000244140625
constant n : signed(31 down to 0) := SIGNED(To_StdLogicVector(11101110011010110)); --.0001220703125
constant o : signed(31 down to 0) := SIGNED(To_StdLogicVector(1110111001101011)); --.00006103515625
PROCESS(clk)
begin
if z_in := 0 then x_out := x_in and y_out := y_in,
end if;
if z_in := a then z1 := a , and x_out := x_in - y_in*1*a, and y_out := y_in + x_in*1*a;
elseif Z_in > a then z1 := a + b, and x1 := x_in - y_in*1*z1, and y1 := y_in + x_in*1*z1,
elseif Z_in < a then z1 := a - b, and x1 := x_in - y_in*1*z1, and y1 := y_in + x_in*1*z1,
end if;
if Z_in := z1 then x_out := x_in - y_in*1*z1, and y_out := y_in + x_in*1*z1,
elseif z_in > z1 then z2 := z1 + c, and x2 := x1 - y1*1*z2, and y2 := y1 + x1*1*z2,
elseif z_in < z1 then z2 := z1 - c, and x2 := x1 - y1*1*z2, and y2 := y1 + x1*1*z2,
endif;
if z_in := z2 then x_out := x1 - y1*1*z2, and y_out := y1 + x1*1*z2,
elseif z_in > z2 then z3 := z2 + d, and x3 := x2 - y2*1*z3, and y3 := y2 + x2*1*z3,
elseif z_in < z2 then z3 := z2 - d, and x3 := x2 - y2*1*z3, and y3 := y2 + x2*1*z3,
endif;
if z_in := z3 then x_out := x2 - y2*1*z3, and y_out := y2 + x2*1*z3,
if z_in > z3 then z4 := z3 + e, and x_out := x3 - y3*1*z4, and y_out := y3 + x3*1*z4,
elseif z_in < z3 then z4 := z3 - e, and x_out := x_in - y_in*1*z4, and y_out := y_in + x_in*1*z4,
endif;
if z_in := z4 then x_out :=
if z_in > z4 then z5 := z4 + f, and x_out := x_in - y_in*1*z5, and y_out := y_in + x_in*1*z5,
elseif z_in < z4 then z5 := z4 - f, and x_out := x_in - y_in*1*z5, and y_out := y_in + x_in*1*z5,
endif;
if z_in > z5 then z6 := z5 + g, and x_out := x_in - y_in*1*z6, and y_out := y_in + x_in*1*z6,
elseif z_in < z5 then z6 := z5 - g, and x_out := x_in - y_in*1*z6, and y_out := y_in + x_in*1*z6,
endif;
if z_in > z6 then z7 := z6 + h, and x_out := x_in - y_in*1*z7, and y_out := y_in + x_in*1*z7,
elseif z_in < z6 then z7 := z6 - h, and x_out := x_in - y_in*1*z7, and y_out := y_in + x_in*1*z7,
endif;
if z_in > z7 then z8 := z7 + i, and x_out := x_in - y_in*1*z8, and y_out := y_in + x_in*1*z8,
elseif z_in < z7 then z8 := z7 - i, and x_out := x_in - y_in*1*z8, and y_out := y_in + x_in*1*z8,
endif;
if z_in > z8 then z9 := z8 + j, and x_out := x_in - y_in*1*z9, and y_out := y_in + x_in*1*z9,
elseif z_in < z8 then z9 := z8 - j, and x_out := x_in - y_in*1*z9, and y_out := y_in + x_in*1*z9,
endif;
if z_in > z9 then z10 := z9 + k, and x_out := x_in - y_in*1*z10, and y_out := y_in + x_in*1*z10,
elseif z_in < z9 then z10 := z9 - k, and x_out := x_in - y_in*1*z10, and y_out := y_in + x_in*1*z10,
endif;
if z_in > z10 then z11 := z10 + l, and x_out := x_in - y_in*1*z11, and y_out := y_in + x_in*1*z11,
elseif z_in < z10 then z11 := z10 - l, and x_out := x_in - y_in*1*z11, and y_out := y_in + x_in*1*z11,
endif;
if z_in > z11 then z12 := z11 + m, and x_out := x_in - y_in*1*z12, and y_out := y_in + x_in*1*z12,
elseif z_in < z11 then z12 := z11 - m, and x_out := x_in - y_in*1*z12, and y_out := y_in + x_in*1*z12,
endif;
if z_in > z12 then z13 := z12 + n, and x_out := x_in - y_in*1*z13, and y_out := y_in + x_in*1*z13,
elseif z_in < z12 then z12 := z12 - n, and x_out := x_in - y_in*1*z13, and y_out := y_in + x_in*1*z13,
endif;
if z_in > z13 then z14 := z13 + o, and x_out := x_in - y_in*1*z14, and y_out := y_in + x_in*1*z14,
elseif z_in < z13 then z14 := z13 - o, and x_out := x_in - y_in*1*z14, and y_out := y_in + x_in*1*z14,
endif;