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

Subversion Repositories raytrac

[/] [raytrac/] [trunk/] [uf.vhd] - Blame information for rev 13

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

Line No. Rev Author Line
1 8 jguarin200
-- RAYTRAC
2
-- Author Julian Andres Guarin
3
-- uf.vhd
4
-- This file is part of raytrac.
5
-- 
6
--     raytrac is free software: you can redistribute it and/or modify
7
--     it under the terms of the GNU General Public License as published by
8
--     the Free Software Foundation, either version 3 of the License, or
9
--     (at your option) any later version.
10
-- 
11
--     raytrac is distributed in the hope that it will be useful,
12
--     but WITHOUT ANY WARRANTY; without even the implied warranty of
13
--     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
--     GNU General Public License for more details.
15
-- 
16
--     You should have received a copy of the GNU General Public License
17
--     along with raytrac.  If not, see <http://www.gnu.org/licenses/>.
18
 
19 2 jguarin200
library ieee;
20
use ieee.std_logic_1164.all;
21
use work.arithpack.all;
22
 
23
entity uf is
24
        port (
25 3 jguarin200
                opcode          : in std_logic;
26 8 jguarin200
                m0f0,m0f1,m1f0m1f1,m2f0,m2f1,m3f0,m3f1,m4f0,m4f1,m5f0,m5f1 : in std_logic_vector(17 downto 0);
27 13 jguarin200
                cpx,cpy,cpz,dp0,dp1 : out std_logic_vector(31 downto 0);
28 8 jguarin200
                clk,rst         : in std_logic
29 2 jguarin200
        );
30
end uf;
31
 
32
architecture uf_arch of uf is
33
 
34 8 jguarin200
        -- Stage 0 signals
35 2 jguarin200
 
36 8 jguarin200
        signal s0mf00,s0mf01,s0mf10,s0mf11,s0mf20,s0mf21,s0mf30,s0mf31,s0mf40,s0mf41,s0mf50,s0mf51 : std_logic_vector(17 downto 0);
37
        signal s0p0,s0p1, s0p2, s0p3, s0p4, s0p5 : std_logic_vector(31 downto 0);
38
        signal s0opcode;
39 2 jguarin200
 
40 8 jguarin200
        --Stage 1 signals 
41 2 jguarin200
 
42 8 jguarin200
        signal s1p0, s1p1, s1p2, s1p3, s1p4, s1p5 : std_logic_vector (31 downto 0);
43
        signal s1a0, s1a1, s1a2 : std_logic_vector (31 downto 0);
44
        signal s1opcode;
45 2 jguarin200
 
46 8 jguarin200
        -- Some support signals
47
        signal s1_internalCarry : std_logic_vector(2 downto 0);
48
        signal s2_internalCarry : std_logic_vector(1 downto 0);
49 2 jguarin200
 
50 8 jguarin200
        --Stage 2 signals
51
 
52
        signal s2a0, s2a2, s2a3, s2a4, s2p2, s2p3 : std_logic_vector (31 downto 0);
53
 
54
 
55
 
56 2 jguarin200
begin
57
 
58 8 jguarin200
        -- Multiplicator Instantiation (StAgE 0)
59 2 jguarin200
 
60 8 jguarin200
        m0 : r_a18_b18_smul_sc32_r
61
        port map (
62
                aclr    => rst,
63
                clock   => clk,
64
                dataa   => s0mf00,
65
                datab   => s0mf01,
66
                result  => s0p0
67
        );
68
        m1 : r_a18_b18_smul_sc32_r
69
        port map (
70
                aclr    => rst,
71
                clock   => clk,
72
                dataa   => s0mf10,
73
                datab   => s0mf11,
74
                result  => s0p1
75
        );
76
        m2 : r_a18_b18_smul_sc32_r
77
        port map (
78
                aclr    => rst,
79
                clock   => clk,
80
                dataa   => s0mf20,
81
                datab   => s0mf21,
82
                result  => s0p2
83
        );
84
        m3 : r_a18_b18_smul_sc32_r
85
        port map (
86
                aclr    => rst,
87
                clock   => clk,
88
                dataa   => s0mf30,
89
                datab   => s0mf31,
90
                result  => s0p3
91
        );
92
        m4 : r_a18_b18_smul_sc32_r
93
        port map (
94
                aclr    => rst,
95
                clock   => clk,
96
                dataa   => s0mf40,
97
                datab   => s0mf41,
98
                result  => s0p4
99
        );
100
        m5 : r_a18_b18_smul_sc32_r
101
        port map (
102
                aclr    => rst,
103
                clock   => clk,
104
                dataa   => s0mf50,
105
                datab   => s0mf51,
106
                result  => s0p5
107
        );
108
 
109
        -- Adder Instantiation (sTaGe 1)
110
 
111
        --Adder 0, low adder 
112
        a0low : adder
113
        generic map (
114
                w => 16,
115
                carry_logic             => "CLA",       --Carry Look Ahead Logic (More Gates Used, But Less Time)
116
                subtractor_selector     => "YES"        --Yes instantiate Xor gates stage in the adder so we can substract on the opcode signal command.
117
        )
118
        port map        (
119
                a => s1p0(15 downto 0),
120
                b => s1p1(15 downto 0),
121
                s => s1opcode,
122
                ci => '0',
123
                result => s1a0(15 downto 0),
124
                cout => s1_internalCarry(0)
125
        );
126
        --Adder 0, high adder
127
        a0high : adder
128
        generic map (
129
                w => 16,
130
                carry_logic             => "CLA",       --Carry Look Ahead Logic (More Gates Used, But Less Time)
131
                subtractor_selector     => "YES"        --Yes instantiate Xor gates stage in the adder so we can substract on the opcode signal command.
132
        )
133
        port map        (
134
                a => s1p0(31 downto 16),
135
                b => s1p1(31 downto 16),
136
                s => s1opcode,
137
                ci => s1_internalCarry(0),
138
                result => s1a0(31 downto 16),
139
                cout => open
140
        );
141
        --Adder 1, low adder 
142
        a1low : adder
143
        generic map (
144
                w => 16,
145
                carry_logic             => "CLA",       --Carry Look Ahead Logic (More Gates Used, But Less Time)
146
                subtractor_selector     => "YES"        --Yes instantiate Xor gates stage in the adder so we can substract on the opcode signal command.
147
        )
148
        port map        (
149
                a => s1p2(15 downto 0),
150
                b => s1p3(15 downto 0),
151
                s => s1opcode,
152
                ci => '0',
153
                result => s1a1(15 downto 0),
154
                cout => s1_internalCarry(1)
155
        );
156
        --Adder 1, high adder
157
        a1high : adder
158
        generic map (
159
                w => 16,
160
                carry_logic             => "CLA",       --Carry Look Ahead Logic (More Gates Used, But Less Time)
161
                subtractor_selector     => "YES"        --Yes instantiate Xor gates stage in the adder so we can substract on the opcode signal command.
162
        )
163
        port map        (
164
                a => s1p2(31 downto 16),
165
                b => s1p3(31 downto 16),
166
                s => s1opcode,
167
                ci => s1_internalCarry(1),
168
                result => s1a1(31 downto 16),
169
                cout => open
170
        );
171
        --Adder 2, low adder 
172
        a1low : adder
173
        generic map (
174
                w => 16,
175
                carry_logic             => "CLA",       --Carry Look Ahead Logic (More Gates Used, But Less Time)
176
                subtractor_selector     => "YES"        --Yes instantiate Xor gates stage in the adder so we can substract on the opcode signal command.
177
        )
178
        port map        (
179
                a => s1p4(15 downto 0),
180
                b => s1p5(15 downto 0),
181
                s => s1opcode,
182
                ci => '0',
183
                result => s1a2(15 downto 0),
184
                cout => s1_internalCarry(2)
185
        );
186
        --Adder 2, high adder
187
        a1high : adder
188
        generic map (
189
                w => 16,
190
                carry_logic             => "CLA",       --Carry Look Ahead Logic (More Gates Used, But Less Time)
191
                subtractor_selector     => "YES"        --Yes instantiate Xor gates stage in the adder so we can substract on the opcode signal command.
192
        )
193
        port map        (
194
                a => s1p4(31 downto 16),
195
                b => s1p5(31 downto 16),
196
                s => s1opcode,
197
                ci => s1_internalCarry(2),
198
                result => s1a2(31 downto 16),
199
                cout => open
200
        );
201
 
202
 
203
        -- Adder Instantiation (Stage 2)
204
        --Adder 3, low adder 
205
        a3low : adder
206
        generic map (
207
                w => 16,
208
                carry_logic             => "CLA",       --Carry Look Ahead Logic (More Gates Used, But Less Time)
209
                subtractor_selector     => "NO"         --No Just Add.
210
        )
211
        port map        (
212
                a => s2a0(15 downto 0),
213
                b => s2p2(15 downto 0),
214
                s => open,
215
                ci => '0',
216
                result => s2a3(15 downto 0),
217
                cout => s2_internalCarry(0)
218
        );
219
        --Adder 3, high adder
220
        a3high : adder
221
        generic map (
222
                w => 16,
223
                carry_logic             => "CLA",       --Carry Look Ahead Logic (More Gates Used, But Less Time)
224
                subtractor_selector     => "NO"         --No Just Add.
225
        )
226
        port map        (
227
                a => s2a0(31 downto 16),
228
                b => s2p2(31 downto 16),
229
                s => open,
230
                ci => s2_internalCarry(0),
231
                result => s2a3(31 downto 16),
232
                cout => open
233
        );
234
        --Adder 4, low adder 
235
        a4low : adder
236
        generic map (
237
                w => 16,
238
                carry_logic             => "CLA",       --Carry Look Ahead Logic (More Gates Used, But Less Time)
239
                subtractor_selector     => "NO"         --No Just Add.
240
        )
241
        port map        (
242
                a => s2p3(15 downto 0),
243
                b => s2a2(15 downto 0),
244
                s => open,
245
                ci => '0',
246
                result => s2a4(15 downto 0),
247
                cout => s2_internalCarry(1)
248
        );
249
        --Adder 4, high adder
250
        a4high : adder
251
        generic map (
252
                w => 16,
253
                carry_logic             => "CLA",       --Carry Look Ahead Logic (More Gates Used, But Less Time)
254
                subtractor_selector     => "NO"         --No Just Add.
255
        )
256
        port map        (
257
                a => s2p3(31 downto 16),
258
                b => s2a2(31 downto 16),
259
                s => open,
260
                ci => s2_internalCarry(1),
261
                result => s2a4(31 downto 16),
262
                cout => open
263
        );
264
 
265
        -- Incoming from opcoder.vhd signals into pipeline's stage 0.
266
        s0mf00 <= m0f0;
267
        s0mf01 <= m0f1;
268
        s0mf10 <= m1f0;
269
        s0mf11 <= m1f1;
270
        s0mf20 <= m2f0;
271
        s0mf21 <= m2f1;
272
        s0mf30 <= m3f0;
273
        s0mf31 <= m3f1;
274
        s0mf40 <= m4f0;
275
        s0mf41 <= m4f1;
276
        s0mf50 <= m5f0;
277
        s0mf51 <= m5f1;
278
 
279
        -- Signal sequencing: as the multipliers use registered output and registered input is not necessary to write the sequence of stage 0 signals to stage 1 signals.
280
        -- so the simplistic path is taken: simply connect stage 0 to stage 1 lines. However this would not apply for the opcode signal
281
        s1p0 <= s0p0;
282
        s1p1 <= s0p1;
283
        s1p2 <= s0p2;
284
        s1p3 <= s0p3;
285
        s1p4 <= s0p4;
286
        s1p5 <= s0p5;
287
 
288
 
289
        --Outcoming to the rest of the system (by the time i wrote this i dont know where this leads to... jeje)
290
        cpx <= s1a0;
291
        cpy <= s1a1;
292
        cpz <= s1a2;
293
        dp0 <= s2a3;
294
        dp1 <= s2a4;
295
 
296
        -- Looking into the design the stage 1 to stage 2 are the sequences pipe stages that must be controlled in this particular HDL.
297
        uf_seq: process (clk,rst)
298
        begin
299
 
300
                if rst=rstMasterValue then
301
                        s0opcode        <= (others => '0');
302
                        s1opcode        <= (others => '0');
303 3 jguarin200
 
304 8 jguarin200
                        s2a2 <= (others => '0');
305
                        s2p3 <= (others => '0');
306
                        s2p2 <= (others => '0');
307
                        s2a0 <= (others => '0');
308
 
309
                elsif clk'event and clk = '1' then
310
 
311
                        s2a2 <= s1a2;
312
                        s2p3 <= s1p3;
313
                        s2p2 <= s1p2;
314
                        s2a0 <= s1a0;
315 3 jguarin200
 
316 8 jguarin200
                        -- Opcode control sequence
317
                        s0opcode <= opcode;
318
                        s1opcode <= s0opcode;
319
 
320
                end if;
321
        end process uf_seq;
322 2 jguarin200
end uf_arch;

powered by: WebSVN 2.1.0

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