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

Subversion Repositories raytrac

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

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
                width                   : integer := 32
41
 
42
        );
43
        port (
44
                exp             : in std_logic_vector (integer(ceil(log(real(width),2.0)))-1 downto 0);
45
                mantis  : in std_logic_vector (mantissa_width-1 downto 0);
46
                result  : out std_logic_vector (width-1 downto 0)
47
        );
48
end RLshifter;
49
 
50
 
51
architecture RLshifter_arch of RLshifter is
52
begin
53
 
54 71 jguarin200
        inverse:
55
        process (mantis,exp)
56
                variable expi : integer ;
57
        begin
58
                expi:= conv_integer(exp);
59
 
60
                for i in width-1 downto 0 loop
61 72 jguarin200
 
62
                        result(i)<='0';
63
 
64 71 jguarin200
                        if shiftFunction="INVERSION" then
65 70 jguarin200
                                if i<=width-1-expi and i>=width-expi-mantissa_width then
66 71 jguarin200
                                        result(i)<=mantis(mantissa_width-width+expi+i);
67 70 jguarin200
                                end if;
68 71 jguarin200
                        end if;
69 72 jguarin200
 
70 71 jguarin200
                        if shiftFunction="SQUARE_ROOT" then
71 72 jguarin200
                                if i<=expi then
72 71 jguarin200
                                        result(i)<=mantis(mantissa_width-1-expi+i);
73
                                end if;
74
                        end if;
75 72 jguarin200
 
76 71 jguarin200
                end loop;
77 72 jguarin200
 
78 71 jguarin200
        end process inverse;
79 72 jguarin200
 
80
end RLshifter_arch;
81
 

powered by: WebSVN 2.1.0

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