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

Subversion Repositories raytrac

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

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 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
                a32,b32         : in std_logic_vector(31 downto 0);
36
                p32                     : out std_logic_vector(31 downto 0)
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 152 jguarin200
        --!TBXSTART:MULT_STAGE0 
47
        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
begin
61 94 jguarin200
 
62 150 jguarin200
 
63 139 jguarin200
        process(clk)
64 82 jguarin200
        begin
65
 
66 139 jguarin200
                if clk'event and clk='1'  then
67 86 jguarin200
                        --! Registro de entrada
68
                        s0sga <= a32(31);
69
                        s0sgb <= b32(31);
70
                        s0exa <= a32(30 downto 23);
71
                        s0exb <= b32(30 downto 23);
72 94 jguarin200
                        s0uma <= a32(22 downto 0);
73
                        s0umb <= b32(22 downto 0);
74 89 jguarin200
                        --! Etapa 0 multiplicacion de la mantissa, suma de los exponentes y multiplicaci&oacute;n de los signos.
75 94 jguarin200
                        s1sgr <= s0sga xor s0sgb;
76
                        s1ad <= s0ad;
77
                        s1bc <= s0bc;
78
                        s1ac <= s0ac;
79 121 jguarin200
                        s1exp <= s0exp;
80 94 jguarin200
 
81
                        --! Etapa 1 Sumas parciales
82
                        s2umu <= s1umu(35 downto 11);
83
                        s2sgr <= s1sgr;
84
                        s2exp <= s1exp;
85
 
86 137 jguarin200
 
87 82 jguarin200
                end if;
88
        end process;
89 137 jguarin200
        --! Etapa 2 entregar el resultado
90
        p32(31) <= s2sgr;
91
        process (s2exp,s2umu)
92
        begin
93
                p32(30 downto 23) <= s2exp+s2umu(24);
94
                if s2umu(24) ='1' then
95
                        p32(22 downto 0) <= s2umu(23 downto 1);
96
                else
97
                        p32(22 downto 0) <= s2umu(22 downto 0);
98
                end if;
99
        end process;
100 82 jguarin200
 
101 94 jguarin200
        --! Combinatorial Gremlin Etapa 0 : multiplicacion de la mantissa, suma de los exponentes y multiplicaci&oacute;n de los signos.
102
 
103
        --! Multipliers
104 157 jguarin200
        s0dataa_alfa <= s0zrs&s0uma(22 downto 6);
105
        s0datab <= s0zrs&s0umb(22 downto 6);
106 94 jguarin200
        mult18x18ac:lpm_mult
107 155 jguarin200
        generic map (
108
                lpm_hint => "DEDICATED_MULTIPLIER_CIRCUITRY=YES,MAXIMIZE_SPEED=9",
109
                lpm_pipeline => 0,
110
                lpm_representation => "UNSIGNED",
111
                lpm_type => "LPM_MULT",
112
                lpm_widtha => 18,
113
                lpm_widthb => 18,
114
                lpm_widthp => 36
115
        )
116
        port map (
117 157 jguarin200
                dataa => s0dataa_alfa,
118
                datab => s0datab,
119 155 jguarin200
                result => s0ac
120
        );
121 157 jguarin200
        s0dataa_beta <= s0zrs&s0uma(22 downto 6);
122 94 jguarin200
        mult18x6ad:lpm_mult
123 155 jguarin200
        generic map (
124
                lpm_hint => "DEDICATED_MULTIPLIER_CIRCUITRY=YES,MAXIMIZE_SPEED=9",
125
                lpm_pipeline => 0,
126
                lpm_representation => "UNSIGNED",
127
                lpm_type => "LPM_MULT",
128
                lpm_widtha => 18,
129
                lpm_widthb => 6,
130
                lpm_widthp => 24
131
        )
132
        port map (
133 157 jguarin200
                dataa => s0dataa_beta,
134 155 jguarin200
                datab => s0umb(5 downto 0),
135
                result => s0ad
136
        );
137 157 jguarin200
        s0dataa_gama <= s0zrs&s0umb(22 downto 6);
138 94 jguarin200
        mult18x6bc:lpm_mult
139 155 jguarin200
        generic map (
140
                lpm_hint => "DEDICATED_MULTIPLIER_CIRCUITRY=YES,MAXIMIZE_SPEED=9",
141
                lpm_pipeline => 0,
142
                lpm_representation => "UNSIGNED",
143
                lpm_type => "LPM_MULT",
144
                lpm_widtha => 18,
145
                lpm_widthb => 6,
146
                lpm_widthp => 24
147
        )
148
        port map (
149 157 jguarin200
                dataa => s0dataa_gama,
150 155 jguarin200
                datab => s0uma(5 downto 0),
151
                result => s0bc
152
        );
153 89 jguarin200
 
154 94 jguarin200
        --! Exponent Addition 
155
        process (s0sga,s0sgb,s0exa,s0exb)
156 121 jguarin200
 
157 89 jguarin200
        begin
158 121 jguarin200
 
159
                if s0exa=x"00" or s0exb=x"00" then
160 94 jguarin200
                        s0exp <= (others => '0');
161
                        s0zrs <= '0';
162 89 jguarin200
                else
163 94 jguarin200
                        s0zrs<='1';
164 121 jguarin200
                        s0exp <= s0exa+s0exb+x"81";
165 89 jguarin200
                end if;
166
        end process;
167
 
168 94 jguarin200
        --! Etapa 1: Suma parcial de la multiplicacion. Suma del exponente      
169
        process(s1ac,s1ad,s1bc)
170
        begin
171
                s1umu <= s1ac+s1ad(23 downto 6)+s1bc(23 downto 6);
172
        end process;
173
 
174
 
175
 
176
 
177
 
178
 
179 153 jguarin200
end architecture;

powered by: WebSVN 2.1.0

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