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

Subversion Repositories jart

[/] [jart/] [trunk/] [BLRT/] [dotCell.vhd] - Blame information for rev 33

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

powered by: WebSVN 2.1.0

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