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

Subversion Repositories raytrac

[/] [raytrac/] [branches/] [fp/] [fmul32.vhd] - Diff between revs 152 and 153

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 152 Rev 153
------------------------------------------------
------------------------------------------------
--! @file fmul32.vhd
--! @file fmul32.vhd
--! @brief RayTrac Mantissa Multiplier  
--! @brief RayTrac Mantissa Multiplier  
--! @author Julián Andrés Guarín Reyes
--! @author Julián Andrés Guarín Reyes
--------------------------------------------------
--------------------------------------------------
 
 
 
 
-- RAYTRAC (FP BRANCH)
-- RAYTRAC (FP BRANCH)
-- Author Julian Andres Guarin
-- Author Julian Andres Guarin
-- fmul32.vhd
-- fmul32.vhd
-- This file is part of raytrac.
-- This file is part of raytrac.
-- 
-- 
--     raytrac is free software: you can redistribute it and/or modify
--     raytrac is free software: you can redistribute it and/or modify
--     it under the terms of the GNU General Public License as published by
--     it under the terms of the GNU General Public License as published by
--     the Free Software Foundation, either version 3 of the License, or
--     the Free Software Foundation, either version 3 of the License, or
--     (at your option) any later version.
--     (at your option) any later version.
-- 
-- 
--     raytrac is distributed in the hope that it will be useful,
--     raytrac is distributed in the hope that it will be useful,
--     but WITHOUT ANY WARRANTY; without even the implied warranty of
--     but WITHOUT ANY WARRANTY; without even the implied warranty of
--     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
--     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
--     GNU General Public License for more details.
--     GNU General Public License for more details.
-- 
-- 
--     You should have received a copy of the GNU General Public License
--     You should have received a copy of the GNU General Public License
--     along with raytrac.  If not, see <http://www.gnu.org/licenses/>
--     along with raytrac.  If not, see <http://www.gnu.org/licenses/>
library ieee;
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_unsigned.all;
entity fmul32 is
entity fmul32 is
 
 
        port (
        port (
                clk             : in std_logic;
                clk             : in std_logic;
                a32,b32         : in std_logic_vector(31 downto 0);
                a32,b32         : in std_logic_vector(31 downto 0);
                p32                     : out std_logic_vector(31 downto 0)
                p32                     : out std_logic_vector(31 downto 0)
 
 
        );
        );
end fmul32;
end entity;
architecture fmul32_arch of fmul32 is
architecture fmul32_arch of fmul32 is
 
 
 
 
        component lpm_mult
        component lpm_mult
        generic (
        generic (
                lpm_hint                        : string;
                lpm_hint                        : string;
                lpm_pipeline            : natural;
                lpm_pipeline            : natural;
                lpm_representation      : string;
                lpm_representation      : string;
                lpm_type                        : string;
                lpm_type                        : string;
                lpm_widtha                      : natural;
                lpm_widtha                      : natural;
                lpm_widthb                      : natural;
                lpm_widthb                      : natural;
                lpm_widthp                      : natural
                lpm_widthp                      : natural
        );
        );
        port (
        port (
                dataa   : in std_logic_vector ( lpm_widtha-1 downto 0 );
                dataa   : in std_logic_vector ( lpm_widtha-1 downto 0 );
                datab   : in std_logic_vector ( lpm_widthb-1 downto 0 );
                datab   : in std_logic_vector ( lpm_widthb-1 downto 0 );
                result  : out std_logic_vector ( lpm_widthp-1 downto 0 )
                result  : out std_logic_vector ( lpm_widthp-1 downto 0 )
        );
        );
        end component;
        end component;
 
 
        --Stage 0 signals
        --Stage 0 signals
        --!TBXSTART:MULT_STAGE0 
        --!TBXSTART:MULT_STAGE0 
        signal s0sga,s0sgb,s0zrs : std_logic;
        signal s0sga,s0sgb,s0zrs : std_logic;
        signal s0exp : std_logic_vector(7 downto 0);
        signal s0exp : std_logic_vector(7 downto 0);
        signal s0uma,s0umb : std_logic_vector(22 downto 0);
        signal s0uma,s0umb : std_logic_vector(22 downto 0);
        signal s0ac : std_logic_vector(35 downto 0);
        signal s0ac : std_logic_vector(35 downto 0);
        --!TBXEND
        --!TBXEND
        signal s1sgr,s2sgr:std_logic;
        signal s1sgr,s2sgr:std_logic;
        signal s0exa,s0exb,s1exp,s2exp:std_logic_vector(7 downto 0);
        signal s0exa,s0exb,s1exp,s2exp:std_logic_vector(7 downto 0);
        signal s0ad,s0bc,s1ad,s1bc:std_logic_vector(23 downto 0);
        signal s0ad,s0bc,s1ad,s1bc:std_logic_vector(23 downto 0);
 
 
 
 
        signal s1ac,s1umu:std_logic_vector(35 downto 0);
        signal s1ac,s1umu:std_logic_vector(35 downto 0);
        signal s2umu:std_logic_vector(24 downto 0);
        signal s2umu:std_logic_vector(24 downto 0);
        signal sxprop : std_logic_vector(2 downto 0);
        signal sxprop : std_logic_vector(2 downto 0);
begin
begin
 
 
 
 
        process(clk)
        process(clk)
        begin
        begin
 
 
                if clk'event and clk='1'  then
                if clk'event and clk='1'  then
                        --! Registro de entrada
                        --! Registro de entrada
                        s0sga <= a32(31);
                        s0sga <= a32(31);
                        s0sgb <= b32(31);
                        s0sgb <= b32(31);
                        s0exa <= a32(30 downto 23);
                        s0exa <= a32(30 downto 23);
                        s0exb <= b32(30 downto 23);
                        s0exb <= b32(30 downto 23);
                        s0uma <= a32(22 downto 0);
                        s0uma <= a32(22 downto 0);
                        s0umb <= b32(22 downto 0);
                        s0umb <= b32(22 downto 0);
                        --! Etapa 0 multiplicacion de la mantissa, suma de los exponentes y multiplicaci&oacute;n de los signos.
                        --! Etapa 0 multiplicacion de la mantissa, suma de los exponentes y multiplicaci&oacute;n de los signos.
                        s1sgr <= s0sga xor s0sgb;
                        s1sgr <= s0sga xor s0sgb;
                        s1ad <= s0ad;
                        s1ad <= s0ad;
                        s1bc <= s0bc;
                        s1bc <= s0bc;
                        s1ac <= s0ac;
                        s1ac <= s0ac;
                        s1exp <= s0exp;
                        s1exp <= s0exp;
 
 
                        --! Etapa 1 Sumas parciales
                        --! Etapa 1 Sumas parciales
                        s2umu <= s1umu(35 downto 11);
                        s2umu <= s1umu(35 downto 11);
                        s2sgr <= s1sgr;
                        s2sgr <= s1sgr;
                        s2exp <= s1exp;
                        s2exp <= s1exp;
 
 
 
 
                end if;
                end if;
        end process;
        end process;
        --! Etapa 2 entregar el resultado
        --! Etapa 2 entregar el resultado
        p32(31) <= s2sgr;
        p32(31) <= s2sgr;
        process (s2exp,s2umu)
        process (s2exp,s2umu)
        begin
        begin
                p32(30 downto 23) <= s2exp+s2umu(24);
                p32(30 downto 23) <= s2exp+s2umu(24);
                if s2umu(24) ='1' then
                if s2umu(24) ='1' then
                        p32(22 downto 0) <= s2umu(23 downto 1);
                        p32(22 downto 0) <= s2umu(23 downto 1);
                else
                else
                        p32(22 downto 0) <= s2umu(22 downto 0);
                        p32(22 downto 0) <= s2umu(22 downto 0);
                end if;
                end if;
        end process;
        end process;
 
 
        --! Combinatorial Gremlin Etapa 0 : multiplicacion de la mantissa, suma de los exponentes y multiplicaci&oacute;n de los signos.
        --! Combinatorial Gremlin Etapa 0 : multiplicacion de la mantissa, suma de los exponentes y multiplicaci&oacute;n de los signos.
 
 
        --! Multipliers
        --! Multipliers
        mult18x18ac:lpm_mult
        mult18x18ac:lpm_mult
        generic map ("DEDICATED_MULTIPLIER_CIRCUITRY=YES,MAXIMIZE_SPEED=9",0,"UNSIGNED","LPM_MULT",18,18,36)
        generic map ("DEDICATED_MULTIPLIER_CIRCUITRY=YES,MAXIMIZE_SPEED=9",0,"UNSIGNED","LPM_MULT",18,18,36)
        port    map (s0zrs&s0uma(22 downto 6),s0zrs&s0umb(22 downto 6),s0ac);
        port    map (s0zrs&s0uma(22 downto 6),s0zrs&s0umb(22 downto 6),s0ac);
        mult18x6ad:lpm_mult
        mult18x6ad:lpm_mult
        generic map ("DEDICATED_MULTIPLIER_CIRCUITRY=YES,MAXIMIZE_SPEED=9",0,"UNSIGNED","LPM_MULT",18,6,24)
        generic map ("DEDICATED_MULTIPLIER_CIRCUITRY=YES,MAXIMIZE_SPEED=9",0,"UNSIGNED","LPM_MULT",18,6,24)
        port    map (s0zrs&s0uma(22 downto 6),s0umb(5 downto 0),s0ad);
        port    map (s0zrs&s0uma(22 downto 6),s0umb(5 downto 0),s0ad);
        mult18x6bc:lpm_mult
        mult18x6bc:lpm_mult
        generic map ("DEDICATED_MULTIPLIER_CIRCUITRY=YES,MAXIMIZE_SPEED=9",0,"UNSIGNED","LPM_MULT",18,6,24)
        generic map ("DEDICATED_MULTIPLIER_CIRCUITRY=YES,MAXIMIZE_SPEED=9",0,"UNSIGNED","LPM_MULT",18,6,24)
        port    map (s0zrs&s0umb(22 downto 6),s0uma(5 downto 0),s0bc);
        port    map (s0zrs&s0umb(22 downto 6),s0uma(5 downto 0),s0bc);
 
 
        --! Exponent Addition 
        --! Exponent Addition 
        process (s0sga,s0sgb,s0exa,s0exb)
        process (s0sga,s0sgb,s0exa,s0exb)
 
 
        begin
        begin
 
 
                if s0exa=x"00" or s0exb=x"00" then
                if s0exa=x"00" or s0exb=x"00" then
                        s0exp <= (others => '0');
                        s0exp <= (others => '0');
                        s0zrs <= '0';
                        s0zrs <= '0';
                else
                else
                        s0zrs<='1';
                        s0zrs<='1';
                        s0exp <= s0exa+s0exb+x"81";
                        s0exp <= s0exa+s0exb+x"81";
                end if;
                end if;
        end process;
        end process;
 
 
        --! Etapa 1: Suma parcial de la multiplicacion. Suma del exponente      
        --! Etapa 1: Suma parcial de la multiplicacion. Suma del exponente      
        process(s1ac,s1ad,s1bc)
        process(s1ac,s1ad,s1bc)
        begin
        begin
                s1umu <= s1ac+s1ad(23 downto 6)+s1bc(23 downto 6);
                s1umu <= s1ac+s1ad(23 downto 6)+s1bc(23 downto 6);
        end process;
        end process;
 
 
 
 
 
 
 
 
 
 
 
 
end fmul32_arch;
 
 No newline at end of file
 No newline at end of file
 
end architecture;
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

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