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

Subversion Repositories raytrac

[/] [raytrac/] [branches/] [fp/] [sqrt32.vhd] - Blame information for rev 223

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

Line No. Rev Author Line
1 121 jguarin200
------------------------------------------------
2
--! @file fsqrt32.vhd
3
--! @brief RayTrac Floating Point Adder  
4
--! @author Julián Andrés Guarín Reyes
5
--------------------------------------------------
6
 
7
 
8
-- RAYTRAC (FP BRANCH)
9
-- Author Julian Andres Guarin
10
-- fsqrt32.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 99 jguarin200
library ieee;
26
use ieee.std_logic_1164.all;
27
use ieee.std_logic_unsigned.all;
28 158 jguarin200
use work.arithpack.all;
29 99 jguarin200
entity sqrt32 is
30 150 jguarin200
 
31 99 jguarin200
        port (
32
 
33 150 jguarin200
                clk     : in std_logic;
34 158 jguarin200
                rd32: in xfloat32;
35
                sq32: out xfloat32
36 99 jguarin200
        );
37 153 jguarin200
end entity;
38 99 jguarin200
architecture sqrt32_arch of sqrt32 is
39
 
40
        component altsyncram
41
        generic (
42
                address_aclr_a          : string;
43
                clock_enable_input_a            : string;
44
                clock_enable_output_a           : string;
45
                init_file               : string;
46
                intended_device_family          : string;
47
                lpm_hint                : string;
48
                lpm_type                : string;
49
                numwords_a              : natural;
50
                operation_mode          : string;
51
                outdata_aclr_a          : string;
52
                outdata_reg_a           : string;
53
                widthad_a               : natural;
54
                width_a         : natural;
55
                width_byteena_a         : natural
56
        );
57
        port (
58 137 jguarin200
                        clock0          :       in std_logic;
59
                        rden_a          :       in std_logic;
60
                        address_a       :       in std_logic_vector (9 downto 0);
61
                        q_a                     :       out std_logic_vector (17 downto 0)
62 99 jguarin200
        );
63
        end component;
64
 
65 103 jguarin200
        signal s0sgn                    : std_logic;
66
        signal s0uexp,s0e129    : std_logic_vector(7 downto 0);
67 99 jguarin200
        signal s0q                              : std_logic_vector(17 downto 0);
68 139 jguarin200
        signal sxprop                   : std_logic;
69 99 jguarin200
begin
70 150 jguarin200
 
71 103 jguarin200
        --! SNAN?
72 139 jguarin200
        process (clk)
73 99 jguarin200
        begin
74 139 jguarin200
                if clk'event and clk='1'  then
75 99 jguarin200
 
76
                        --!Carga de Operando.
77 103 jguarin200
                        s0sgn <= rd32(31);
78
                        s0uexp <= rd32(30 downto 23);
79 137 jguarin200
 
80 99 jguarin200
                end if;
81
        end process;
82
 
83 137 jguarin200
        --! Etapa 0: Calcular direcci&oacute;n a partir del exponente y el exponente.
84
        sq32(31) <= s0sgn;
85
        sq32(30 downto 23) <= (s0e129(7)&s0e129(7 downto 1))+127;
86
        sq32(22 downto 6) <= s0q(16 downto 0);
87
 
88
 
89 99 jguarin200
        --! Combinatorial Gremlin: Etapa 0, calculo del exponente. 
90 103 jguarin200
        s0e129<=s0uexp+("1000000"&s0uexp(0));
91
        sq32(5 downto 0) <= (others => '0');
92 104 jguarin200
        --! Combinatorial Gremlin, Etapa 0, calcula la ra&iacute;z cuadrada de la mantissa
93
        --! Recuerde que aunque rd32(23) no pertenece a la mantissa indica si el exponente es par o impar, 1 (par) y 0 (impar)
94
        altsyncram_component : altsyncram
95
        generic map (
96
                address_aclr_a => "NONE",
97
                clock_enable_input_a => "BYPASS",
98
                clock_enable_output_a => "BYPASS",
99 150 jguarin200
                --init_file => "X:/Code/Indigo/fp/fp/memsqrt.mif",
100
                init_file => "//IMACJULIAN/imac/Code/Indigo/fp/fp/memsqrt.mif",
101 104 jguarin200
                intended_device_family => "Cyclone III",
102
                lpm_hint => "ENABLE_RUNTIME_MOD=NO",
103
                lpm_type => "altsyncram",
104
                numwords_a => 1024,
105
                operation_mode => "ROM",
106
                outdata_aclr_a => "NONE",
107
                outdata_reg_a => "UNREGISTERED",
108
                widthad_a => 10,
109
                width_a => 18,
110
                width_byteena_a => 1
111
        )
112 150 jguarin200
        port map (rden_a => '1', clock0 => clk, address_a => rd32(23 downto 14), q_a => s0q);
113 99 jguarin200
 
114 153 jguarin200
end architecture;

powered by: WebSVN 2.1.0

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