1 |
16 |
jguarin200 |
-- Author : Julian Andres Guarin Reyes.
|
2 |
|
|
-- Project : JART, Just Another Ray Tracer.
|
3 |
|
|
-- email : jguarin2002 at gmail.com, j.guarin at javeriana.edu.co
|
4 |
|
|
|
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 |
|
|
-- 16X50M Intersection Tests
|
25 |
|
|
|
26 |
|
|
library ieee;
|
27 |
|
|
use ieee.std_logic_1164.all;
|
28 |
|
|
|
29 |
|
|
package powerGrid is
|
30 |
|
|
|
31 |
|
|
-- Signed "less than"
|
32 |
|
|
component sl32
|
33 |
|
|
port (
|
34 |
|
|
dataa : in std_logic_vector (31 downto 0);
|
35 |
|
|
datab : in std_logic_vector (31 downto 0);
|
36 |
|
|
AlB : out std_logic
|
37 |
|
|
);
|
38 |
|
|
end component;
|
39 |
|
|
|
40 |
|
|
-- Signed "greater than"
|
41 |
|
|
component sge32
|
42 |
|
|
port (
|
43 |
|
|
dataa : in std_logic_vector (31 downto 0);
|
44 |
|
|
datab : in std_logic_vector (31 downto 0);
|
45 |
|
|
AgeB : out std_logic
|
46 |
|
|
);
|
47 |
|
|
end component;
|
48 |
|
|
|
49 |
|
|
-- Minimun distance Comparison
|
50 |
|
|
component dComparisonCell
|
51 |
|
|
generic ( W : integer := 32; -- V.D, minDistance and selectD Width
|
52 |
|
|
idColW : integer := 2; -- Column Sphere ID width. 1 = 2 columns max, 2= 4 colums max... and so on.
|
53 |
|
|
idCol : integer := 0 -- Column Id
|
54 |
|
|
);
|
55 |
|
|
port (
|
56 |
|
|
clk : in std_logic;
|
57 |
|
|
rst : in std_logic;
|
58 |
|
|
|
59 |
|
|
cIdd : in std_logic_vector (idColW - 1 downto 0); -- This is the reference column identification input.
|
60 |
|
|
cIdq : out std_logic_vector (idColW - 1 downto 0); -- This is the sphere identification output.
|
61 |
|
|
refvd : in std_logic_vector (W - 1 downto 0); -- This is the projection incoming from the previous cell.
|
62 |
|
|
colvd : in std_logic_vector (W - 1 downto 0); -- This is the projection of the sphere position over the ray traced vector, a.k.a. V.D! .
|
63 |
|
|
selvd : out std_logic_vector (W - 1 downto 0) -- This is the smallest value between refvd and colvd.
|
64 |
|
|
)
|
65 |
|
|
end component;
|
66 |
|
|
|
67 |
|
|
-- Dot Product Calculation.
|
68 |
|
|
component dotCell
|
69 |
|
|
generic ( levelW : integer := 18; -- Actual Level Width
|
70 |
|
|
nLevelW : integer := 32); -- Next Level Width
|
71 |
|
|
port (
|
72 |
|
|
clk : in std_logic;
|
73 |
|
|
rst : in std_logic;
|
74 |
|
|
|
75 |
|
|
-- Object control.
|
76 |
|
|
nxtSphere : in std_logic; -- This bit controls when the sphere center goes to the next row.
|
77 |
|
|
-- First Side.
|
78 |
|
|
vxInput : in std_logic_vector(levelW-1 downto 0);
|
79 |
|
|
vyInput : in std_logic_vector(levelW-1 downto 0);
|
80 |
|
|
vzInput : in std_logic_vector(levelW-1 downto 0);
|
81 |
|
|
|
82 |
|
|
-- Second Side (Opposite to the first one)
|
83 |
|
|
vxOutput : out std_logic_vector(levelW-1 downto 0);
|
84 |
|
|
vyOutput : out std_logic_vector(levelW-1 downto 0);
|
85 |
|
|
vzOutput : out std_logic_vector(levelW-1 downto 0);
|
86 |
|
|
|
87 |
|
|
-- Third Side (Perpendicular to the first and second ones)
|
88 |
|
|
dxInput : in std_logic_vector(levelW-1 downto 0);
|
89 |
|
|
dyInput : in std_logic_vector(levelW-1 downto 0);
|
90 |
|
|
dzInput : in std_logic_vector(levelW-1 downto 0);
|
91 |
|
|
|
92 |
|
|
--Fourth Side (Opposite to the third one)
|
93 |
|
|
dxOutput : in std_logic_vector(levelW-1 downto 0);
|
94 |
|
|
dyOutput : in std_logic_vector(levelW-1 downto 0);
|
95 |
|
|
dzOutput : in std_logic_vector(levelW-1 downto 0);
|
96 |
|
|
|
97 |
|
|
--Fifth Side (Going to the floor right upstairs!)
|
98 |
|
|
vdOutput : out std_logic_vector(nLevelW-1 downto 0); -- Dot product.
|
99 |
|
|
|
100 |
|
|
);
|
101 |
|
|
end component;
|
102 |
|
|
|
103 |
|
|
-- K discriminant comparison.
|
104 |
|
|
component kComparisonCell
|
105 |
|
|
generic ( W : integer := 32;
|
106 |
|
|
idW : integer := 12
|
107 |
|
|
);
|
108 |
|
|
port (
|
109 |
|
|
clk : in std_logic;
|
110 |
|
|
rst : in std_logic;
|
111 |
|
|
|
112 |
|
|
nxtRow : in std_logic; -- Controls when the sphere goes to the next Row.
|
113 |
|
|
vdinput : in std_logic_vector (W-1 downto 0);
|
114 |
|
|
kinput : in std_logic_vector (W-1 downto 0);
|
115 |
|
|
koutput : out std_logic_vector (W-1 downto 0);
|
116 |
|
|
|
117 |
|
|
sDP : out std_logic_vector (W-1 downto 0) -- Selected dot product.
|
118 |
|
|
|
119 |
|
|
|
120 |
|
|
);
|
121 |
|
|
end component;
|
122 |
|
|
|