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

Subversion Repositories raytrac

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

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

powered by: WebSVN 2.1.0

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