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

Subversion Repositories raytrac

[/] [raytrac/] [trunk/] [sqrtdiv/] [shift.vhd] - Blame information for rev 60

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

Line No. Rev Author Line
1 59 jguarin200
------------------------------------------------
2
--! @file shift.vhd
3
--! @brief RayTrac TestBench
4
--! @author Julián Andrés Guarín Reyes
5
--------------------------------------------------
6
 
7
 
8
-- RAYTRAC
9
-- Author Julian Andres Guarin
10
-- shift.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
library ieee;
26
use ieee.std_logic_1164.all;
27
use ieee.std_logic_arith.all;
28
use ieee.std_logic_signed.all;
29 60 jguarin200
use ieee.math_real.all;
30 59 jguarin200
 
31
 
32
entity shifter is
33
        generic (
34 60 jguarin200
                address_width   : integer       := 9;
35
                width                   : integer       := 32;
36
                even_shifter    : string        := "YES"
37
 
38 59 jguarin200
        );
39
        port (
40
                data                    : in std_logic_vector(width - 1 downto 0);
41 60 jguarin200
                exp                             : out std_logic_vector(integer(ceil(log(real(width),2.0)))-1 downto 0);
42 59 jguarin200
                address                 : out std_logic_vector (address_width-1 downto 0);
43 60 jguarin200
                zero                    : out std_logic
44 59 jguarin200
        );
45
end shifter;
46
 
47
architecture shifter_arch of shifter is
48 60 jguarin200
 
49
        -- signal datamask : std_logic_vector(width+address_width-1 downto 0);
50 59 jguarin200
begin
51 60 jguarin200
        -- datamask (width+address_width-1 downto address_width) <= data(width-1 downto 0);
52
        -- datamask (address_width-1 downto 0) <= (others=>'0');
53 59 jguarin200
 
54
        sanityLost:
55 60 jguarin200
        process (data)
56
                variable index: integer range-1 to width+address_width-1:=width+address_width-1;
57 59 jguarin200
 
58
        begin
59
                address<=(others=>'0');
60 60 jguarin200
                exp<=(others=>'0');
61
 
62
                zero<=data(0);
63
 
64
                if even_shifter="YES" then
65
                        index:=width-1;
66
                else
67
                        index:=width-2;
68
                end if;
69
 
70
                while index>=1 loop
71
                        if data(index)='1' then
72
                                zero<='0';
73
                                exp<=CONV_STD_LOGIC_VECTOR(index, exp'high+1);
74
                                if index>=address_width then
75
                                        address <= data (index-1 downto index-address_width);
76
                                else
77
                                        address(address_width-1 downto address_width-index) <= data (index-1 downto 0);
78
                                        address(address_width-index-1 downto 0) <= (others =>'0');
79 59 jguarin200
                                end if;
80
                                exit;
81
                        end if;
82 60 jguarin200
                        index:=index-2; --Boost
83
                end loop;
84 59 jguarin200
 
85 60 jguarin200
 
86
 
87
 
88 59 jguarin200
        end process sanityLost;
89 60 jguarin200
        -- process (data)
90
        -- begin
91
                -- if data=0 then
92
                        -- zero<='1';
93
                -- else
94
                        -- zero<='0';
95
                -- end if;
96
        -- end process;
97 59 jguarin200
 
98
end shifter_arch;
99
 
100
 
101
 
102
 
103
 
104
 

powered by: WebSVN 2.1.0

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