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

Subversion Repositories raytrac

[/] [raytrac/] [branches/] [fp/] [fmul32.vhd] - Blame information for rev 142

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

Line No. Rev Author Line
1 82 jguarin200
------------------------------------------------
2 121 jguarin200
--! @file fmul32.vhd
3 82 jguarin200
--! @brief RayTrac Mantissa Multiplier  
4
--! @author Julián Andrés Guarín Reyes
5
--------------------------------------------------
6
 
7
 
8
-- RAYTRAC (FP BRANCH)
9
-- Author Julian Andres Guarin
10 121 jguarin200
-- fmul32.vhd
11 82 jguarin200
-- 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
library ieee;
26
use ieee.std_logic_1164.all;
27
use ieee.std_logic_unsigned.all;
28 121 jguarin200
entity fmul32 is
29 139 jguarin200
        generic (
30
                propagation_chain : string := "ON"
31
        );
32 82 jguarin200
        port (
33 139 jguarin200
                clk,prop_in             : in std_logic;
34
                a32,b32                 : in std_logic_vector(31 downto 0);
35
                p32,prop_out    : out std_logic_vector(31 downto 0)
36 82 jguarin200
 
37
        );
38 121 jguarin200
end fmul32;
39
architecture fmul32_arch of fmul32 is
40 82 jguarin200
 
41 89 jguarin200
 
42 82 jguarin200
        component lpm_mult
43
        generic (
44
                lpm_hint                        : string;
45
                lpm_pipeline            : natural;
46
                lpm_representation      : string;
47
                lpm_type                        : string;
48
                lpm_widtha                      : natural;
49
                lpm_widthb                      : natural;
50
                lpm_widthp                      : natural
51
        );
52
        port (
53 94 jguarin200
                dataa   : in std_logic_vector ( lpm_widtha-1 downto 0 );
54
                datab   : in std_logic_vector ( lpm_widthb-1 downto 0 );
55
                result  : out std_logic_vector ( lpm_widthp-1 downto 0 )
56 82 jguarin200
        );
57
        end component;
58
 
59 94 jguarin200
        --Stage 0 signals
60 139 jguarin200
 
61 94 jguarin200
        signal s0sga,s0sgb,s0zrs,s1sgr,s2sgr:std_logic;
62
        signal s0exa,s0exb,s1exp,s2exp:std_logic_vector(7 downto 0);
63 121 jguarin200
        signal s0exp : std_logic_vector(7 downto 0);
64 94 jguarin200
        signal s0uma,s0umb:std_logic_vector(22 downto 0);
65
        signal s0ad,s0bc,s1ad,s1bc:std_logic_vector(23 downto 0);
66
        signal s0ac:std_logic_vector(35 downto 0);
67
 
68
 
69
        signal s1ac,s1umu:std_logic_vector(35 downto 0);
70
        signal s2umu:std_logic_vector(24 downto 0);
71 139 jguarin200
        signal sxprop : std_logic_vector(2 downto 0);
72
begin
73
        propagation:
74
        if propagation_chain="ON" generate
75
                prop_out <= sxprop(2);
76
                process (clk)
77
                begin
78
                        if clk'event and clk='1' then
79
                                for i in 2 downto 1 loop
80
                                        sxprop(i) <= sxprop(i-1);
81
                                end loop;
82
                                sxprop(0) <= prop_in;
83
                        end if;
84
                end process;
85
        end generate propagation ;
86 94 jguarin200
 
87 139 jguarin200
        process(clk)
88 82 jguarin200
        begin
89
 
90 139 jguarin200
                if clk'event and clk='1'  then
91 86 jguarin200
                        --! Registro de entrada
92
                        s0sga <= a32(31);
93
                        s0sgb <= b32(31);
94
                        s0exa <= a32(30 downto 23);
95
                        s0exb <= b32(30 downto 23);
96 94 jguarin200
                        s0uma <= a32(22 downto 0);
97
                        s0umb <= b32(22 downto 0);
98 89 jguarin200
                        --! Etapa 0 multiplicacion de la mantissa, suma de los exponentes y multiplicaci&oacute;n de los signos.
99 94 jguarin200
                        s1sgr <= s0sga xor s0sgb;
100
                        s1ad <= s0ad;
101
                        s1bc <= s0bc;
102
                        s1ac <= s0ac;
103 121 jguarin200
                        s1exp <= s0exp;
104 94 jguarin200
 
105
                        --! Etapa 1 Sumas parciales
106
                        s2umu <= s1umu(35 downto 11);
107
                        s2sgr <= s1sgr;
108
                        s2exp <= s1exp;
109
 
110 137 jguarin200
 
111 82 jguarin200
                end if;
112
        end process;
113 137 jguarin200
        --! Etapa 2 entregar el resultado
114
        p32(31) <= s2sgr;
115
        process (s2exp,s2umu)
116
        begin
117
                p32(30 downto 23) <= s2exp+s2umu(24);
118
                if s2umu(24) ='1' then
119
                        p32(22 downto 0) <= s2umu(23 downto 1);
120
                else
121
                        p32(22 downto 0) <= s2umu(22 downto 0);
122
                end if;
123
        end process;
124 82 jguarin200
 
125 94 jguarin200
        --! Combinatorial Gremlin Etapa 0 : multiplicacion de la mantissa, suma de los exponentes y multiplicaci&oacute;n de los signos.
126
 
127
        --! Multipliers
128
        mult18x18ac:lpm_mult
129 89 jguarin200
        generic map ("DEDICATED_MULTIPLIER_CIRCUITRY=YES,MAXIMIZE_SPEED=9",0,"UNSIGNED","LPM_MULT",18,18,36)
130 94 jguarin200
        port    map (s0zrs&s0uma(22 downto 6),s0zrs&s0umb(22 downto 6),s0ac);
131
        mult18x6ad:lpm_mult
132
        generic map ("DEDICATED_MULTIPLIER_CIRCUITRY=YES,MAXIMIZE_SPEED=9",0,"UNSIGNED","LPM_MULT",18,6,24)
133
        port    map (s0zrs&s0uma(22 downto 6),s0umb(5 downto 0),s0ad);
134
        mult18x6bc:lpm_mult
135
        generic map ("DEDICATED_MULTIPLIER_CIRCUITRY=YES,MAXIMIZE_SPEED=9",0,"UNSIGNED","LPM_MULT",18,6,24)
136
        port    map (s0zrs&s0umb(22 downto 6),s0uma(5 downto 0),s0bc);
137 89 jguarin200
 
138 94 jguarin200
        --! Exponent Addition 
139
        process (s0sga,s0sgb,s0exa,s0exb)
140 121 jguarin200
 
141 89 jguarin200
        begin
142 121 jguarin200
 
143
                if s0exa=x"00" or s0exb=x"00" then
144 94 jguarin200
                        s0exp <= (others => '0');
145
                        s0zrs <= '0';
146 89 jguarin200
                else
147 94 jguarin200
                        s0zrs<='1';
148 121 jguarin200
                        s0exp <= s0exa+s0exb+x"81";
149 89 jguarin200
                end if;
150
        end process;
151
 
152 94 jguarin200
        --! Etapa 1: Suma parcial de la multiplicacion. Suma del exponente      
153
        process(s1ac,s1ad,s1bc)
154
        begin
155
                s1umu <= s1ac+s1ad(23 downto 6)+s1bc(23 downto 6);
156
        end process;
157
 
158
 
159
 
160
 
161
 
162
 
163 121 jguarin200
end fmul32_arch;

powered by: WebSVN 2.1.0

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