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

Subversion Repositories floating_point_adder_subtractor

[/] [floating_point_adder_subtractor/] [web_uploads/] [normalize.vhd] - Blame information for rev 6

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 6 root
library ieee;
2
use ieee.std_logic_1164.all;
3
use ieee.std_logic_arith.all;
4
use ieee.std_logic_unsigned.all;
5
 
6
entity normalize is
7
port (
8
                input : in std_logic_vector(33 downto 0);
9
                clk,finish_add,reset : in std_logic;
10
                output_addsub : out std_logic_vector(31 downto 0);
11
                finish_nor_addsub : out std_logic
12
          );
13
end normalize;
14
 
15
architecture normalize of normalize is
16
begin
17
process(clk,input,finish_add,reset)
18
variable mantissa : std_logic_vector(24 downto 0);
19
variable exp : std_logic_vector(7 downto 0);
20
variable nor_mantissa : std_logic_vector(22 downto 0);
21
begin
22
if clk='1' and clk'event then
23
if(reset='1' or finish_add='0') then
24
finish_nor_addsub <= '0';
25
output_addsub <= "00000000000000000000000000000000";
26
elsif (reset='0' and finish_add='1' and input="0000000000000000000000000000000000") then
27
finish_nor_addsub <= '1';
28
output_addsub <= "00000000000000000000000000000000";
29
elsif (reset='0' and finish_add='1') then
30
          mantissa:=input(24 downto 0);
31
          exp:=input(32 downto 25);                             --mantissa overflow,shit to right
32
          if (mantissa(24)='1') then                    --add exponent
33
             mantissa(23 downto 0):=mantissa(24 downto 1);
34
             exp:=exp + 1;
35
          else
36
        a : for i in 1 to 10 loop                               --if concanated not equal to 1 then
37
            if (mantissa(23)='0') then                   --shitft to left,minus exponent
38
            mantissa(23 downto 1):=mantissa(22 downto 0);
39
            exp:=exp - 1;
40
            else
41
            exit a;
42
            end if;
43
            end loop;
44
         end if;
45
         output_addsub <= input(33) & exp & mantissa(22 downto 0);
46
         finish_nor_addsub <= '1';
47
        end if;
48
end if;
49
end process;
50
end normalize;
51
 
52
 
53
 
54
 

powered by: WebSVN 2.1.0

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