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

Subversion Repositories nova

[/] [nova/] [trunk/] [src/] [Inter_pred_LPE.v] - Blame information for rev 11

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 10 eexuke
//--------------------------------------------------------------------------------------------------
2
// Design    : nova
3
// Author(s) : Ke Xu
4
// Email           : eexuke@yahoo.com
5
// File      : Inter_pred_LPE.v
6
// Generated : Oct 11, 2005
7
// Copyright (C) 2008 Ke Xu                
8
//-------------------------------------------------------------------------------------------------
9
// Description 
10
// Processing Element for Inter prediction of Luma pixels
11
//-------------------------------------------------------------------------------------------------
12
 
13
// synopsys translate_off
14
`include "timescale.v"
15
// synopsys translate_on
16
`include "nova_defines.v"
17
 
18
module Inter_pred_LPE (clk,reset_n,pos_FracL,IsInterLuma,
19
        blk4x4_inter_calculate_counter,
20
        Inter_H_window_0_0,Inter_H_window_1_0,Inter_H_window_2_0,Inter_H_window_3_0,Inter_H_window_4_0,Inter_H_window_5_0,
21
        Inter_H_window_0_1,Inter_H_window_1_1,Inter_H_window_2_1,Inter_H_window_3_1,Inter_H_window_4_1,Inter_H_window_5_1,
22
        Inter_H_window_0_2,Inter_H_window_1_2,Inter_H_window_2_2,Inter_H_window_3_2,Inter_H_window_4_2,Inter_H_window_5_2,
23
        Inter_H_window_0_3,Inter_H_window_1_3,Inter_H_window_2_3,Inter_H_window_3_3,Inter_H_window_4_3,Inter_H_window_5_3,
24
        Inter_H_window_0_4,Inter_H_window_1_4,Inter_H_window_2_4,Inter_H_window_3_4,Inter_H_window_4_4,Inter_H_window_5_4,
25
        Inter_H_window_0_5,Inter_H_window_1_5,Inter_H_window_2_5,Inter_H_window_3_5,Inter_H_window_4_5,Inter_H_window_5_5,
26
        Inter_H_window_0_6,Inter_H_window_1_6,Inter_H_window_2_6,Inter_H_window_3_6,Inter_H_window_4_6,Inter_H_window_5_6,
27
        Inter_H_window_0_7,Inter_H_window_1_7,Inter_H_window_2_7,Inter_H_window_3_7,Inter_H_window_4_7,Inter_H_window_5_7,
28
        Inter_H_window_0_8,Inter_H_window_1_8,Inter_H_window_2_8,Inter_H_window_3_8,Inter_H_window_4_8,Inter_H_window_5_8,
29
        Inter_V_window_0,Inter_V_window_1,Inter_V_window_2,Inter_V_window_3,Inter_V_window_4,
30
        Inter_V_window_5,Inter_V_window_6,Inter_V_window_7,Inter_V_window_8,
31
        Inter_bi_window_0,Inter_bi_window_1,Inter_bi_window_2,Inter_bi_window_3,
32
 
33
        LPE0_out,LPE1_out,LPE2_out,LPE3_out
34
        );
35
        input clk,reset_n;
36
        input [3:0] pos_FracL;
37
        input IsInterLuma;
38
        input [3:0] blk4x4_inter_calculate_counter;
39
 
40
        input [7:0] Inter_H_window_0_0,Inter_H_window_1_0,Inter_H_window_2_0,Inter_H_window_3_0,Inter_H_window_4_0,Inter_H_window_5_0;
41
        input [7:0] Inter_H_window_0_1,Inter_H_window_1_1,Inter_H_window_2_1,Inter_H_window_3_1,Inter_H_window_4_1,Inter_H_window_5_1;
42
        input [7:0] Inter_H_window_0_2,Inter_H_window_1_2,Inter_H_window_2_2,Inter_H_window_3_2,Inter_H_window_4_2,Inter_H_window_5_2;
43
        input [7:0] Inter_H_window_0_3,Inter_H_window_1_3,Inter_H_window_2_3,Inter_H_window_3_3,Inter_H_window_4_3,Inter_H_window_5_3;
44
        input [7:0] Inter_H_window_0_4,Inter_H_window_1_4,Inter_H_window_2_4,Inter_H_window_3_4,Inter_H_window_4_4,Inter_H_window_5_4;
45
        input [7:0] Inter_H_window_0_5,Inter_H_window_1_5,Inter_H_window_2_5,Inter_H_window_3_5,Inter_H_window_4_5,Inter_H_window_5_5;
46
        input [7:0] Inter_H_window_0_6,Inter_H_window_1_6,Inter_H_window_2_6,Inter_H_window_3_6,Inter_H_window_4_6,Inter_H_window_5_6;
47
        input [7:0] Inter_H_window_0_7,Inter_H_window_1_7,Inter_H_window_2_7,Inter_H_window_3_7,Inter_H_window_4_7,Inter_H_window_5_7;
48
        input [7:0] Inter_H_window_0_8,Inter_H_window_1_8,Inter_H_window_2_8,Inter_H_window_3_8,Inter_H_window_4_8,Inter_H_window_5_8;
49
        input [7:0] Inter_V_window_0,Inter_V_window_1,Inter_V_window_2,Inter_V_window_3,Inter_V_window_4;
50
        input [7:0] Inter_V_window_5,Inter_V_window_6,Inter_V_window_7,Inter_V_window_8;
51
        input [7:0] Inter_bi_window_0,Inter_bi_window_1,Inter_bi_window_2,Inter_bi_window_3;
52
 
53
        output [7:0] LPE0_out,LPE1_out,LPE2_out,LPE3_out;
54
 
55
        reg [7:0] LPE0_out,LPE1_out,LPE2_out,LPE3_out;
56
 
57
        reg [14:0] b0_raw_reg,b1_raw_reg,b2_raw_reg,b3_raw_reg,b4_raw_reg,b5_raw_reg,b6_raw_reg,b7_raw_reg,b8_raw_reg;
58
        reg [7:0] b0_reg,b1_reg,b2_reg,b3_reg;
59
        reg [7:0] h0_reg,h1_reg,h2_reg,h3_reg;
60
        //------------------------
61
        //Vertical 6tap filter
62
        //------------------------
63
        wire Is_V_jfqik; //Is_V_jfqik: whether read from original [7:0] integer pixels and round as +16 >> 5 or read from b_raw[14:0] and round as +512 >> 10
64
        wire [14:0] V_6tapfilter0_A,V_6tapfilter0_B,V_6tapfilter0_C,V_6tapfilter0_D,V_6tapfilter0_E,V_6tapfilter0_F;
65
        wire [14:0] V_6tapfilter1_A,V_6tapfilter1_B,V_6tapfilter1_C,V_6tapfilter1_D,V_6tapfilter1_E,V_6tapfilter1_F;
66
        wire [14:0] V_6tapfilter2_A,V_6tapfilter2_B,V_6tapfilter2_C,V_6tapfilter2_D,V_6tapfilter2_E,V_6tapfilter2_F;
67
        wire [14:0] V_6tapfilter3_A,V_6tapfilter3_B,V_6tapfilter3_C,V_6tapfilter3_D,V_6tapfilter3_E,V_6tapfilter3_F;
68
        wire [7:0] V_6tapfilter0_round_out,V_6tapfilter1_round_out,V_6tapfilter2_round_out,V_6tapfilter3_round_out;
69
        filterV_6tap V_6tapfilter0 (
70
                .A(V_6tapfilter0_A),
71
                .B(V_6tapfilter0_B),
72
                .C(V_6tapfilter0_C),
73
                .D(V_6tapfilter0_D),
74
                .E(V_6tapfilter0_E),
75
                .F(V_6tapfilter0_F),
76
                .Is_jfqik(Is_V_jfqik),
77
                .round_out(V_6tapfilter0_round_out)
78
                );
79
        filterV_6tap V_6tapfilter1 (
80
                .A(V_6tapfilter1_A),
81
                .B(V_6tapfilter1_B),
82
                .C(V_6tapfilter1_C),
83
                .D(V_6tapfilter1_D),
84
                .E(V_6tapfilter1_E),
85
                .F(V_6tapfilter1_F),
86
                .Is_jfqik(Is_V_jfqik),
87
                .round_out(V_6tapfilter1_round_out)
88
                );
89
        filterV_6tap V_6tapfilter2 (
90
                .A(V_6tapfilter2_A),
91
                .B(V_6tapfilter2_B),
92
                .C(V_6tapfilter2_C),
93
                .D(V_6tapfilter2_D),
94
                .E(V_6tapfilter2_E),
95
                .F(V_6tapfilter2_F),
96
                .Is_jfqik(Is_V_jfqik),
97
                .round_out(V_6tapfilter2_round_out)
98
                );
99
        filterV_6tap V_6tapfilter3 (
100
                .A(V_6tapfilter3_A),
101
                .B(V_6tapfilter3_B),
102
                .C(V_6tapfilter3_C),
103
                .D(V_6tapfilter3_D),
104
                .E(V_6tapfilter3_E),
105
                .F(V_6tapfilter3_F),
106
                .Is_jfqik(Is_V_jfqik),
107
                .round_out(V_6tapfilter3_round_out)
108
                );
109
        assign Is_V_jfqik = (
110
        (pos_FracL == `pos_j && (
111
                        blk4x4_inter_calculate_counter == 4'd4 || blk4x4_inter_calculate_counter == 4'd3 ||
112
                        blk4x4_inter_calculate_counter == 4'd2 || blk4x4_inter_calculate_counter == 4'd1))      ||
113
        ((pos_FracL == `pos_f || pos_FracL == `pos_q) && (
114
                        blk4x4_inter_calculate_counter == 4'd4 || blk4x4_inter_calculate_counter == 4'd3 ||
115
                        blk4x4_inter_calculate_counter == 4'd2 || blk4x4_inter_calculate_counter == 4'd1))      ||
116
        ((pos_FracL == `pos_i || pos_FracL == `pos_k) && (
117
                        blk4x4_inter_calculate_counter == 4'd7 || blk4x4_inter_calculate_counter == 4'd5 ||
118
                        blk4x4_inter_calculate_counter == 4'd3 || blk4x4_inter_calculate_counter == 4'd1)))? 1'b1:1'b0;
119
 
120
        assign V_6tapfilter0_A = (Is_V_jfqik)? b0_raw_reg:{7'b0,Inter_V_window_0};
121
        assign V_6tapfilter0_B = (Is_V_jfqik)? b1_raw_reg:{7'b0,Inter_V_window_1};
122
        assign V_6tapfilter0_C = (Is_V_jfqik)? b2_raw_reg:{7'b0,Inter_V_window_2};
123
        assign V_6tapfilter0_D = (Is_V_jfqik)? b3_raw_reg:{7'b0,Inter_V_window_3};
124
        assign V_6tapfilter0_E = (Is_V_jfqik)? b4_raw_reg:{7'b0,Inter_V_window_4};
125
        assign V_6tapfilter0_F = (Is_V_jfqik)? b5_raw_reg:{7'b0,Inter_V_window_5};
126
 
127
        assign V_6tapfilter1_A = (Is_V_jfqik)? b1_raw_reg:{7'b0,Inter_V_window_1};
128
        assign V_6tapfilter1_B = (Is_V_jfqik)? b2_raw_reg:{7'b0,Inter_V_window_2};
129
        assign V_6tapfilter1_C = (Is_V_jfqik)? b3_raw_reg:{7'b0,Inter_V_window_3};
130
        assign V_6tapfilter1_D = (Is_V_jfqik)? b4_raw_reg:{7'b0,Inter_V_window_4};
131
        assign V_6tapfilter1_E = (Is_V_jfqik)? b5_raw_reg:{7'b0,Inter_V_window_5};
132
        assign V_6tapfilter1_F = (Is_V_jfqik)? b6_raw_reg:{7'b0,Inter_V_window_6};
133
 
134
        assign V_6tapfilter2_A = (Is_V_jfqik)? b2_raw_reg:{7'b0,Inter_V_window_2};
135
        assign V_6tapfilter2_B = (Is_V_jfqik)? b3_raw_reg:{7'b0,Inter_V_window_3};
136
        assign V_6tapfilter2_C = (Is_V_jfqik)? b4_raw_reg:{7'b0,Inter_V_window_4};
137
        assign V_6tapfilter2_D = (Is_V_jfqik)? b5_raw_reg:{7'b0,Inter_V_window_5};
138
        assign V_6tapfilter2_E = (Is_V_jfqik)? b6_raw_reg:{7'b0,Inter_V_window_6};
139
        assign V_6tapfilter2_F = (Is_V_jfqik)? b7_raw_reg:{7'b0,Inter_V_window_7};
140
 
141
        assign V_6tapfilter3_A = (Is_V_jfqik)? b3_raw_reg:{7'b0,Inter_V_window_3};
142
        assign V_6tapfilter3_B = (Is_V_jfqik)? b4_raw_reg:{7'b0,Inter_V_window_4};
143
        assign V_6tapfilter3_C = (Is_V_jfqik)? b5_raw_reg:{7'b0,Inter_V_window_5};
144
        assign V_6tapfilter3_D = (Is_V_jfqik)? b6_raw_reg:{7'b0,Inter_V_window_6};
145
        assign V_6tapfilter3_E = (Is_V_jfqik)? b7_raw_reg:{7'b0,Inter_V_window_7};
146
        assign V_6tapfilter3_F = (Is_V_jfqik)? b8_raw_reg:{7'b0,Inter_V_window_8};
147
 
148
        //------------------------
149
        //Horizontal 6tap filter
150
        //------------------------
151
        wire H_need_round;
152
        wire [14:0] H_6tapfilter0_raw_out;
153
        wire [14:0] H_6tapfilter1_raw_out;
154
        wire [14:0] H_6tapfilter2_raw_out;
155
        wire [14:0] H_6tapfilter3_raw_out;
156
        wire [14:0] H_6tapfilter4_raw_out;
157
        wire [14:0] H_6tapfilter5_raw_out;
158
        wire [14:0] H_6tapfilter6_raw_out;
159
        wire [14:0] H_6tapfilter7_raw_out;
160
        wire [14:0] H_6tapfilter8_raw_out;
161
        wire [7:0]  H_6tapfilter0_round_out;
162
        wire [7:0]  H_6tapfilter1_round_out;
163
        wire [7:0]  H_6tapfilter2_round_out;
164
        wire [7:0]  H_6tapfilter3_round_out;
165
        wire [7:0]  H_6tapfilter4_round_out;
166
        wire [7:0]  H_6tapfilter5_round_out;
167
        wire [7:0]  H_6tapfilter6_round_out;
168
        wire [7:0]  H_6tapfilter7_round_out;
169
        wire [7:0]  H_6tapfilter8_round_out;
170
 
171
        assign H_need_round = (blk4x4_inter_calculate_counter != 0 && pos_FracL != `pos_Int && pos_FracL != `pos_i
172
        && pos_FracL != `pos_j && pos_FracL != `pos_k && pos_FracL != `pos_d && pos_FracL != `pos_n);
173
 
174
        filterH_6tap H_6tapfilter0 (
175
                .A(Inter_H_window_0_0),
176
                .B(Inter_H_window_1_0),
177
                .C(Inter_H_window_2_0),
178
                .D(Inter_H_window_3_0),
179
                .E(Inter_H_window_4_0),
180
                .F(Inter_H_window_5_0),
181
                .H_need_round(1'b0),
182
                .raw_out(H_6tapfilter0_raw_out),
183
                .round_out(H_6tapfilter0_round_out)
184
                );
185
        filterH_6tap H_6tapfilter1 (
186
                .A(Inter_H_window_0_1),
187
                .B(Inter_H_window_1_1),
188
                .C(Inter_H_window_2_1),
189
                .D(Inter_H_window_3_1),
190
                .E(Inter_H_window_4_1),
191
                .F(Inter_H_window_5_1),
192
                .H_need_round(1'b0),
193
                .raw_out(H_6tapfilter1_raw_out),
194
                .round_out(H_6tapfilter1_round_out)
195
                );
196
        filterH_6tap H_6tapfilter2 (
197
                .A(Inter_H_window_0_2),
198
                .B(Inter_H_window_1_2),
199
                .C(Inter_H_window_2_2),
200
                .D(Inter_H_window_3_2),
201
                .E(Inter_H_window_4_2),
202
                .F(Inter_H_window_5_2),
203
                .H_need_round(H_need_round),
204
                .raw_out(H_6tapfilter2_raw_out),
205
                .round_out(H_6tapfilter2_round_out)
206
                );
207
        filterH_6tap H_6tapfilter3 (
208
                .A(Inter_H_window_0_3),
209
                .B(Inter_H_window_1_3),
210
                .C(Inter_H_window_2_3),
211
                .D(Inter_H_window_3_3),
212
                .E(Inter_H_window_4_3),
213
                .F(Inter_H_window_5_3),
214
                .H_need_round(H_need_round),
215
                .raw_out(H_6tapfilter3_raw_out),
216
                .round_out(H_6tapfilter3_round_out)
217
                );
218
        filterH_6tap H_6tapfilter4 (
219
                .A(Inter_H_window_0_4),
220
                .B(Inter_H_window_1_4),
221
                .C(Inter_H_window_2_4),
222
                .D(Inter_H_window_3_4),
223
                .E(Inter_H_window_4_4),
224
                .F(Inter_H_window_5_4),
225
                .H_need_round(H_need_round),
226
                .raw_out(H_6tapfilter4_raw_out),
227
                .round_out(H_6tapfilter4_round_out)
228
                );
229
        filterH_6tap H_6tapfilter5 (
230
                .A(Inter_H_window_0_5),
231
                .B(Inter_H_window_1_5),
232
                .C(Inter_H_window_2_5),
233
                .D(Inter_H_window_3_5),
234
                .E(Inter_H_window_4_5),
235
                .F(Inter_H_window_5_5),
236
                .H_need_round(H_need_round),
237
                .raw_out(H_6tapfilter5_raw_out),
238
                .round_out(H_6tapfilter5_round_out)
239
                );
240
        filterH_6tap H_6tapfilter6 (
241
                .A(Inter_H_window_0_6),
242
                .B(Inter_H_window_1_6),
243
                .C(Inter_H_window_2_6),
244
                .D(Inter_H_window_3_6),
245
                .E(Inter_H_window_4_6),
246
                .F(Inter_H_window_5_6),
247
                .H_need_round(H_need_round),
248
                .raw_out(H_6tapfilter6_raw_out),
249
                .round_out(H_6tapfilter6_round_out)
250
                );
251
        filterH_6tap H_6tapfilter7 (
252
                .A(Inter_H_window_0_7),
253
                .B(Inter_H_window_1_7),
254
                .C(Inter_H_window_2_7),
255
                .D(Inter_H_window_3_7),
256
                .E(Inter_H_window_4_7),
257
                .F(Inter_H_window_5_7),
258
                .H_need_round(1'b0),
259
                .raw_out(H_6tapfilter7_raw_out),
260
                .round_out(H_6tapfilter7_round_out)
261
                );
262
        filterH_6tap H_6tapfilter8 (
263
                .A(Inter_H_window_0_8),
264
                .B(Inter_H_window_1_8),
265
                .C(Inter_H_window_2_8),
266
                .D(Inter_H_window_3_8),
267
                .E(Inter_H_window_4_8),
268
                .F(Inter_H_window_5_8),
269
                .H_need_round(1'b0),
270
                .raw_out(H_6tapfilter8_raw_out),
271
                .round_out(H_6tapfilter8_round_out)
272
                );
273
 
274
        //--------------------
275
        //bilinear filter
276
        //--------------------
277
        reg [7:0] bilinear0_A,bilinear0_B;
278
        reg [7:0] bilinear1_A,bilinear1_B;
279
        reg [7:0] bilinear2_A,bilinear2_B;
280
        reg [7:0] bilinear3_A,bilinear3_B;
281
        wire [7:0] bilinear0_out;
282
        wire [7:0] bilinear1_out;
283
        wire [7:0] bilinear2_out;
284
        wire [7:0] bilinear3_out;
285
        bilinear bilinear0 (
286
                .A(bilinear0_A),
287
                .B(bilinear0_B),
288
                .bilinear_out(bilinear0_out)
289
                );
290
        bilinear bilinear1 (
291
                .A(bilinear1_A),
292
                .B(bilinear1_B),
293
                .bilinear_out(bilinear1_out)
294
                );
295
        bilinear bilinear2 (
296
                .A(bilinear2_A),
297
                .B(bilinear2_B),
298
                .bilinear_out(bilinear2_out)
299
                );
300
        bilinear bilinear3 (
301
                .A(bilinear3_A),
302
                .B(bilinear3_B),
303
                .bilinear_out(bilinear3_out)
304
                );
305
        always @ (IsInterLuma or pos_FracL or blk4x4_inter_calculate_counter
306
                or Inter_bi_window_0 or Inter_bi_window_1 or Inter_bi_window_2 or Inter_bi_window_3
307
                or H_6tapfilter2_round_out or H_6tapfilter3_round_out or H_6tapfilter4_round_out or H_6tapfilter5_round_out
308
                or V_6tapfilter0_round_out or V_6tapfilter1_round_out or V_6tapfilter2_round_out or V_6tapfilter3_round_out
309
                or b0_reg or b1_reg or b2_reg or b3_reg or h0_reg or h1_reg or h2_reg or h3_reg)
310
                if (IsInterLuma)
311
                        case ({pos_FracL})
312
                                `pos_a,`pos_c:
313
                                if (blk4x4_inter_calculate_counter != 4'd0)
314
                                        begin
315
                                                bilinear0_A <= Inter_bi_window_0; bilinear0_B <= H_6tapfilter2_round_out;
316
                                                bilinear1_A <= Inter_bi_window_1; bilinear1_B <= H_6tapfilter3_round_out;
317
                                                bilinear2_A <= Inter_bi_window_2; bilinear2_B <= H_6tapfilter4_round_out;
318
                                                bilinear3_A <= Inter_bi_window_3; bilinear3_B <= H_6tapfilter5_round_out;
319
                                        end
320
                                else
321
                                        begin
322
                                                bilinear0_A <= 0; bilinear0_B <= 0; bilinear1_A <= 0; bilinear1_B <= 0;
323
                                                bilinear2_A <= 0; bilinear2_B <= 0; bilinear3_A <= 0; bilinear3_B <= 0;
324
                                        end
325
                                `pos_d,`pos_n:
326
                                if (blk4x4_inter_calculate_counter != 4'd0)
327
                                        begin
328
                                                bilinear0_A <= Inter_bi_window_0; bilinear0_B <= V_6tapfilter0_round_out;
329
                                                bilinear1_A <= Inter_bi_window_1; bilinear1_B <= V_6tapfilter1_round_out;
330
                                                bilinear2_A <= Inter_bi_window_2; bilinear2_B <= V_6tapfilter2_round_out;
331
                                                bilinear3_A <= Inter_bi_window_3; bilinear3_B <= V_6tapfilter3_round_out;
332
                                        end
333
                                else
334
                                        begin
335
                                                bilinear0_A <= 0; bilinear0_B <= 0; bilinear1_A <= 0; bilinear1_B <= 0;
336
                                                bilinear2_A <= 0; bilinear2_B <= 0; bilinear3_A <= 0; bilinear3_B <= 0;
337
                                        end
338
                                `pos_e,`pos_g,`pos_p,`pos_r:
339
                                if (blk4x4_inter_calculate_counter != 4'd0)
340
                                        begin
341
                                                bilinear0_A <= H_6tapfilter2_round_out; bilinear0_B <= V_6tapfilter0_round_out;
342
                                                bilinear1_A <= H_6tapfilter3_round_out; bilinear1_B <= V_6tapfilter1_round_out;
343
                                                bilinear2_A <= H_6tapfilter4_round_out; bilinear2_B <= V_6tapfilter2_round_out;
344
                                                bilinear3_A <= H_6tapfilter5_round_out; bilinear3_B <= V_6tapfilter3_round_out;
345
                                        end
346
                                else
347
                                        begin
348
                                                bilinear0_A <= 0; bilinear0_B <= 0; bilinear1_A <= 0; bilinear1_B <= 0;
349
                                                bilinear2_A <= 0; bilinear2_B <= 0; bilinear3_A <= 0; bilinear3_B <= 0;
350
                                        end
351
                                `pos_i,`pos_k:
352
                                if (blk4x4_inter_calculate_counter == 4'd7 || blk4x4_inter_calculate_counter == 4'd5 ||
353
                                        blk4x4_inter_calculate_counter == 4'd3 || blk4x4_inter_calculate_counter == 4'd1)
354
                                        begin
355
                                                bilinear0_A <= h0_reg;  bilinear0_B <= V_6tapfilter0_round_out;
356
                                                bilinear1_A <= h1_reg;  bilinear1_B <= V_6tapfilter1_round_out;
357
                                                bilinear2_A <= h2_reg;  bilinear2_B <= V_6tapfilter2_round_out;
358
                                                bilinear3_A <= h3_reg;  bilinear3_B <= V_6tapfilter3_round_out;
359
                                        end
360
                                else
361
                                        begin
362
                                                bilinear0_A <= 0; bilinear0_B <= 0; bilinear1_A <= 0; bilinear1_B <= 0;
363
                                                bilinear2_A <= 0; bilinear2_B <= 0; bilinear3_A <= 0; bilinear3_B <= 0;
364
                                        end
365
                                `pos_f,`pos_q:
366
                                if (blk4x4_inter_calculate_counter != 4'd5 && blk4x4_inter_calculate_counter != 4'd0)
367
                                        begin
368
                                                bilinear0_A <= b0_reg;  bilinear0_B <= V_6tapfilter0_round_out;
369
                                                bilinear1_A <= b1_reg;  bilinear1_B <= V_6tapfilter1_round_out;
370
                                                bilinear2_A <= b2_reg;  bilinear2_B <= V_6tapfilter2_round_out;
371
                                                bilinear3_A <= b3_reg;  bilinear3_B <= V_6tapfilter3_round_out;
372
                                        end
373
                                else
374
                                        begin
375
                                                bilinear0_A <= 0; bilinear0_B <= 0; bilinear1_A <= 0; bilinear1_B <= 0;
376
                                                bilinear2_A <= 0; bilinear2_B <= 0; bilinear3_A <= 0; bilinear3_B <= 0;
377
                                        end
378
                                default:
379
                                        begin
380
                                                bilinear0_A <= 0; bilinear0_B <= 0; bilinear1_A <= 0; bilinear1_B <= 0;
381
                                                bilinear2_A <= 0; bilinear2_B <= 0; bilinear3_A <= 0; bilinear3_B <= 0;
382
                                        end
383
                        endcase
384
                else
385
                        begin
386
                                bilinear0_A <= 0; bilinear0_B <= 0; bilinear1_A <= 0; bilinear1_B <= 0;
387
                                bilinear2_A <= 0; bilinear2_B <= 0; bilinear3_A <= 0; bilinear3_B <= 0;
388
                        end
389
 
390
        //------------------------------------------------------------------------------------------            
391
        //only "b","h" and "j" of half-pel positions need to be stored to predict quater-pel samples
392
        //------------------------------------------------------------------------------------------
393
 
394
        //b0_raw_reg0 ~ b8_raw_reg:update after j/f/q/i/k horizontal filtering
395
        wire b_raw_reg_ena;
396
        assign b_raw_reg_ena = (IsInterLuma &&
397
        ((pos_FracL == `pos_j && blk4x4_inter_calculate_counter != 4'd1 && blk4x4_inter_calculate_counter != 4'd0) ||
398
        ((pos_FracL == `pos_f || pos_FracL == `pos_q) && (blk4x4_inter_calculate_counter == 4'd5 ||
399
                                                                                                    blk4x4_inter_calculate_counter == 4'd4 ||
400
                                                                                                    blk4x4_inter_calculate_counter == 4'd3 ||
401
                                                                                                    blk4x4_inter_calculate_counter == 4'd2))    ||
402
        ((pos_FracL == `pos_i || pos_FracL == `pos_k) && (blk4x4_inter_calculate_counter == 4'd8 ||
403
                                                                                                        blk4x4_inter_calculate_counter == 4'd6 ||
404
                                                                                                        blk4x4_inter_calculate_counter == 4'd4 ||
405
                                                                                                        blk4x4_inter_calculate_counter == 4'd2))));
406
 
407
        always @ (posedge clk)
408
                if (reset_n == 1'b0)
409
                        begin
410
                                b0_raw_reg <= 0; b1_raw_reg <= 0; b2_raw_reg <= 0; b3_raw_reg <= 0; b4_raw_reg <= 0;
411
                                b5_raw_reg <= 0; b6_raw_reg <= 0; b7_raw_reg <= 0; b8_raw_reg <= 0;
412
                        end
413
                else if (b_raw_reg_ena)
414
                        begin
415
                                b0_raw_reg <= H_6tapfilter0_raw_out;b1_raw_reg <= H_6tapfilter1_raw_out;b2_raw_reg <= H_6tapfilter2_raw_out;
416
                                b3_raw_reg <= H_6tapfilter3_raw_out;b4_raw_reg <= H_6tapfilter4_raw_out;b5_raw_reg <= H_6tapfilter5_raw_out;
417
                                b6_raw_reg <= H_6tapfilter6_raw_out;b7_raw_reg <= H_6tapfilter7_raw_out;b8_raw_reg <= H_6tapfilter8_raw_out;
418
                        end
419
 
420
        //b0_reg ~ b3_reg:update for decoding f,q
421
        //Note:position q needs "b" of next line
422
        wire b_reg_ena;
423
        assign b_reg_ena = (IsInterLuma && ((pos_FracL == `pos_f || pos_FracL == `pos_q) && (blk4x4_inter_calculate_counter == 4'd5 ||
424
        blk4x4_inter_calculate_counter == 4'd4 || blk4x4_inter_calculate_counter == 4'd3 || blk4x4_inter_calculate_counter == 4'd2)));
425
 
426
        always @ (posedge clk)
427
                if (reset_n == 1'b0)
428
                        begin
429
                                b0_reg <= 0; b1_reg <= 0; b2_reg <= 0; b3_reg <= 0;
430
                        end
431
                else if (b_reg_ena)
432
                        begin
433
                                if (pos_FracL == `pos_q)
434
                                        begin
435
                                                b0_reg <= H_6tapfilter3_round_out; b1_reg <= H_6tapfilter4_round_out;
436
                                                b2_reg <= H_6tapfilter5_round_out; b3_reg <= H_6tapfilter6_round_out;
437
                                        end
438
                                else
439
                                        begin
440
                                                b0_reg <= H_6tapfilter2_round_out; b1_reg <= H_6tapfilter3_round_out;
441
                                                b2_reg <= H_6tapfilter4_round_out; b3_reg <= H_6tapfilter5_round_out;
442
                                        end
443
                        end
444
 
445
        //h0_reg ~ h3_reg:update for decoding i,k
446
        wire h_reg_ena;
447
        assign h_reg_ena = (IsInterLuma && ((pos_FracL == `pos_i || pos_FracL == `pos_k) && (blk4x4_inter_calculate_counter == 4'd8 ||
448
        blk4x4_inter_calculate_counter == 4'd6 || blk4x4_inter_calculate_counter == 4'd4 || blk4x4_inter_calculate_counter == 4'd2)));
449
 
450
        always @ (posedge clk)
451
                if (reset_n == 1'b0)
452
                        begin
453
                                h0_reg <= 0; h1_reg <= 0; h2_reg <= 0; h3_reg <= 0;
454
                        end
455
                else if (h_reg_ena)
456
                        begin
457
                                h0_reg <= V_6tapfilter0_round_out; h1_reg <= V_6tapfilter1_round_out;
458
                                h2_reg <= V_6tapfilter2_round_out; h3_reg <= V_6tapfilter3_round_out;
459
                        end
460
        //------------------------------------------------------------------------------------------            
461
        //LPE output
462
        //------------------------------------------------------------------------------------------
463
        always @ (IsInterLuma or pos_FracL or blk4x4_inter_calculate_counter
464
                or V_6tapfilter0_round_out or V_6tapfilter1_round_out or V_6tapfilter2_round_out or V_6tapfilter3_round_out
465
                or H_6tapfilter2_round_out or H_6tapfilter3_round_out or H_6tapfilter4_round_out or H_6tapfilter5_round_out
466
                or bilinear0_out or bilinear1_out or bilinear2_out or bilinear3_out)
467
                if (IsInterLuma)
468
                        case (pos_FracL)
469
                                //pos_Int: directly bypassed by Inter_pix_copy0 ~ Inter_pix_copy3
470
                                `pos_b:
471
                                if (blk4x4_inter_calculate_counter != 0)
472
                                        begin
473
                                                LPE0_out <= H_6tapfilter2_round_out; LPE1_out <= H_6tapfilter3_round_out;
474
                                                LPE2_out <= H_6tapfilter4_round_out; LPE3_out <= H_6tapfilter5_round_out;
475
                                        end
476
                                else
477
                                        begin LPE0_out <= 0; LPE1_out <= 0;LPE2_out <= 0; LPE3_out <= 0;end
478
                                `pos_h:
479
                                if (blk4x4_inter_calculate_counter != 0)
480
                                        begin
481
                                                LPE0_out <= V_6tapfilter0_round_out; LPE1_out <= V_6tapfilter1_round_out;
482
                                                LPE2_out <= V_6tapfilter2_round_out; LPE3_out <= V_6tapfilter3_round_out;
483
                                        end
484
                                else
485
                                        begin LPE0_out <= 0; LPE1_out <= 0;LPE2_out <= 0; LPE3_out <= 0;end
486
                                `pos_j:
487
                                if (blk4x4_inter_calculate_counter != 4'd5 && blk4x4_inter_calculate_counter != 0)
488
                                        begin
489
                                                LPE0_out <= V_6tapfilter0_round_out; LPE1_out <= V_6tapfilter1_round_out;
490
                                                LPE2_out <= V_6tapfilter2_round_out; LPE3_out <= V_6tapfilter3_round_out;
491
                                        end
492
                                else
493
                                        begin LPE0_out <= 0; LPE1_out <= 0;LPE2_out <= 0; LPE3_out <= 0;end
494
                                `pos_a,`pos_c,`pos_d,`pos_e,`pos_g,`pos_n,`pos_p,`pos_r,`pos_f,`pos_q:
495
                                if (blk4x4_inter_calculate_counter == 4'd4 || blk4x4_inter_calculate_counter == 4'd3 ||
496
                                        blk4x4_inter_calculate_counter == 4'd2 || blk4x4_inter_calculate_counter == 4'd1)
497
                                        begin
498
                                                LPE0_out <= bilinear0_out; LPE1_out <= bilinear1_out;
499
                                                LPE2_out <= bilinear2_out; LPE3_out <= bilinear3_out;
500
                                        end
501
                                else
502
                                        begin LPE0_out <= 0; LPE1_out <= 0;LPE2_out <= 0; LPE3_out <= 0;end
503
                                `pos_i,`pos_k:
504
                                if (blk4x4_inter_calculate_counter == 4'd7 || blk4x4_inter_calculate_counter == 4'd5 ||
505
                                        blk4x4_inter_calculate_counter == 4'd3 || blk4x4_inter_calculate_counter == 4'd1)
506
                                        begin
507
                                                LPE0_out <= bilinear0_out; LPE1_out <= bilinear1_out;
508
                                                LPE2_out <= bilinear2_out; LPE3_out <= bilinear3_out;
509
                                        end
510
                                else
511
                                        begin LPE0_out <= 0; LPE1_out <= 0;LPE2_out <= 0; LPE3_out <= 0;end
512
                                default:
513
                                        begin LPE0_out <= 0; LPE1_out <= 0;LPE2_out <= 0; LPE3_out <= 0;end
514
                        endcase
515
                else
516
                        begin LPE0_out <= 0; LPE1_out <= 0;LPE2_out <= 0; LPE3_out <= 0;end
517
 
518
endmodule
519
 
520
module filterH_6tap(A,B,C,D,E,F,H_need_round,raw_out,round_out);
521
        input [7:0] A,B,C,D,E,F;
522
        input H_need_round;
523
        output [14:0] raw_out;   //always output
524
        output [7:0]  round_out;
525
 
526
        wire [8:0] sum_AF;
527
        wire [8:0] sum_BE;
528
        wire [8:0] sum_CD;
529
        wire [10:0] sum_4CD;
530
        wire [11:0] sum_1;
531
        wire [12:0] sum_2;
532
        wire [13:0] sum_3;
533
        wire [14:0] sum_round;
534
        wire [9:0] round_tmp;
535
 
536
        assign sum_AF = A + F;
537
        assign sum_BE = B + E;
538
        assign sum_CD = C + D;
539
        assign sum_4CD = {sum_CD,2'b0};
540
        assign sum_1 = {1'b0,sum_4CD} + {3'b111,~sum_BE} + 1;
541
        assign sum_2 = {4'b0,sum_AF} + {sum_1[11],sum_1};
542
        assign sum_3 = {sum_1,2'b0};
543
        assign raw_out = {{2{sum_2[12]}},sum_2} + {sum_3[13],sum_3};
544
        //round
545
        assign sum_round = (H_need_round)? (raw_out + 16):0;
546
        assign round_tmp = (H_need_round)? sum_round[14:5]:0;
547
        assign round_out = (round_tmp[9])? 8'd0:((round_tmp[8])? 8'd255:round_tmp[7:0]);
548
endmodule
549
 
550
module filterV_6tap(A,B,C,D,E,F,Is_jfqik,round_out);
551
        input [14:0] A,B,C,D,E,F;
552
        input Is_jfqik;
553
        output [7:0] round_out;
554
 
555
        wire [15:0] sum_AF;
556
        wire [15:0] sum_BE;
557
        wire [15:0] sum_CD;
558
        wire [17:0] sum_4CD;
559
        wire [17:0] sum_1;
560
        wire [17:0] sum_2;
561
        wire [19:0] sum_3;
562
        wire [19:0] raw_out;
563
 
564
        wire [19:0] sum_round;
565
        wire [9:0] round_tmp;
566
 
567
        assign sum_AF = {A[14],A} + {F[14],F};
568
        assign sum_BE = {B[14],B} + {E[14],E};
569
        assign sum_CD = {C[14],C} + {D[14],D};
570
        assign sum_4CD = {sum_CD,2'b0};
571
        assign sum_1 = sum_4CD + {~sum_BE[15],~sum_BE[15],~sum_BE} + 1;
572
        assign sum_2 = {{2{sum_AF[15]}},sum_AF} + sum_1;
573
        assign sum_3 = {sum_1,2'b0};
574
        assign raw_out = {{2{sum_2[17]}},sum_2} + sum_3;
575
        //round
576
        assign sum_round = (Is_jfqik)? (raw_out + 512):(raw_out + 16);
577
        assign round_tmp = (Is_jfqik)? sum_round[19:10]:sum_round[14:5];
578
        assign round_out = (round_tmp[9])? 8'd0:((round_tmp[8])? 8'd255:round_tmp[7:0]);
579
endmodule
580
 
581
module bilinear (A,B,bilinear_out);
582
        input [7:0] A,B;
583
        output [7:0] bilinear_out;
584
        wire [8:0] sum_AB;
585
 
586
        assign sum_AB = A + B + 1; //here A and B should NOT extend as {A[7],A}
587
        assign bilinear_out = sum_AB[8:1];
588
endmodule
589
 
590
 
591
 

powered by: WebSVN 2.1.0

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