1 |
2 |
eexuke |
//--------------------------------------------------------------------------------------------------
|
2 |
|
|
// Design : nova
|
3 |
|
|
// Author(s) : Ke Xu
|
4 |
|
|
// Email : eexuke@yahoo.com
|
5 |
|
|
// File : DF_reg_ctrl.v
|
6 |
|
|
// Generated : Nov 27,2005
|
7 |
|
|
// Copyright (C) 2008 Ke Xu
|
8 |
|
|
//-------------------------------------------------------------------------------------------------
|
9 |
|
|
// Description
|
10 |
|
|
// buffer buf0 ~ buf3 & transpose reg t0 ~ t1 control
|
11 |
|
|
//-------------------------------------------------------------------------------------------------
|
12 |
|
|
|
13 |
|
|
// synopsys translate_off
|
14 |
|
|
`include "timescale.v"
|
15 |
|
|
// synopsys translate_on
|
16 |
|
|
`include "nova_defines.v"
|
17 |
|
|
|
18 |
|
|
module DF_reg_ctrl (gclk_DF,reset_n,DF_edge_counter_MW,one_edge_counter_MW,
|
19 |
|
|
mb_num_h_DF,mb_num_v_DF,q0_MW,q1_MW,q2_MW,q3_MW,p0_MW,p1_MW,p2_MW,p3_MW,
|
20 |
|
|
buf0_0,buf0_1,buf0_2,buf0_3,buf1_0,buf1_1,buf1_2,buf1_3,
|
21 |
|
|
buf2_0,buf2_1,buf2_2,buf2_3,buf3_0,buf3_1,buf3_2,buf3_3,
|
22 |
|
|
t0_0,t0_1,t0_2,t0_3,t1_0,t1_1,t1_2,t1_3,t2_0,t2_1,t2_2,t2_3);
|
23 |
|
|
input gclk_DF,reset_n;
|
24 |
|
|
input [5:0] DF_edge_counter_MW;
|
25 |
|
|
input [1:0] one_edge_counter_MW;
|
26 |
|
|
input [3:0] mb_num_h_DF;
|
27 |
|
|
input [3:0] mb_num_v_DF;
|
28 |
|
|
input [7:0] q0_MW,q1_MW,q2_MW,q3_MW;
|
29 |
|
|
input [7:0] p0_MW,p1_MW,p2_MW,p3_MW;
|
30 |
|
|
|
31 |
|
|
output [31:0] buf0_0,buf0_1,buf0_2,buf0_3;
|
32 |
|
|
output [31:0] buf1_0,buf1_1,buf1_2,buf1_3;
|
33 |
|
|
output [31:0] buf2_0,buf2_1,buf2_2,buf2_3;
|
34 |
|
|
output [31:0] buf3_0,buf3_1,buf3_2,buf3_3;
|
35 |
|
|
output [31:0] t0_0,t0_1,t0_2,t0_3;
|
36 |
|
|
output [31:0] t1_0,t1_1,t1_2,t1_3;
|
37 |
|
|
output [31:0] t2_0,t2_1,t2_2,t2_3;
|
38 |
|
|
|
39 |
|
|
reg [31:0] buf0_0,buf0_1,buf0_2,buf0_3;
|
40 |
|
|
reg [31:0] buf1_0,buf1_1,buf1_2,buf1_3;
|
41 |
|
|
reg [31:0] buf2_0,buf2_1,buf2_2,buf2_3;
|
42 |
|
|
reg [31:0] buf3_0,buf3_1,buf3_2,buf3_3;
|
43 |
|
|
reg [31:0] t0_0,t0_1,t0_2,t0_3;
|
44 |
|
|
reg [31:0] t1_0,t1_1,t1_2,t1_3;
|
45 |
|
|
reg [31:0] t2_0,t2_1,t2_2,t2_3;
|
46 |
|
|
//------------------------------------------------------
|
47 |
|
|
//buf0
|
48 |
|
|
//------------------------------------------------------
|
49 |
|
|
wire buf0_no_transpose; //buf0 updated without transpose
|
50 |
|
|
wire buf0_transpose; //buf0 updated after transpose
|
51 |
|
|
assign buf0_no_transpose = (
|
52 |
|
|
DF_edge_counter_MW == 6'd0 || DF_edge_counter_MW == 6'd4 || DF_edge_counter_MW == 6'd6 ||
|
53 |
|
|
DF_edge_counter_MW == 6'd12 || DF_edge_counter_MW == 6'd16 || DF_edge_counter_MW == 6'd20 ||
|
54 |
|
|
DF_edge_counter_MW == 6'd22 || DF_edge_counter_MW == 6'd28 || DF_edge_counter_MW == 6'd32 ||
|
55 |
|
|
DF_edge_counter_MW == 6'd36 || DF_edge_counter_MW == 6'd40 || DF_edge_counter_MW == 6'd44);
|
56 |
|
|
assign buf0_transpose = (
|
57 |
|
|
DF_edge_counter_MW == 6'd1 || DF_edge_counter_MW == 6'd5 || DF_edge_counter_MW == 6'd10 ||
|
58 |
|
|
DF_edge_counter_MW == 6'd14 || DF_edge_counter_MW == 6'd17 || DF_edge_counter_MW == 6'd26 ||
|
59 |
|
|
DF_edge_counter_MW == 6'd30 || DF_edge_counter_MW == 6'd33 || DF_edge_counter_MW == 6'd38 ||
|
60 |
|
|
DF_edge_counter_MW == 6'd41 || DF_edge_counter_MW == 6'd46);
|
61 |
|
|
|
62 |
|
|
always @ (posedge gclk_DF or negedge reset_n)
|
63 |
|
|
if (reset_n == 1'b0)
|
64 |
|
|
begin
|
65 |
|
|
buf0_0 <= 0; buf0_1 <= 0; buf0_2 <= 0; buf0_3 <= 0;
|
66 |
|
|
end
|
67 |
|
|
//no transpose update,always "q" position (right or down of the edge to be filtered)
|
68 |
|
|
else if (buf0_no_transpose)
|
69 |
|
|
case (one_edge_counter_MW)
|
70 |
|
|
2'd0:buf0_0 <= {q3_MW,q2_MW,q1_MW,q0_MW};
|
71 |
|
|
2'd1:buf0_1 <= {q3_MW,q2_MW,q1_MW,q0_MW};
|
72 |
|
|
2'd2:buf0_2 <= {q3_MW,q2_MW,q1_MW,q0_MW};
|
73 |
|
|
2'd3:buf0_3 <= {q3_MW,q2_MW,q1_MW,q0_MW};
|
74 |
|
|
endcase
|
75 |
|
|
//transpose update,always "p" position (left or up of the edge to be filtered)
|
76 |
|
|
else if (buf0_transpose)
|
77 |
|
|
case (one_edge_counter_MW)
|
78 |
|
|
2'd0:begin buf0_0[7:0] <= p3_MW; buf0_1[7:0] <= p2_MW;
|
79 |
|
|
buf0_2[7:0] <= p1_MW; buf0_3[7:0] <= p0_MW; end
|
80 |
|
|
2'd1:begin buf0_0[15:8] <= p3_MW; buf0_1[15:8] <= p2_MW;
|
81 |
|
|
buf0_2[15:8] <= p1_MW; buf0_3[15:8] <= p0_MW; end
|
82 |
|
|
2'd2:begin buf0_0[23:16] <= p3_MW; buf0_1[23:16] <= p2_MW;
|
83 |
|
|
buf0_2[23:16] <= p1_MW; buf0_3[23:16] <= p0_MW; end
|
84 |
|
|
2'd3:begin buf0_0[31:24] <= p3_MW; buf0_1[31:24] <= p2_MW;
|
85 |
|
|
buf0_2[31:24] <= p1_MW; buf0_3[31:24] <= p0_MW; end
|
86 |
|
|
endcase
|
87 |
|
|
//------------------------------------------------------
|
88 |
|
|
//buf1
|
89 |
|
|
//------------------------------------------------------
|
90 |
|
|
wire buf1_no_transpose; //buf1 updated without transpose
|
91 |
|
|
wire buf1_transpose; //buf1 updated after transpose
|
92 |
|
|
wire buf1_transpose_p; //buf1 transpose and buf1 stores "p" position pixels
|
93 |
|
|
assign buf1_no_transpose = (
|
94 |
|
|
DF_edge_counter_MW == 6'd1 || DF_edge_counter_MW == 6'd8 || DF_edge_counter_MW == 6'd13 ||
|
95 |
|
|
DF_edge_counter_MW == 6'd17 || DF_edge_counter_MW == 6'd24 || DF_edge_counter_MW == 6'd29 ||
|
96 |
|
|
DF_edge_counter_MW == 6'd37 || DF_edge_counter_MW == 6'd45);
|
97 |
|
|
assign buf1_transpose = (
|
98 |
|
|
DF_edge_counter_MW == 6'd6 || DF_edge_counter_MW == 6'd10 || DF_edge_counter_MW == 6'd22 ||
|
99 |
|
|
DF_edge_counter_MW == 6'd26 || DF_edge_counter_MW == 6'd33 || DF_edge_counter_MW == 6'd41);
|
100 |
|
|
assign buf1_transpose_p = (DF_edge_counter_MW == 6'd6 || DF_edge_counter_MW == 6'd9
|
101 |
|
|
|| DF_edge_counter_MW == 6'd22);
|
102 |
|
|
always @ (posedge gclk_DF or negedge reset_n)
|
103 |
|
|
if (reset_n == 1'b0)
|
104 |
|
|
begin
|
105 |
|
|
buf1_0 <= 0; buf1_1 <= 0; buf1_2 <= 0; buf1_3 <= 0;
|
106 |
|
|
end
|
107 |
|
|
//no transpose update,always "q" position (right or down of the edge to be filtered)
|
108 |
|
|
else if (buf1_no_transpose)
|
109 |
|
|
case (one_edge_counter_MW)
|
110 |
|
|
2'd0:buf1_0 <= {q3_MW,q2_MW,q1_MW,q0_MW};
|
111 |
|
|
2'd1:buf1_1 <= {q3_MW,q2_MW,q1_MW,q0_MW};
|
112 |
|
|
2'd2:buf1_2 <= {q3_MW,q2_MW,q1_MW,q0_MW};
|
113 |
|
|
2'd3:buf1_3 <= {q3_MW,q2_MW,q1_MW,q0_MW};
|
114 |
|
|
endcase
|
115 |
|
|
//transpose update,"p":6/9/22,"q":10,26,33,41
|
116 |
|
|
else if (buf1_transpose)
|
117 |
|
|
begin
|
118 |
|
|
if (buf1_transpose_p) // edge 6,22 "p"
|
119 |
|
|
case (one_edge_counter_MW)
|
120 |
|
|
2'd0:begin buf1_0[7:0] <= p3_MW; buf1_1[7:0] <= p2_MW;
|
121 |
|
|
buf1_2[7:0] <= p1_MW; buf1_3[7:0] <= p0_MW; end
|
122 |
|
|
2'd1:begin buf1_0[15:8] <= p3_MW; buf1_1[15:8] <= p2_MW;
|
123 |
|
|
buf1_2[15:8] <= p1_MW; buf1_3[15:8] <= p0_MW; end
|
124 |
|
|
2'd2:begin buf1_0[23:16] <= p3_MW; buf1_1[23:16] <= p2_MW;
|
125 |
|
|
buf1_2[23:16] <= p1_MW; buf1_3[23:16] <= p0_MW; end
|
126 |
|
|
2'd3:begin buf1_0[31:24] <= p3_MW; buf1_1[31:24] <= p2_MW;
|
127 |
|
|
buf1_2[31:24] <= p1_MW; buf1_3[31:24] <= p0_MW; end
|
128 |
|
|
endcase
|
129 |
|
|
else //edge 10,26,33,41 "q"
|
130 |
|
|
case (one_edge_counter_MW)
|
131 |
|
|
2'd0:begin buf1_0[7:0] <= q0_MW; buf1_1[7:0] <= q1_MW;
|
132 |
|
|
buf1_2[7:0] <= q2_MW; buf1_3[7:0] <= q3_MW; end
|
133 |
|
|
2'd1:begin buf1_0[15:8] <= q0_MW; buf1_1[15:8] <= q1_MW;
|
134 |
|
|
buf1_2[15:8] <= q2_MW; buf1_3[15:8] <= q3_MW; end
|
135 |
|
|
2'd2:begin buf1_0[23:16] <= q0_MW; buf1_1[23:16] <= q1_MW;
|
136 |
|
|
buf1_2[23:16] <= q2_MW; buf1_3[23:16] <= q3_MW; end
|
137 |
|
|
2'd3:begin buf1_0[31:24] <= q0_MW; buf1_1[31:24] <= q1_MW;
|
138 |
|
|
buf1_2[31:24] <= q2_MW; buf1_3[31:24] <= q3_MW; end
|
139 |
|
|
endcase
|
140 |
|
|
end
|
141 |
|
|
//------------------------------------------------------
|
142 |
|
|
//buf2
|
143 |
|
|
//------------------------------------------------------
|
144 |
|
|
wire buf2_no_transpose; //buf2 updated without transpose
|
145 |
|
|
wire buf2_transpose; //buf2 updated after transpose
|
146 |
|
|
wire buf2_transpose_p; //buf2 transpose and buf2 stores "p" position pixels
|
147 |
|
|
assign buf2_no_transpose = (
|
148 |
|
|
DF_edge_counter_MW == 6'd2 || DF_edge_counter_MW == 6'd7 || DF_edge_counter_MW == 6'd18 ||
|
149 |
|
|
DF_edge_counter_MW == 6'd23 || DF_edge_counter_MW == 6'd34 || DF_edge_counter_MW == 6'd42);
|
150 |
|
|
assign buf2_transpose = (
|
151 |
|
|
DF_edge_counter_MW == 6'd3 || DF_edge_counter_MW == 6'd11 || DF_edge_counter_MW == 6'd19 ||
|
152 |
|
|
DF_edge_counter_MW == 6'd21 || DF_edge_counter_MW == 6'd27 || DF_edge_counter_MW == 6'd30 ||
|
153 |
|
|
DF_edge_counter_MW == 6'd35 || DF_edge_counter_MW == 6'd38 || DF_edge_counter_MW == 6'd43 ||
|
154 |
|
|
DF_edge_counter_MW == 6'd46);
|
155 |
|
|
assign buf2_transpose_p = (DF_edge_counter_MW == 6'd3 || DF_edge_counter_MW == 6'd11
|
156 |
|
|
|| DF_edge_counter_MW == 6'd19 || DF_edge_counter_MW == 6'd27
|
157 |
|
|
|| DF_edge_counter_MW == 6'd35 || DF_edge_counter_MW == 6'd43);
|
158 |
|
|
always @ (posedge gclk_DF or negedge reset_n)
|
159 |
|
|
if (reset_n == 1'b0)
|
160 |
|
|
begin
|
161 |
|
|
buf2_0 <= 0; buf2_1 <= 0; buf2_2 <= 0; buf2_3 <= 0;
|
162 |
|
|
end
|
163 |
|
|
//no transpose update,always "q" position (right or down of the edge to be filtered)
|
164 |
|
|
else if (buf2_no_transpose)
|
165 |
|
|
case (one_edge_counter_MW)
|
166 |
|
|
2'd0:buf2_0 <= {q3_MW,q2_MW,q1_MW,q0_MW};
|
167 |
|
|
2'd1:buf2_1 <= {q3_MW,q2_MW,q1_MW,q0_MW};
|
168 |
|
|
2'd2:buf2_2 <= {q3_MW,q2_MW,q1_MW,q0_MW};
|
169 |
|
|
2'd3:buf2_3 <= {q3_MW,q2_MW,q1_MW,q0_MW};
|
170 |
|
|
endcase
|
171 |
|
|
//transpose update,"p":3,11,19,27,35,43 "q":21,30,38,46
|
172 |
|
|
else if (buf2_transpose)
|
173 |
|
|
begin
|
174 |
|
|
if (buf2_transpose_p) //"p":3,11,19,27,35,43
|
175 |
|
|
case (one_edge_counter_MW)
|
176 |
|
|
2'd0:begin buf2_0[7:0] <= p3_MW; buf2_1[7:0] <= p2_MW;
|
177 |
|
|
buf2_2[7:0] <= p1_MW; buf2_3[7:0] <= p0_MW; end
|
178 |
|
|
2'd1:begin buf2_0[15:8] <= p3_MW; buf2_1[15:8] <= p2_MW;
|
179 |
|
|
buf2_2[15:8] <= p1_MW; buf2_3[15:8] <= p0_MW; end
|
180 |
|
|
2'd2:begin buf2_0[23:16] <= p3_MW; buf2_1[23:16] <= p2_MW;
|
181 |
|
|
buf2_2[23:16] <= p1_MW; buf2_3[23:16] <= p0_MW; end
|
182 |
|
|
2'd3:begin buf2_0[31:24] <= p3_MW; buf2_1[31:24] <= p2_MW;
|
183 |
|
|
buf2_2[31:24] <= p1_MW; buf2_3[31:24] <= p0_MW; end
|
184 |
|
|
endcase
|
185 |
|
|
else //"q":21,30,38,46
|
186 |
|
|
case (one_edge_counter_MW)
|
187 |
|
|
2'd0:begin buf2_0[7:0] <= q0_MW; buf2_1[7:0] <= q1_MW;
|
188 |
|
|
buf2_2[7:0] <= q2_MW; buf2_3[7:0] <= q3_MW; end
|
189 |
|
|
2'd1:begin buf2_0[15:8] <= q0_MW; buf2_1[15:8] <= q1_MW;
|
190 |
|
|
buf2_2[15:8] <= q2_MW; buf2_3[15:8] <= q3_MW; end
|
191 |
|
|
2'd2:begin buf2_0[23:16] <= q0_MW; buf2_1[23:16] <= q1_MW;
|
192 |
|
|
buf2_2[23:16] <= q2_MW; buf2_3[23:16] <= q3_MW; end
|
193 |
|
|
2'd3:begin buf2_0[31:24] <= q0_MW; buf2_1[31:24] <= q1_MW;
|
194 |
|
|
buf2_2[31:24] <= q2_MW; buf2_3[31:24] <= q3_MW; end
|
195 |
|
|
endcase
|
196 |
|
|
end
|
197 |
|
|
//------------------------------------------------------
|
198 |
|
|
//buf3
|
199 |
|
|
//------------------------------------------------------
|
200 |
|
|
wire buf3_no_transpose; //buf3 updated without transpose
|
201 |
|
|
wire buf3_transpose; //buf3 updated after transpose
|
202 |
|
|
wire buf3_transpose_p; //buf3 transpose and buf1 stores "p" position pixels
|
203 |
|
|
assign buf3_no_transpose = (DF_edge_counter_MW == 6'd3 || DF_edge_counter_MW == 6'd19);
|
204 |
|
|
assign buf3_transpose = ( DF_edge_counter_MW == 6'd7 ||
|
205 |
|
|
DF_edge_counter_MW == 6'd11 || DF_edge_counter_MW == 6'd23 || DF_edge_counter_MW == 6'd27 ||
|
206 |
|
|
DF_edge_counter_MW == 6'd25 || DF_edge_counter_MW == 6'd35 || DF_edge_counter_MW == 6'd43);
|
207 |
|
|
assign buf3_transpose_p = (DF_edge_counter_MW == 6'd7 || DF_edge_counter_MW == 6'd23);
|
208 |
|
|
always @ (posedge gclk_DF or negedge reset_n)
|
209 |
|
|
if (reset_n == 1'b0)
|
210 |
|
|
begin
|
211 |
|
|
buf3_0 <= 0; buf3_1 <= 0; buf3_2 <= 0; buf3_3 <= 0;
|
212 |
|
|
end
|
213 |
|
|
//no transpose update,always "q" position (right or down of the edge to be filtered)
|
214 |
|
|
else if (buf3_no_transpose)
|
215 |
|
|
case (one_edge_counter_MW)
|
216 |
|
|
2'd0:buf3_0 <= {q3_MW,q2_MW,q1_MW,q0_MW};
|
217 |
|
|
2'd1:buf3_1 <= {q3_MW,q2_MW,q1_MW,q0_MW};
|
218 |
|
|
2'd2:buf3_2 <= {q3_MW,q2_MW,q1_MW,q0_MW};
|
219 |
|
|
2'd3:buf3_3 <= {q3_MW,q2_MW,q1_MW,q0_MW};
|
220 |
|
|
endcase
|
221 |
|
|
//transpose update,"p":7,23 "q":11,25,27,35,43
|
222 |
|
|
else if (buf3_transpose)
|
223 |
|
|
begin
|
224 |
|
|
if (buf3_transpose_p) //"p":7,23
|
225 |
|
|
case (one_edge_counter_MW)
|
226 |
|
|
2'd0:begin buf3_0[7:0] <= p3_MW; buf3_1[7:0] <= p2_MW;
|
227 |
|
|
buf3_2[7:0] <= p1_MW; buf3_3[7:0] <= p0_MW; end
|
228 |
|
|
2'd1:begin buf3_0[15:8] <= p3_MW; buf3_1[15:8] <= p2_MW;
|
229 |
|
|
buf3_2[15:8] <= p1_MW; buf3_3[15:8] <= p0_MW; end
|
230 |
|
|
2'd2:begin buf3_0[23:16] <= p3_MW; buf3_1[23:16] <= p2_MW;
|
231 |
|
|
buf3_2[23:16] <= p1_MW; buf3_3[23:16] <= p0_MW; end
|
232 |
|
|
2'd3:begin buf3_0[31:24] <= p3_MW; buf3_1[31:24] <= p2_MW;
|
233 |
|
|
buf3_2[31:24] <= p1_MW; buf3_3[31:24] <= p0_MW; end
|
234 |
|
|
endcase
|
235 |
|
|
else //"q":11,25,35,43
|
236 |
|
|
case (one_edge_counter_MW)
|
237 |
|
|
2'd0:begin buf3_0[7:0] <= q0_MW; buf3_1[7:0] <= q1_MW;
|
238 |
|
|
buf3_2[7:0] <= q2_MW; buf3_3[7:0] <= q3_MW; end
|
239 |
|
|
2'd1:begin buf3_0[15:8] <= q0_MW; buf3_1[15:8] <= q1_MW;
|
240 |
|
|
buf3_2[15:8] <= q2_MW; buf3_3[15:8] <= q3_MW; end
|
241 |
|
|
2'd2:begin buf3_0[23:16] <= q0_MW; buf3_1[23:16] <= q1_MW;
|
242 |
|
|
buf3_2[23:16] <= q2_MW; buf3_3[23:16] <= q3_MW; end
|
243 |
|
|
2'd3:begin buf3_0[31:24] <= q0_MW; buf3_1[31:24] <= q1_MW;
|
244 |
|
|
buf3_2[31:24] <= q2_MW; buf3_3[31:24] <= q3_MW; end
|
245 |
|
|
endcase
|
246 |
|
|
end
|
247 |
|
|
//------------------------------------------------------
|
248 |
|
|
//T0:always updated after transpose,always "p" position
|
249 |
|
|
//------------------------------------------------------
|
250 |
|
|
wire t0_transpose; //t0 updated after transpose
|
251 |
|
|
assign t0_transpose = (
|
252 |
|
|
DF_edge_counter_MW == 6'd4 || DF_edge_counter_MW == 6'd8 || DF_edge_counter_MW == 6'd12 || DF_edge_counter_MW == 6'd36 ||
|
253 |
|
|
DF_edge_counter_MW == 6'd44 || DF_edge_counter_MW == 6'd15 || DF_edge_counter_MW == 6'd20 || DF_edge_counter_MW == 6'd24 ||
|
254 |
|
|
DF_edge_counter_MW == 6'd28 || DF_edge_counter_MW == 6'd31 || DF_edge_counter_MW == 6'd39 || DF_edge_counter_MW == 6'd47);
|
255 |
|
|
|
256 |
|
|
always @ (posedge gclk_DF or negedge reset_n)
|
257 |
|
|
if (reset_n == 1'b0)
|
258 |
|
|
begin
|
259 |
|
|
t0_0 <= 0; t0_1 <= 0; t0_2 <= 0; t0_3 <= 0;
|
260 |
|
|
end
|
261 |
|
|
//always transpose update for "p" position
|
262 |
|
|
else if (t0_transpose)
|
263 |
|
|
case (one_edge_counter_MW)
|
264 |
|
|
2'd0:begin t0_0[7:0] <= p3_MW; t0_1[7:0] <= p2_MW;
|
265 |
|
|
t0_2[7:0] <= p1_MW; t0_3[7:0] <= p0_MW; end
|
266 |
|
|
2'd1:begin t0_0[15:8] <= p3_MW; t0_1[15:8] <= p2_MW;
|
267 |
|
|
t0_2[15:8] <= p1_MW; t0_3[15:8] <= p0_MW; end
|
268 |
|
|
2'd2:begin t0_0[23:16] <= p3_MW; t0_1[23:16] <= p2_MW;
|
269 |
|
|
t0_2[23:16] <= p1_MW; t0_3[23:16] <= p0_MW; end
|
270 |
|
|
2'd3:begin t0_0[31:24] <= p3_MW; t0_1[31:24] <= p2_MW;
|
271 |
|
|
t0_2[31:24] <= p1_MW; t0_3[31:24] <= p0_MW; end
|
272 |
|
|
endcase
|
273 |
|
|
//------------------------------------------------------
|
274 |
|
|
//T1:always updated after transpose
|
275 |
|
|
//------------------------------------------------------
|
276 |
|
|
wire t1_transpose; //t1 updated after transpose
|
277 |
|
|
wire t1_transpose_q; //t1 transpose and t1 stores "q" position pixels
|
278 |
|
|
assign t1_transpose = (
|
279 |
|
|
DF_edge_counter_MW == 6'd13 || DF_edge_counter_MW == 6'd37 || DF_edge_counter_MW == 6'd45 || DF_edge_counter_MW == 6'd9 ||
|
280 |
|
|
DF_edge_counter_MW == 6'd21 || DF_edge_counter_MW == 6'd25 || DF_edge_counter_MW == 6'd29 || DF_edge_counter_MW == 6'd31 ||
|
281 |
|
|
DF_edge_counter_MW == 6'd39 || DF_edge_counter_MW == 6'd47);
|
282 |
|
|
|
283 |
|
|
assign t1_transpose_q = (DF_edge_counter_MW == 6'd31 || DF_edge_counter_MW == 6'd39 ||
|
284 |
|
|
DF_edge_counter_MW == 6'd47);
|
285 |
|
|
always @ (posedge gclk_DF or negedge reset_n)
|
286 |
|
|
if (reset_n == 1'b0)
|
287 |
|
|
begin
|
288 |
|
|
t1_0 <= 0; t1_1 <= 0; t1_2 <= 0; t1_3 <= 0;
|
289 |
|
|
end
|
290 |
|
|
else if (t1_transpose && !t1_transpose_q) //t1 transpose "p"
|
291 |
|
|
case (one_edge_counter_MW)
|
292 |
|
|
2'd0:begin t1_0[7:0] <= p3_MW; t1_1[7:0] <= p2_MW;
|
293 |
|
|
t1_2[7:0] <= p1_MW; t1_3[7:0] <= p0_MW; end
|
294 |
|
|
2'd1:begin t1_0[15:8] <= p3_MW; t1_1[15:8] <= p2_MW;
|
295 |
|
|
t1_2[15:8] <= p1_MW; t1_3[15:8] <= p0_MW; end
|
296 |
|
|
2'd2:begin t1_0[23:16] <= p3_MW; t1_1[23:16] <= p2_MW;
|
297 |
|
|
t1_2[23:16] <= p1_MW; t1_3[23:16] <= p0_MW; end
|
298 |
|
|
2'd3:begin t1_0[31:24] <= p3_MW; t1_1[31:24] <= p2_MW;
|
299 |
|
|
t1_2[31:24] <= p1_MW; t1_3[31:24] <= p0_MW; end
|
300 |
|
|
endcase
|
301 |
|
|
else if (t1_transpose) //t1 transpose "q"
|
302 |
|
|
case (one_edge_counter_MW)
|
303 |
|
|
2'd0:begin t1_0[7:0] <= q0_MW; t1_1[7:0] <= q1_MW;
|
304 |
|
|
t1_2[7:0] <= q2_MW; t1_3[7:0] <= q3_MW; end
|
305 |
|
|
2'd1:begin t1_0[15:8] <= q0_MW; t1_1[15:8] <= q1_MW;
|
306 |
|
|
t1_2[15:8] <= q2_MW; t1_3[15:8] <= q3_MW; end
|
307 |
|
|
2'd2:begin t1_0[23:16] <= q0_MW; t1_1[23:16] <= q1_MW;
|
308 |
|
|
t1_2[23:16] <= q2_MW; t1_3[23:16] <= q3_MW; end
|
309 |
|
|
2'd3:begin t1_0[31:24] <= q0_MW; t1_1[31:24] <= q1_MW;
|
310 |
|
|
t1_2[31:24] <= q2_MW; t1_3[31:24] <= q3_MW; end
|
311 |
|
|
endcase
|
312 |
|
|
//--------------------------------------------------------------------
|
313 |
|
|
//T2:only used after filter edge 18/34/42 to update mbAddrB of left MB
|
314 |
|
|
//--------------------------------------------------------------------
|
315 |
|
|
wire t2_wr;
|
316 |
|
|
assign t2_wr = ((mb_num_h_DF != 0 && mb_num_v_DF != 4'd8) &&
|
317 |
|
|
(DF_edge_counter_MW == 6'd18 || DF_edge_counter_MW == 6'd34 || DF_edge_counter_MW == 6'd42));
|
318 |
|
|
always @ (posedge gclk_DF or negedge reset_n)
|
319 |
|
|
if (reset_n == 1'b0)
|
320 |
|
|
begin
|
321 |
|
|
t2_0 <= 0; t2_1 <= 0; t2_2 <= 0; t2_3 <= 0;
|
322 |
|
|
end
|
323 |
|
|
else if (t2_wr)
|
324 |
|
|
case (one_edge_counter_MW)
|
325 |
|
|
2'd0:begin t2_0[7:0] <= p3_MW; t2_1[7:0] <= p2_MW;
|
326 |
|
|
t2_2[7:0] <= p1_MW; t2_3[7:0] <= p0_MW; end
|
327 |
|
|
2'd1:begin t2_0[15:8] <= p3_MW; t2_1[15:8] <= p2_MW;
|
328 |
|
|
t2_2[15:8] <= p1_MW; t2_3[15:8] <= p0_MW; end
|
329 |
|
|
2'd2:begin t2_0[23:16] <= p3_MW; t2_1[23:16] <= p2_MW;
|
330 |
|
|
t2_2[23:16] <= p1_MW; t2_3[23:16] <= p0_MW; end
|
331 |
|
|
2'd3:begin t2_0[31:24] <= p3_MW; t2_1[31:24] <= p2_MW;
|
332 |
|
|
t2_2[31:24] <= p1_MW; t2_3[31:24] <= p0_MW; end
|
333 |
|
|
endcase
|
334 |
|
|
endmodule
|
335 |
|
|
|