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

Subversion Repositories jart

[/] [jart/] [trunk/] [BLRT/] [dComparisonCell.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
-- A single fixed minimun distance comparison cell.
25 14 jguarin200
library ieee;
26
 
27
use ieee.std_logic_1164.all;
28
use ieee.std_logic_arith.all;
29
use ieee.std_logic_unsigned.all;
30
 
31
use work.powerGrid.all;
32
 
33
 
34
entity dComparisonCell is
35
        generic (       W               : integer := 32;        -- V.D, minDistance and selectD Width 
36
                                idColW  : integer := 2;         -- Column Sphere ID width. 1 = 2 columns max, 2= 4 colums max... and so on.
37
                                idCol   : integer := 0           -- Column Id
38
        );
39
 
40
 
41
        port    (
42
                                clk             : in std_logic;
43
                                rst             : in std_logic;
44
 
45
                                cIdd    : in    std_logic_vector (idColW - 1 downto 0);  -- This is the reference column identification input.
46
                                cIdq    : out   std_logic_vector (idColW - 1 downto 0);  -- This is the sphere identification output.
47
                                refvd   : in    std_logic_vector (W - 1 downto 0);               -- This is the projection incoming from the previous cell.
48
                                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! .
49
                                selvd   : out   std_logic_vector (W - 1 downto 0)                -- This is the smallest value between refvd and colvd.
50
        )
51
        end port;
52
 
53
 
54
 
55
end entity;
56
 
57
 
58
architecture rtl of dComparisonCell is
59
 
60 17 jguarin200
        signal ssl32 : std_logic;       -- This signal indicates if refvd is less than colvd
61 14 jguarin200
 
62
begin
63
 
64
        -- A less than B comparison, check if colvd is less than refvd, meaning the act V.D less than actual max V.D
65 17 jguarin200
        cl32                    : sl32  port map (      dataa   => colvd,
66 14 jguarin200
                                                                                datab   => refvd,
67
                                                                                AlB             => sl32
68
                                                                                );
69
 
70
        -- A flip flop with 2 to 1 mux.
71
        selector                : scanFF        generic map (   W = 32  )
72
                                                                port map        (       clk     => clk,
73
                                                                                                rst     => rst,
74 17 jguarin200
                                                                                                scLoad  => ssl32,
75 14 jguarin200
                                                                                                extData => colvd,
76
                                                                                                dStage  => refvd,
77
                                                                                                qStage  => selvd);
78
 
79
 
80
        colIdSelector : process (clk,rst)
81
        begin
82
 
83
                if rst = '0' then
84
 
85
                        --Set max Distance on reset and column identifier       
86
                        cIdq <= CONV_STD_LOGIC_VECTOR(idCol,idColW);
87
                        selvd(W-1) <= '0';
88
                        selvd(W-2 downto 0) <= (others => '1');
89
 
90
                elsif rising_edge(clk) then
91
 
92 17 jguarin200
                        if ssl32 ='0' then
93 14 jguarin200
 
94
                                -- If reference V.D. is less than column V.D then shift the reference id. 
95
                                cIdq <= cIdd;
96
 
97
                        else
98
 
99
                                --If column V.D. is less than
100
                                cIdq <= CONV_STD_LOGIC(idCol,idColW);
101
 
102
                end if;
103
 
104
 
105
        end process;
106
 
107
 
108
 
109
 
110
end rtl;

powered by: WebSVN 2.1.0

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