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

Subversion Repositories theia_gpu

[/] [theia_gpu/] [branches/] [beta_1.1/] [rtl/] [Collaterals/] [Module_RadixRMul.v] - Blame information for rev 170

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

Line No. Rev Author Line
1 39 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
FFD_POSEDGE_ASYNC_RESET #(1) FFOutputReadyDelay1
83
(
84
        .Clock( Clock ),
85
        .Clear( Reset ),
86
        .D( iInputReady ),
87
        .Q( wInputDelay1 )
88
);
89
 
90
FFD_POSEDGE_ASYNC_RESET #(1) FFOutputReadyDelay2
91
(
92
        .Clock( Clock ),
93
        .Clear( Reset ),
94
        .D(  wInputDelay1 ),
95
        .Q( OutputReady  )
96
);
97
 
98
wire [31:0] wA, w2A, w3A, wB;
99
wire SignA,SignB;
100
 
101
assign SignA = A[31];
102
assign SignB = B[31];
103
 
104
 
105
assign wB = (SignB == 1) ? ~B + 1'b1 : B;
106
assign wA = (SignA == 1) ? ~A + 1'b1 : A;
107
 
108
assign w2A = wA << 1;
109
assign w3A = w2A + wA;
110
 
111
wire [31:0] wPartialResult0,wPartialResult1,wPartialResult2,wPartialResult3,wPartialResult4,wPartialResult5;
112
wire [31:0] wPartialResult6,wPartialResult7,wPartialResult8,wPartialResult9,wPartialResult10,wPartialResult11;
113
wire [31:0] wPartialResult12,wPartialResult13,wPartialResult14,wPartialResult15;
114
 
115
MUX_4_TO_1_32Bits_FullParallel MUX0
116
(
117
                .i1( 32'b 0 ),
118
                .i2( wA ),
119
                .i3( w2A ),
120
                .i4( w3A ),
121
                .Sel( {wB[1],wB[0]} ),
122
                .O( wPartialResult0 )
123
);
124
 
125
 
126
MUX_4_TO_1_32Bits_FullParallel MUX1
127
(
128
                .i1( 32'b 0 ),
129
                .i2( wA ),
130
                .i3( w2A ),
131
                .i4( w3A ),
132
                .Sel( {wB[3],wB[2]} ),
133
                .O( wPartialResult1 )
134
);
135
 
136
MUX_4_TO_1_32Bits_FullParallel MUX2
137
(
138
                .i1( 32'b 0 ),
139
                .i2( wA ),
140
                .i3( w2A ),
141
                .i4( w3A ),
142
                .Sel( {wB[5],wB[4]} ),
143
                .O( wPartialResult2 )
144
);
145
 
146
MUX_4_TO_1_32Bits_FullParallel MUX3
147
(
148
                .i1( 32'b 0 ),
149
                .i2( wA ),
150
                .i3( w2A ),
151
                .i4( w3A ),
152
                .Sel( {wB[7],wB[6]} ),
153
                .O( wPartialResult3 )
154
);
155
 
156
MUX_4_TO_1_32Bits_FullParallel MUX4
157
(
158
                .i1( 32'b 0 ),
159
                .i2( wA ),
160
                .i3( w2A ),
161
                .i4( w3A ),
162
                .Sel( {wB[9],wB[8]} ),
163
                .O( wPartialResult4 )
164
);
165
 
166
MUX_4_TO_1_32Bits_FullParallel MUX5
167
(
168
                .i1( 32'b 0 ),
169
                .i2( wA ),
170
                .i3( w2A ),
171
                .i4( w3A ),
172
                .Sel( {wB[11],wB[10]} ),
173
                .O( wPartialResult5 )
174
);
175
 
176
MUX_4_TO_1_32Bits_FullParallel MUX6
177
(
178
                .i1( 32'b 0 ),
179
                .i2( wA ),
180
                .i3( w2A ),
181
                .i4( w3A ),
182
                .Sel( {wB[13],wB[12]} ),
183
                .O( wPartialResult6 )
184
);
185
 
186
MUX_4_TO_1_32Bits_FullParallel MUX7
187
(
188
                .i1( 32'b 0 ),
189
                .i2( wA ),
190
                .i3( w2A ),
191
                .i4( w3A ),
192
                .Sel( {wB[15],wB[14]} ),
193
                .O( wPartialResult7 )
194
);
195
 
196
MUX_4_TO_1_32Bits_FullParallel MUX8
197
(
198
                .i1( 32'b 0 ),
199
                .i2( wA ),
200
                .i3( w2A ),
201
                .i4( w3A ),
202
                .Sel( {wB[17],wB[16]} ),
203
                .O( wPartialResult8 )
204
);
205
 
206
MUX_4_TO_1_32Bits_FullParallel MUX9
207
(
208
                .i1( 32'b 0 ),
209
                .i2( wA ),
210
                .i3( w2A ),
211
                .i4( w3A ),
212
                .Sel( {wB[19],wB[18]} ),
213
                .O( wPartialResult9 )
214
);
215
 
216
MUX_4_TO_1_32Bits_FullParallel MUX10
217
(
218
                .i1( 32'b 0 ),
219
                .i2( wA ),
220
                .i3( w2A ),
221
                .i4( w3A ),
222
                .Sel( {wB[21],wB[20]} ),
223
                .O( wPartialResult10 )
224
);
225
 
226
MUX_4_TO_1_32Bits_FullParallel MUX11
227
(
228
                .i1( 32'b 0 ),
229
                .i2( wA ),
230
                .i3( w2A ),
231
                .i4( w3A ),
232
                .Sel( {wB[23],wB[22]} ),
233
                .O( wPartialResult11 )
234
);
235
 
236
MUX_4_TO_1_32Bits_FullParallel MUX12
237
(
238
                .i1( 32'b 0 ),
239
                .i2( wA ),
240
                .i3( w2A ),
241
                .i4( w3A ),
242
                .Sel( {wB[25],wB[24]} ),
243
                .O( wPartialResult12 )
244
);
245
 
246
MUX_4_TO_1_32Bits_FullParallel MUX13
247
(
248
                .i1( 32'b 0 ),
249
                .i2( wA ),
250
                .i3( w2A ),
251
                .i4( w3A ),
252
                .Sel( {wB[27],wB[26]} ),
253
                .O( wPartialResult13 )
254
);
255
 
256
MUX_4_TO_1_32Bits_FullParallel MUX14
257
(
258
                .i1( 32'b 0 ),
259
                .i2( wA ),
260
                .i3( w2A ),
261
                .i4( w3A ),
262
                .Sel( {wB[29],wB[28]} ),
263
                .O( wPartialResult14 )
264
);
265
 
266
MUX_4_TO_1_32Bits_FullParallel MUX15
267
(
268
                .i1( 32'b 0 ),
269
                .i2( wA ),
270
                .i3( w2A ),
271
                .i4( w3A ),
272
                .Sel( {wB[31],wB[30]} ),
273
                .O( wPartialResult15 )
274
);
275
 
276
 
277
 
278
wire[63:0] wPartialResult1_0,wPartialResult1_1,wPartialResult1_2,wPartialResult1_3,
279
wPartialResult1_4,wPartialResult1_5,wPartialResult1_6,wPartialResult1_7;
280
 
281
 
282
assign wPartialResult1_0 = (wPartialResult0) + (wPartialResult1<<2);
283
assign wPartialResult1_1 = (wPartialResult2 << 4) + (wPartialResult3<<6);
284
assign wPartialResult1_2 = (wPartialResult4 << 8) + (wPartialResult5<<10);
285
assign wPartialResult1_3 = (wPartialResult6 << 12)+ (wPartialResult7<<14);
286
assign wPartialResult1_4 = (wPartialResult8 << 16)+ (wPartialResult9<<18);
287
assign wPartialResult1_5 = (wPartialResult10 << 20) + (wPartialResult11<< 22);
288
assign wPartialResult1_6 = (wPartialResult12 << 24) + (wPartialResult13 << 26);
289
assign wPartialResult1_7 = (wPartialResult14 << 28) + (wPartialResult15 << 30);
290
 
291
 
292
 
293
 
294
wire [63:0] wPartialResult2_0,wPartialResult2_1,wPartialResult2_2,wPartialResult2_3;
295
 
296
assign wPartialResult2_0 = wPartialResult1_0 + wPartialResult1_1;
297
assign wPartialResult2_1 = wPartialResult1_2 + wPartialResult1_3;
298
assign wPartialResult2_2 = wPartialResult1_4 + wPartialResult1_5;
299
assign wPartialResult2_3 = wPartialResult1_6 + wPartialResult1_7;
300
 
301
wire [63:0] wPartialResult3_0,wPartialResult3_1;
302
 
303
assign wPartialResult3_0 = wPartialResult2_0 + wPartialResult2_1;
304
assign wPartialResult3_1 = wPartialResult2_2 + wPartialResult2_3;
305
 
306
wire [63:0] R_pre1,R_pre2;
307
 
308
//assign R_pre1 = (wPartialResult3_0 + wPartialResult3_1);
309
assign R_pre1 = (iUnscaled == 1) ? (wPartialResult3_0 + wPartialResult3_1) : ((wPartialResult3_0 + wPartialResult3_1) >> `SCALE);
310
 
311
assign R_pre2 = ( (SignA ^ SignB) == 1) ? ~R_pre1 + 1'b1 : R_pre1;
312
 
313
//assign R = R_pre2 >> `SCALE;
314
assign R = R_pre2;
315
 
316
endmodule

powered by: WebSVN 2.1.0

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