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

Subversion Repositories jart

[/] [jart/] [trunk/] [BL00/] [block00.vhd] - Blame information for rev 2

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

Line No. Rev Author Line
1 2 jguarin200
-- Author : Julian Andres Guarin Reyes.
2
-- Project : JART, Just Another Ray Tracer.
3
 
4
-- This code was entirely written by Julian Andres Guarin Reyes.
5
-- The following code is licensed under GNU Public License
6
-- http://www.gnu.org/licenses/gpl-3.0.txt.
7
 
8
 -- This file is part of JART (Just Another Ray Tracer).
9
 
10
    -- JART (Just Another Ray Tracer) is free software: you can redistribute it and/or modify
11
    -- it under the terms of the GNU General Public License as published by
12
    -- the Free Software Foundation, either version 3 of the License, or
13
    -- (at your option) any later version.
14
 
15
    -- JART (Just Another Ray Tracer) is distributed in the hope that it will be useful,
16
    -- but WITHOUT ANY WARRANTY; without even the implied warranty of
17
    -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
    -- GNU General Public License for more details.
19
 
20
    -- You should have received a copy of the GNU General Public License
21
    -- along with JART (Just Another Ray Tracer).  If not, see <http://www.gnu.org/licenses/>.
22
 
23
 
24
-- The following HDL is a dot product calculator.  V and D are the vectors to be processed. 
25
-- Vx,Vy,Vz,Dx,Dy,Dz are the vectors components.
26
-- vn_A7_10, vn_A7_10 are both signed fixed representations of vectorial components where 7 bits are for the integer part and
27
-- 10 bits are for the decimal part.
28
-- vd_A15_16 is the signed fixed representation of the V and D dot product operation, where 15 bits are for the integer part and 
29
-- 16 bits are for the decimal part. 
30
 
31
 
32
library ieee;
33
use ieee.std_logic_1164.all;
34
 
35
-- Fixed Point Representation :
36
-- 
37
-- A(7,10) signed 18 bits fixed point representation :
38
--      1 bit for sign
39
--      7 bits for integer part (128) numbers.
40
--      10 bits for decimal part (1024) numbers. 
41
-- Representation Range = -128, 128-(1/1024)
42
-- Decimal part Resolution : 1/1024 = 0.00098 aprox, 0.001
43
 
44
 
45
entity bl00 is
46
        port (
47
                -- <vx, vy, vz> y <dx, dy, dz> fixed point A(7,10) => 18 bits de representacion.
48
                vx_A7_10        : in std_logic_vector (17 downto 0);
49
                vy_A7_10        : in std_logic_vector (17 downto 0);
50
                vz_A7_10        : in std_logic_vector (17 downto 0);
51
 
52
 
53
                dx_A7_10 :      in std_logic_vector (17 downto 0);
54
                dy_A7_10 :      in std_logic_vector (17 downto 0);
55
                dz_A7_10 :      in std_logic_vector (17 downto 0);
56
 
57
                -- <vxdx + vydy + vzdz> fixed point A(15,6) => 32 bits de representacion.
58
                vd_A15_16 :     out std_logic_vector (31 downto 0)
59
 
60
        );
61
 
62
end entity;
63
 
64
 
65
architecture rtl of bl00 is
66
 
67
        signal px :     std_logic_vector (31 downto 0); -- Producto A(15,20), se trunca despues a A(15,16)
68
        signal py :     std_logic_vector (31 downto 0); -- Producto A(15,20), se trunca despues a A(15,16)
69
        signal pz :     std_logic_vector (31 downto 0); -- Producto A(15,20), se trunca despues a A(15,16)
70
        signal s0 :     std_logic_vector (31 downto 0); -- Suma : A(15,16) + A(15,16) = A(15,16) = 31 bits de representacion. 
71
 
72
 
73
 
74
        component mult_A15_20
75
        port
76
        (
77
                dataa           : in std_logic_vector(17 downto 0);
78
                datab           : in std_logic_vector(17 downto 0);
79
                result          : out std_logic_vector (35 downto 0)
80
        );
81
        end component;
82
 
83
        component add_A15_16
84
        port
85
        (
86
                dataa           : in std_logic_vector (31 downto 0);
87
                datab           : in std_logic_vector (31 downto 0);
88
                result          : out std_logic_vector(31 downto 0)
89
        );
90
        end component;
91
 
92
 
93
 
94
 
95
begin
96
        -- Productos, trunco de una vez 4 bits para performance y espacio.
97
        vxdx : mult_A15_20 port map (dataa=>vx_A7_10, datab=> dx_A7_10, result(35 downto 4) => px);
98
        vydy : mult_A15_20 port map (dataa=>vy_A7_10, datab=> dy_A7_10, result(35 downto 4) => py);
99
        vzdz : mult_A15_20 port map (dataa=>vz_A7_10, datab=> dz_A7_10, result(35 downto 4) => pz);
100
 
101
        -- Sumas de 32 bits A(21,10).
102
 
103
        add0 : add_A15_16 port map (dataa=> px, datab => py , result=>s0(31 downto 0));
104
        add1 : add_A15_16 port map (dataa=> s0, datab => pz , result=>vd_A15_16(31 downto 0));
105
 
106
end rtl;
107
 
108
 

powered by: WebSVN 2.1.0

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