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

Subversion Repositories encore

[/] [encore/] [trunk/] [fpmult/] [src/] [fpmult_stage0.vhdl] - Blame information for rev 6

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
use work.fp_generic.all;
5
use work.fpmult_stage0_comp.all;
6
 
7
entity fpmult_stage0 is
8
        port(
9
                clk:in std_logic;
10
                d:in fpmult_stage0_in_type;
11
                q:out fpmult_stage0_out_type
12
        );
13
end;
14
 
15
architecture twoproc of fpmult_stage0 is
16
        type reg_type is record
17
                a:fp_type;
18
                b:fp_type;
19
 
20
                p_sign:fp_sign_type;
21
                p_exp:fp_exp_type;
22
                p_mantissa:fp_long_mantissa_type;
23
        end record;
24
        signal r,rin:reg_type;
25
begin
26
        comb:process(d,r)
27
                variable v:reg_type;
28 6 aloy.amber
                variable a_is_normal,b_is_normal:boolean;
29
                variable a_is_subnormal,b_is_subnormal:boolean;
30
                variable a_is_zero,b_is_zero:boolean;
31
                variable a_is_infinite,b_is_infinite:boolean;
32
                variable a_is_nan,b_is_nan:boolean;
33
                variable is_normal:boolean;
34
                variable is_zero:boolean;
35
                variable is_infinite:boolean;
36
                variable is_nan:boolean;
37 4 aloy.amber
        begin
38
                -- sample register outputs
39
                v:=r;
40
 
41
                -- overload
42
                v.a:=d.a;
43
                v.b:=d.b;
44
 
45 6 aloy.amber
                a_is_normal:=fp_is_normal(v.a);
46
                b_is_normal:=fp_is_normal(v.b);
47
                a_is_subnormal:=fp_is_subnormal(v.a);
48
                b_is_subnormal:=fp_is_subnormal(v.b);
49
                a_is_zero:=fp_is_zero(v.a);
50
                b_is_zero:=fp_is_zero(v.b);
51
                a_is_infinite:=fp_is_infinite(v.a);
52
                b_is_infinite:=fp_is_infinite(v.b);
53
                a_is_nan:=fp_is_nan(v.a);
54
                b_is_nan:=fp_is_nan(v.b);
55
 
56
                if a_is_normal or b_is_normal then
57
                        if a_is_normal and b_is_normal then
58
                                is_normal:=true;
59
                        end if;
60
                        if a_is_zero or b_is_zero then
61
                                is_zero:=true;
62
                        end if;
63
                        if a_is_infinite or b_is_infinite then
64
                                is_infinite:=true;
65
                        end if;
66
                        if a_is_nan or b_is_nan then
67
                                is_nan:=true;
68
                        end if;
69
                end if;
70
 
71 4 aloy.amber
                v.p_sign:=fp_sign(d.a) xor fp_sign(d.b);
72
                v.p_exp:=fp_exp(d.a) + fp_exp(d.b) - 127;
73
                if fp_mantissa(d.b)(0)='1' then
74
                        v.p_mantissa:=resize(fp_mantissa(d.a),48);
75
                else
76
                        v.p_mantissa:=(others=>'0');
77
                end if;
78
 
79
                -- drive register inputs
80
                rin<=v;
81
 
82
                -- drive outputs
83
                q.a<=r.a;
84
                q.b<=r.b;
85
 
86
                q.p_sign<=r.p_sign;
87
                q.p_exp<=r.p_exp;
88
                q.p_mantissa<=r.p_mantissa;
89
        end process;
90
 
91
        seq:process(clk,rin)
92
        begin
93
                if rising_edge(clk) then
94
                        r<=rin;
95
                end if;
96
        end process;
97
end;

powered by: WebSVN 2.1.0

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