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

Subversion Repositories jart

[/] [jart/] [branches/] [ver0branch/] [yu.vhd] - Blame information for rev 85

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

Line No. Rev Author Line
1 77 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 vector Y component integrator. In a memory block of 1x16384 bits, it is stored the FY' that represents the first derivate of FY, this function is the Y function along any horizontal line in the image.
25
-- The derivative is stored in this way: logic 0 means a 0 pendant and logic 1 means a -1 pendant. So a counter with enable / disable control it is everything we need, and of course a load input  to represent the initial value added to the integral.   
26
 
27
library ieee;
28
use ieee.std_logic_1164.all;
29
use ieee.std_logic_signed.all;
30
use work.powerGrid.all;
31
 
32
 
33
entity yu is
34
        generic (
35
                TOP : integer := 1024;                                                          -- Define the max counting number.. the number must be expressed as 2 power, cause the range of counting is going to be defined as TOP-1 downto TOP/2.
36
                                                                                                                        -- However this is going to be by now, cause in the future the ray generation will GO on for higher resolution images , and perhaps it would be required a more extended range for the yu component.
37 80 jguarin200
                SCREENW : integer := 320                        --  resolution width is 320 
38 77 jguarin200
        );
39
        port (
40 80 jguarin200
                clk,rst,ena             : in std_logic;
41 77 jguarin200
                lineDone                : out std_logic;                                        -- Finished image row. once a hundred and sixty times....
42
                ypos                    : out integer range TOP/2 to TOP-1
43
--              ocntr                   : out integer range 0 to SCREENW/2 
44
        );
45
end entity;
46
 
47
architecture rtl of yu is
48
 
49
        -- 1x16384 bits, true dual port, ROM Memory declaration.
50
        -- This memory uses 2 cycles.. a memory fetch cycle and a data to q memory cycle.
51
        component yurom
52
        port
53
        (
54
                address_a       : in std_logic_vector (13 downto 0);
55
                address_b       : in std_logic_vector (13 downto 0);
56
                clock           : in std_logic ;
57
                q_a                     : out std_logic_vector (0 downto 0);
58
                q_b                     : out std_logic_vector (0 downto 0)
59
        );
60
 
61
        end component;
62
 
63
 
64 84 jguarin200
        constant linefeed : integer range 0 to (SCREENW/2) := (SCREENW/2)-2;
65 77 jguarin200
 
66
 
67
        -- Support signals.
68
        signal s1addf0  : std_logic_vector (13 downto 0);        -- The function 0 is the function of the y component derivative.
69
        signal s1addf1  : std_logic_vector (13 downto 0);        -- The function 1 is the function of the y component integration curve initial constant.
70
        signal sf0              : std_logic_vector (0 downto 0);  -- Derivative function
71
        signal sf1              : std_logic_vector (0 downto 0);  -- Derivative curve, initial constant derivative function.
72 84 jguarin200
        signal cc               : integer range 0 to SCREENW/2;
73
        signal f0 : integer range TOP/2 to TOP-1;
74 77 jguarin200
 
75
begin
76
 
77 84 jguarin200
        -- Connect f0, to the output.
78
        ypos <= f0;
79
 
80 77 jguarin200
        derivate : yurom
81
        port map (
82
                address_a       => s1addf0,
83
                address_b       => s1addf1,
84
                clock           => clk,
85
                q_a                     => sf0,
86
                q_b                     => sf1
87
        );
88
 
89
 
90 84 jguarin200
        integrationControl : process (clk,rst,ena)
91 77 jguarin200
                variable f1 : integer range TOP/2 to TOP-1;
92 84 jguarin200
        begin
93 77 jguarin200
 
94
                if rst='0' then
95 84 jguarin200
 
96
                        f0<=TOP-1;
97 77 jguarin200
                        f1:=TOP-1;
98 84 jguarin200
                        lineDone<='0';
99 77 jguarin200
 
100 84 jguarin200
                elsif rising_edge(clk) and ena='1' then
101
 
102
                        if cc=0 then
103
                                lineDone<='1';
104
                                if sf1(0) ='1' then
105
                                        f1 := f1 - 1;
106
                                end if;
107
                                f0 <= f1;
108 77 jguarin200
 
109 84 jguarin200
                        else
110
                                lineDone<='0';
111
                                if sf0(0) = '1' then
112
                                        f0 <= f0-1;
113
                                end if;
114 77 jguarin200
 
115 84 jguarin200
                        end if;
116 77 jguarin200
 
117
 
118 84 jguarin200
 
119
                end if;
120
 
121
 
122
        end process;
123
 
124
        counterControl : process (clk,rst,ena)
125
        begin
126
 
127
                if rst='0' then
128
 
129
                        cc<=0;
130
 
131
                elsif rising_edge(clk) and ena='1' then
132
                        if cc=(SCREENW/2)-1 then
133
                                cc<=0;
134
                        else
135
                                cc<=cc+1;
136 77 jguarin200
                        end if;
137 84 jguarin200
                end if;
138
 
139
        end process;
140
 
141
        addressControl : process (clk,rst,ena)
142
        begin
143
                if rst='0' then
144
                        -- Right from the start.
145
                        s1addf0 (13 downto 1) <= (others=>'0');          -- 00001.
146
                        s1addf0 (0) <= '1';
147
                        s1addf1 <= "11111010000000";    -- 3E80.        
148
 
149
                elsif rising_edge(clk) and ena='1' then
150
 
151
                        s1addf0 <= s1addf0+1;
152
                        -- Count f1 address (158)
153 77 jguarin200
                        if cc=linefeed then
154
                                s1addf1 <= s1addf1+1;
155
                        end if;
156
 
157
                end if;
158 84 jguarin200
 
159 77 jguarin200
        end process;
160
 
161 84 jguarin200
 
162
 
163
 
164
 
165 77 jguarin200
 
166
end rtl;
167
 
168
 
169
 
170
 
171
 
172
 

powered by: WebSVN 2.1.0

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