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

Subversion Repositories theia_gpu

[/] [theia_gpu/] [branches/] [beta_2.0/] [rtl/] [Module_RadixRMul.v] - Blame information for rev 218

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

Line No. Rev Author Line
1 213 diegovalve
`timescale 1ns / 1ps
2
`include "aDefinitions.v"
3
//////////////////////////////////////////////////////////////////////////////////
4
// Company: 
5
// Engineer: 
6
// 
7
// Create Date:    19:49:14 01/13/2009 
8
// Design Name: 
9
// Module Name:    RadixRMul 
10
// Project Name: 
11
// Target Devices: 
12
// Tool versions: 
13
// Description: 
14
//
15
// Dependencies: 
16
//
17
// Revision: 
18
// Revision 0.01 - File Created
19
// Additional Comments: 
20
//
21
//////////////////////////////////////////////////////////////////////////////////
22
 
23
`default_nettype none
24
 
25
 
26
//---------------------------------------------------
27
module MUX_4_TO_1_32Bits_FullParallel
28
(
29
        input wire [31:0] i1,i2,i3,i4,
30
        output reg [31:0] O,
31
        input wire [1:0] Sel
32
);
33
 
34
always @ ( Sel or i1 or i2 or i3 or i4 )
35
begin
36
        case (Sel)
37
                2'b00: O = i1;
38
                2'b01: O = i2;
39
                2'b10: O = i3;
40
                2'b11: O = i4;
41
        endcase
42
 
43
end
44
 
45
endmodule
46
//---------------------------------------------------
47
/*
48
module SHIFTER2_16_BITS
49
(
50
input wire C,
51
input wire[15:0] In,
52
output reg[15:0] Out
53
);
54
 
55
reg [15:0] Temp;
56
always @ (posedge C )
57
begin
58
        Out =  In << 2;
59
 
60
end
61
 
62
endmodule
63
*/
64
//---------------------------------------------------
65
module RADIX_R_MUL_32_FULL_PARALLEL
66
(
67
        input wire Clock,
68
        input wire Reset,
69
        input wire[31:0] A,
70
        input wire[31:0] B,
71
        output wire[63:0] R,
72
        input wire iUnscaled,
73
        input wire iInputReady,
74
        output wire OutputReady
75
 
76
 
77
);
78
 
79
 
80
wire wInputDelay1;
81
//-------------------
82
wire [31:0] wALatched,wBLatched;
83
FFD_POSEDGE_SYNCRONOUS_RESET # ( `WIDTH ) FFD1
84
(
85
        .Clock( Clock ),
86
        .Reset( Reset),
87
        .Enable( iInputReady ),
88
        .D( A ),
89
        .Q( wALatched)
90
);
91
FFD_POSEDGE_SYNCRONOUS_RESET # ( `WIDTH ) FFD2
92
(
93
        .Clock( Clock ),
94
        .Reset( Reset),
95
        .Enable( iInputReady ),
96
        .D( B ),
97
        .Q( wBLatched )
98
);
99
 
100
//-------------------
101
 
102
 
103
FFD_POSEDGE_SYNCRONOUS_RESET #(1) FFOutputReadyDelay1
104
(
105
        .Clock( Clock ),
106
        .Reset( Reset ),
107
        .Enable( 1'b1 ),
108
        .D( iInputReady ),
109
        .Q( wInputDelay1 )
110
);
111
 
112
FFD_POSEDGE_SYNCRONOUS_RESET #(1) FFOutputReadyDelay2
113
(
114
        .Clock( Clock ),
115
        .Reset( Reset ),
116
        .Enable( 1'b1 ),
117
        .D(  wInputDelay1 ),
118
        .Q( OutputReady  )
119
);
120
 
121
wire [31:0] wA, w2A, w3A, wB;
122
wire SignA,SignB;
123
 
124
assign SignA = wALatched[31];
125
assign SignB = wBLatched[31];
126
 
127
 
128
assign wB = (SignB == 1) ? ~wBLatched + 1'b1 : wBLatched;
129
assign wA = (SignA == 1) ? ~wALatched + 1'b1 : wALatched;
130
 
131
assign w2A = wA << 1;
132
assign w3A = w2A + wA;
133
 
134
wire [31:0] wPartialResult0,wPartialResult1,wPartialResult2,wPartialResult3,wPartialResult4,wPartialResult5;
135
wire [31:0] wPartialResult6,wPartialResult7,wPartialResult8,wPartialResult9,wPartialResult10,wPartialResult11;
136
wire [31:0] wPartialResult12,wPartialResult13,wPartialResult14,wPartialResult15;
137
 
138
MUX_4_TO_1_32Bits_FullParallel MUX0
139
(
140
                .i1( 32'b 0 ),
141
                .i2( wA ),
142
                .i3( w2A ),
143
                .i4( w3A ),
144
                .Sel( {wB[1],wB[0]} ),
145
                .O( wPartialResult0 )
146
);
147
 
148
 
149
MUX_4_TO_1_32Bits_FullParallel MUX1
150
(
151
                .i1( 32'b 0 ),
152
                .i2( wA ),
153
                .i3( w2A ),
154
                .i4( w3A ),
155
                .Sel( {wB[3],wB[2]} ),
156
                .O( wPartialResult1 )
157
);
158
 
159
MUX_4_TO_1_32Bits_FullParallel MUX2
160
(
161
                .i1( 32'b 0 ),
162
                .i2( wA ),
163
                .i3( w2A ),
164
                .i4( w3A ),
165
                .Sel( {wB[5],wB[4]} ),
166
                .O( wPartialResult2 )
167
);
168
 
169
MUX_4_TO_1_32Bits_FullParallel MUX3
170
(
171
                .i1( 32'b 0 ),
172
                .i2( wA ),
173
                .i3( w2A ),
174
                .i4( w3A ),
175
                .Sel( {wB[7],wB[6]} ),
176
                .O( wPartialResult3 )
177
);
178
 
179
MUX_4_TO_1_32Bits_FullParallel MUX4
180
(
181
                .i1( 32'b 0 ),
182
                .i2( wA ),
183
                .i3( w2A ),
184
                .i4( w3A ),
185
                .Sel( {wB[9],wB[8]} ),
186
                .O( wPartialResult4 )
187
);
188
 
189
MUX_4_TO_1_32Bits_FullParallel MUX5
190
(
191
                .i1( 32'b 0 ),
192
                .i2( wA ),
193
                .i3( w2A ),
194
                .i4( w3A ),
195
                .Sel( {wB[11],wB[10]} ),
196
                .O( wPartialResult5 )
197
);
198
 
199
MUX_4_TO_1_32Bits_FullParallel MUX6
200
(
201
                .i1( 32'b 0 ),
202
                .i2( wA ),
203
                .i3( w2A ),
204
                .i4( w3A ),
205
                .Sel( {wB[13],wB[12]} ),
206
                .O( wPartialResult6 )
207
);
208
 
209
MUX_4_TO_1_32Bits_FullParallel MUX7
210
(
211
                .i1( 32'b 0 ),
212
                .i2( wA ),
213
                .i3( w2A ),
214
                .i4( w3A ),
215
                .Sel( {wB[15],wB[14]} ),
216
                .O( wPartialResult7 )
217
);
218
 
219
MUX_4_TO_1_32Bits_FullParallel MUX8
220
(
221
                .i1( 32'b 0 ),
222
                .i2( wA ),
223
                .i3( w2A ),
224
                .i4( w3A ),
225
                .Sel( {wB[17],wB[16]} ),
226
                .O( wPartialResult8 )
227
);
228
 
229
MUX_4_TO_1_32Bits_FullParallel MUX9
230
(
231
                .i1( 32'b 0 ),
232
                .i2( wA ),
233
                .i3( w2A ),
234
                .i4( w3A ),
235
                .Sel( {wB[19],wB[18]} ),
236
                .O( wPartialResult9 )
237
);
238
 
239
MUX_4_TO_1_32Bits_FullParallel MUX10
240
(
241
                .i1( 32'b 0 ),
242
                .i2( wA ),
243
                .i3( w2A ),
244
                .i4( w3A ),
245
                .Sel( {wB[21],wB[20]} ),
246
                .O( wPartialResult10 )
247
);
248
 
249
MUX_4_TO_1_32Bits_FullParallel MUX11
250
(
251
                .i1( 32'b 0 ),
252
                .i2( wA ),
253
                .i3( w2A ),
254
                .i4( w3A ),
255
                .Sel( {wB[23],wB[22]} ),
256
                .O( wPartialResult11 )
257
);
258
 
259
MUX_4_TO_1_32Bits_FullParallel MUX12
260
(
261
                .i1( 32'b 0 ),
262
                .i2( wA ),
263
                .i3( w2A ),
264
                .i4( w3A ),
265
                .Sel( {wB[25],wB[24]} ),
266
                .O( wPartialResult12 )
267
);
268
 
269
MUX_4_TO_1_32Bits_FullParallel MUX13
270
(
271
                .i1( 32'b 0 ),
272
                .i2( wA ),
273
                .i3( w2A ),
274
                .i4( w3A ),
275
                .Sel( {wB[27],wB[26]} ),
276
                .O( wPartialResult13 )
277
);
278
 
279
MUX_4_TO_1_32Bits_FullParallel MUX14
280
(
281
                .i1( 32'b 0 ),
282
                .i2( wA ),
283
                .i3( w2A ),
284
                .i4( w3A ),
285
                .Sel( {wB[29],wB[28]} ),
286
                .O( wPartialResult14 )
287
);
288
 
289
MUX_4_TO_1_32Bits_FullParallel MUX15
290
(
291
                .i1( 32'b 0 ),
292
                .i2( wA ),
293
                .i3( w2A ),
294
                .i4( w3A ),
295
                .Sel( {wB[31],wB[30]} ),
296
                .O( wPartialResult15 )
297
);
298
 
299
 
300
 
301
wire[63:0] wPartialResult1_0,wPartialResult1_1,wPartialResult1_2,wPartialResult1_3,
302
wPartialResult1_4,wPartialResult1_5,wPartialResult1_6,wPartialResult1_7;
303
 
304
 
305
 
306
assign wPartialResult1_0 = ({32'b0,wPartialResult0}) + ({32'b0,wPartialResult1}<<2);
307
assign wPartialResult1_1 = ({32'b0,wPartialResult2} << 4) + ({32'b0,wPartialResult3}<<6);
308
assign wPartialResult1_2 = ({32'b0,wPartialResult4} << 8) + ({32'b0,wPartialResult5}<<10);
309
assign wPartialResult1_3 = ({32'b0,wPartialResult6} << 12)+ ({32'b0,wPartialResult7}<<14);
310
assign wPartialResult1_4 = ({32'b0,wPartialResult8} << 16)+ ({32'b0,wPartialResult9}<<18);
311
assign wPartialResult1_5 = ({32'b0,wPartialResult10} << 20) + ({32'b0,wPartialResult11}<< 22);
312
assign wPartialResult1_6 = ({32'b0,wPartialResult12} << 24) + ({32'b0,wPartialResult13} << 26);
313
assign wPartialResult1_7 = ({32'b0,wPartialResult14} << 28) + ({32'b0,wPartialResult15} << 30);
314
 
315
 
316
 
317
 
318
wire [63:0] wPartialResult2_0,wPartialResult2_1,wPartialResult2_2,wPartialResult2_3;
319
 
320
assign wPartialResult2_0 = wPartialResult1_0 + wPartialResult1_1;
321
assign wPartialResult2_1 = wPartialResult1_2 + wPartialResult1_3;
322
assign wPartialResult2_2 = wPartialResult1_4 + wPartialResult1_5;
323
assign wPartialResult2_3 = wPartialResult1_6 + wPartialResult1_7;
324
 
325
wire [63:0] wPartialResult3_0,wPartialResult3_1;
326
 
327
assign wPartialResult3_0 = wPartialResult2_0 + wPartialResult2_1;
328
assign wPartialResult3_1 = wPartialResult2_2 + wPartialResult2_3;
329
 
330
wire [63:0] R_pre1,R_pre2;
331
 
332
//assign R_pre1 = (wPartialResult3_0 + wPartialResult3_1);
333
assign R_pre1 = (iUnscaled == 1) ? (wPartialResult3_0 + wPartialResult3_1) : ((wPartialResult3_0 + wPartialResult3_1) >> `SCALE);
334
 
335
assign R_pre2 = ( (SignA ^ SignB) == 1) ? ~R_pre1 + 1'b1 : R_pre1;
336
 
337
//assign R = R_pre2 >> `SCALE;
338
assign R = R_pre2;
339
 
340
endmodule

powered by: WebSVN 2.1.0

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