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

Subversion Repositories jart

[/] [jart/] [trunk/] [BLRT/] [kComparisonCell.vhd] - Blame information for rev 17

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

Line No. Rev Author Line
1 17 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
-- This is a discriminant proof cell.   
25
 
26 14 jguarin200
library ieee;
27
use ieee.std_logic_1164.all;
28
use work.powerGrid.all;
29
 
30
 
31
entity kComparisonCell is
32
        generic (       W               : integer := 32;
33
                                idW             : integer := 12
34
                        );
35
        port (
36 17 jguarin200
                                clk                     : in std_logic;
37
                                rst                     : in std_logic;
38 14 jguarin200
 
39 17 jguarin200
                                nxtRow  : in std_logic; -- Controls when the sphere goes to the next Row. 
40 14 jguarin200
                                vdinput : in std_logic_vector (W-1 downto 0);
41
                                kinput  : in std_logic_vector (W-1 downto 0);
42
                                koutput : out std_logic_vector (W-1 downto 0);
43
 
44 17 jguarin200
                                sDP                     : out std_logic_vector (W-1 downto 0) -- Selected dot product.
45 14 jguarin200
 
46
 
47
        );
48
        end port;
49
end entity;
50
 
51
 
52
architecture rtl of kComparisonCell is
53
 
54 17 jguarin200
        signal ssge32   : std_logic;    -- Greater or equal signed signal.
55 14 jguarin200
 
56
begin
57
 
58
        -- Instantiation of the compare.
59
        discriminantCompare : ge32 port map (
60
                dataa    => vdinput,
61
                datab    => kinput,
62 17 jguarin200
                AgeB     => ssge32
63 14 jguarin200
        );
64
 
65
 
66 17 jguarin200
        -- When ssge32 (greater or equal signal) is set then V.D > kte, therefore intersection is confirmed and  V.D is to be shifted to the distance comparison grid.
67 14 jguarin200
 
68
        intersectionSelector : for i in 0 to W-1 generate
69
 
70
                selector : process (rst,clk)
71
                begin
72
 
73
                        if rst='0' then
74
 
75
                                -- At the beginning set the Maximum over Maximum distance.
76
                                if i = W-1 then
77
                                        sDP (i) <= '0';
78
                                else
79
                                        sDP (i) <= '1';
80
                                end if;
81
 
82
                        elsif rising_edge(clk) then
83
 
84
                                if i = W-1 then
85 17 jguarin200
                                        sDP (i) <= ssge32 and vdinput(i);
86 14 jguarin200
                                else
87 17 jguarin200
                                        sDP (i) <= (ssge32 and vdinput(i)) or not(ssge32);
88 14 jguarin200
                                end if;
89
 
90
                        end if;
91
 
92
                end process;
93
 
94
        end generate;
95
 
96
        kPipeStage : process (clk,rst)
97
        begin
98
 
99
                if rst='0' then
100
 
101
                        koutput <= (others => '0');
102
 
103 17 jguarin200
                elsif rising_edge(clk) and nxtRow='1' then
104 14 jguarin200
 
105
                        koutput <= kinput;
106 17 jguarin200
 
107
                else -- Avoid Latch Inference
108 14 jguarin200
 
109 17 jguarin200
                        koutput <= koutput;
110
 
111 14 jguarin200
                end if;
112
 
113
        end process;
114
 
115
 
116
 
117
end rtl;
118
 
119
 
120
 
121
 
122
 

powered by: WebSVN 2.1.0

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