Line 58... |
Line 58... |
--! funky::Segunda etapa: Calculo del valor de la funcion evaluada en f.
|
--! funky::Segunda etapa: Calculo del valor de la funcion evaluada en f.
|
signal funkyadd : std_logic_vector (2*awidth-1 downto 0);
|
signal funkyadd : std_logic_vector (2*awidth-1 downto 0);
|
signal funkyexp : std_logic_vector (2*integer(ceil(log(real(iwidth),2.0)))-1 downto 0);
|
signal funkyexp : std_logic_vector (2*integer(ceil(log(real(iwidth),2.0)))-1 downto 0);
|
signal funkyzero : std_logic;
|
signal funkyzero : std_logic;
|
|
|
signal funkyq : std_logic_vector (2*c3width-1 downto 0);
|
signal funkyq : std_logic_vector (2*c3width+3 downto 0);
|
signal funkyselector : std_logic;
|
signal funkyselector : std_logic;
|
|
|
--! cumpa::Tercera etapa: Selecci'on de valores de acuerdo al exp escogido.
|
--! cumpa::Tercera etapa: Selecci'on de valores de acuerdo al exp escogido.
|
signal cumpaexp : std_logic_vector (2*integer(ceil(log(real(iwidth),2.0)))-1 downto 0);
|
signal cumpaexp : std_logic_vector (2*integer(ceil(log(real(iwidth),2.0)))-1 downto 0);
|
signal cumpaq : std_logic_vector (2*c3width-1 downto 0);
|
signal cumpaq : std_logic_vector (2*c3width+3 downto 0);
|
signal cumpaselector : std_logic;
|
signal cumpaselector : std_logic;
|
signal cumpazero : std_logic;
|
signal cumpazero : std_logic;
|
|
|
signal cumpaN : std_logic_vector (integer(ceil(log(real(iwidth),2.0)))-1 downto 0);
|
signal cumpaN : std_logic_vector (integer(ceil(log(real(iwidth),2.0)))-1 downto 0);
|
signal cumpaF : std_logic_vector (c3width-1 downto 0);
|
signal cumpaF : std_logic_vector (c3width+1 downto 0);
|
|
|
--! chief::Cuarta etapa: Corrimiento a la izquierda o derecha, para el caso de la ra'iz cuadrada o la inversi'on respectivamente.
|
--! chief::Cuarta etapa: Corrimiento a la izquierda o derecha, para el caso de la ra'iz cuadrada o la inversi'on respectivamente.
|
|
|
signal chiefN : std_logic_vector (integer(ceil(log(real(iwidth),2.0)))-1 downto 0);
|
signal chiefN : std_logic_vector (integer(ceil(log(real(iwidth),2.0)))-1 downto 0);
|
signal chiefF : std_logic_vector (c3width-1 downto 0);
|
signal chiefF : std_logic_vector (c3width+1 downto 0);
|
|
|
|
|
--! Constantes para manejar el tamaño de los vectores
|
--! Constantes para manejar el tamaño de los vectores
|
constant exp1H : integer := 2*integer(ceil(log(real(iwidth),2.0)))-1;
|
constant exp1H : integer := 2*integer(ceil(log(real(iwidth),2.0)))-1;
|
constant exp1L : integer := integer(ceil(log(real(iwidth),2.0)));
|
constant exp1L : integer := integer(ceil(log(real(iwidth),2.0)));
|
constant exp0H : integer := exp1L-1;
|
constant exp0H : integer := exp1L-1;
|
constant exp0L : integer := 0;
|
constant exp0L : integer := 0;
|
constant add1H : integer := 2*awidth-1;
|
constant add1H : integer := 2*awidth-1;
|
constant add1L : integer := awidth;
|
constant add1L : integer := awidth;
|
constant add0H : integer := add1L-1;
|
constant add0H : integer := awidth-1;
|
constant add0L : integer := 0;
|
constant add0L : integer := 0;
|
|
|
|
|
constant c3qHH : integer := 2*c3width-1;
|
constant c3qHH : integer := 2*c3width+3;
|
constant c3qHL : integer := c3width;
|
constant c3qHL : integer := c3width+2;
|
constant c3qLH : integer := c3width-1;
|
constant c3qLH : integer := c3width+1;
|
constant c3qLL : integer := 0;
|
constant c3qLL : integer := 0;
|
|
|
begin
|
begin
|
|
|
--! expomantis.
|
--! expomantis.
|
Line 124... |
Line 124... |
process (clk,rst,expomantisexp, expomantiszero)
|
process (clk,rst,expomantisexp, expomantiszero)
|
begin
|
begin
|
if rst=rstMasterValue then
|
if rst=rstMasterValue then
|
funkyexp <= (others => '0');
|
funkyexp <= (others => '0');
|
funkyzero <= '0';
|
funkyzero <= '0';
|
|
funkyadd <= (others => '0');
|
|
|
elsif clk'event and clk='1' then
|
elsif clk'event and clk='1' then
|
|
|
funkyexp(exp1H downto 0) <= expomantisexp(exp1H downto 0);
|
funkyexp(exp1H downto 0) <= expomantisexp(exp1H downto 0);
|
funkyzero <= expomantiszero;
|
funkyzero <= expomantiszero;
|
|
funkyadd <= expomantisadd;
|
|
|
end if;
|
end if;
|
end process funkyProc;
|
end process funkyProc;
|
funkyadd <= expomantisadd;
|
|
funkyget:
|
funkyget:
|
process (funkyexp)
|
process (funkyexp)
|
begin
|
begin
|
if (funkyexp(exp0H downto 0)>funkyexp(exp1H downto exp1L)) then
|
if (funkyexp(exp0H downto 0)>funkyexp(exp1H downto exp1L)) then
|
funkyselector<='0';
|
funkyselector<='0';
|
Line 143... |
Line 148... |
end process funkyget;
|
end process funkyget;
|
|
|
funkyinversion:
|
funkyinversion:
|
if functype="INVERSION" generate
|
if functype="INVERSION" generate
|
meminvr:func
|
meminvr:func
|
generic map ("X:/Tesis/Workspace/hw/rt_lib/arith/src/trunk/sqrtdiv/meminvr.mif")
|
generic map ("../../../MinGW/MSys/1.0/home/julian/code/testbench/trunk/utils/arachnophobia.mif")
|
|
--generic map ("X:/Tesis/Workspace/hw/rt_lib/arith/src/trunk/sqrtdiv/meminvr.mif")
|
port map(
|
port map(
|
funkyadd(add0H downto add0L),
|
expomantisadd(awidth-1 downto 0),
|
funkyadd(add1H downto add1L),
|
expomantisadd(2*awidth-1 downto awidth),
|
clk,
|
clk,
|
funkyq(c3qLH downto c3qLL),
|
funkyq(c3qLH-2 downto c3qLL),
|
funkyq(c3qHH downto c3qHL));
|
funkyq(c3qHH-2 downto c3qHL));
|
|
funkynibbles:
|
|
process(funkyadd)
|
|
begin
|
|
|
|
if funkyadd(awidth-1 downto 0) = conv_std_logic_vector(0,awidth) then
|
|
funkyq(c3qLH downto c3qLH-1) <= "10";
|
|
else
|
|
funkyq(c3qLH downto c3qLH-1) <= "01";
|
|
end if;
|
|
if funkyadd(2*awidth-1 downto awidth) = conv_std_logic_vector(0,awidth) then
|
|
funkyq(c3qHH downto c3qHH-1) <= "10";
|
|
else
|
|
funkyq(c3qHH downto c3qHH-1) <= "01";
|
|
end if;
|
|
end process funkynibbles;
|
|
|
end generate funkyinversion;
|
end generate funkyinversion;
|
funkysquare_root:
|
funkysquare_root:
|
if functype="SQUARE_ROOT" generate
|
if functype="SQUARE_ROOT" generate
|
sqrt: func
|
sqrt: func
|
generic map ("X:/Tesis/Workspace/hw/rt_lib/arith/src/trunk/sqrtdiv/memsqrt.mif")
|
generic map ("../../../MinGW/MSys/1.0/home/julian/code/testbench/trunk/utils/phobia.mif")
|
|
--generic map ("X:/Tesis/Workspace/hw/rt_lib/arith/src/trunk/sqrtdiv/memsqrt.mif")
|
port map(
|
port map(
|
funkyadd(add0H downto add0L),
|
expomantisadd(awidth-1 downto 0),
|
(others => '0'),
|
(others => '0'),
|
clk,
|
clk,
|
funkyq(c3qLH downto c3qLL),
|
funkyq(c3qLH-2 downto c3qLL),
|
open);
|
open);
|
|
|
sqrt2x: func
|
sqrt2x: func
|
generic map ("X:/Tesis/Workspace/hw/rt_lib/arith/src/trunk/sqrtdiv/memsqrt2f.mif")
|
generic map ("../../../MinGW/MSys/1.0/home/julian/code/testbench/trunk/utils/phobia2.mif")
|
|
--generic map ("X:/Tesis/Workspace/hw/rt_lib/arith/src/trunk/sqrtdiv/memsqrt2f.mif")
|
port map(
|
port map(
|
(others => '0'),
|
(others => '0'),
|
funkyadd(add1H downto add1L),
|
expomantisadd(2*awidth-1 downto awidth),
|
clk,
|
clk,
|
open,
|
open,
|
funkyq(c3qHH downto c3qHL));
|
funkyq(c3qHH-2 downto c3qHL));
|
|
funkynibbles:
|
|
process(funkyadd)
|
|
begin
|
|
--! Siempre ser'a 2 el nibble mas significativo cuando estemos calculando f**0.5.
|
|
funkyq(c3qLH downto c3qLH-1) <= "10";
|
|
--! Siempre ser'a 1 el bit mas significativo cuando estemos calculando 2f**0.5.
|
|
funkyq(c3qHH) <= '1';
|
|
if funkyadd(2*awidth-1 downto awidth) >= conv_std_logic_vector(64,awidth) then
|
|
funkyq(c3qHH-1) <= '1';
|
|
else
|
|
funkyq(c3qHH-1) <= '0';
|
|
end if;
|
|
end process funkynibbles;
|
|
|
end generate funkysquare_root;
|
end generate funkysquare_root;
|
|
|
--! cumpa.
|
--! cumpa.
|
cumpaProc:
|
cumpaProc:
|
process (clk,rst)
|
process (clk,rst)
|
Line 214... |
Line 252... |
chiefN <= cumpaN;
|
chiefN <= cumpaN;
|
zero <= cumpazero;
|
zero <= cumpazero;
|
end if;
|
end if;
|
end process chiefProc;
|
end process chiefProc;
|
chiefShifter: RLshifter
|
chiefShifter: RLshifter
|
generic map(functype,c3width,iwidth,owidth)
|
generic map(functype,c3width+2,iwidth,owidth)
|
port map(
|
port map(
|
chiefN,
|
chiefN,
|
chiefF,
|
chiefF,
|
result);
|
result);
|
|
|