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

Subversion Repositories raytrac

[/] [raytrac/] [branches/] [fp_sgdma/] [arith/] [single/] [fmul32.vhd] - Blame information for rev 238

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 155 jguarin200
use work.arithpack.all;
29
 
30
 
31 121 jguarin200
entity fmul32 is
32 150 jguarin200
 
33 82 jguarin200
        port (
34 150 jguarin200
                clk             : in std_logic;
35 158 jguarin200
                a32,b32         : in xfloat32;
36
                p32                     : out xfloat32
37 82 jguarin200
 
38
        );
39 153 jguarin200
end entity;
40 121 jguarin200
architecture fmul32_arch of fmul32 is
41 82 jguarin200
 
42 89 jguarin200
 
43 155 jguarin200
 
44 94 jguarin200
        --Stage 0 signals
45 157 jguarin200
        signal s0dataa_alfa,s0dataa_beta,s0dataa_gama,s0datab : std_logic_vector(17 downto 0);
46 160 jguarin200
        --!TXBXSTART:MULT_STAGE0        
47 152 jguarin200
        signal s0sga,s0sgb,s0zrs : std_logic;
48
        signal s0exp : std_logic_vector(7 downto 0);
49
        signal s0uma,s0umb : std_logic_vector(22 downto 0);
50
        signal s0ac : std_logic_vector(35 downto 0);
51
        --!TBXEND
52
        signal s1sgr,s2sgr:std_logic;
53 94 jguarin200
        signal s0exa,s0exb,s1exp,s2exp:std_logic_vector(7 downto 0);
54
        signal s0ad,s0bc,s1ad,s1bc:std_logic_vector(23 downto 0);
55
 
56
 
57
        signal s1ac,s1umu:std_logic_vector(35 downto 0);
58
        signal s2umu:std_logic_vector(24 downto 0);
59 139 jguarin200
        signal sxprop : std_logic_vector(2 downto 0);
60 219 jguarin200
 
61
        --! LPM_MULTIPLIER
62
        component lpm_mult
63
        generic (
64
                lpm_hint                        : string;
65
                lpm_pipeline            : natural;
66
                lpm_representation      : string;
67
                lpm_type                        : string;
68
                lpm_widtha                      : natural;
69
                lpm_widthb                      : natural;
70
                lpm_widthp                      : natural
71
        );
72
        port (
73
                dataa   : in std_logic_vector ( lpm_widtha-1 downto 0 );
74
                datab   : in std_logic_vector ( lpm_widthb-1 downto 0 );
75
                result  : out std_logic_vector( lpm_widthp-1 downto 0 )
76
        );
77
        end component;
78
 
79
 
80 139 jguarin200
begin
81 94 jguarin200
 
82 150 jguarin200
 
83 139 jguarin200
        process(clk)
84 82 jguarin200
        begin
85
 
86 139 jguarin200
                if clk'event and clk='1'  then
87 86 jguarin200
                        --! Registro de entrada
88
                        s0sga <= a32(31);
89
                        s0sgb <= b32(31);
90
                        s0exa <= a32(30 downto 23);
91
                        s0exb <= b32(30 downto 23);
92 94 jguarin200
                        s0uma <= a32(22 downto 0);
93
                        s0umb <= b32(22 downto 0);
94 89 jguarin200
                        --! Etapa 0 multiplicacion de la mantissa, suma de los exponentes y multiplicaci&oacute;n de los signos.
95 94 jguarin200
                        s1sgr <= s0sga xor s0sgb;
96
                        s1ad <= s0ad;
97
                        s1bc <= s0bc;
98
                        s1ac <= s0ac;
99 121 jguarin200
                        s1exp <= s0exp;
100 94 jguarin200
 
101
                        --! Etapa 1 Sumas parciales
102
                        s2umu <= s1umu(35 downto 11);
103
                        s2sgr <= s1sgr;
104
                        s2exp <= s1exp;
105
 
106 137 jguarin200
 
107 82 jguarin200
                end if;
108
        end process;
109 137 jguarin200
        --! Etapa 2 entregar el resultado
110
        p32(31) <= s2sgr;
111
        process (s2exp,s2umu)
112
        begin
113
                p32(30 downto 23) <= s2exp+s2umu(24);
114
                if s2umu(24) ='1' then
115
                        p32(22 downto 0) <= s2umu(23 downto 1);
116
                else
117
                        p32(22 downto 0) <= s2umu(22 downto 0);
118
                end if;
119
        end process;
120 82 jguarin200
 
121 94 jguarin200
        --! Combinatorial Gremlin Etapa 0 : multiplicacion de la mantissa, suma de los exponentes y multiplicaci&oacute;n de los signos.
122
 
123
        --! Multipliers
124 157 jguarin200
        s0dataa_alfa <= s0zrs&s0uma(22 downto 6);
125
        s0datab <= s0zrs&s0umb(22 downto 6);
126 94 jguarin200
        mult18x18ac:lpm_mult
127 155 jguarin200
        generic map (
128
                lpm_hint => "DEDICATED_MULTIPLIER_CIRCUITRY=YES,MAXIMIZE_SPEED=9",
129
                lpm_pipeline => 0,
130
                lpm_representation => "UNSIGNED",
131
                lpm_type => "LPM_MULT",
132
                lpm_widtha => 18,
133
                lpm_widthb => 18,
134
                lpm_widthp => 36
135
        )
136
        port map (
137 157 jguarin200
                dataa => s0dataa_alfa,
138
                datab => s0datab,
139 155 jguarin200
                result => s0ac
140
        );
141 157 jguarin200
        s0dataa_beta <= s0zrs&s0uma(22 downto 6);
142 94 jguarin200
        mult18x6ad:lpm_mult
143 155 jguarin200
        generic map (
144
                lpm_hint => "DEDICATED_MULTIPLIER_CIRCUITRY=YES,MAXIMIZE_SPEED=9",
145
                lpm_pipeline => 0,
146
                lpm_representation => "UNSIGNED",
147
                lpm_type => "LPM_MULT",
148
                lpm_widtha => 18,
149
                lpm_widthb => 6,
150
                lpm_widthp => 24
151
        )
152
        port map (
153 157 jguarin200
                dataa => s0dataa_beta,
154 155 jguarin200
                datab => s0umb(5 downto 0),
155
                result => s0ad
156
        );
157 157 jguarin200
        s0dataa_gama <= s0zrs&s0umb(22 downto 6);
158 94 jguarin200
        mult18x6bc:lpm_mult
159 155 jguarin200
        generic map (
160
                lpm_hint => "DEDICATED_MULTIPLIER_CIRCUITRY=YES,MAXIMIZE_SPEED=9",
161
                lpm_pipeline => 0,
162
                lpm_representation => "UNSIGNED",
163
                lpm_type => "LPM_MULT",
164
                lpm_widtha => 18,
165
                lpm_widthb => 6,
166
                lpm_widthp => 24
167
        )
168
        port map (
169 157 jguarin200
                dataa => s0dataa_gama,
170 155 jguarin200
                datab => s0uma(5 downto 0),
171
                result => s0bc
172
        );
173 89 jguarin200
 
174 94 jguarin200
        --! Exponent Addition 
175
        process (s0sga,s0sgb,s0exa,s0exb)
176 121 jguarin200
 
177 89 jguarin200
        begin
178 121 jguarin200
 
179
                if s0exa=x"00" or s0exb=x"00" then
180 94 jguarin200
                        s0exp <= (others => '0');
181
                        s0zrs <= '0';
182 89 jguarin200
                else
183 94 jguarin200
                        s0zrs<='1';
184 121 jguarin200
                        s0exp <= s0exa+s0exb+x"81";
185 89 jguarin200
                end if;
186
        end process;
187
 
188 94 jguarin200
        --! Etapa 1: Suma parcial de la multiplicacion. Suma del exponente      
189
        process(s1ac,s1ad,s1bc)
190
        begin
191
                s1umu <= s1ac+s1ad(23 downto 6)+s1bc(23 downto 6);
192
        end process;
193
 
194
 
195
 
196
 
197
 
198
 
199 153 jguarin200
end architecture;

powered by: WebSVN 2.1.0

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