| 1 |
60 |
jguarin200 |
------------------------------------------------
|
| 2 |
|
|
--! @file shifter2xstage.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 |
|
|
-- shifter2xstage.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 |
|
|
library ieee;
|
| 27 |
|
|
use ieee.std_logic_1164.all;
|
| 28 |
|
|
use ieee.math_real.all;
|
| 29 |
|
|
use work.arithpack.all;
|
| 30 |
|
|
|
| 31 |
|
|
entity shifter2xstage is
|
| 32 |
|
|
generic (
|
| 33 |
|
|
address_width : integer := 9;
|
| 34 |
|
|
width : integer := 16
|
| 35 |
|
|
);
|
| 36 |
|
|
port (
|
| 37 |
|
|
data : in std_logic_vector (width-1 downto 0);
|
| 38 |
|
|
exp : out std_logic_vector (2*integer(ceil(log(real(width),2.0)))-1 downto 0);
|
| 39 |
|
|
add : out std_logic_vector (2*address_width-1 downto 0);
|
| 40 |
|
|
zero : out std_logic_vector (1 downto 0)
|
| 41 |
|
|
);
|
| 42 |
|
|
end shifter2xstage;
|
| 43 |
|
|
|
| 44 |
|
|
architecture shifter2xstage_arch of shifter2xstage is
|
| 45 |
|
|
|
| 46 |
|
|
signal exp0 : std_logic_vector (integer(ceil(log(real(width),2.0)))-1 downto 0);
|
| 47 |
|
|
signal exp1 : std_logic_vector (integer(ceil(log(real(width),2.0)))-1 downto 0);
|
| 48 |
|
|
signal add0 : std_logic_vector (address_width-1 downto 0);
|
| 49 |
|
|
signal add1 : std_logic_vector (address_width-1 downto 0);
|
| 50 |
|
|
|
| 51 |
|
|
begin
|
| 52 |
|
|
|
| 53 |
|
|
evenS:shifter
|
| 54 |
|
|
generic map (address_width,width,"YES")
|
| 55 |
|
|
port map (data,exp0,add0,zero(0));
|
| 56 |
|
|
oddS:shifter
|
| 57 |
|
|
generic map (address_width,width,"NO")
|
| 58 |
|
|
port map (data,exp1,add1,zero(1));
|
| 59 |
|
|
exp(integer(ceil(log(real(width),2.0)))-1 downto 0)<=exp0;
|
| 60 |
|
|
exp(2*integer(ceil(log(real(width),2.0)))-1 downto integer(ceil(log(real(width),2.0))))<=exp1;
|
| 61 |
|
|
add(address_width-1 downto 0)<=add0;
|
| 62 |
|
|
add(2*address_width-1 downto address_width)<=add1;
|
| 63 |
|
|
end shifter2xstage_arch;
|
| 64 |
|
|
|