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

Subversion Repositories encore

[/] [encore/] [trunk/] [fpmult/] [src/] [fp_generic.vhdl] - Blame information for rev 4

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

Line No. Rev Author Line
1 4 aloy.amber
library ieee;
2
use ieee.std_logic_1164.all;
3
use ieee.numeric_std.all;
4
 
5
package fp_generic is
6
 
7
subtype fp_type is std_logic_vector(31 downto 0);
8
subtype fp_sign_type is std_logic;
9
subtype fp_exp_type is unsigned(7 downto 0);
10
subtype fp_mantissa_type is unsigned(23 downto 0);
11
subtype fp_long_mantissa_type is unsigned(47 downto 0);
12
 
13
subtype fp_error_type is std_logic_vector(5 downto 0);
14
constant FP_ERR_INVALID:fp_error_type:="000001";
15
constant FP_ERR_DIVBYZERO:fp_error_type:="000100";
16
constant FP_ERR_OVERFLOW:fp_error_type:="001000";
17
constant FP_ERR_UNDERFLOW:fp_error_type:="010000";
18
constant FP_ERR_INEXACT:fp_error_type:="100000";
19
 
20
function fp_sign(fp:fp_type) return fp_sign_type;
21
function fp_exp(fp:fp_type) return fp_exp_type;
22
function fp_mantissa(fp:fp_type) return fp_mantissa_type;
23
 
24
function fp_is_normal(fp:fp_type) return boolean;
25
function fp_is_zero(fp:fp_type) return boolean;
26
function fp_is_subnormal(fp:fp_type) return boolean;
27
function fp_is_infinite(fp:fp_type) return boolean;
28
function fp_is_nan(fp:fp_type) return boolean;
29
function fp_is_signalling(fp:fp_type) return boolean;
30
function fp_is_quiet(fp:fp_type) return boolean;
31
 
32
end package;
33
 
34
package body fp_generic is
35
 
36
function fp_sign(fp:fp_type) return fp_sign_type is
37
begin
38
        return fp(31);
39
end function fp_sign;
40
 
41
function fp_exp(fp:fp_type) return fp_exp_type is
42
begin
43
        return unsigned(fp(30 downto 23));
44
end function fp_exp;
45
 
46
function fp_mantissa(fp:fp_type) return fp_mantissa_type is
47
begin
48
        return unsigned("1"&fp(22 downto 0));    -- Prepend implied '1' bit of IEEE-754 mantissa in order to return a 24 bit entity
49
end function fp_mantissa;
50
 
51
function fp_is_normal(fp:fp_type) return boolean is
52
        variable e:fp_exp_type;
53
begin
54
        e:=fp_exp(fp);
55
 
56
        return (e/=(others=>'0')) and (e/=(others=>'1'));
57
end function fp_is_normal;
58
 
59
function fp_is_zero(fp:fp_type) return boolean is
60
begin
61
        return (unsigned(fp_exp(fp))=0) and (unsigned(fp_mantissa(fp))=0);
62
end function fp_is_zero;
63
 
64
function fp_is_subnormal(fp:fp_type) return boolean is
65
begin
66
        return (fp_exp(fp)=(others=>'0')) and (fp_mantissa(fp)/=(others=>'0'));
67
end function fp_is_subnormal;
68
 
69
function fp_is_infinite(fp:fp_type) return boolean is
70
begin
71
        return (fp_exp(fp)=(others=>'1')) and (fp_mantissa(fp)=(others=>'0'));
72
end function fp_is_infinite;
73
 
74
function fp_is_nan(fp:fp_type) return boolean is
75
begin
76
        return (fp_exp(fp)=(others=>'1')) and (fp_mantissa(fp)/=(others=>'0'));
77
end function fp_is_nan;
78
 
79
function fp_is_signalling(fp:fp_type) return boolean is
80
begin
81
        return fp_is_nan(fp) and fp_mantissa(fp)(22)='0';
82
end function fp_is_signalling;
83
 
84
function fp_is_quiet(fp:fp_type) return boolean is
85
begin
86
        return fp_is_nan(fp) and fp_mantissa(fp)(22)='1';
87
end function fp_is_quiet;
88
 
89
end package body fp_generic;

powered by: WebSVN 2.1.0

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