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

Subversion Repositories jart

[/] [jart/] [branches/] [ver0branch/] [dComparisonCell.vhd] - Blame information for rev 80

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
entity dComparisonCell is
34 39 jguarin200
        generic (
35
                W1      : integer := 32;        -- operands Width ( reference V.D and column V.D) 
36
                IDW     : integer := 2;         -- Column Sphere ID width. 1 = 2 columns max, 2= 4 colums max... and so on.
37
                C       : integer := 0           -- Column Id
38 14 jguarin200
        );
39
 
40
 
41
        port    (
42 39 jguarin200
                                -- The usual control signals.
43
                clk, rst, pipeOn        : in std_logic;
44
 
45
                -- Scan signals (not so usual)
46
                -- scanOut disables the main comparison functionality of the cell and turns it into a scan shift.
47
                -- when scanOut is set (1), scan shift mode is on, scanCommand commands what scan action is taking place,
48
                -- when scanCommand is set (1), a scan load action is taking place, when is not set (0) a scan shift is taking place.
49
                scanOut, scanCommand    : in std_logic;
50
 
51
                -- Reference intersection signal.
52
                intd : in std_logic;
53
                intq : out std_logic;
54
 
55
                cIdd    : in    std_logic_vector (IDW - 1 downto 0);     -- This is the reference column identification input.
56
                cIdq    : out   std_logic_vector (IDW - 1 downto 0);     -- This is the sphere identification output.
57
 
58
                refk    : in    std_logic_vector (W1 - 1 downto 0); -- This is the columns sphere constant
59
                colk    : in    std_logic_vector (W1 - 1 downto 0); -- This is the reference sphere constant
60 62 jguarin200
                selk    : out   std_logic_vector (W1 - 1 downto 0); -- This is the selected sphere constant
61 39 jguarin200
 
62
                refvd   : in    std_logic_vector (W1 - 1 downto 0);      -- This is the projection incoming from the previous cell.
63
                colvd   : in    std_logic_vector (W1 - 1 downto 0);      -- This is the projection of the sphere position over the ray traced vector, a.k.a. V.D! .
64
                selvd   : out   std_logic_vector (W1 - 1 downto 0)       -- This is the smallest value between refvd and colvd.
65 21 jguarin200
        );
66 14 jguarin200
 
67
end entity;
68
 
69
 
70
architecture rtl of dComparisonCell is
71
 
72 39 jguarin200
        signal          sena    : std_logic;    -- This signal enables the scan ff.
73
        signal          ssl32   : std_logic;    -- This signal indicates if refvd is less than colvd
74
        signal          qdist   : std_logic_vector (IDW+W1 downto 0);
75 21 jguarin200
 
76 14 jguarin200
begin
77
 
78 21 jguarin200
        -- A less than B comparison, check if colvd is less than refvd, meaning the act V.D less than actual min V.D
79 39 jguarin200
        cl32: sl32
80
        port map (
81
                dataa   => colvd,
82
                datab   => refvd,
83
                AlB             => ssl32
84
        );
85 14 jguarin200
 
86 32 jguarin200
        -- A flip flop with 2 to 1 mux.Selects between the smallest vd.
87 39 jguarin200
        selectorVD: scanFF generic map ( W => W1)
88
        port map (
89
                clk     => clk,
90
                rst => rst,
91
                ena     => pipeOn or scanOut,
92
                sel => (ssl32 and not(scanOut))or(scanCommand and scanOut),
93
                d0      => refvd,
94
                d1      => colvd,
95
                q       => selvd
96
        );
97
        -- Another flip flip with 2 to 1 mux. Selects the column id the intersection signal of the smallest vd and the selected K.
98
        selectorID: scanFF
99
        generic map     (
100 62 jguarin200
                W => W1+IDW+1
101 39 jguarin200
        )
102
        port map (
103
                clk => clk,
104
                rst     => rst,
105
                ena     => pipeOn or scanOut,
106
                sel     => (ssl32 and not(scanOut))or(scanCommand and scanOut),
107
                d0      => refk&cIdd&intd,
108
                d1      => colk&conv_std_logic_vector(C,IDW)&ssl32,
109
                q       => qdist
110
        );
111 32 jguarin200
 
112 39 jguarin200
        selk <= qdist(IDW + W1 downto IDW+1);
113
        cIdq <= qdist(IDW downto 1);
114 32 jguarin200
        intq <= qdist(0);
115
 
116 14 jguarin200
 
117
end rtl;

powered by: WebSVN 2.1.0

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