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

Subversion Repositories raytrac

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

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
--use work.arithpack.all;
33 68 jguarin200
 
34
 
35
 
36
entity RLshifter is
37
        generic (
38 70 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
        leftShift:
55
        if shiftFunction="SQUARE_ROOT" generate
56
                sqroot:
57
                process (mantis, exp)
58 70 jguarin200
                        variable expi : integer;
59 68 jguarin200
                begin
60 70 jguarin200
                        expi := conv_integer(exp);
61
                        lupe:
62
                        for i in width-1 downto 0 loop
63
                                if i>expi then
64
                                        result(i)<='0';
65
                                else
66
                                        result(i)<=mantis(mantissa_width-1-expi+i);
67
                                end if;
68
                        end loop lupe;
69
                end process sqroot;
70 68 jguarin200
        end generate leftShift;
71
        rightShift:
72
        if shiftFunction="INVERSION" generate
73
                inverse:
74
                process (mantis,exp)
75 70 jguarin200
                        variable expi : integer ;
76 68 jguarin200
                begin
77 70 jguarin200
                        expi:= conv_integer(exp);
78
 
79
                        for i in width-1 downto 0 loop
80
                                if i<=width-1-expi and i>=width-expi-mantissa_width then
81
                                        result(i)
82
                                        <=mantis(mantissa_width-width+expi+i);
83
                                else
84
                                        result(i)<='0';
85
                                end if;
86
                        end loop;
87
                end process inverse;
88
        end generate rightShift;
89 68 jguarin200
end RLshifter_arch;

powered by: WebSVN 2.1.0

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