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

Subversion Repositories raytrac

[/] [raytrac/] [trunk/] [sqrtdiv/] [RLshifter.vhd] - Blame information for rev 136

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 68 jguarin200
------------------------------------------------
2
--! @file RLshifter.vhd
3
--! @brief RayTrac Arithmetic Shifter 
4
--! @author Julián Andrés Guarín Reyes
5
--------------------------------------------------
6
 
7
 
8
-- RAYTRAC
9
-- Author Julian Andres Guarin
10
-- RLshifter.vhd
11
-- This file is part of raytrac.
12
-- 
13
--     raytrac is free software: you can redistribute it and/or modify
14
--     it under the terms of the GNU General Public License as published by
15
--     the Free Software Foundation, either version 3 of the License, or
16
--     (at your option) any later version.
17
-- 
18
--     raytrac is distributed in the hope that it will be useful,
19
--     but WITHOUT ANY WARRANTY; without even the implied warranty of
20
--     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21
--     GNU General Public License for more details.
22
-- 
23
--     You should have received a copy of the GNU General Public License
24
--     along with raytrac.  If not, see <http://www.gnu.org/licenses/>
25
 
26
 
27
library ieee;
28
use ieee.std_logic_1164.all;
29 70 jguarin200
use ieee.std_logic_arith.all;
30 68 jguarin200
use ieee.std_logic_unsigned.all;
31 70 jguarin200
use ieee.math_real.all;
32 68 jguarin200
 
33
 
34
 
35 73 jguarin200
 
36 68 jguarin200
entity RLshifter is
37
        generic (
38 72 jguarin200
                shiftFunction   : string  := "SQUARE_ROOT";
39 68 jguarin200
                mantissa_width  : integer := 18;
40 74 jguarin200
                iwidth                  : integer := 32;
41
                owidth                  : integer := 16
42 68 jguarin200
 
43
        );
44
        port (
45 74 jguarin200
                exp             : in std_logic_vector (integer(ceil(log(real(iwidth),2.0)))-1 downto 0);
46 68 jguarin200
                mantis  : in std_logic_vector (mantissa_width-1 downto 0);
47 74 jguarin200
                result  : out std_logic_vector (owidth-1 downto 0)
48 68 jguarin200
        );
49
end RLshifter;
50
 
51
 
52
architecture RLshifter_arch of RLshifter is
53
begin
54
 
55 71 jguarin200
        inverse:
56
        process (mantis,exp)
57
                variable expi : integer ;
58
        begin
59 81 jguarin200
                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)  
60 71 jguarin200
 
61 74 jguarin200
                for i in owidth-1 downto 0 loop
62 72 jguarin200
 
63
                        result(i)<='0';
64
 
65 71 jguarin200
                        if shiftFunction="INVERSION" then
66 74 jguarin200
                                if i<=owidth-1-expi and i>=owidth-expi-mantissa_width then
67
                                        result(i)<=mantis(mantissa_width-owidth+expi+i);
68 70 jguarin200
                                end if;
69 71 jguarin200
                        end if;
70 72 jguarin200
 
71 71 jguarin200
                        if shiftFunction="SQUARE_ROOT" then
72 72 jguarin200
                                if i<=expi then
73 71 jguarin200
                                        result(i)<=mantis(mantissa_width-1-expi+i);
74
                                end if;
75
                        end if;
76 72 jguarin200
 
77 71 jguarin200
                end loop;
78 72 jguarin200
 
79 71 jguarin200
        end process inverse;
80 72 jguarin200
 
81
end RLshifter_arch;
82
 

powered by: WebSVN 2.1.0

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