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

Subversion Repositories raytrac

[/] [raytrac/] [trunk/] [sqrtdiv/] [RLshifter.vhd] - Diff between revs 74 and 78

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 74 Rev 78
------------------------------------------------
------------------------------------------------
--! @file RLshifter.vhd
--! @file RLshifter.vhd
--! @brief RayTrac Arithmetic Shifter 
--! @brief RayTrac Arithmetic Shifter 
--! @author Julián Andrés Guarín Reyes
--! @author Julián Andrés Guarín Reyes
--------------------------------------------------
--------------------------------------------------
 
 
 
 
-- RAYTRAC
-- RAYTRAC
-- Author Julian Andres Guarin
-- Author Julian Andres Guarin
-- RLshifter.vhd
-- RLshifter.vhd
-- This file is part of raytrac.
-- This file is part of raytrac.
-- 
-- 
--     raytrac is free software: you can redistribute it and/or modify
--     raytrac is free software: you can redistribute it and/or modify
--     it under the terms of the GNU General Public License as published by
--     it under the terms of the GNU General Public License as published by
--     the Free Software Foundation, either version 3 of the License, or
--     the Free Software Foundation, either version 3 of the License, or
--     (at your option) any later version.
--     (at your option) any later version.
-- 
-- 
--     raytrac is distributed in the hope that it will be useful,
--     raytrac is distributed in the hope that it will be useful,
--     but WITHOUT ANY WARRANTY; without even the implied warranty of
--     but WITHOUT ANY WARRANTY; without even the implied warranty of
--     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
--     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
--     GNU General Public License for more details.
--     GNU General Public License for more details.
-- 
-- 
--     You should have received a copy of the GNU General Public License
--     You should have received a copy of the GNU General Public License
--     along with raytrac.  If not, see <http://www.gnu.org/licenses/>
--     along with raytrac.  If not, see <http://www.gnu.org/licenses/>
 
 
 
 
library ieee;
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_unsigned.all;
use ieee.math_real.all;
use ieee.math_real.all;
 
 
 
 
 
 
 
 
entity RLshifter is
entity RLshifter is
        generic (
        generic (
                shiftFunction   : string  := "SQUARE_ROOT";
                shiftFunction   : string  := "SQUARE_ROOT";
                mantissa_width  : integer := 18;
                mantissa_width  : integer := 18;
                iwidth                  : integer := 32;
                iwidth                  : integer := 32;
                owidth                  : integer := 16
                owidth                  : integer := 16
 
 
        );
        );
        port (
        port (
                exp             : in std_logic_vector (integer(ceil(log(real(iwidth),2.0)))-1 downto 0);
                exp             : in std_logic_vector (integer(ceil(log(real(iwidth),2.0)))-1 downto 0);
                mantis  : in std_logic_vector (mantissa_width-1 downto 0);
                mantis  : in std_logic_vector (mantissa_width-1 downto 0);
                result  : out std_logic_vector (owidth-1 downto 0)
                result  : out std_logic_vector (owidth-1 downto 0)
        );
        );
end RLshifter;
end RLshifter;
 
 
 
 
architecture RLshifter_arch of RLshifter is
architecture RLshifter_arch of RLshifter is
begin
begin
 
 
        inverse:
        inverse:
        process (mantis,exp)
        process (mantis,exp)
                variable expi : integer ;
                variable expi : integer ;
        begin
        begin
                if shiftFunction="INVERSION" then
                if shiftFunction="INVERSION" then
                        expi:= conv_integer(exp);
                        expi:= conv_integer(exp);
                else
                else
                        expi:= conv_integer(exp(exp'high downto 1));
                        expi:= conv_integer(exp(exp'high downto 1)); --! Por qu'e hasta 1 y no hasta 0!? Porque el corrimiento de la raiz cuadrada es 2^(N/2)  
                end if;
                end if;
 
 
                for i in owidth-1 downto 0 loop
                for i in owidth-1 downto 0 loop
 
 
                        result(i)<='0';
                        result(i)<='0';
 
 
                        if shiftFunction="INVERSION" then
                        if shiftFunction="INVERSION" then
                                if i<=owidth-1-expi and i>=owidth-expi-mantissa_width then
                                if i<=owidth-1-expi and i>=owidth-expi-mantissa_width then
                                        result(i)<=mantis(mantissa_width-owidth+expi+i);
                                        result(i)<=mantis(mantissa_width-owidth+expi+i);
                                end if;
                                end if;
                        end if;
                        end if;
 
 
                        if shiftFunction="SQUARE_ROOT" then
                        if shiftFunction="SQUARE_ROOT" then
                                if i<=expi then
                                if i<=expi then
                                        result(i)<=mantis(mantissa_width-1-expi+i);
                                        result(i)<=mantis(mantissa_width-1-expi+i);
                                end if;
                                end if;
                        end if;
                        end if;
 
 
                end loop;
                end loop;
 
 
        end process inverse;
        end process inverse;
 
 
end RLshifter_arch;
end RLshifter_arch;
 
 
 
 

powered by: WebSVN 2.1.0

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