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

Subversion Repositories jart

[/] [jart/] [branches/] [ver0branch/] [dotCell.vhd] - Blame information for rev 46

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 dot product cell.
25
 
26 14 jguarin200
library ieee;
27
use ieee.std_logic_1164.all;
28
use work.powerGrid.all;
29
 
30
entity dotCell is
31 36 jguarin200
 
32
        generic (       RV      : string := "yes";
33
                                W0      : integer := 18;        -- Actual Level Width
34
                                W1      : integer := 32);       -- Next Level Width
35 14 jguarin200
        port    (       clk             : in std_logic;
36
                                rst             : in std_logic;
37
 
38
                                -- Object control.
39 19 jguarin200
                                nxtSphere       : in std_logic; -- This signal controls when the sphere center goes to the next row.
40
                                nxtRay          : in std_logic; -- This signal controls when the ray goes to the next column.
41
 
42 14 jguarin200
                                -- First Side.
43 36 jguarin200
                                vxInput         : in std_logic_vector(W0-1 downto 0);
44
                                vyInput         : in std_logic_vector(W0-1 downto 0);
45
                                vzInput         : in std_logic_vector(W0-1 downto 0);
46 14 jguarin200
 
47
                                -- Second Side (Opposite to the first one)
48 36 jguarin200
                                vxOutput                : out std_logic_vector(W0-1 downto 0);
49
                                vyOutput                : out std_logic_vector(W0-1 downto 0);
50
                                vzOutput                : out std_logic_vector(W0-1 downto 0);
51 14 jguarin200
 
52
                                -- Third Side (Perpendicular to the first and second ones)
53 36 jguarin200
                                dxInput         : in std_logic_vector(W0-1 downto 0);
54
                                dyInput         : in std_logic_vector(W0-1 downto 0);
55
                                dzInput         : in std_logic_vector(W0-1 downto 0);
56 14 jguarin200
 
57
                                --Fourth Side (Opposite to the third one)
58 36 jguarin200
                                dxOutput                : out std_logic_vector(W0-1 downto 0);
59
                                dyOutput                : out std_logic_vector(W0-1 downto 0);
60
                                dzOutput                : out std_logic_vector(W0-1 downto 0);
61 14 jguarin200
 
62
                                --Fifth Side (Going to the floor right upstairs!)
63 36 jguarin200
                                vdOutput                : out std_logic_vector(W1-1 downto 0) -- Dot product.
64 14 jguarin200
 
65 17 jguarin200
        );
66 19 jguarin200
 
67 14 jguarin200
end entity;
68
 
69
 
70 19 jguarin200
architecture rtl of dotCell is
71 14 jguarin200
 
72
 
73 36 jguarin200
        signal s36vd    : std_logic_vector (2*W0-1 downto 0);
74
        signal s36m0    : std_logic_vector (2*W0-1 downto 0);
75
        signal s36m1    : std_logic_vector (2*W0-1 downto 0);
76
        signal s36m2    : std_logic_vector (2*W0-1 downto 0);
77 14 jguarin200
 
78 36 jguarin200
        signal pAdd     : std_logic_vector (W0-1 downto 0);
79 19 jguarin200
 
80
 
81 14 jguarin200
begin
82
 
83
        -- The Dotprod Machine
84 19 jguarin200
 
85
        -- 18x18 1 stage pipe Multipliers.
86
        m0      : p1m18 port map (
87
                aclr    => not(rst),
88
                clken   => nxtRay,
89
                clock   => clk,
90
                dataa   => vxInput,
91
                datab   => dxInput,
92
                result  => s36m0
93 14 jguarin200
                );
94 19 jguarin200
        m1      : p1m18 port map (
95
                aclr    => not(rst),
96
                clken   => nxtRay,
97
                clock   => clk,
98
                dataa   => vyInput,
99
                datab   => dyInput,
100
                result  => s36m1
101
                );
102
        m2      : p1m18 port map (
103
                aclr    => not(rst),
104
                clken   => nxtRay,
105
                clock   => clk,
106
                dataa   => vzInput,
107
                datab   => dzInput,
108
                result  => s36m2
109
                );
110 14 jguarin200
 
111 19 jguarin200
        --  36 bits a+b+c 1 stage pipe Adder. 
112 36 jguarin200
        a0      : p1ax  port map (
113 19 jguarin200
                clk             => clk,
114
                rst             => rst,
115
                enable  => nxtRay,
116
                dataa   => s36m0,
117
                datab   => s36m1,
118
                datac   => s36m2,
119
                result  => s36vd
120
                );
121
 
122
        -- Truncate the less signifcative 4 bits 35 downto 4.
123 36 jguarin200
        vdOutput <= s36vd (2*W0-1 downto 2*W0-W1);
124 19 jguarin200
 
125 14 jguarin200
        -- Ray PipeLine
126 19 jguarin200
        rayPipeStage : process (clk,rst,nxtRay)
127 14 jguarin200
        begin
128 19 jguarin200
 
129 14 jguarin200
                if rst = '0' then
130
                        -- There is no ray load yet.
131
                        dxOutput <= (others => '0');
132
                        dyOutput <= (others => '0');
133
                        dzOutput <= (others => '0');
134
 
135 19 jguarin200
                elsif rising_edge (clk) and nxtRay='1' then
136 14 jguarin200
 
137
                        -- Set 
138
                        dxOutput <= dxInput;
139
                        dyOutput <= dyInput;
140
                        dzOutput <= dzInput;
141
 
142
                end if;
143
 
144
        end process;
145
 
146
        -- Sphere Pipe Line
147 36 jguarin200
        registerV : if RV="yes" generate
148 14 jguarin200
 
149 36 jguarin200
                spherePipeStage : process (clk,rst,nxtSphere)
150
                begin
151
                        if rst = '0' then
152
 
153
                        -- There is no object center yet.
154
                                vxOutput <= (others => '0');
155
                                vyOutput <= (others => '0');
156
                                vzOutput <= (others => '0');
157
 
158
                        elsif rising_edge (clk) and nxtSphere ='1' then
159 14 jguarin200
 
160 36 jguarin200
                                -- Shift sphere to the next row.
161
 
162
                                        vxOutput <= vxInput;
163
                                        vyOutput <= vyInput;
164
                                        vzOutput <= vzInput;
165
 
166
                        end if;
167 14 jguarin200
 
168 36 jguarin200
                end process;
169 14 jguarin200
 
170 36 jguarin200
        end generate;
171 14 jguarin200
 
172
 
173
end rtl;
174
 
175
 
176
 
177
 
178
 
179
 

powered by: WebSVN 2.1.0

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