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

Subversion Repositories jart

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

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

powered by: WebSVN 2.1.0

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