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

Subversion Repositories raytrac

[/] [raytrac/] [trunk/] [fpbranch/] [mul/] [mul2.vhd] - Blame information for rev 93

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 82 jguarin200
------------------------------------------------
2
--! @file mmp.vhd
3
--! @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
-- mmp.vhd
11
-- 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
 
26
 
27
library ieee;
28
use ieee.std_logic_1164.all;
29 89 jguarin200
use ieee.std_logic_arith.all;
30 82 jguarin200
use ieee.std_logic_unsigned.all;
31
library lpm;
32
use lpm.all;
33
 
34 86 jguarin200
entity mul2 is
35 82 jguarin200
        port (
36 86 jguarin200
                clk             : in std_logic;
37
                a32,b32         : in std_logic_vector(31 downto 0);
38
                p32                     : out std_logic_vector(31 downto 0)
39 82 jguarin200
 
40
        );
41 86 jguarin200
end mul2;
42 82 jguarin200
 
43 86 jguarin200
architecture mul2_arch of mul2 is
44 89 jguarin200
 
45
 
46 82 jguarin200
        component lpm_mult
47
        generic (
48
                lpm_hint                        : string;
49
                lpm_pipeline            : natural;
50
                lpm_representation      : string;
51
                lpm_type                        : string;
52
                lpm_widtha                      : natural;
53
                lpm_widthb                      : natural;
54
                lpm_widthp                      : natural
55
        );
56
        port (
57
                dataa   : in std_logic_vector ( 17 downto 0 );
58
                datab   : in std_logic_vector ( 17 downto 0 );
59 89 jguarin200
--              clock   : in std_logic;
60 82 jguarin200
                result  : out std_logic_vector ( 35 downto 0 )
61
        );
62
        end component;
63
 
64 93 jguarin200
        signal s0sga,s0sgb,s1sg,s0significandMSB:std_logic;
65 89 jguarin200
        signal s0exa,s0exb,s1ex:std_logic_vector(7 downto 0);
66
        signal s0ex : std_logic_vector(8 downto 0);
67
        signal s0uma,s0umb:std_logic_vector(16 downto 0);
68
        signal s0map:std_logic_vector(35 downto 0);
69
        signal s1map:std_logic_vector(24 downto 0);
70
 
71 82 jguarin200
begin
72
 
73 89 jguarin200
        process(clk)
74 82 jguarin200
        begin
75
 
76 86 jguarin200
                if clk'event and clk='1' then
77
                        --! Registro de entrada
78
                        s0sga <= a32(31);
79
                        s0sgb <= b32(31);
80
                        s0exa <= a32(30 downto 23);
81
                        s0exb <= b32(30 downto 23);
82 89 jguarin200
                        s0uma <= a32(22 downto 6);
83
                        s0umb <= b32(22 downto 6);
84
                        --! Etapa 0 multiplicacion de la mantissa, suma de los exponentes y multiplicaci&oacute;n de los signos.
85
                        s1map <= s0map(35 downto 11);
86
                        s1ex <= s0ex(7 downto 0);
87 93 jguarin200
                        s1sg <= s0sga xor s0sgb;
88
                        --! Etapa 1 entregar el resultado
89
                        p32(31) <= s1sg;
90
                        p32(30 downto 23) <= s1ex+s1map(24);
91
                        if s1map(24) ='1' then
92
                                p32(22 downto 0) <= s1map(23 downto 1);
93
                        else
94
                                p32(22 downto 0) <= s1map(22 downto 0);
95
                        end if;
96 82 jguarin200
                end if;
97
        end process;
98
 
99
        --! Combinatorial Gremlin
100
        mult:lpm_mult
101 89 jguarin200
        generic map ("DEDICATED_MULTIPLIER_CIRCUITRY=YES,MAXIMIZE_SPEED=9",0,"UNSIGNED","LPM_MULT",18,18,36)
102
        port    map (s0significandMSB&s0uma,s0significandMSB&s0umb,s0map);
103
 
104
        process (s0sga,s0sgb,s0exa,s0exb,s0uma,s0umb)
105
                variable i8s0exa,i8s0exb: integer range 0 to 255;
106
        begin
107
                i8s0exa:=conv_integer(s0exa);
108
                i8s0exb:=conv_integer(s0exb);
109
                if i8s0exa = 0 or i8s0exb = 0  then
110
                        s0ex <= (others => '0');
111
                        s0significandMSB <= '0';
112
                else
113
                        s0significandMSB<='1';
114
                        s0ex <= conv_std_logic_vector(i8s0exb+i8s0exa+129,9);
115
                end if;
116
        end process;
117
 
118 86 jguarin200
end mul2_arch;

powered by: WebSVN 2.1.0

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