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

Subversion Repositories special_functions_unit

[/] [special_functions_unit/] [Open_source_SFU/] [cordic_vhdl/] [parts/] [right_shifter.vhd] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 divadnauj
----------------------------------------------------------------------------------
2
-- Right Shifter for FP addition-subtraction (right_shifter.vhd)
3
-- P: number of fractional (significant) bits
4
-- right shift up to E positions. Generates in the last bit the sticky bit.
5
-- PLOG is log (P); numbers of bits to represent P
6
-- Used in FP add of section 12.5.1
7
----------------------------------------------------------------------------------
8
 
9
library ieee;
10
use ieee.std_logic_1164.all;
11
use ieee.std_logic_arith.all;
12
use ieee.std_logic_unsigned.all;
13
entity right_shifter is
14
    generic (P: natural:= 27; E: natural := 8; PLOG: natural := 4);
15
    Port ( frac : in  std_logic_vector (P downto 0);
16
           diff_exp : in  std_logic_vector (E downto 0);
17
           frac_align : out  std_logic_vector (P downto 0));
18
end right_shifter;
19
 
20
architecture Behavioral of right_shifter is
21
   signal fracAlign_int : std_logic_vector(P downto 0);
22
   constant allShifted : std_logic_vector(P downto 0) := (0 =>'1', others =>'0');
23
   constant ZEROS : std_logic_vector(P downto PLOG) := (others =>'0');
24
 
25
begin
26
   --Right Shifter. Shifts up to p+3 positions
27
   process(diff_exp, frac)
28
      variable temp : std_logic_vector(P downto 0);
29
      variable dtemp : std_logic_vector(P downto 0);
30
      variable fracAgnVar : std_logic_vector(P downto 0);
31
      variable sticky : std_logic;
32
      constant zeros : std_logic_vector(P downto 0) := (others => '0');
33
   begin
34
      temp := frac;
35
      sticky := '0';
36
      for i in PLOG downto 0 loop --4 downto 0 for single (P=24+3=27)
37
         if (diff_exp(i) = '1') then
38
            dtemp := (others => '0');
39
            dtemp(P - 2**i downto 0) := temp(P downto 2**i);
40
            if temp(2**i -1 downto 0) /= zeros(2**i downto 0) then
41
               sticky := '1';
42
            end if;
43
         else --if (diff_exp(i) = '0') 
44
            dtemp := temp;
45
         end if;
46
       temp := dtemp;
47
      end loop;
48
 
49
      fracAlign_int <= dtemp(P downto 1) & (dtemp(0) or sticky);
50
 
51
   end process;
52
 
53
   frac_align <= fracAlign_int when diff_exp(E downto PLOG+1) = ZEROS else allShifted; --if diffexp >> P -> allshifted
54
 
55
end Behavioral;
56
 

powered by: WebSVN 2.1.0

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