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

Subversion Repositories raytrac

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

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

powered by: WebSVN 2.1.0

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