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

Subversion Repositories raytrac

[/] [raytrac/] [trunk/] [sqrtdiv/] [shift.vhd] - Diff between revs 60 and 67

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

Rev 60 Rev 67
------------------------------------------------
------------------------------------------------
--! @file shift.vhd
--! @file shift.vhd
--! @brief RayTrac TestBench
--! @brief RayTrac TestBench
--! @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
-- shift.vhd
-- shift.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_signed.all;
use ieee.std_logic_signed.all;
use ieee.math_real.all;
use ieee.math_real.all;
 
 
 
 
 
--! \brief Dado que cualquier n&uacute;mero entero A, se puede escribir 2^n * f, es importante obtener una representaci&oacute;n del valor de f en base 2. Una vez hallado este valor y evaluado en una funci&oacute;n bastara con realizar un corrimiento a la izquierda n bits del resultado, para calcular funciones como A^-1 o A^0.5.
entity shifter is
entity shifter is
        generic (
        generic (
                address_width   : integer       := 9;
                address_width   : integer       := 9;
                width                   : integer       := 32;
                width                   : integer       := 32;
                even_shifter    : string        := "YES"
                even_shifter    : string        := "YES"
 
 
        );
        );
        port (
        port (
                data                    : in std_logic_vector(width - 1 downto 0);
                data                    : in std_logic_vector(width - 1 downto 0);
                exp                             : out std_logic_vector(integer(ceil(log(real(width),2.0)))-1 downto 0);
                exp                             : out std_logic_vector(integer(ceil(log(real(width),2.0)))-1 downto 0);
                address                 : out std_logic_vector (address_width-1 downto 0);
                address                 : out std_logic_vector (address_width-1 downto 0);
                zero                    : out std_logic
                zero                    : out std_logic
        );
        );
end shifter;
end shifter;
 
 
architecture shifter_arch of shifter is
architecture shifter_arch of shifter is
 
 
        -- signal datamask : std_logic_vector(width+address_width-1 downto 0);
 
begin
begin
        -- datamask (width+address_width-1 downto address_width) <= data(width-1 downto 0);
 
        -- datamask (address_width-1 downto 0) <= (others=>'0');
 
 
 
        sanityLost:
        sanityLost:
        process (data)
        process (data)
                variable index: integer range-1 to width+address_width-1:=width+address_width-1;
                variable index: integer range-1 to width+address_width-1:=width+address_width-1;
 
 
        begin
        begin
                address<=(others=>'0');
                address<=(others=>'0');
                exp<=(others=>'0');
                exp<=(others=>'0');
 
 
                zero<=data(0);
                zero<=data(0);
 
 
                if even_shifter="YES" then
                if even_shifter="YES" then
                        index:=width-1;
                        index:=width-1;
                else
                else
                        index:=width-2;
                        index:=width-2;
                end if;
                end if;
 
 
                while index>=1 loop
                while index>=1 loop
                        if data(index)='1' then
                        if data(index)='1' then
                                zero<='0';
                                zero<='0';
                                exp<=CONV_STD_LOGIC_VECTOR(index, exp'high+1);
                                exp<=CONV_STD_LOGIC_VECTOR(index, exp'high+1);
                                if index>=address_width then
                                if index>=address_width then
                                        address <= data (index-1 downto index-address_width);
                                        address <= data (index-1 downto index-address_width);
                                else
                                else
                                        address(address_width-1 downto address_width-index) <= data (index-1 downto 0);
                                        address(address_width-1 downto address_width-index) <= data (index-1 downto 0);
                                        address(address_width-index-1 downto 0) <= (others =>'0');
                                        address(address_width-index-1 downto 0) <= (others =>'0');
                                end if;
                                end if;
                                exit;
                                exit;
                        end if;
                        end if;
                        index:=index-2; --Boost
                        index:=index-2; --Boost
                end loop;
                end loop;
 
 
 
 
 
 
 
 
        end process sanityLost;
        end process sanityLost;
        -- process (data)
 
        -- begin
 
                -- if data=0 then
 
                        -- zero<='1';
 
                -- else
 
                        -- zero<='0';
 
                -- end if;
 
        -- end process;
 
 
 
end shifter_arch;
end shifter_arch;
 
 
 
 
 
 
 
 
 
 
 
 

powered by: WebSVN 2.1.0

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