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

Subversion Repositories jart

[/] [jart/] [trunk/] [BLRT/] [kComparisonCell.vhd] - Diff between revs 17 and 20

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 17 Rev 20
-- Author : Julian Andres Guarin Reyes.
-- Author : Julian Andres Guarin Reyes.
-- Project : JART, Just Another Ray Tracer.
-- Project : JART, Just Another Ray Tracer.
-- email : jguarin2002 at gmail.com, j.guarin at javeriana.edu.co
-- email : jguarin2002 at gmail.com, j.guarin at javeriana.edu.co
 
 
-- This code was entirely written by Julian Andres Guarin Reyes.
-- This code was entirely written by Julian Andres Guarin Reyes.
-- The following code is licensed under GNU Public License
-- The following code is licensed under GNU Public License
-- http://www.gnu.org/licenses/gpl-3.0.txt.
-- http://www.gnu.org/licenses/gpl-3.0.txt.
 
 
 -- This file is part of JART (Just Another Ray Tracer).
 -- This file is part of JART (Just Another Ray Tracer).
 
 
    -- JART (Just Another Ray Tracer) is free software: you can redistribute it and/or modify
    -- JART (Just Another Ray Tracer) is free software: you can redistribute it and/or modify
    -- it under the terms of the GNU General Public License as published by
    -- it under the terms of the GNU General Public License as published by
    -- the Free Software Foundation, either version 3 of the License, or
    -- the Free Software Foundation, either version 3 of the License, or
    -- (at your option) any later version.
    -- (at your option) any later version.
 
 
    -- JART (Just Another Ray Tracer) is distributed in the hope that it will be useful,
    -- JART (Just Another Ray Tracer) is distributed in the hope that it will be useful,
    -- but WITHOUT ANY WARRANTY; without even the implied warranty of
    -- but WITHOUT ANY WARRANTY; without even the implied warranty of
    -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    -- GNU General Public License for more details.
    -- GNU General Public License for more details.
 
 
    -- You should have received a copy of the GNU General Public License
    -- You should have received a copy of the GNU General Public License
    -- along with JART (Just Another Ray Tracer).  If not, see <http://www.gnu.org/licenses/>.
    -- along with JART (Just Another Ray Tracer).  If not, see <http://www.gnu.org/licenses/>.
 
 
-- This is a discriminant proof cell.   
-- This is a discriminant proof cell.   
 
 
library ieee;
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_1164.all;
use work.powerGrid.all;
use work.powerGrid.all;
 
 
 
 
entity kComparisonCell is
entity kComparisonCell is
        generic (       W               : integer := 32;
        generic (       W               : integer := 32 );
                                idW             : integer := 12
 
                        );
 
        port (
        port (
                                clk                     : in std_logic;
                                clk,rst         : in std_logic;
                                rst                     : in std_logic;
 
 
 
                                nxtRow  : in std_logic; -- Controls when the sphere goes to the next Row. 
                                nxtSphere       : in std_logic; -- Controls when the sphere goes to the next Row. 
                                vdinput : in std_logic_vector (W-1 downto 0);
 
                                kinput  : in std_logic_vector (W-1 downto 0);
                                kinput  : in std_logic_vector (W-1 downto 0);
                                koutput : out std_logic_vector (W-1 downto 0);
                                koutput         : out std_logic_vector (W-1 downto 0);
 
 
                                sDP                     : out std_logic_vector (W-1 downto 0) -- Selected dot product.
                                vdinput         : in std_logic_vector (W-1 downto 0);    -- V.D input.
 
                                vdoutput        : out std_logic_vector (W-1 downto 0)    -- Selected dot product.
 
 
 
 
        );
        );
        end port;
        end port;
end entity;
end entity;
 
 
 
 
architecture rtl of kComparisonCell is
architecture rtl of kComparisonCell is
 
 
        signal ssge32   : std_logic;    -- Greater or equal signed signal.
        signal ssge32   : std_logic;    -- Signed "Greater or equal  than" signal.
 
 
begin
begin
 
 
        -- Instantiation of the compare.
        comparison : sge32 port map (
        discriminantCompare : ge32 port map (
 
                dataa    => vdinput,
                dataa    => vdinput,
                datab    => kinput,
                datab   => kinput,
                AgeB     => ssge32
                AgeB    => ssge32
        );
                );
 
 
 
 
        -- 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.
        -- 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.
 
        selector : process (rst,clk,ssg32)
        intersectionSelector : for i in 0 to W-1 generate
 
 
 
                selector : process (rst,clk)
 
                begin
                begin
 
 
                        if rst='0' then
                if rst='0' then
 
 
                                -- At the beginning set the Maximum over Maximum distance.
                                -- At the beginning set the Maximum over Maximum distance.
                                if i = W-1 then
                        vdoutput <= '0' & (others =>'1');
                                        sDP (i) <= '0';
 
                                else
 
                                        sDP (i) <= '1';
 
                                end if;
 
 
 
                        elsif rising_edge(clk) then
                elsif rising_edge(clk) then
 
 
                                if i = W-1 then
                        if ssge32 = '1' then -- If VD ids grater or equal than K .....
                                        sDP (i) <= ssge32 and vdinput(i);
                                vdoutput <= vdinput;
                                else
                                else
                                        sDP (i) <= (ssge32 and vdinput(i)) or not(ssge32);
                                vdoutput <= '0' & (others =>'1');
                                end if;
                                end if;
 
 
                        end if;
                end if;
 
 
                end process;
        end process;
 
 
        end generate;
        -- Behavioral : When nxtSphere is set, the Sphere and its K constant should go the the next row
 
 
        kPipeStage : process (clk,rst)
        kPipeStage : process (clk,rst,nxtSphere)
        begin
        begin
 
 
                if rst='0' then
                if rst='0' then
 
 
                        koutput <= (others => '0');
                        koutput <= (others => '0');
 
 
                elsif rising_edge(clk) and nxtRow='1' then
                elsif rising_edge(clk) and nxtSphere ='1' then
 
 
                        koutput <= kinput;
                        koutput <= kinput;
 
 
                else -- Avoid Latch Inference
 
 
 
                        koutput <= koutput;
 
 
 
                end if;
                end if;
 
 
        end process;
        end process;
 
 
 
 
 
 
end rtl;
end rtl;
 
 
 
 
 
 
 
 
 
 

powered by: WebSVN 2.1.0

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