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

Subversion Repositories jart

[/] [jart/] [branches/] [ver0branch/] [urs.vhd] - Blame information for rev 79

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

Line No. Rev Author Line
1 79 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/>.library ieee;
23
 
24
-- Unitary Ray Set generator. 
25
-- This file is the description of    
26
 
27
library ieee;
28
use ieee.std_logic_1164.all;
29
use ieee.std_logic_arith.all;
30
use ieee.std_logic_signed.all;
31
use work.powerGrid.all;
32
 
33
entity urs is
34
        generic (
35
                GRIDS   : integer := 2;         -- The number of grids.
36
                TOP             : integer := 1024;      -- Range.
37
                SCREENH : integer := 200;       -- Screen Height Resolution.
38
                SCREENW : integer := 320        -- Screen Width Resolution.
39
        );
40
 
41
        port (
42
                clk,rst,ena                     : in std_logic;                                         -- The usual control signals
43
                y                                       : out integer range TOP/2 to TOP-1;
44
                xn, xp, zp, zn,yp       : out std_logic_vector (mylog2(TOP-1,"signed")*GRIDS-1 downto 0); -- Signed
45
                urs                                     : out std_logic
46
 
47
        );
48
 
49
end entity;
50
 
51
 
52
architecture rtl of urs is
53
 
54
        constant localwidth0 : integer := mylog2(TOP-1,"signed"); -- 0 to 9 value. 10 sign.
55
 
56
 
57
        signal szpos,szneg,sxpos,sxneg          : integer range -TOP to TOP-1;
58
        signal sypos                                            : integer range 0 to TOP-1;
59
        signal slockd,slockq                            : std_logic;
60
        signal grid_enable                                      : std_logic_vector (GRIDS-1 downto 0);
61
 
62
        -- slockd : marks whenever a screen line has been finished.
63
        -- slockq : indicates if ycompo has already started.
64
 
65
begin
66
 
67
        xcompo : zu
68
        generic map (
69
                VALSTART => 34  -- Value required for X component.
70
        )
71
        port map (
72
                clk             => clk,
73
                rst     => rst,
74
                ena     => ena and slockq,
75
                clr             => slockd,
76
                zpos    => sxpos,
77
                zneg    => sxneg
78
 
79
        );
80
 
81
        zcompo : zu
82
        port map (
83
                clk             => clk,
84
                rst             => rst,
85
                ena             => slockd,
86
                clr             => slockd and not(slockq),
87
                zpos    => szpos,
88
                zneg    => szneg
89
 
90
        );
91
 
92
 
93
        ycompo : yu
94
        generic map (
95
 
96
                TOP     => TOP,
97
                SCREENW => SCREENW
98
        )
99
        port map(
100
                clk             => clk,
101
                rst             => rst,
102
                ena             => ena,
103
                lineDone=> slockd,
104
                ypos    => sypos
105
        );
106
 
107
        process (clk,rst,ena)
108
                variable colcounter             : integer range 0 to (SCREENW/2)-1;
109
                variable linecounter    : integer range 0 to (SCREENH/2)-1;
110
                variable gridindex              : integer range 0 to GRIDS-1;
111
        begin
112
 
113
                if rst ='0' then
114
 
115
 
116
                        slockq          <='0';
117
                        urs                     <='0';
118
                        linecounter := 0;
119
                        gridindex       := 0;
120
 
121
                elsif rising_edge(clk) and ena='1' then
122
                        y <= sypos;
123
                        -- Calculate the locked 
124
                        if slockq = '1' then -- If we already load the initial ypos value, then we must be unlocked!
125
                                if slockd = '1' then
126
                                        if linecounter = (SCREENW/2)-1 then
127
                                                urs <= '1'; -- Finished the URS.
128
                                        else
129
                                                linecounter:=linecounter+1;
130
                                        end if;
131
 
132
                                end if;
133
 
134
                        else
135
 
136
                                slockq <= slockd or slockq;
137
 
138
                        end if;
139
 
140
                        -- Calculate the enable. (One Hot Deco)
141
                        for i in 0 to GRIDS-1 loop
142
                                if i = gridindex then
143
                                        grid_enable(i)<='1';
144
                                else
145
                                        grid_enable(i)<='0';
146
                                end if;
147
                        end loop;
148
                        gridindex:=gridindex+1;
149
 
150
                end if;
151
 
152
        end process;
153
 
154
 
155
        rowExits : for i in 0 to GRIDS-1 generate
156
 
157
                process (clk,rst,grid_enable(i))
158
                begin
159
                        if rst = '0'  then
160
                                xp(localwidth0*(i+1)-1 downto (i*localwidth0))<= (others=>'0');
161
                                xn(localwidth0*(i+1)-1 downto (i*localwidth0))<= (others=>'0');
162
                                zp(localwidth0*(i+1)-1 downto (i*localwidth0))<= (others=>'0');
163
                                zn(localwidth0*(i+1)-1 downto (i*localwidth0))<= (others=>'0');
164
                                yp(localwidth0*(i+1)-1 downto (i*localwidth0))<= (others=>'0');
165
                        elsif rising_edge (clk) and grid_enable(i) = '1' then
166
                                xp(localwidth0*(i+1)-1 downto (i*localwidth0)) <= CONV_STD_LOGIC_VECTOR (sxpos,localwidth0);
167
                                zp(localwidth0*(i+1)-1 downto (i*localwidth0)) <= CONV_STD_LOGIC_VECTOR (szpos,localwidth0);
168
                                xn(localwidth0*(i+1)-1 downto (i*localwidth0)) <= CONV_STD_LOGIC_VECTOR (sxneg,localwidth0);
169
                                zn(localwidth0*(i+1)-1 downto (i*localwidth0)) <= CONV_STD_LOGIC_VECTOR (szneg,localwidth0);
170
                                yp(localwidth0*(i+1)-1 downto (i*localwidth0)) <= CONV_STD_LOGIC_VECTOR (sypos,localwidth0);
171
                        end if;
172
                end process;
173
        end generate rowExits;
174
        -- Result Intercalation.
175
 
176
 
177
 
178
 
179
 
180
 
181
end rtl;
182
 
183
 
184
 

powered by: WebSVN 2.1.0

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