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

Subversion Repositories raytrac

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

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