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

Subversion Repositories raytrac

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

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
use ieee.std_logic_unsigned.all;
30
use work.arithpack.all;
31
 
32
 
33
 
34
entity RLshifter is
35
        generic (
36
                shiftFunction   : string  := "SQUARE_ROOT"
37
                mantissa_width  : integer := 18;
38
                width                   : integer := 32
39
 
40
        );
41
        port (
42
                exp             : in std_logic_vector (integer(ceil(log(real(width),2.0)))-1 downto 0);
43
                mantis  : in std_logic_vector (mantissa_width-1 downto 0);
44
                result  : out std_logic_vector (width-1 downto 0)
45
        );
46
end RLshifter;
47
 
48
 
49
architecture RLshifter_arch of RLshifter is
50
begin
51
 
52
        leftShift:
53
        if shiftFunction="SQUARE_ROOT" generate
54
 
55
                sqroot:
56
                process (mantis, exp)
57
                        variable expi : integer := conv_integer(exp);
58
                begin
59
                        result(width-1 downto expi+1)   <= (others=>'0');
60
                        result(expi     downto 0)                        <= mantissa(mantissa_width-1 downto mantissa_width-1-exp);
61
                end sqroot;
62
 
63
        end generate leftShift;
64
 
65
        rightShift:
66
        if shiftFunction="INVERSION" generate
67
 
68
                inverse:
69
                process (mantis,exp)
70
                        variable expi : integer := conv_integer(exp);
71
                begin
72
                        if expi>0 then
73
                                result (width-1 downto width-expi) <= (others =>'0');
74
                                if expi+mantissa_width<width then
75
                                        result (width-expi-1 downto width-expi-mantissa_width) <= mantis(mantissa_width-1 downto 0);
76
                                        result (width-expi-mantissa_width-1 downto 0) <= (others=>'0');
77
                                else
78
                                        result (width-expi-1 downto 0) <= mantis(mantissa_width-1 downto mantissa_width+expi-width);
79
                                end if;
80
                        else
81
                                result (width-1 downto width-mantissa_width) <= mantis(mantissa_width-1 downto 0);
82
 
83
                end inverse;
84
 
85
end RLshifter_arch;

powered by: WebSVN 2.1.0

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