x393
1.0
FPGAcodeforElphelNC393camera
focus_sharp393.v
Go to the documentation of this file.
1
39
78
// This file may be used to define same pre-processor macros to be included into each parsed file
79
`ifndef
SYSTEM_DEFINES
80
`define
SYSTEM_DEFINES
81
// TODO: Later compare instantiate/infer
82
`define
INSTANTIATE_DSP48E1
83
`define
DEBUG_DCT1D// undefine after debugging is over
// `define USE_OLD_DCT
84
85
// Parameters from x393_sata project
86
`define
USE_DRP
87
`define
ALIGN_CLOCKS
88
// `define STRAIGHT_XCLK
89
`define
USE_DATASCOPE
90
// `define DATASCOPE_INCOMING_RAW
91
`define
PRELOAD_BRAMS
92
// `define AHCI_SATA 1
93
// `define DEBUG_ELASTIC
94
// End of parameters from x393_sata project
95
96
`define
PRELOAD_BRAMS
97
`define
DISPLAY_COMPRESSED_DATA
// if HISPI is not defined, parallel sensor interface is used for all channels
98
`define
HISPI /*************** CHANGE here and x393_hispi/x393_parallel in bitstream tool settings ****************/
// `define USE_OLD_XDCT393
99
// `define USE_PCLK2X
100
// `define USE_XCLK2X
101
`define
REVERSE_LANES 1
`define
DEBUG_RING 1
`define
USE_HARD_CURPARAMS// Adjustment of actual hardware may break simulation
// `define DEBUG_SENS_MEM_PAGES 1
102
// `define MCLK_VCO_MULT 16
103
// DDR3 memory speed grade and density
104
`define
sg25 1
// `define sg15E 1
105
// `define sg187E 1
106
`define
den4096Mb 1
107
`define
MCLK_VCO_MULT 16
// `define MCLK_VCO_MULT 18
108
// `define MCLK_VCO_MULT 20
109
110
`define
MEMBRIDGE_DEBUG_WRITE 1
// Enviroment-dependent options
111
`ifdef
IVERILOG
112
`define
SIMULATION
113
`define
OPEN_SOURCE_ONLY
114
`endif
115
116
`ifdef
COCOTB
117
`define
SIMULATION
118
`define
OPEN_SOURCE_ONLY
119
`endif
120
121
`ifdef
CVC
122
`define
SIMULATION
123
`define
OPEN_SOURCE_ONLY
124
`endif
// CVC
125
126
// will not use simultaneous reset in shift registers, just and input data with ~rst
127
`define
SHREG_SEQUENTIAL_RESET 1
// synthesis does to recognize global clock as G input of the primitive latch
128
`undef
INFER_LATCHES
129
// define when using CDC - it does not support them
130
`undef
IGNORE_ATTR
131
//`define MEMBRIDGE_DEBUG_READ 1
132
`define
use200Mhz 1
`define
USE_CMD_ENCOD_TILED_32_RD 1
// chn 0 is read from memory and write to memory
133
`define
def_enable_mem_chn0
134
`define
def_read_mem_chn0
135
`define
def_write_mem_chn0
136
`undef
def_scanline_chn0
137
`undef
def_tiled_chn0
138
139
// chn 1 is scanline r+w
140
`define
def_enable_mem_chn1
141
`define
def_read_mem_chn1
142
`define
def_write_mem_chn1
143
`define
def_scanline_chn1
144
`undef
def_tiled_chn1
145
146
// chn 2 is tiled r+w
147
`define
def_enable_mem_chn2
148
`define
def_read_mem_chn2
149
`define
def_write_mem_chn2
150
`undef
def_scanline_chn2
151
`define
def_tiled_chn2
152
153
// chn 3 is scanline r+w (reuse later)
154
`define
def_enable_mem_chn3
155
`define
def_read_mem_chn3
156
`define
def_write_mem_chn3
157
`define
def_scanline_chn3
158
`undef
def_tiled_chn3
159
160
// chn 4 is tiled r+w (reuse later)
161
`define
def_enable_mem_chn4
162
`define
def_read_mem_chn4
163
`define
def_write_mem_chn4
164
`undef
def_scanline_chn4
165
`define
def_tiled_chn4
166
167
// chn 5 is disabled
168
`undef
def_enable_mem_chn5
169
170
// chn 6 is disabled
171
`undef
def_enable_mem_chn6
172
173
// chn 7 is disabled
174
`undef
def_enable_mem_chn7
175
176
// chn 8 is scanline w (sensor channel 0)
177
`define
def_enable_mem_chn8
178
`undef
def_read_mem_chn8
179
`define
def_write_mem_chn8
180
`define
def_scanline_chn8
181
`undef
def_tiled_chn8
182
183
// chn 9 is scanline w (sensor channel 1)
184
`define
def_enable_mem_chn9
185
`undef
def_read_mem_chn9
186
`define
def_write_mem_chn9
187
`define
def_scanline_chn9
188
`undef
def_tiled_chn9
189
190
// chn 10 is scanline w (sensor channel 2)
191
`define
def_enable_mem_chn10
192
`undef
def_read_mem_chn10
193
`define
def_write_mem_chn10
194
`define
def_scanline_chn10
195
`undef
def_tiled_chn10
196
197
// chn 11 is scanline w (sensor channel 3)
198
`define
def_enable_mem_chn11
199
`undef
def_read_mem_chn11
200
`define
def_write_mem_chn11
201
`define
def_scanline_chn11
202
`undef
def_tiled_chn11
203
204
// chn 12 is tiled read (compressor channel 0)
205
`define
def_enable_mem_chn12
206
`define
def_read_mem_chn12
207
`undef
def_write_mem_chn12
208
`undef
def_scanline_chn12
209
`define
def_tiled_chn12
210
211
// chn 12 is tiled read (compressor channel 1)
212
`define
def_enable_mem_chn13
213
`define
def_read_mem_chn13
214
`undef
def_write_mem_chn13
215
`undef
def_scanline_chn13
216
`define
def_tiled_chn13
217
218
// chn 12 is tiled read (compressor channel 2)
219
`define
def_enable_mem_chn14
220
`define
def_read_mem_chn14
221
`undef
def_write_mem_chn14
222
`undef
def_scanline_chn14
223
`define
def_tiled_chn14
224
225
// chn 12 is tiled read (compressor channel 3)
226
`define
def_enable_mem_chn15
227
`define
def_read_mem_chn15
228
`undef
def_write_mem_chn15
229
`undef
def_scanline_chn15
230
`define
def_tiled_chn15
231
`endif
232
233
`timescale 1ns/1ps
234
// TODO: Modify to work with other modes (now only on color)
235
// NOTE: when removing clk2x, temporarily use clk here, just keep mode ==0 (disabled)
236
module
focus_sharp393
(
237
input
clk
,
// pixel clock, posedge
238
input
clk2x
,
// 2x pixel clock
239
input
en
,
// enable (0 resets)
240
input
mclk
,
// system clock to write tables
241
input
tser_we
,
// enable write to a table
242
input
tser_a_not_d
,
// address/not data distributed to submodules
243
input
[
7
:
0
]
tser_d
,
// byte-wide serialized tables address/data to submodules
244
input
[
1
:
0
]
mode
,
// focus mode (combine image with focus info) - 0 - none, 1 - replace, 2 - combine all, 3 - combine woi
245
input
firsti
,
// first macroblock
246
input
lasti
,
// last macroblock
247
input
[
2
:
0
]
tni
,
// block number in a macronblock - 0..3 - Y, >=4 - color (sync to stb)
248
input
stb
,
// strobe that writes ctypei, dci
249
input
start
,
// marks first input pixel (needs 1 cycle delay from previous DCT stage)
250
input
[
12
:
0
]
di
,
// [11:0] pixel data in (signed)
251
input
quant_ds
,
// quantizator ds
252
input
[
12
:
0
]
quant_d
,
// [11:0]quantizator data output
253
input
[
15
:
0
]
quant_dc_tdo
,
// [15:0], MSB aligned coefficient for the DC component (used in focus module)
254
output
reg
[
12
:
0
]
do
,
// [11:0] pixel data out, make timing ignore (valid 1.5 clk earlier that Quantizer output)
255
output
reg
ds
,
// data out strobe (one ahead of the start of dv)
256
output
reg
[
31
:
0
]
hifreq
);
//[31:0]) // accumulated high frequency components in a frame sub-window
257
258
wire
[
15
:
0
]
tdo
;
259
reg
[
5
:
0
]
tba
;
260
reg
[
11
:
0
]
wnd_reg
;
// intermediate register
261
reg
wnd_wr
;
// writing window
262
reg
[
2
:
0
]
wnd_a
;
// window register address
263
264
// next measured in 8x8 blocks, totalwidth - write one less than needed (i.e. 511 fro the 512-wide window)
265
// blocks on the border are included
266
reg
[
8
:
0
]
wnd_left
;
267
reg
[
8
:
0
]
wnd_right
;
268
reg
[
8
:
0
]
wnd_top
;
269
reg
[
8
:
0
]
wnd_bottom
;
270
reg
[
8
:
1
]
wnd_totalwidth
;
271
reg
[
3
:
0
]
filt_sel0
;
// select filter number, 0..14 (15 used for window parameters)
272
reg
[
3
:
0
]
filt_sel
;
// select filter number, 0..14 (15 used for window parameters)
273
reg
stren
;
// strength (visualization)
274
reg
[
2
:
0
]
ic
;
275
reg
[
2
:
0
]
oc
;
276
wire
first
,
last
;
//valid at start (with first di word), switches immediately after
277
wire
[
2
:
0
]
tn
;
278
reg
[
39
:
0
]
acc_frame
;
279
reg
[
12
:
0
]
pre_do
;
280
reg
pre_ds
;
281
reg
need_corr_max
;
// limit output by quant_dc_tdo
282
reg
[
11
:
0
]
fdo
;
// focus data output
283
reg
start_d
;
//start delayed by 1
284
reg
[
2
:
0
]
tn_d
;
//tn delayed by 1
285
286
wire
out_mono
;
287
wire
out_window
;
288
wire
[
12
:
0
]
combined_qf
;
289
wire
[
12
:
0
]
next_do
;
290
wire
[
12
:
0
]
fdo_minus_max
;
291
reg
[
11
:
0
]
di_d
;
292
reg
[
11
:
0
]
d1
;
293
reg
[
8
:
0
]
start2
;
294
// reg [7:0] finish2;
295
reg
[
6
:
0
]
finish2
;
// bit[7] never used
296
reg
[
5
:
0
]
use_k_dly
;
297
reg
[
23
:
0
]
acc_blk
;
// accumulator for the sum ((a[i]*d[i])^2)
298
reg
[
22
:
0
]
sum_blk
;
// accumulator for the sum ((a[i]*d[i])^2), copied at block end
299
reg
acc_ldval
;
// value to load to acc_blk: 0 - 24'h0, 1 - 24'h7fffff
300
wire
acc_clear
=
start2
[
8
];
301
wire
acc_add
=
use_k_dly
[
4
];
302
wire
acc_corr
=
use_k_dly
[
5
];
303
wire
acc_to_out
=
finish2
[
6
];
304
wire
[
17
:
0
]
mult_a
;
305
wire
[
17
:
0
]
mult_b
;
306
wire
[
35
:
0
]
mult_p
;
307
308
reg
[
17
:
0
]
mult_s
;
//truncated and saturated (always positive) multiplier result (before calculating squared)
309
reg
next_ac
;
// next will be AC component
310
reg
use_coef
;
// use multiplier for the first operation - DCT coeff. by table elements
311
reg
started_luma
;
// started Luma block
312
reg
luma_dc_out
;
// 1 cycle ahead of the luma DC component out (optionally combined with the WOI (mode=3))
313
reg
luma_dc_acc
;
// 1 cycle ahead of the luma DC component out (always combined with the WOI)
314
reg
was_last_luma
;
315
reg
copy_acc_frame
;
316
317
wire
twe
;
318
wire
[
15
:
0
]
tdi
;
319
wire
[
22
:
0
]
ta
;
320
321
assign
fdo_minus_max
[
12
:
0
]= {
1'b0
,
fdo
[
11
:
0
]}-{
1'b0
,
quant_dc_tdo
[
15
:
5
]};
322
assign
combined_qf
[
12
:
0
]=
stren
?({
quant_d
[
12
:
0
]}+{
1'b0
,
fdo
[
11
:
0
]}):
//original image plus positive
323
({
quant_d
[
12
],
quant_d
[
12
:
1
]}+
// half original
324
{
fdo_minus_max
[
12
],
fdo_minus_max
[
12
:
1
]});
// plus half signed
325
assign
next_do
[
12
:
0
] = (
mode
[
1
:
0
]==
2'h1
)?(
luma_dc_out
?
fdo_minus_max
[
12
:
0
]:
13'h0
):
326
((
mode
[
1
] &&
luma_dc_out
)?
combined_qf
[
12
:
0
]: {
quant_d
[
12
:
0
]} );
327
328
always
@ (
posedge
clk
)
begin
329
if
(!
en
)
ic
[
2
:
0
] <=
3'b0
;
330
else
if
(
stb
)
ic
[
2
:
0
] <=
ic
[
2
:
0
]+
1
;
331
if
(!
en
)
oc
[
2
:
0
] <=
3'b0
;
332
else
if
(
start
)
oc
[
2
:
0
] <=
oc
[
2
:
0
]+
1
;
333
end
334
335
// writing window parameters in the last bank of a table
336
always
@ (
posedge
mclk
)
begin
337
if
(
twe
)
begin
338
wnd_reg
[
11
:
0
] <=
tdi
[
11
:
0
] ;
339
wnd_a
<=
ta
[
2
:
0
];
340
end
341
wnd_wr
<=
twe
&& (
ta
[
9
:
3
]==
7'h78
) ;
// first 8 location in the last 64-word bank
342
if
(
wnd_wr
)
begin
343
case
(
wnd_a
[
2
:
0
])
344
3'h0
:
wnd_left
[
8
:
0
] <=
wnd_reg
[
11
:
3
] ;
345
3'h1
:
wnd_right
[
8
:
0
] <=
wnd_reg
[
11
:
3
] ;
346
3'h2
:
wnd_top
[
8
:
0
] <=
wnd_reg
[
11
:
3
] ;
347
3'h3
:
wnd_bottom
[
8
:
0
] <=
wnd_reg
[
11
:
3
] ;
348
3'h4
:
wnd_totalwidth
[
8
:
1
] <=
wnd_reg
[
11
:
4
] ;
349
3'h5
:
filt_sel0
[
3
:
0
] <=
wnd_reg
[
3
:
0
] ;
350
3'h6
:
stren
<=
wnd_reg
[
0
] ;
351
default
:
begin
end
352
endcase
353
end
354
end
355
356
// determine if this block needs to be processed (Y, inside WOI)
357
reg
[
7
:
0
]
mblk_hor
;
//horizontal macroblock (2x2 blocks) counter
358
reg
[
7
:
0
]
mblk_vert
;
//vertical macroblock (2x2 blocks) counter
359
wire
start_of_line
= (
first
|| (
mblk_hor
[
7
:
0
] ==
wnd_totalwidth
[
8
:
1
]));
360
wire
first_in_macro
= (
tn
[
2
:
0
]==
3'h0
);
361
reg
in_woi
;
// maybe specified as slow
362
363
always
@(
posedge
clk
)
begin
364
if
(
first_in_macro
&&
start
)
mblk_hor
[
7
:
0
] <=
start_of_line
?
8'h0
:(
mblk_hor
[
7
:
0
]+
1
);
365
if
(
first_in_macro
&&
start
&&
start_of_line
)
mblk_vert
[
7
:
0
] <=
first
?
8'h0
:(
mblk_vert
[
7
:
0
]+
1
);
366
start_d
<=
start
;
367
tn_d
[
2
:
0
] <=
tn
[
2
:
0
];
368
if
(
start_d
)
in_woi
<= !
tn_d
[
2
] &&
369
({
mblk_hor
[
7
:
0
],
tn_d
[
0
]} >=
wnd_left
[
8
:
0
]) &&
370
({
mblk_hor
[
7
:
0
],
tn_d
[
0
]} <=
wnd_right
[
8
:
0
]) &&
371
({
mblk_vert
[
7
:
0
],
tn_d
[
1
]} >=
wnd_top
[
8
:
0
]) &&
372
({
mblk_vert
[
7
:
0
],
tn_d
[
1
]} <=
wnd_bottom
[
8
:
0
]);
373
end
374
375
//Will use posedge sclk to balance huffman and system
376
377
// wire clkdiv2;
378
// FD i_clkdiv2(.C(clk), .D(!clkdiv2), .Q(clkdiv2));
379
380
reg
clkdiv2
=
0
;
381
always
@ (
posedge
clk
)
begin
382
clkdiv2
<= ~
clkdiv2
;
383
end
384
385
386
reg
[
2
:
0
]
clksync
;
387
wire
csync
=
clksync
[
2
];
388
always
@ (
posedge
clk2x
)
begin
389
clksync
[
2
:
0
] <= {(
clksync
[
1
]==
clksync
[
0
]),
clksync
[
0
],
clkdiv2
};
390
end
391
392
always
@ (
posedge
clk
)
begin
393
if
(
di
[
11
]==
di
[
12
])
di_d
[
11
:
0
] <=
di
[
11
:
0
];
394
else
di_d
[
11
:
0
] <= {~
di
[
11
],{
11
{
di
[
11
]}}};
//saturate
395
end
396
397
assign
mult_a
[
17
:
0
] =
use_coef
? {
1'b0
,
tdo
[
15
:
0
],
1'b0
}:
mult_s
[
17
:
0
];
398
assign
mult_b
[
17
:
0
] =
use_coef
? {
d1
[
10
:
0
],{
7
{
d1
[
0
]}}}:
mult_s
[
17
:
0
];
399
400
always
@ (
posedge
clk2x
)
begin
401
filt_sel
[
3
:
0
] <=
filt_sel0
[
3
:
0
];
402
if
(
clksync
[
2
])
d1
[
11
:
0
]<=
di_d
[
11
:
0
];
403
start2
[
8
:
0
] <= {
start2
[
7
:
0
],
start
&&
csync
};
404
// finish2[7:0]<= {finish2[6:0],use_coef && !next_ac};
405
finish2
[
6
:
0
]<= {
finish2
[
5
:
0
],
use_coef
&& !
next_ac
};
// finish2[7] was never used
406
if
(!
en
||
start2
[
0
])
tba
[
5
:
0
] <=
6'h0
;
407
else
if
(!
csync
&& (
tba
[
5
:
0
] !=
6'h3f
))
tba
[
5
:
0
] <=
tba
[
5
:
0
] +
1
;
408
// mult_s[17:0] <= (&mult_p[35:31] || !(&mult_p[35:31]))?mult_p[31:14]:18'h1ffff;
409
mult_s
[
17
:
0
] <= (&
mult_p
[
35
:
31
] || !(|
mult_p
[
35
:
31
]))?
mult_p
[
31
:
14
]:
18'h1ffff
;
410
next_ac
<=
en
&& (
start2
[
3
] || (
next_ac
&& ((
tba
[
5
:
0
] !=
6'h3f
) ||
csync
)));
411
use_coef
<=
next_ac
&& !
csync
;
412
use_k_dly
[
5
:
0
] <= {
use_k_dly
[
4
:
0
],
use_coef
};
413
acc_ldval
<= !(|
start2
[
7
:
6
]);
414
if
(
acc_clear
|| (
acc_corr
&&
acc_blk
[
23
]))
acc_blk
[
23
:
0
] <= {
1'b0
,{
23
{
acc_ldval
}}};
415
else
if
(
acc_add
)
acc_blk
[
23
:
0
] <=
acc_blk
[
23
:
0
] +
mult_p
[
31
:
8
];
// mult_p[35:8];
416
if
(
acc_to_out
)
fdo
[
11
:
0
] <= (|
acc_blk
[
23
:
20
])?
12'hfff
:
acc_blk
[
19
:
8
];
// positive, 0..0xfff
417
if
(
acc_to_out
)
sum_blk
[
22
:
0
] <=
acc_blk
[
22
:
0
];
// accumulator for the sum ((a[i]*d[i])^2), copied at block end
418
end
419
420
// acc_blk will (after corr) be always with MSB=0 - max 24'h7fffff
421
// for image output - max 24'h0fffff->12 bit signed, shifted
422
// combining output
423
//assign combined_qf[12:0]={quant_d[11],quant_d[11:0]}+{fdo[11],fdo[11:0]};
424
425
// SRL16 i_out_mono (.Q(out_mono), .A0(1'b1), .A1(1'b1), .A2(1'b1), .A3(1'b1), .CLK(clk), .D(started_luma)); // timing not critical
426
// SRL16 i_out_window (.Q(out_window), .A0(1'b1), .A1(1'b1), .A2(1'b1), .A3(1'b1), .CLK(clk), .D(in_woi)); // timing not critical
427
dly_16
#(.
WIDTH
(
1
))
i_out_mono
(.
clk
(
clk
), .
rst
(
1'b0
), .
dly
(
4'd15
), .
din
(
started_luma
), .
dout
(
out_mono
));
// timing not critical
428
dly_16
#(.
WIDTH
(
1
))
i_out_window
(.
clk
(
clk
),.
rst
(
1'b0
), .
dly
(
4'd15
), .
din
(
in_woi
), .
dout
(
out_window
));
// timing not critical
429
430
always
@ (
posedge
clk
)
begin
431
if
(
start
)
started_luma
<= !
tn
[
2
];
432
luma_dc_out
<=
quant_ds
&&
out_mono
&& ((
mode
[
1
:
0
]!=
3
) ||
out_window
);
433
luma_dc_acc
<=
quant_ds
&&
out_mono
&&
out_window
;
434
was_last_luma
<=
en
&&
last
&&
out_mono
;
435
copy_acc_frame
<=
was_last_luma
&& !
out_mono
;
436
if
(
first
&&
first_in_macro
)
acc_frame
[
39
:
0
] <=
40'h0
;
437
else
if
(
luma_dc_acc
)
acc_frame
[
39
:
0
] <=
acc_frame
[
39
:
0
] +
sum_blk
[
22
:
0
];
438
if
(
copy_acc_frame
)
hifreq
[
31
:
0
] <=
acc_frame
[
39
:
8
];
439
pre_ds
<=
quant_ds
;
440
ds
<=
pre_ds
;
441
pre_do
[
12
:
0
] <=
next_do
[
12
:
0
];
442
need_corr_max
<=
luma_dc_out
&& (
mode
[
1
:
0
]!=
2'h0
);
443
do
[
12
:
0
] <= (
need_corr_max
&& !
pre_do
[
12
] && (
pre_do
[
11
] || (
pre_do
[
10
:
0
]>
quant_dc_tdo
[
15
:
5
])) )?
444
{
2'b0
,
quant_dc_tdo
[
15
:
5
]} :
445
pre_do
[
12
:
0
];
446
end
447
448
table_ad_receive
#(
449
.
MODE_16_BITS
(
1
),
450
.
NUM_CHN
(
1
)
451
)
table_ad_receive_i
(
452
.
clk
(
mclk
),
// input
453
.
a_not_d
(
tser_a_not_d
),
// input
454
.
ser_d
(
tser_d
),
// input[7:0]
455
.
dv
(
tser_we
),
// input
456
.
ta
(
ta
),
// output[22:0]
457
.
td
(
tdi
),
// output[15:0]
458
.
twe
(
twe
)
// output
459
);
460
461
462
/*
463
MULT18X18SIO #(
464
.AREG(1), // Enable the input registers on the A port (1=on, 0=off)
465
.BREG(1), // Enable the input registers on the B port (1=on, 0=off)
466
.B_INPUT("DIRECT"), // B cascade input "DIRECT" or "CASCADE"
467
.PREG(1) // Enable the input registers on the P port (1=on, 0=off)
468
) i_focus_mult (
469
.BCOUT(), // 18-bit cascade output
470
.P(mult_p), // 36-bit multiplier output
471
.A(mult_a), // 18-bit multiplier input
472
.B(mult_b), // 18-bit multiplier input
473
.BCIN(18'h0), // 18-bit cascade input
474
.CEA(en), // Clock enable input for the A port
475
.CEB(en), // Clock enable input for the B port
476
.CEP(en), // Clock enable input for the P port
477
.CLK(sclk), // Clock input
478
.RSTA(1'b0), // Synchronous reset input for the A port
479
.RSTB(1'b0), // Synchronous reset input for the B port
480
.RSTP(1'b0) // Synchronous reset input for the P port
481
);
482
*/
483
reg
[
35
:
0
]
mult_p_r
;
484
reg
[
17
:
0
]
mult_a_r
;
485
reg
[
17
:
0
]
mult_b_r
;
486
assign
mult_p
=
mult_p_r
;
487
always
@(
posedge
clk2x
)
begin
488
mult_a_r
<=
mult_a
;
489
mult_b_r
<=
mult_b
;
490
mult_p_r
<=
mult_a_r
*
mult_b_r
;
491
end
492
493
/*
494
RAM16X1D i_tn0 (.D(tni[0]),.DPO(tn[0]),.A0(ic[0]),.A1(ic[1]),.A2(1'b0),.A3(1'b0),.DPRA0(oc[0]),.DPRA1(oc[1]),.DPRA2(1'b0),.DPRA3(1'b0),.WCLK(clk),.WE(stb));
495
RAM16X1D i_tn1 (.D(tni[1]),.DPO(tn[1]),.A0(ic[0]),.A1(ic[1]),.A2(1'b0),.A3(1'b0),.DPRA0(oc[0]),.DPRA1(oc[1]),.DPRA2(1'b0),.DPRA3(1'b0),.WCLK(clk),.WE(stb));
496
RAM16X1D i_tn2 (.D(tni[2]),.DPO(tn[2]),.A0(ic[0]),.A1(ic[1]),.A2(1'b0),.A3(1'b0),.DPRA0(oc[0]),.DPRA1(oc[1]),.DPRA2(1'b0),.DPRA3(1'b0),.WCLK(clk),.WE(stb));
497
RAM16X1D i_first (.D(firsti),.DPO(first),.A0(ic[0]),.A1(ic[1]),.A2(1'b0),.A3(1'b0),.DPRA0(oc[0]),.DPRA1(oc[1]),.DPRA2(1'b0),.DPRA3(1'b0),.WCLK(clk),.WE(stb));
498
RAM16X1D i_last (.D(lasti), .DPO(last), .A0(ic[0]),.A1(ic[1]),.A2(1'b0),.A3(1'b0),.DPRA0(oc[0]),.DPRA1(oc[1]),.DPRA2(1'b0),.DPRA3(1'b0),.WCLK(clk),.WE(stb));
499
*/
500
reg
[
4
:
0
]
ram4
[
0
:
3
];
501
always
@ (
posedge
clk
)
begin
502
ram4
[
ic
[
1
:
0
]] <= {
lasti
,
firsti
,
tni
[
2
:
0
]};
503
end
504
assign
{
last
,
first
,
tn
[
2
:
0
]} =
ram4
[
oc
[
1
:
0
]];
505
// is it correct posedge sclk on rd, negedge on wr and no xclk?
506
/*
507
RAMB16_S18_S18 i_focus_dct_tab (
508
.DOA(tdo[15:0]), // Port A 16-bit Data Output
509
.DOPA(), // Port A 2-bit Parity Output
510
.ADDRA({filt_sel[3:0],tba[2:0],tba[5:3]}), // Port A 10-bit Address Input
511
.CLKA(sclk), // Port A Clock
512
.DIA(16'b0), // Port A 16-bit Data Input
513
.DIPA(2'b0), // Port A 2-bit parity Input
514
.ENA(1'b1), // Port A RAM Enable Input
515
.SSRA(1'b0), // Port A Synchronous Set/Reset Input
516
.WEA(1'b0), // Port A Write Enable Input
517
518
.DOB(), // Port B 16-bit Data Output
519
.DOPB(), // Port B 4-bit Parity Output
520
.ADDRB({ta[9:0]}), // Port B 2-bit Address Input
521
.CLKB(!sclk), // Port B Clock
522
.DIB(tdi[15:0]), // Port B 16-bit Data Input
523
.DIPB(2'b0), // Port-B 2-bit parity Input
524
.ENB(1'b1), // PortB RAM Enable Input
525
.SSRB(1'b0), // Port B Synchronous Set/Reset Input
526
.WEB(twe) // Port B Write Enable Input
527
);
528
*/
529
ram18_var_w_var_r
#(
530
.
REGISTERS
(
0
),
531
.
LOG2WIDTH_WR
(
4
),
532
.
LOG2WIDTH_RD
(
4
),
533
.
DUMMY
(
0
)
534
`ifdef
PRELOAD_BRAMS, .INIT_00 (
256'h000008880FFF0FFF0888044401110111000008880FFF0FFF0888044401110000
)
535
, .
INIT_01
(
256'h00000222044408880FFF0FFF088808880000044408880FFF0FFF088804440444
)
536
, .
INIT_02
(
256'h0000000001110222044408880FFF0FFF000001110222044408880FFF0FFF0FFF
)
537
, .
INIT_03
(
256'h0000000000000000000000000000000000000000000001110222044408880888
)
538
, .
INIT_04
(
256'h00008888FFFFFFFF888844441111111100008888FFFFFFFF8888444411110000
)
539
, .
INIT_05
(
256'h0000222244448888FFFFFFFF88888888000044448888FFFFFFFF888844444444
)
540
, .
INIT_06
(
256'h000000001111222244448888FFFFFFFF00001111222244448888FFFFFFFFFFFF
)
541
, .
INIT_07
(
256'h0000000000000000000000000000000000000000000011112222444488888888
)
542
543
`endif
544
)
i_focus_dct_tab
(
545
.
rclk
(
clk
),
// input
546
.
raddr
({
filt_sel
[
3
:
0
],
tba
[
2
:
0
],
tba
[
5
:
3
]}),
// input[9:0]
547
.
ren
(
1'b1
),
// input
548
.
regen
(
1'b1
),
// input
549
.
data_out
(
tdo
[
15
:
0
]),
// output[31:0]
550
.
wclk
(
mclk
),
// input
551
.
waddr
(
ta
[
9
:
0
]),
// input[8:0]
552
.
we
(
twe
),
// input
553
.
web
(
4'hf
),
// input[3:0]
554
.
data_in
(
tdi
[
15
:
0
])
// input[31:0]
555
);
556
557
endmodule
558
559
ram18_var_w_var_r.11591regen
11591regen
Definition:
ram18_var_w_var_r.v:114
focus_sharp393.2390start_d
2390start_dreg
Definition:
focus_sharp393.v:91
focus_sharp393.2361quant_ds
2361quant_ds
Definition:
focus_sharp393.v:59
focus_sharp393.2356lasti
2356lasti
Definition:
focus_sharp393.v:54
dly_16.10332clk
10332clk
Definition:
dly_16.v:44
focus_sharp393.2385acc_frame
2385acc_framereg[39:0]
Definition:
focus_sharp393.v:86
focus_sharp393.2388need_corr_max
2388need_corr_maxreg
Definition:
focus_sharp393.v:89
focus_sharp393.dly_16
i_out_window dly_16
Definition:
focus_sharp393.v:236
focus_sharp393.2363quant_dc_tdo
[15:0] 2363quant_dc_tdo
Definition:
focus_sharp393.v:61
focus_sharp393.2383last
2383lastwire
Definition:
focus_sharp393.v:84
focus_sharp393.2398d1
2398d1reg[11:0]
Definition:
focus_sharp393.v:100
table_ad_receive.11054twe
[NUM_CHN-1:0] 11054twe
Definition:
table_ad_receive.v:51
focus_sharp393.2353tser_d
[ 7:0] 2353tser_d
Definition:
focus_sharp393.v:51
focus_sharp393.table_ad_receive
table_ad_receive_i table_ad_receive
Definition:
focus_sharp393.v:256
focus_sharp393.2364do
reg [12:0] 2364do
Definition:
focus_sharp393.v:62
focus_sharp393.2377filt_sel0
2377filt_sel0reg[3:0]
Definition:
focus_sharp393.v:79
focus_sharp393.2415started_luma
2415started_lumareg
Definition:
focus_sharp393.v:119
table_ad_receive.11049a_not_d
11049a_not_d
Definition:
table_ad_receive.v:46
focus_sharp393.2384tn
2384tnwire[2:0]
Definition:
focus_sharp393.v:85
focus_sharp393.2378filt_sel
2378filt_selreg[3:0]
Definition:
focus_sharp393.v:80
focus_sharp393.2357tni
[ 2:0] 2357tni
Definition:
focus_sharp393.v:55
focus_sharp393.2372wnd_left
2372wnd_leftreg[8:0]
Definition:
focus_sharp393.v:74
focus_sharp393.2425start_of_line
2425start_of_linewire
Definition:
focus_sharp393.v:167
focus_sharp393.2394combined_qf
2394combined_qfwire[12:0]
Definition:
focus_sharp393.v:96
focus_sharp393.2365ds
reg 2365ds
Definition:
focus_sharp393.v:63
focus_sharp393.2416luma_dc_out
2416luma_dc_outreg
Definition:
focus_sharp393.v:120
ram18_var_w_var_r.11597data_in
[1 << LOG2WIDTH_WR-1:0] 11597data_in
Definition:
ram18_var_w_var_r.v:121
focus_sharp393.2410mult_b
2410mult_bwire[17:0]
Definition:
focus_sharp393.v:113
focus_sharp393.2395next_do
2395next_dowire[12:0]
Definition:
focus_sharp393.v:97
focus_sharp393.2428clkdiv2
2428clkdiv2reg
Definition:
focus_sharp393.v:188
focus_sharp393.2407acc_corr
2407acc_corrwire
Definition:
focus_sharp393.v:110
ram18_var_w_var_r.11592data_out
[1 << LOG2WIDTH_RD-1:0] 11592data_out
Definition:
ram18_var_w_var_r.v:115
focus_sharp393.2419copy_acc_frame
2419copy_acc_framereg
Definition:
focus_sharp393.v:123
focus_sharp393.2434ram4
[0:3] 2434ram4reg[4:0]
Definition:
focus_sharp393.v:308
focus_sharp393.2418was_last_luma
2418was_last_lumareg
Definition:
focus_sharp393.v:122
focus_sharp393.2359start
2359start
Definition:
focus_sharp393.v:57
focus_sharp393.2381oc
2381ocreg[2:0]
Definition:
focus_sharp393.v:83
ram18_var_w_var_r.11589raddr
[13-LOG2WIDTH_RD:0] 11589raddr
Definition:
ram18_var_w_var_r.v:112
focus_sharp393.2380ic
2380icreg[2:0]
Definition:
focus_sharp393.v:82
focus_sharp393.2397di_d
2397di_dreg[11:0]
Definition:
focus_sharp393.v:99
focus_sharp393.2420twe
2420twewire
Definition:
focus_sharp393.v:125
focus_sharp393.2429clksync
2429clksyncreg[2:0]
Definition:
focus_sharp393.v:194
focus_sharp393.2369wnd_reg
2369wnd_regreg[11:0]
Definition:
focus_sharp393.v:68
focus_sharp393.2360di
[12:0] 2360di
Definition:
focus_sharp393.v:58
focus_sharp393.2403sum_blk
2403sum_blkreg[22:0]
Definition:
focus_sharp393.v:106
focus_sharp393.2352tser_a_not_d
2352tser_a_not_d
Definition:
focus_sharp393.v:50
focus_sharp393.2376wnd_totalwidth
2376wnd_totalwidthreg[8:1]
Definition:
focus_sharp393.v:78
focus_sharp393.2405acc_clear
2405acc_clearwire
Definition:
focus_sharp393.v:108
focus_sharp393.2400finish2
2400finish2reg[6:0]
Definition:
focus_sharp393.v:103
focus_sharp393.ram18_var_w_var_r
i_focus_dct_tab ram18_var_w_var_r
Definition:
focus_sharp393.v:337
focus_sharp393.2413next_ac
2413next_acreg
Definition:
focus_sharp393.v:117
dly_16.10336dout
[WIDTH-1:0] 10336dout
Definition:
dly_16.v:48
focus_sharp393.2417luma_dc_acc
2417luma_dc_accreg
Definition:
focus_sharp393.v:121
table_ad_receive.11053td
[MODE_16_BITS?15:7:0] 11053td
Definition:
table_ad_receive.v:50
focus_sharp393.2366hifreq
reg [31:0] 2366hifreq
Definition:
focus_sharp393.v:64
focus_sharp393.2431mult_p_r
2431mult_p_rreg[35:0]
Definition:
focus_sharp393.v:291
ram18_var_w_var_r.11588rclk
11588rclk
Definition:
ram18_var_w_var_r.v:110
ram18_var_w_var_r.11596web
[ 3:0] 11596web
Definition:
ram18_var_w_var_r.v:120
focus_sharp393.2370wnd_wr
2370wnd_wrreg
Definition:
focus_sharp393.v:69
focus_sharp393.2412mult_s
2412mult_sreg[17:0]
Definition:
focus_sharp393.v:116
table_ad_receive.11050ser_d
[7:0] 11050ser_d
Definition:
table_ad_receive.v:47
focus_sharp393.2362quant_d
[12:0] 2362quant_d
Definition:
focus_sharp393.v:60
focus_sharp393.2432mult_a_r
2432mult_a_rreg[17:0]
Definition:
focus_sharp393.v:292
focus_sharp393.2399start2
2399start2reg[8:0]
Definition:
focus_sharp393.v:101
focus_sharp393.2355firsti
2355firsti
Definition:
focus_sharp393.v:53
focus_sharp393.2389fdo
2389fdoreg[11:0]
Definition:
focus_sharp393.v:90
focus_sharp393.2350mclk
2350mclk
Definition:
focus_sharp393.v:48
dly_16.10335din
[WIDTH-1:0] 10335din
Definition:
dly_16.v:47
focus_sharp393.2375wnd_bottom
2375wnd_bottomreg[8:0]
Definition:
focus_sharp393.v:77
ram18_var_w_var_r.11590ren
11590ren
Definition:
ram18_var_w_var_r.v:113
focus_sharp393.2406acc_add
2406acc_addwire
Definition:
focus_sharp393.v:109
focus_sharp393.2427in_woi
2427in_woireg
Definition:
focus_sharp393.v:169
focus_sharp393
Definition:
focus_sharp393.v:44
ram18_var_w_var_r.11595we
11595we
Definition:
ram18_var_w_var_r.v:119
focus_sharp393.2374wnd_top
2374wnd_topreg[8:0]
Definition:
focus_sharp393.v:76
focus_sharp393.2396fdo_minus_max
2396fdo_minus_maxwire[12:0]
Definition:
focus_sharp393.v:98
focus_sharp393.2358stb
2358stb
Definition:
focus_sharp393.v:56
focus_sharp393.2368tba
2368tbareg[5:0]
Definition:
focus_sharp393.v:67
focus_sharp393.2426first_in_macro
2426first_in_macrowire
Definition:
focus_sharp393.v:168
focus_sharp393.2347clk
2347clk
Definition:
focus_sharp393.v:45
focus_sharp393.2404acc_ldval
2404acc_ldvalreg
Definition:
focus_sharp393.v:107
focus_sharp393.2411mult_p
2411mult_pwire[35:0]
Definition:
focus_sharp393.v:114
focus_sharp393.2371wnd_a
2371wnd_areg[2:0]
Definition:
focus_sharp393.v:70
focus_sharp393.2409mult_a
2409mult_awire[17:0]
Definition:
focus_sharp393.v:112
table_ad_receive.11052ta
[23-MODE_16_BITS:0] 11052ta
Definition:
table_ad_receive.v:49
focus_sharp393.2423mblk_hor
2423mblk_horreg[7:0]
Definition:
focus_sharp393.v:165
focus_sharp393.2348clk2x
2348clk2x
Definition:
focus_sharp393.v:46
ram18_var_w_var_r.11594waddr
[13-LOG2WIDTH_WR:0] 11594waddr
Definition:
ram18_var_w_var_r.v:118
focus_sharp393.2424mblk_vert
2424mblk_vertreg[7:0]
Definition:
focus_sharp393.v:166
focus_sharp393.2422ta
2422tawire[22:0]
Definition:
focus_sharp393.v:127
focus_sharp393.2367tdo
2367tdowire[15:0]
Definition:
focus_sharp393.v:66
focus_sharp393.2354mode
[ 1:0] 2354mode
Definition:
focus_sharp393.v:52
focus_sharp393.2349en
2349en
Definition:
focus_sharp393.v:47
focus_sharp393.2402acc_blk
2402acc_blkreg[23:0]
Definition:
focus_sharp393.v:105
focus_sharp393.2408acc_to_out
2408acc_to_outwire
Definition:
focus_sharp393.v:111
focus_sharp393.2421tdi
2421tdiwire[15:0]
Definition:
focus_sharp393.v:126
focus_sharp393.2430csync
2430csyncwire
Definition:
focus_sharp393.v:195
focus_sharp393.2414use_coef
2414use_coefreg
Definition:
focus_sharp393.v:118
focus_sharp393.2351tser_we
2351tser_we
Definition:
focus_sharp393.v:49
focus_sharp393.2382first
2382firstwire
Definition:
focus_sharp393.v:84
focus_sharp393.2391tn_d
2391tn_dreg[2:0]
Definition:
focus_sharp393.v:92
focus_sharp393.2393out_window
2393out_windowwire
Definition:
focus_sharp393.v:95
focus_sharp393.2379stren
2379strenreg
Definition:
focus_sharp393.v:81
focus_sharp393.2392out_mono
2392out_monowire
Definition:
focus_sharp393.v:94
focus_sharp393.2373wnd_right
2373wnd_rightreg[8:0]
Definition:
focus_sharp393.v:75
focus_sharp393.2401use_k_dly
2401use_k_dlyreg[5:0]
Definition:
focus_sharp393.v:104
focus_sharp393.2386pre_do
2386pre_doreg[12:0]
Definition:
focus_sharp393.v:87
dly_16.10333rst
10333rst
Definition:
dly_16.v:45
focus_sharp393.2387pre_ds
2387pre_dsreg
Definition:
focus_sharp393.v:88
table_ad_receive.11051dv
[NUM_CHN-1:0] 11051dv
Definition:
table_ad_receive.v:48
table_ad_receive.11048clk
11048clk
Definition:
table_ad_receive.v:45
ram18_var_w_var_r.11593wclk
11593wclk
Definition:
ram18_var_w_var_r.v:117
focus_sharp393.2433mult_b_r
2433mult_b_rreg[17:0]
Definition:
focus_sharp393.v:293
dly_16.10334dly
[3:0] 10334dly
Definition:
dly_16.v:46
compressor_jp
focus_sharp393.v
Generated by
1.8.12