x393  1.0
FPGAcodeforElphelNC393camera
jp_channel.v
Go to the documentation of this file.
1 
39 `timescale 1ns/1ps
40 
41 module jp_channel#(
42  parameter CMPRS_NUMBER = 0,
43  parameter CMPRS_GROUP_ADDR = 'h600,
44  parameter CMPRS_BASE_INC = 'h10,
45  parameter CMPRS_STATUS_REG_BASE= 'h10,
46  parameter CMPRS_HIFREQ_REG_BASE= 'h14,
47  parameter CMPRS_STATUS_REG_INC= 1,
48  parameter CMPRS_HIFREQ_REG_INC= 1,
49  parameter CMPRS_MASK= 'h7f8,
50  parameter CMPRS_CONTROL_REG= 0,
51  parameter CMPRS_STATUS_CNTRL= 1,
52  parameter CMPRS_FORMAT= 2,
53  parameter CMPRS_COLOR_SATURATION= 3,
54  parameter CMPRS_CORING_MODE= 4,
55  parameter CMPRS_INTERRUPTS= 5,
56  parameter CMPRS_TABLES= 6, // 6(data)..7(address)
57  parameter TABLE_QUANTIZATION_INDEX = 0,
58  parameter TABLE_CORING_INDEX = 1,
59  parameter TABLE_FOCUS_INDEX = 2,
60  parameter TABLE_HUFFMAN_INDEX = 3,
61 
62  parameter FRAME_HEIGHT_BITS= 16, // Maximal frame height
63  parameter LAST_FRAME_BITS= 16, // number of bits in frame counter (before rolls over)
64  // Bit-fields in compressor control word
65  parameter CMPRS_CBIT_RUN = 2, // bit # to control compressor run modes
66  parameter CMPRS_CBIT_RUN_BITS = 2, // number of bits to control compressor run modes
67  parameter CMPRS_CBIT_QBANK = 6, // bit # to control quantization table page
68  parameter CMPRS_CBIT_QBANK_BITS = 3, // number of bits to control quantization table page
69  parameter CMPRS_CBIT_DCSUB = 8, // bit # to control extracting DC components bypassing DCT
70  parameter CMPRS_CBIT_DCSUB_BITS = 1, // bit # to control extracting DC components bypassing DCT
71  parameter CMPRS_CBIT_CMODE = 13, // bit # to control compressor color modes
72  parameter CMPRS_CBIT_CMODE_BITS = 4, // number of bits to control compressor color modes
73  parameter CMPRS_CBIT_FRAMES = 15, // bit # to control compressor multi/single frame buffer modes
74  parameter CMPRS_CBIT_FRAMES_BITS = 1, // number of bits to control compressor multi/single frame buffer modes
75  parameter CMPRS_CBIT_BAYER = 20, // bit # to control compressor Bayer shift mode
76  parameter CMPRS_CBIT_BAYER_BITS = 2, // number of bits to control compressor Bayer shift mode
77  parameter CMPRS_CBIT_FOCUS = 23, // bit # to control compressor focus display mode
78  parameter CMPRS_CBIT_FOCUS_BITS = 2, // number of bits to control compressor focus display mode
79  // compressor bit-fields decode
80  parameter CMPRS_CBIT_RUN_RST = 2'h0, // reset compressor, stop immediately
81 // parameter CMPRS_CBIT_RUN_DISABLE = 2'h1, // disable compression of the new frames, finish any already started
82  parameter CMPRS_CBIT_RUN_STANDALONE = 2'h2, // enable compressor, compress single frame from memory (async)
83  parameter CMPRS_CBIT_RUN_ENABLE = 2'h3, // enable compressor, enable synchronous compression mode
84  parameter CMPRS_CBIT_CMODE_JPEG18 = 4'h0, // color 4:2:0
85  parameter CMPRS_CBIT_CMODE_MONO6 = 4'h1, // mono 4:2:0 (6 blocks)
86  parameter CMPRS_CBIT_CMODE_JP46 = 4'h2, // jp4, 6 blocks, original
87  parameter CMPRS_CBIT_CMODE_JP46DC = 4'h3, // jp4, 6 blocks, dc -improved
88  parameter CMPRS_CBIT_CMODE_JPEG20 = 4'h4, // mono, 4 blocks (but still not actual monochrome JPEG as the blocks are scanned in 2x2 macroblocks)
89  parameter CMPRS_CBIT_CMODE_JP4 = 4'h5, // jp4, 4 blocks, dc-improved
90  parameter CMPRS_CBIT_CMODE_JP4DC = 4'h6, // jp4, 4 blocks, dc-improved
91  parameter CMPRS_CBIT_CMODE_JP4DIFF = 4'h7, // jp4, 4 blocks, differential
92  parameter CMPRS_CBIT_CMODE_JP4DIFFHDR = 4'h8, // jp4, 4 blocks, differential, hdr
93  parameter CMPRS_CBIT_CMODE_JP4DIFFDIV2 = 4'h9, // jp4, 4 blocks, differential, divide by 2
94  parameter CMPRS_CBIT_CMODE_JP4DIFFHDRDIV2 = 4'ha, // jp4, 4 blocks, differential, hdr,divide by 2
95  parameter CMPRS_CBIT_CMODE_MONO1 = 4'hb, // mono JPEG (not yet implemented)
96  parameter CMPRS_CBIT_CMODE_MONO4 = 4'he, // mono 4 blocks
97  parameter CMPRS_CBIT_FRAMES_SINGLE = 0, //1, // use a single-frame buffer for images
98 
99  parameter CMPRS_COLOR18 = 0, // JPEG 4:2:0 with 18x18 overlapping tiles for de-bayer
100  parameter CMPRS_COLOR20 = 1, // JPEG 4:2:0 with 18x18 overlapping tiles for de-bayer (not implemented)
101  parameter CMPRS_MONO16 = 2, // JPEG 4:2:0 with 16x16 non-overlapping tiles, color components zeroed
102  parameter CMPRS_JP4 = 3, // JP4 mode with 16x16 macroblocks
103  parameter CMPRS_JP4DIFF = 4, // JP4DIFF mode TODO: see if correct
104  parameter CMPRS_MONO8 = 7, // Regular JPEG monochrome with 8x8 macroblocks (not yet implemented)
105 
106  parameter CMPRS_FRMT_MBCM1 = 0, // bit # of number of macroblock columns minus 1 field in format word
107  parameter CMPRS_FRMT_MBCM1_BITS = 13, // number of bits in number of macroblock columns minus 1 field in format word
108  parameter CMPRS_FRMT_MBRM1 = 13, // bit # of number of macroblock rows minus 1 field in format word
109  parameter CMPRS_FRMT_MBRM1_BITS = 13, // number of bits in number of macroblock rows minus 1 field in format word
110  parameter CMPRS_FRMT_LMARG = 26, // bit # of left margin field in format word
111  parameter CMPRS_FRMT_LMARG_BITS = 5, // number of bits in left margin field in format word
112  parameter CMPRS_CSAT_CB = 0, // bit # of number of blue scale field in color saturation word
113  parameter CMPRS_CSAT_CB_BITS = 10, // number of bits in blue scale field in color saturation word
114  parameter CMPRS_CSAT_CR = 12, // bit # of number of red scale field in color saturation word
115  parameter CMPRS_CSAT_CR_BITS = 10, // number of bits in red scale field in color saturation word
116  parameter CMPRS_CORING_BITS = 3, // number of bits in coring mode
117 
118  parameter CMPRS_TIMEOUT_BITS= 12,
119  parameter CMPRS_TIMEOUT= 1000, // mclk cycles
120  parameter NUM_FRAME_BITS = 4 // number of bits use for frame number
121 
122 `ifdef DEBUG_RING
123  ,parameter DEBUG_CMD_LATENCY = 2 //SuppressThisWarning VEditor - not used
124 `endif
125 
126 )(
127  input xclk, // global clock input, compressor single clock rate
128 `ifdef USE_XCLK2X
129  input xclk2x, // global clock input, compressor double clock rate, nominally rising edge aligned
130 `endif
131  input mrst, // @posedge mclk, sync reset
132  input xrst, // @posedge xclk, sync reset
133  input hrst, // @posedge xclk, sync reset
134 
135  // programming interface
136  input mclk, // global system/memory clock
137  input [7:0] cmd_ad, // byte-serial command address/data (up to 6 bytes: AL-AH-D0-D1-D2-D3
138  input cmd_stb, // strobe (with first byte) for the command a/d
139  output [7:0] status_ad, // status address/data - up to 5 bytes: A - {seq,status[1:0]} - status[2:9] - status[10:17] - status[18:25]
140  output status_rq, // input request to send status downstream
141  input status_start, // Acknowledge of the first status packet byte (address)
142  output irq, // processor interrupt
143 
144  // Buffer interface (buffer to be a part of the memory controller - it is connected there by a 64-bit data, here - by an 9-bit one
145  input xfer_reset_page_rd, // from mcntrl_tiled_rw (
147  input buf_wpage_nxt, // advance to next page memory interface writes to
148  input buf_we, // @!mclk write buffer from memory, increment write
149  input [63:0] buf_din, // data out
150 
151 
152  input page_ready_chn, // single mclk (posedge)
153  output next_page_chn, // single mclk (posedge): Done with the page in the buffer, memory controller may read more data
154 // Master(sensor)/slave(compressor) synchronization signals
155  output frame_start_dst, // @mclk - trigger receive (tiledc) memory channel (it will take care of single/repetitive
156  // these output either follows vsync_late (reclocks it) or generated in non-bonded mode
157  // (compress from memory)
158  input [FRAME_HEIGHT_BITS-1:0] line_unfinished_src,// number of the current (unfinished ) line, in the source (sensor) channel (RELATIVE TO FRAME, NOT WINDOW?)
159  input [LAST_FRAME_BITS-1:0] frame_number_src, // current frame number (for multi-frame ranges) in the source (sensor) channel
160  input frame_done_src, // single-cycle pulse when the full frame (window) was transferred to/from DDR3 memory
161  // frame_done_src is later than line_unfinished_src/ frame_number_src changes
162  // Used withe a single-frame buffers
163 
164  input [FRAME_HEIGHT_BITS-1:0] line_unfinished_dst,// number of the current (unfinished ) line in this (compressor) channel
165  input [LAST_FRAME_BITS-1:0] frame_number_dst, // current frame number (for multi-frame ranges) in this (compressor channel
166  input frame_done_dst, // single-cycle pulse when the full frame (window) was transferred to/from DDR3 memory
167  // use as 'eot_real' in 353
168  output suspend, // suspend reading data for this channel - waiting for the source data
169  output reg [LAST_FRAME_BITS-1:0] frame_number_finished, // valid after stuffer done
170 
171 
172 // statistics data was not used in late nc353
173  input dccout, //enable output of DC and HF components for brightness/color/focus adjustments
174  input [2:0] hfc_sel, // [2:0] (for autofocus) only components with both spacial frequencies higher than specified will be added
176  output [15:0] statistics_do,
177 
178 // Timestamp messages (@mclk)
179  input ts_pre_stb, // @mclk - 1 cycle before receiving 8 bytes of timestamp data
180  input [7:0] ts_data, // timestamp data (s0,s1,s2,s3,us0,us1,us2,us3==0)
181 
183  output stuffer_done_mclk,
184 
185 // output [31:0] hifreq, // accumulated high frequency components in a frame sub-window
186  input vsync_late, // delayed start of frame, @mclk. In 353 it was 16 lines after VACT active
187  // source channel should already start, some delay give time for sequencer commands
188  // that should arrive before it
189  input [NUM_FRAME_BITS-1:0] frame_num_compressed,
190 
191  // Output interface to the AFI mux
192  input hclk,
193  input fifo_rst, // reset FIFO (set read address to write, reset count)
194  input fifo_ren,
195  output [63:0] fifo_rdata,
196  output fifo_eof, // single rclk pulse signaling EOF
197  input eof_written, // confirm frame written over AFI to the system memory (single rclk pulse)
198  output fifo_flush, // EOF, need to output all what is in FIFO (Stays active until enough data chunks are read)
199  output flush_hclk, // output before writing last chunk - use it to suspend AFI to have
200  // last burst marked as the last one (otherwise last may be empty if frame had %4==0 chunks)
201  output [7:0] fifo_count // number of 32-byte chunks in FIFO
202 `ifdef DEBUG_RING
203  ,output debug_do, // output to the debug ring
204  input debug_sl, // 0 - idle, (1,0) - shift, (1,1) - load // SuppressThisWarning VEditor - not used
205  input debug_di // input from the debug ring
206 `endif
207 );
208 //`ifdef DEBUG_RING
209 // assign debug_do = debug_di; // just temporarily to short-circuit the ring
210 //`endif
215  wire [31:0] hifreq; // accumulated high frequency components in a frame sub-window was output, now - with status
216 
217  // Control signals to be defined
218  wire frame_en; // if 0 - will reset logic immediately (but not page number)
219  wire frame_start_xclk; // re-clocked, parameters are copied at this pulse
220  wire stuffer_en; // extended enable to allow stuffer to gracefully finish
221 
222  wire frame_go=frame_en; // start frame: if idle, will start reading data (if available),
223  // if running - will not restart a new frame if 0.
224  wire [CMPRS_FRMT_LMARG_BITS-1:0] left_marg; // left margin (for not-yet-implemented) mono JPEG (8 lines tile row) can need 7 bits (mod 32 - tile)
225  wire [CMPRS_FRMT_MBCM1_BITS-1:0] n_blocks_in_row_m1; // number of macroblocks in a macroblock row minus 1
226  wire [CMPRS_FRMT_MBRM1_BITS-1:0] n_block_rows_m1; // number of macroblock rows in a frame minus 1
227  wire ignore_color; // zero Cb/Cr components (TODO: maybe include into converter_type?)
228  wire [ 1:0] bayer_phase; // [1:0]) bayer color filter phase 0:(GR/BG), 1:(RG/GB), 2: (BG/GR), 3: (GB/RG)
229 // wire four_blocks; // use only 6 blocks for the output, not 6
230  wire jp4_dc_improved; // in JP4 mode, compare DC coefficients to the same color ones
231 // wire [ 1:0] tile_margin; // margins around 16x16 tiles (0/1/2)
232 // wire [ 2:0] tile_shift; // tile shift from top left corner
233  wire [ 2:0] converter_type; // 0 - color18, 1 - color20, 2 - mono, 3 - jp4, 4 - jp4-diff, 7 - mono8 (not yet implemented)
234  wire scale_diff; // divide differences by 2 (to fit in 8-bit range)
235  wire hdr; // second green absolute, not difference
236  wire subtract_dc; // subtract/restore DC components
237  wire [CMPRS_CSAT_CB_BITS-1:0] m_cb; // [9:0] scale for CB - default 0.564 (10'h90)
238  wire [CMPRS_CSAT_CR_BITS-1:0] m_cr; // [9:0] scale for CR - default 0.713 (10'hb6)
240  wire [ 1:0] cmprs_fmode; // focusing/overlay mode
241 
242  //TODO: assign next 5 values from converter_type[2:0]
243  wire [ 5:0] mb_w_m1; // macroblock width minus 1
244  wire [ 5:0] mb_h_m1; // macroblock height -1
245  wire [ 4:0] mb_hper; // macroblock horizontal period (8/16) // 3 LSB not used
246  wire [ 1:0] tile_width; // memory tile width (can be 128 for monochrome JPEG) Can be 32/64/128: 0 - 16, 1 - 32, 2 - 64, 3 - 128
247  wire tile_col_width; // 0 - 16 pixels, 1 -32 pixels
248 
249 
250  // signals connecting modules: cmprs_macroblock_buf_iface_i and cmprs_pixel_buf_iface_i:
251  wire mb_pre_end; // from cmprs_pixel_buf_iface - just in time to start a new macroblock w/o gaps
252  wire mb_release_buf; // send required "next_page" pulses to buffer. Having rather long minimal latency in the memory
253  // controller this can just be the same as mb_pre_end_in
254  wire mb_pre_start; // 1 clock cycle before stream of addresses to the buffer
255  wire [ 1:0] start_page; // page to read next tile from (or first of several pages)
256  wire [ 6:0] macroblock_x; // macroblock left pixel x relative to a tile (page) Maximal page - 128 bytes wide
257 
258  // signals connecting modules: cmprs_macroblock_buf_iface_i and cmprs_buf_average:
259 
260  wire first_mb; // output reg
261  wire last_mb; // output
262 
263  // signals connecting modules: cmprs_pixel_buf_iface_i and chn_rd_buf_i:
264 // wire [ 7:0] buf_di; // data from the buffer
265 // wire [11:0] buf_ra; // buffer read address (2 MSB - page number)
266  wire [ 1:0] buf_rd; // buf {regen, re}
267  wire [ 7:0] buf_pxd; // 8-bit pixel data from the memory buffer
268  wire [11:0] buf_ra; // Memory buffer read address
269  // signals connecting modules: chn_rd_buf_i and ???:
270  wire [ 7:0] mb_data_out; // Macroblock data out in scanline order
271  wire mb_pre_first_out; // Macroblock data out strobe - 1 cycle just before data valid
272  wire mb_pre2_first_out; // Macroblock data out strobe - 2 cycles just before data valid
273 // wire mb_data_valid; // Macroblock data out valid
274 
275  wire limit_diff = 1'b1; // as in the prototype - just a constant 1
276 
277  // signals connecting modules: csconvert and cmprs_buf_average:
278 
279 
280  wire [8:0] signed_y; // was y_in
281  wire [8:0] signed_c; // was c_in
282  wire [7:0] yaddrw;
283  wire ywe;
284  wire [7:0] caddrw;
285  wire cwe;
286  wire yc_pre_first_out; // pre first output from color converter (was pre_first_out) - last cycle of writing (may inc wpage
287  // How they are used? Can it be average instead?
288  wire [7:0] n000; // number of all 0 in macroblock (255 for 256), valid only for color JPEG
289  wire [7:0] n255; // number of all 255 in macroblock (255 for 256), valid only for color JPEG
290 
291  // signals connecting modules: cmprs_buf_average and ???:
293  wire [ 9:0] yc_nodc; // [9:0] data out (4:2:0) (signed, average=0)
294  wire [ 8:0] yc_avr; // [8:0] DC (average value) - RAM output, no register. For Y components 9'h080..9'h07f, for C - 9'h100..9'h0ff!
295 // wire yc_nodc_dv; // out data valid (will go high for at least 64 cycles)
296  wire dct_start; // single-cycle mark of the first_r pixel in a 64 (8x8) - pixel block
297  wire [ 2:0] color_tn; // [2:0] tile number 0..3 - Y, 4 - Cb, 5 - Cr (valid with start)
298  wire color_first; // sending first_r MCU (valid @ ds)
299  wire color_last; // sending last_r MCU (valid @ ds)
300 // below signals valid at ds ( 1 later than tn, first_r, last_r)
301  wire [2:0] component_num; //[2:0] - component number (YCbCr: 0 - Y, 1 - Cb, 2 - Cr, JP4: 0-1-2-3 in sequence (depends on shift) 4 - don't use
302  wire component_color; // use color quantization table (YCbCR, jp4diff)
303  wire component_first; // first this component in a frame (DC absolute, otherwise - difference to previous)
304 
305  wire component_lastinmb; // last_r component in a macroblock;
306 
307 
308 // control signals valid @ mclk
309  wire cmprs_en_extend; // extend cmprs_en_xclk to include flushing
310  wire cmprs_en_mclk; // resets immediately
311  wire cmprs_run_mclk; // enable propagation of vsync_late to frame_start_dst in bonded(sync to src) mode
312  wire cmprs_standalone; // single-cycle: generate a single frame_start_dst in unbonded (not synchronized) mode. cmprs_run should be off
313  wire sigle_frame_buf; // input - memory controller uses a single frame buffer (frame_number_* == 0), use other sync
314 
315 
317  wire force_flush_long;
318 /// wire enc_last; not used
319  wire [15:0] enc_do;
320  wire enc_dv;
321 
322 //TODO: use next signals for status
324  wire reading_frame;
325 // SuppressWarnings VEditor unused
326  wire frame_started_mclk;// store frame number ? Wrong, frame number should come from the sensor channel
328  reg [LAST_FRAME_BITS-1:0] frame_number_started; // valid when stuffer started
329 
330 // output reg [LAST_FRAME_BITS-1:0] frame_number_finished, // valid after stuffer done
331  always @ (posedge mclk) begin
335 
336  end
337 
338 `ifdef USE_XCLK2X
339  wire [15:0] huff_do; // output[15:0] reg
340  wire [3:0] huff_dl; // output[3:0] reg
341  wire huff_dv; // output reg
342  wire flush; // output reg @ negedge xclk2x
343  wire last_block; // @negedge xxlk2x - used to copy timestamp in stuffer
344  wire stuffer_rdy; // receiver (bit stuffer) is ready to accept data;
345 `endif
346 
348  wire [31:0] cmd_data; // 32-bit data to write to tables and registers(LSB first) - from cmd_deser
349  wire cmd_we; // control register write enable
350  wire [2:0] cmd_a; // control register write enable
351 
353  wire set_status_w;
359 
360  wire stuffer_running; // @negedge xclk2x from registering timestamp until done
361 
362  wire [12:0] quant_do;
363  wire quant_ds;
364  wire [15:0] quant_dc_tdo;// MSB aligned coefficient for the DC component (used in focus module)
365  wire [ 2:0] cmprs_qpage;
366  wire [ 2:0] coring_num;
367  reg dcc_en;
368 
369 
370  wire [15:0] dccdata; // was not used in late nc353
371  wire dccvld; // was not used in late nc353
372 
375  assign set_format_w = cmd_we && (cmd_a== CMPRS_FORMAT);
377  assign set_coring_w = cmd_we && (cmd_a== CMPRS_CORING_MODE);
379  assign set_tables_w = cmd_we && ((cmd_a & 6)== CMPRS_TABLES);
380 
381 
382 `ifdef USE_XCLK2X
383  // re-sync to posedge xclk2x
384  reg xrst2xn;
385  always @ (negedge xclk2x) xrst2xn <= xrst;
386 `endif
387 
388 `ifdef DEBUG_RING
389  `ifndef USE_XCLK2X
390 // wire [15:0] huff_do; // output[15:0] reg
391 // wire [3:0] huff_dl; // output[3:0] reg
392 // wire huff_dv; // output reg
393 // wire flush; // output reg @ negedge xclk2x
394  wire last_block = 0; // @negedge xxlk2x - used to copy timestamp in stuffer
395  wire stuffer_rdy = 1; // receiver (bit stuffer) is ready to accept data;
396  wire xrst2xn = xrst;
397  `endif
401  reg [31:0] debug_fifo_in;
402  reg [31:0] debug_fifo_out;
403  reg [15:0] pre_start_cntr;
404  reg [15:0] pre_end_cntr;
406  reg [15:0] pages_requested;
407  reg [15:0] pages_got;
408  wire [1:0] dbg_add_invalid;
410  reg [15:0] pages_needed; // count number requested
411  reg [15:0] page_requests; // count regardless of how many requested
414  wire [3:0] etrax_dma;
415  wire dbg_ts_rstb; // output
416  wire [7:0] dbg_ts_dout; //output [7:0]
417  wire [31:0] dbg_sec;
418  wire [31:0] dbg_usec;
419 
423 
427  wire dbg_gotLastBlock;
429  wire dbg_last_DCAC;
431  reg dbg_lastBlock_sent;
432  wire dbg_fifo_or_full;
433  wire dbg_comp_lastinmbo;
434  wire [2:0] dbg_block_mem_ra;
435  reg [15:0] dbg_stb_cntr;
436  reg [15:0] dbg_zds_cntr;
437  wire [2:0] dbg_block_mem_wa;
438  wire [2:0] dbg_block_mem_wa_save;
439  `ifndef USE_XCLK2X
440  // temporarily assigning unused debug signals to 0
441 // assign dbg_add_invalid = 0;
442 // assign dbg_mb_release_buf = 0;
443 // assign etrax_dma = 0;
444 // assign dbg_ts_rstb = 0; // output
445 // assign dbg_ts_dout = 0; //output [7:0]
446  assign dbg_flushing = 0; // still not used in huffman_stuffer_meta
447 // assign dbg_test_lbw = 0;
448 // assign dbg_gotLastBlock = 0;
449  assign dbg_fifo_or_full = 0; // still not used in huffman_stuffer_meta
450 
451  `endif
452  timestamp_to_parallel dbg_timestamp_to_parallel_i (
453  `ifdef USE_XCLK2X
454  .clk (~xclk2x), // input
455  `else
456  .clk (xclk), // input
457  `endif
458  .pre_stb (dbg_ts_rstb), // input
459  .tdata (dbg_ts_dout), // input[7:0]
460  .sec (dbg_sec), // output[31:0] reg
461  .usec (dbg_usec[19:0]), // output[19:0] reg
462  .done() // output
463  );
464 
465 
466 // cmprs_standalone - use to reset flush
467  `ifdef USE_XCLK2X
468  always @ (posedge ~xclk2x) begin
469  `else
470  always @ (posedge xclk) begin
471  `endif
473  if (xrst2xn || dbg_reset_fifo) debug_fifo_in <= 0;
474  else if (stuffer_dv) debug_fifo_in <= debug_fifo_in + 1;
475 
477 
479  else if (last_block) dbg_last_block_persist <= 1;
480 
483 
484 //dbg_last_block_persist
485  end
486  always @ (posedge hclk) begin
487  if (hrst) debug_fifo_out <= 0;
488  else if (fifo_rst) debug_fifo_out <= 0; // debug_fifo_in >> 2;
489  else if (fifo_ren) debug_fifo_out <= debug_fifo_out + 1;
490 
492 
494  else if (flush_hclk) dbg_flush_hclk <= 1;
495  end
496 
497  always @ (posedge mclk) begin
498  if (!cmprs_en_mclk) pages_requested <= 0;
500 
501  if (!cmprs_en_mclk) pages_got <= 0;
502  else if (page_ready_chn) pages_got <= pages_got + 1;
503 
504  if (!cmprs_en_mclk) debug_frame_done <= 0;
505  else if (frame_done_dst) debug_frame_done <= 1;
506 
509 
510  end
511 
512  always @ (posedge xclk) begin
513  if (!frame_en) pre_start_cntr <= 0;
514  else if (mb_pre_start) pre_start_cntr <= pre_start_cntr + 1;
515 
516  if (!frame_en) pre_end_cntr <= 0;
517  else if (mb_pre_end) pre_end_cntr <= pre_end_cntr + 1;
518 
519  if (!frame_en) pages_needed <= 0;
521 
522  if (!frame_en) page_requests <= 0;
524 
525  if (!frame_en) dbg_lastBlock_sent <= 0;
526  else if (enc_dv && enc_do[15] && enc_do[14] && enc_do[12] ) dbg_lastBlock_sent <= 1;
527 // else if enc_do[15:0]
528 
529  if (!frame_en) dbg_stb_cntr <= 0;
530  else if (dct_start) dbg_stb_cntr <= dbg_stb_cntr + 1;
531 
532  if (!frame_en) dbg_zds_cntr <= 0;
533  else if (focus_ds) dbg_zds_cntr <= dbg_zds_cntr + 1;
534 
535  end
536 //frame_start_dst
537 
538  debug_slave #(
539  .SHIFT_WIDTH (384),
540  .READ_WIDTH (384),
541  .WRITE_WIDTH (32),
542  .DEBUG_CMD_LATENCY (DEBUG_CMD_LATENCY)
543  ) debug_slave_i (
544  .mclk (mclk), // input
545  .mrst (mrst), // input
546  .debug_di (debug_di), // input
547  .debug_sl (debug_sl), // input
548  .debug_do (debug_do), // output
549  .rd_data ({
550  dbg_usec,
551  dbg_sec,
552  26'h0, dbg_block_mem_wa_save[2:0],dbg_block_mem_wa[2:0],
553  dbg_zds_cntr[15:0],
554  dbg_stb_cntr[15:0],
555  pages_needed[15:0],
556  page_requests[15:0],
557  pre_end_cntr[15:0],
558  pre_start_cntr[15:0],
559  pages_got[15:0],
560  pages_requested[15:0],
562  debug_fifo_in[31:0],
565  fifo_count[7:0],
567  frame_number_dst[15:0],
568  line_unfinished_dst[15:0],
569  frame_number_src[15:0],
570  line_unfinished_src[15:0]
571  }), // input[31:0]
572  .wr_data (), // output[31:0] - not used
573  .stb () // output - not used
574  );
575 // wire [2:0] dbg_block_mem_wa;
576 // wire [2:0] dbg_block_mem_wa_save;
577 
578  pulse_cross_clock dbg_fs_hclk_i (
579  .rst (!cmprs_en_mclk),
580  .src_clk (mclk),
581  .dst_clk (hclk),
584  .busy ());
585 
586 
587 `endif
588 
589  cmd_deser #(
590  .ADDR (CMPRS_ADDR),
591  .ADDR_MASK (CMPRS_MASK),
592  .NUM_CYCLES (6),
593  .ADDR_WIDTH (3),
594  .DATA_WIDTH (32)
595  ) cmd_deser_32bit_i (
596  .rst (1'b0), //rst), // input
597  .clk (mclk), // input
598  .srst (mrst), // input
599  .ad (cmd_ad), // input[7:0]
600  .stb (cmd_stb), // input
601  .addr (cmd_a), // output[3:0]
602  .data (cmd_data), // output[31:0]
603  .we (cmd_we) // output
604  );
605 
606  wire [11:0] status_data;
608  .NUM_FRAME_BITS(4)
609  ) cmprs_status_i (
610  .mrst (mrst), // input
611  .mclk (mclk), // input
612  .eof_written (eof_written_mclk), // input
614  .reading_frame (reading_frame), // input
616  .set_interrupts (set_interrupts_w), // input
617  .data_in (cmd_data[1:0]), // input[1:0]
618  .status (status_data), // output[9:0]
619  .irq (irq) // output
620  );
621 
622  status_generate #(
623  .STATUS_REG_ADDR (CMPRS_STATUS_REG_ADDR),
624  .PAYLOAD_BITS (14),
625  .EXTRA_WORDS (1),
626  .EXTRA_REG_ADDR (CMPRS_HIFREQ_REG_ADDR)
627 
628  ) status_generate_i (
629  .rst (1'b0), // input
630  .clk (mclk), // input
631  .srst (mrst), // input
632  .we (set_status_w), // input
633  .wd (cmd_data[7:0]), // input[7:0]
634  .status ({hifreq,status_data,2'b0}), // input[45:0]
635  .ad (status_ad), // output[7:0]
636  .rq (status_rq), // output
637  .start (status_start) // input
638  );
639 
640 //hifreq
641 // Not needed?
642 // reg emul64;
643 // always @ (negedge mclk) begin
644 // emul64 <= tile_width[1]; // will not work for monochrome (128 pixel wide) - chnge to 64?
645 // end
646 
647 
648  mcntrl_buf_rd #(
649  .LOG2WIDTH_RD(3) // 64 bit external interface
650  ) chn_rd_buf_i (
651  .ext_clk (xclk), // input
652  .ext_raddr (buf_ra), // input[11:0]
653  .ext_rd (buf_rd[0]), // input
654  .ext_regen (buf_rd[1]), // input
655  .ext_data_out (buf_pxd), // output[7:0]
656 // .emul64 (1'b0), //emul64), // input Modify buffer addresses (used for JP4 until a 64-wide mode is implemented)
657  .wclk (!mclk), // input
658  .wpage_in (2'b0), // input[1:0]
659  .wpage_set (xfer_reset_page_rd), // input TODO: Generate @ negedge mclk on frame start
660  .page_next (buf_wpage_nxt), // input
661  .page (), // output[1:0]
662  .we (buf_we), // input
663  .data_in (buf_din) // input[63:0]
664  );
665 
701  .CMPRS_JP4 (CMPRS_JP4),
715  ) cmprs_cmd_decode_i (
716 // .rst (rst), // input
717  .xclk (xclk), // input - global clock input, compressor single clock rate
718  .mclk (mclk), // input - global system/memory clock
719  .mrst (mrst), // input
720  .ctrl_we (set_ctrl_reg_w), // input - control register write enable
721  .format_we (set_format_w), // input - write number of tiles and left margin
722  .color_sat_we (set_color_saturation_w), // input - write color saturation values
723  .coring_we (set_coring_w), // input - write color saturation values
724  .di (cmd_data), // input[31:0] - 32-bit data to write to control register (24LSB are used)
725  .frame_start (frame_start_dst), // input @mclk
726  .frame_start_xclk (frame_start_xclk), // re-clocked, parameters are copied during this pulse
727  .cmprs_en_mclk (cmprs_en_mclk), // output
728  .cmprs_en_extend (cmprs_en_extend), // input
729  .cmprs_run_mclk (cmprs_run_mclk), // output reg
730  .cmprs_standalone (cmprs_standalone), // output reg
731  .sigle_frame_buf (sigle_frame_buf), // output reg
732  .cmprs_en_xclk (frame_en), // output reg
733  .cmprs_en_late_xclk (stuffer_en), // output reg - extended enable to allow stuffer to gracefully finish
734  .cmprs_qpage (cmprs_qpage), // output[2:0] reg
735  .cmprs_dcsub (subtract_dc), // output reg
736  .cmprs_fmode (cmprs_fmode), // output[1:0] reg
737  .bayer_shift (bayer_phase), // output[1:0] reg
738  .ignore_color (ignore_color), // output reg
739 // .four_blocks (four_blocks), // output reg Not used?
740  .four_blocks (), // output reg Not used?
741  .jp4_dc_improved (jp4_dc_improved), // output reg
742  .converter_type (converter_type), // output[2:0] reg
743  .scale_diff (scale_diff), // output reg
744  .hdr (hdr), // output reg
745  .left_marg (left_marg), // output[4:0] reg
746  .n_blocks_in_row_m1 (n_blocks_in_row_m1), // output[12:0] reg
747  .n_block_rows_m1 (n_block_rows_m1), // output[12:0] reg
748  .color_sat_cb (m_cb), // output[9:0] reg
749  .color_sat_cr (m_cr), // output[9:0] reg
750  .coring (coring_num) // output[2:0] reg
751  );
752 
753 // set derived parameters from converter_type
754 // wire [ 2:0] converter_type; // 0 - color18, 1 - color20, 2 - mono, 3 - jp4, 4 - jp4-diff, 7 - mono8 (not yet implemented)
755  cmprs_tile_mode_decode #( // fully combinatorial
759  .CMPRS_JP4 (CMPRS_JP4),
762  ) cmprs_tile_mode_decode_i (
763  .converter_type (converter_type), // input[2:0]
764  .mb_w_m1 (mb_w_m1), // output[5:0] reg
765  .mb_h_m1 (mb_h_m1), // output[5:0] reg
766  .mb_hper (mb_hper), // output[4:0] reg
767  .tile_width (tile_width), // output[1:0] reg
768  .tile_col_width (tile_col_width) // output reg
769  );
770 
771 
777  ) cmprs_frame_sync_i (
778 // .rst (rst), // input
779  .xclk (xclk), // input - global clock input, compressor single clock rate
780  .mclk (mclk), // input - global system/memory clock
781  .mrst (mrst), // input
782  .xrst (xrst), // input
783  .cmprs_en (cmprs_en_mclk), // input - @mclk 0 resets immediately
784  .cmprs_en_extend (cmprs_en_extend), // output
785  .cmprs_run (cmprs_run_mclk), // input - @mclk enable propagation of vsync_late to frame_start_dst in bonded(sync to src) mode
786  .cmprs_standalone (cmprs_standalone), // input - @mclk single-cycle: generate a single frame_start_dst in unbonded (not synchronized) mode.
787  // cmprs_run should be off
788  .sigle_frame_buf (sigle_frame_buf), // input - memory controller uses a single frame buffer (frame_number_* == 0), use other sync
789  .vsync_late (vsync_late), // input - @mclk delayed start of frame, @xclk. In 353 it was 16 lines after VACT active
790  // source channel should already start, some delay give time for sequencer commands
791  // that should arrive before it
792  .frame_started (first_mb && mb_pre_start), // @xclk started first macroblock (checking for broken frames)
793  .frame_start_dst (frame_start_dst), // output reg @mclk - trigger receive (tiled) memory channel (it will take care of
794  // single/repetitive modes itself this output either follows vsync_late (reclocks it)
795  // or generated in non-bonded mode (compress from memory once)
796  .line_unfinished_src(line_unfinished_src), // input[15:0] - number of the current (unfinished ) line, in the source (sensor) channel
797  .frame_number_src (frame_number_src), // input[15:0] - current frame number (for multi-frame ranges) in the source (sensor) channel
798  .frame_done_src (frame_done_src), // input - single-cycle pulse when the full frame (window) was transferred to/from DDR3 memory
799  // frame_done_src is later than line_unfinished_src/ frame_number_src changes
800  // Used withe a single-frame buffers
801  .line_unfinished (line_unfinished_dst), // input[15:0] - number of the current (unfinished ) line in this (compressor) channel
802  .frame_number (frame_number_dst), // input[15:0] - current frame number (for multi-frame ranges) in this (compressor channel
803  .frame_done (frame_done_dst), // input - single-cycle pulse when the full frame (window) was transferred to/from DDR3 memory
804  .suspend (suspend), // output reg - suspend reading data for this channel - waiting for the source data
805  .stuffer_running (stuffer_running), // input
806  .force_flush_long (force_flush_long), // output reg - @ mclk tried to start frame compression before the previous one was finished
808  .reading_frame (reading_frame), // output
810  );
811 
812  cmprs_macroblock_buf_iface cmprs_macroblock_buf_iface_i (
813 // .rst (rst), // input
814  .xclk (xclk), // input
815  .mclk (mclk), // input
816  .mrst (mrst), // input
817  .xrst (xrst), // input
819  .page_ready_chn (page_ready_chn), // input
820  .next_page_chn (next_page_chn), // output
821  .frame_en (frame_en), // input
822  .frame_start_xclk (frame_start_xclk), // input@posedge xclk - parameters are copied @ this pulse
823  .frame_go (frame_go), // input - do not use - assign to frame_en? Running frames can be controlled by other means
824  .left_marg (left_marg), // input[4:0]
825  .n_blocks_in_row_m1 (n_blocks_in_row_m1), // input[12:0]
826  .n_block_rows_m1 (n_block_rows_m1), // input[12:0]
827  .mb_w_m1 (mb_w_m1), // input[5:0] // macroblock width minus 1 // 3 LSB not used here
828  .mb_hper (mb_hper), // input[4:0] // macroblock horizontal period (8/16) // 3 LSB not used (set them 0)
829  .tile_width (tile_width), // input[1:0] // memory tile width. Can be 32/64/128: 0 - 16, 1 - 32, 2 - 64, 3 - 128
830  .mb_pre_end_in (mb_pre_end), // input
831  .mb_release_buf (mb_release_buf), // input
832  .mb_pre_start_out (mb_pre_start), // output
833  .start_page (start_page), // output[1:0]
834  .macroblock_x (macroblock_x), // output[6:0]
835  .first_mb (first_mb), // output reg
836  .last_mb (last_mb) // output
837 `ifdef DEBUG_RING
840 `endif
841  );
842 
844  .CMPRS_PREEND_EARLY (6), // TODO:Check / Adjust
845  .CMPRS_RELEASE_EARLY (16),
846  .CMPRS_BUF_EXTRA_LATENCY (0),
850  .CMPRS_JP4 (CMPRS_JP4),
853 
854  ) cmprs_pixel_buf_iface_i (
855  .xclk (xclk), // input
856  .frame_en (frame_en), // input
857  .buf_di (buf_pxd), // input[7:0]
858  .buf_ra (buf_ra), // output[11:0]
859  .buf_rd (buf_rd), // output[1:0]
860  .converter_type (converter_type), // input[2:0]
861  .mb_w_m1 (mb_w_m1), // input[5:0]
862  .mb_h_m1 (mb_h_m1), // input[5:0]
863  .tile_width (tile_width), // input[1:0]
864  .tile_col_width (tile_col_width), // input
865  .mb_pre_end (mb_pre_end), // output
866  .mb_release_buf (mb_release_buf), // output
867  .mb_pre_start (mb_pre_start), // input
868  .start_page (start_page), // input[1:0]
869  .macroblock_x (macroblock_x), // input[6:0]
870  .data_out (mb_data_out), // output[7:0] // Macroblock data out in scanline order
871  .pre_first_out (mb_pre_first_out), // output // Macroblock data out strobe - 1 cycle just before data valid == old pre_first_pixel?
872 // .data_valid (mb_data_valid) // output // Macroblock data out valid
873  .pre2_first_out (mb_pre2_first_out), // output reg
874  .data_valid () // output reg // Macroblock data out valid Unused
875  );
876 
877  csconvert #(
881  .CMPRS_JP4 (CMPRS_JP4),
884  ) csconvert_i (
885  .xclk (xclk), // input
886  .frame_en (frame_en), // input
887  .converter_type (converter_type), // input[2:0]
888  .ignore_color (ignore_color), // input
889  .scale_diff (scale_diff), // input
890  .hdr (hdr), // input
891  .limit_diff (limit_diff), // input
892  .m_cb (m_cb), // input[9:0]
893  .m_cr (m_cr), // input[9:0]
894  .mb_din (mb_data_out), // input[7:0]
895  .bayer_phase (bayer_phase), // input[1:0]
896  .pre2_first_in (mb_pre2_first_out),// input
897  .signed_y (signed_y), // output[8:0] reg
898  .signed_c (signed_c), // output[8:0] reg
899  .yaddrw (yaddrw), // output[7:0] reg
900  .ywe (ywe), // output reg
901  .caddrw (caddrw), // output[7:0] reg
902  .cwe (cwe), // output reg
903  .pre_first_out (yc_pre_first_out), // output reg
904  .n000 (n000), // output[7:0] reg
905  .n255 (n255) // output[7:0] reg
906  );
907 
908 
913  .CMPRS_JP4 (CMPRS_JP4),
916  ) cmprs_buf_average_i (
917  .xclk (xclk), // input
918  .frame_en (frame_en), // input
919  .converter_type (converter_type), // input[2:0]
920  .pre_first_in (mb_pre_first_out), // input
922  .bayer_phase (bayer_phase), // input[1:0]
923  .jp4_dc_improved (jp4_dc_improved), // input
924  .hdr (hdr), // input
925  .subtract_dc_in (subtract_dc), // input
926  .first_mb_in (first_mb), // input - calculate in cmprs_macroblock_buf_iface
927  .last_mb_in (last_mb), // input - calculate in cmprs_macroblock_buf_iface
928  .yaddrw (yaddrw), // input[7:0]
929  .ywe (ywe), // input
930  .signed_y (signed_y), // input[8:0]
931  .caddrw (caddrw), // input[7:0]
932  .cwe (cwe), // input
933  .signed_c (signed_c), // input[8:0]
934  .do (yc_nodc), // output[9:0]
935  .avr (yc_avr), // output[8:0]
936 // .dv (yc_nodc_dv), // output
937  .dv (), // output unused?
938  .ds (dct_start), // output
939  .tn (color_tn), // output[2:0]
940  .first (color_first), // output reg
941  .last (color_last), // output reg
942  .component_num (component_num), // output[2:0]
943  .component_color (component_color), // output
944  .component_first (component_first), // output
946  );
947 // wire [ 9:0] yc_nodc; // [9:0] data out (4:2:0) (signed, average=0)
950 ///TODO: Replace always@ with a module?
951 
952  wire dct_last_in;
953  wire dct_pre_first_out;
954 // wire dct_dv;
955  wire [12:0] dct_out;
956 
957 
958  //propagation of first block through compressor pipeline
959 
960  wire first_block_color=(color_tn[2:0]==3'h0) && color_first; // while color conversion,
961  reg first_block_color_after; // after color conversion,
962  reg first_block_dct; // after DCT
963  wire first_block_quant; // after quantizer
964  always @ (posedge xclk) begin
967  end
968 
969  // 8x8 DCT implementing Chen algorithm and 2 passes
970  // Each pass (1d) uses 5 DSP48E1 modules (2 - multipliers and 3 SIMD (2x24) adder/subracters
971  // Needs a small (<48, but did not calculate yet) pause between block if they did not come
972  // immediately after each other. This pause is needed to restart pipeline
973 
974  dct2d8x8_chen #(
975  .INPUT_WIDTH (10),
976  .OUTPUT_WIDTH (13),
977  .STAGE1_SAFE_BITS (3),
978  .STAGE2_SAFE_BITS (3),
979  .TRANSPOSE_WIDTH (16),
980  .TRIM_STAGE_1 (1),
981  .TRIM_STAGE_2 (0),
982  .DSP_WIDTH (24),
983  .DSP_B_WIDTH (18),
984  .DSP_A_WIDTH (25),
985  .DSP_P_WIDTH (48)
986  ) dct2d8x8_chen_i (
987  .clk (xclk), // input
988  .rst (!frame_en), // input
989  .start (dct_start), // input
990  .xin (yc_nodc), // input[9:0] signed
991  .last_in (dct_last_in), // output reg
992  .pre_first_out (dct_pre_first_out), // output
993  .dv (), // output
994  .d_out (dct_out) // output[12:0] signed
995  );
996 
998  dly_16 #(.WIDTH(1)) i_quant_start (.clk(xclk),.rst(1'b0), .dly(4'd0), .din(dct_pre_first_out), .dout(quant_start)); // dly=0+1
999 
1001  always @ (posedge xclk) begin
1002  if (!dccout) dcc_en <=1'b0;
1003  else if (dct_start && color_first && (color_tn[2:0]==3'b001)) dcc_en <=1'b1; // 3'b001 - closer to the first "start" in quantizator
1004  end
1005 
1006 
1007 // wire table_a_not_d; // writing table address /not data (a[0] from cmd_deser)
1008 // wire table_we; // writing to tables (decoded stb from cmd_deser)
1009  wire tser_a_not_d; // address/not data distributed to submodules
1010  wire [ 7:0] tser_d; // byte-wide serialized tables address/data to submodules
1011  wire [ 3:0] tser_sel; // vector of individual table selects (decoded from the 8 MSBs of the table address)
1012  wire tser_qe = tser_sel[TABLE_QUANTIZATION_INDEX]; // write serialized table data to quantizer
1013  wire tser_ce = tser_sel[TABLE_CORING_INDEX]; // write serialized table data to coring
1014  wire tser_fe = tser_sel[TABLE_FOCUS_INDEX]; // write serialized table data to focusing
1015  wire tser_he = tser_sel[TABLE_HUFFMAN_INDEX]; // write serialized table data to Huffman
1016 //{tser_he,tser_fe,tser_ce,tser_qe}
1017 // As all commands are 32-bit data, all 4 bytes will be written to a designated table (usually 2 of 16-bit writes)
1019  .NUM_CHANNELS(4),
1020  .ADDR_BITS(3)
1021  ) table_ad_transmit_i (
1022  .clk (mclk), // input @posedge
1023  .srst (mrst), // @posedge mclk
1024  .a_not_d_in (cmd_a[0]), // input writing table address /not data (a[0] from cmd_deser)
1025  .we (set_tables_w), // input writing to tables (decoded stb from cmd_deser)
1026  .din (cmd_data), // input[31:0] 32-bit data to serialize/write to tables (LSB first) - from cmd_deser
1027  .ser_d (tser_d), // output[7:0] byte-wide serialized tables address/data to submodules
1028  .a_not_d (tser_a_not_d), // output reg address/not data distributed to submodules
1029 // .chn_en ({tser_he,tser_fe,tser_ce,tser_qe}) // output[0:0] reg - table 1-hot select outputs
1030  .chn_en (tser_sel) // output[0:0] reg - table 1-hot select outputs
1031  );
1032 
1033 
1034 
1035  quantizer393 quantizer393_i (
1036  .clk (xclk), // input
1037  .en (frame_en), // input
1038  .mclk (mclk), // input system clock, twqe, twce, ta,tdi - valid @posedge (ra, tdi - 2 cycles ahead (was negedge)
1039  .tser_qe (tser_qe), // input - write to a quantization table
1040  .tser_ce (tser_ce), // input - write to a coring table
1041  .tser_a_not_d (tser_a_not_d), // input - address/not data to tables
1042  .tser_d (tser_d), // input[7:0] - byte-wide data to tables
1043  .ctypei (component_color), // input component type input (Y/C)
1044  .dci (yc_avr), // input[8:0] - average value in a block - subtracted before DCT. now normal signed number
1045  .first_stb (first_block_color), // input - this is first stb pulse in a frame
1046  .stb (dct_start), // input - strobe that writes ctypei, dci
1047  .tsi (cmprs_qpage[2:0]), // input[2:0] - table (quality) select [2:0]
1048  .pre_start (dct_pre_first_out), // input - marks first input pixel (one before)
1049  .first_in (first_block_dct), // input - first block in (valid @ start)
1050  .first_out (first_block_quant), // output reg - valid @ ds
1051  .di (dct_out[12:0]), // input[12:0] - pixel data in (signed)
1052  .do (quant_do[12:0]), // output[12:0] - pixel data out (AC is only 9 bits long?) - changed to 10
1053  .dv (), // output reg - data out valid
1054  .ds (quant_ds), // output reg - data out strobe (one ahead of the start of dv)
1055  .dc_tdo (quant_dc_tdo[15:0]), // output[15:0] reg - MSB aligned coefficient for the DC component (used in focus module)
1056  .dcc_en (dcc_en), // input - enable dcc (sync to beginning of a new frame)
1057  .hfc_sel (hfc_sel), // input[2:0] - hight frequency components select [2:0] (includes components with both numbers >=hfc_sel
1058  .color_first (color_first), // input - first MCU in a frame
1059  .coring_num (coring_num), // input[2:0] - coring table pair number (0..7)
1060  .dcc_vld (dccvld), // output reg - single cycle when dcc_data is valid
1061  .dcc_data (dccdata[15:0]), // output[15:0] - dc component data out (for reading by software)
1062  .n000 (n000), // input[7:0] - number of zero pixels (255 if 256) - to be multiplexed with dcc
1063  .n255 (n255) // input[7:0] - number of 0xff pixels (255 if 256) - to be multiplexed with dcc
1064  );
1065 
1066  // focus sharp module calculates amount of high-frequency components and optioanlly overlays/replaces actual image
1067  wire [12:0] focus_do; // output[12:0] reg pixel data out, make timing ignore (valid 1.5 clk earlier that Quantizer output)
1068  wire focus_ds; // output reg data out strobe (one ahead of the start of dv)
1069  // TODO: Verify focus_sharp393: quantizer output (with strobes) is now 2 cycles later than in 353 (relative to xdct out). Seems to be OK.
1070  focus_sharp393 focus_sharp393_i (
1071  .clk (xclk), // input - pixel clock
1072 `ifdef USE_XCLK2X
1073  .clk2x (xclk2x), // input 2x pixel clock
1074 `else
1075  .clk2x (xclk), // FIXME: fix the module not to use xclk2x
1076 `endif
1077  .en (frame_en), // input
1078 
1079  .mclk (mclk), // input system clock to write tables
1080  .tser_we (tser_fe), // input - write to a focus sharpness table
1081  .tser_a_not_d (tser_a_not_d), // input - address/not data to tables
1082  .tser_d (tser_d), // input[7:0] - byte-wide data to tables
1083 
1084  .mode (cmprs_fmode[1:0]), // input[1:0] focus mode (combine image with focus info) - 0 - none, 1 - replace, 2 - combine all, 3 - combine woi
1085  .firsti (color_first), // input first macroblock
1086  .lasti (color_last), // input last macroblock
1087  .tni (color_tn[2:0]), // input[2:0] block number in a macronblock - 0..3 - Y, >=4 - color (sync to stb)
1088  .stb (dct_start), // input strobe that writes ctypei, dci
1089  .start (quant_start), // input marks first input pixel (needs 1 cycle delay from previous DCT stage)
1090  .di (dct_out), // input[12:0] pixel data in (signed)
1091  .quant_ds (quant_ds), // input quantizator ds
1092  .quant_d (quant_do[12:0]), // input[12:0] quantizator data output
1093  .quant_dc_tdo (quant_dc_tdo), // input[15:0] MSB aligned coefficient for the DC component (used in focus module)
1094  .do (focus_do[12:0]), // output[12:0] reg pixel data out, make timing ignore (valid 1.5 clk earlier that Quantizer output)
1095  .ds (focus_ds), // output reg data out strobe (one ahead of the start of dv)
1096  .hifreq (hifreq[31:0]) // output[31:0] reg accumulated high frequency components in a frame sub-window
1097  );
1098 
1099  // Format DC components to be output as a mini-frame. Was not used in the late NC353 as the dma1 channel was used for IMU instead of dcc
1100  wire finish_dcc;
1101 `ifdef USE_XCLK2X
1102  wire [15:0] stuffer_do;
1103 `else
1104  wire [31:0] stuffer_do;
1105 `endif
1106  wire stuffer_dv;
1107  wire stuffer_done;
1108 
1109 `ifdef USE_XCLK2X
1110  pulse_cross_clock finish_dcc_i (.rst(xrst2xn), .src_clk(~xclk2x), .dst_clk(xclk2x), .in_pulse(stuffer_done), .out_pulse(finish_dcc),.busy());
1111 `else
1112  assign finish_dcc = stuffer_done;
1113 `endif
1114 
1115  dcc_sync393 dcc_sync393_i (
1116 `ifdef USE_XCLK2X
1117  .sclk (xclk2x), // input
1118 `else
1119  .sclk (xclk), // input
1120 `endif
1121  .dcc_en (dcc_en), // input xclk rising, sync with start of the frame
1122  .finish_dcc (finish_dcc), // input @ sclk rising
1123  .dcc_vld (dccvld), // input xclk rising
1124  .dcc_data (dccdata[15:0]), // input[15:0] @clk rising
1125  .statistics_dv (statistics_dv), // output reg
1126  .statistics_do (statistics_do[15:0]) // output[15:0] reg @ sclk
1127  );
1128 
1129 
1130 // generate DC data/strobe for the direct output (re) using sdram channel3 buffering
1131 // encoderDCAC is updated to handle 13-bit signed data instead of the 12-bit. It will limit the values on ot's own
1132  encoderDCAC393 encoderDCAC393_i (
1133  .clk (xclk), // input
1134  .en (frame_en), // input
1135  .lasti (color_last), // input - was "last MCU in a frame" (@ stb)
1136  .first_blocki (first_block_color), // input - first block in frame - save fifo write address (@ stb)
1137  .comp_numberi (component_num[2:0]), // input[2:0] - component number 0..2 in color, 0..3 - in jp4diff, >= 4 - don't use (@ stb)
1138  .comp_firsti (component_first), // input - first this component in a frame (reset DC) (@ stb)
1139  .comp_colori (component_color), // input - use color - huffman? (@ stb)
1140  .comp_lastinmbi (component_lastinmb), // input - last component in a macroblock (@ stb) is it needed?
1141  .stb (dct_start), // input - strobe that writes firsti, lasti, tni,average
1142  .zdi (focus_do[12:0]), // input[12:0] - zigzag-reordered data input
1143  .first_blockz (first_block_quant), // input - first block input (@zds)
1144  .zds (focus_ds), // input - strobe - one ahead of the DC component output
1145 `ifdef DEBUG_RING
1146  .last (dbg_last_DCAC), // output reg - not used
1147 `else
1148  .last (), // output reg - not used
1149 `endif
1150  .do (enc_do[15:0]), // output[15:0] reg
1151  .dv (enc_dv) // output reg
1152 `ifdef DEBUG_RING
1157 `else
1158  ,.comp_lastinmbo ()
1159  ,.dbg_block_mem_ra ()
1160  ,.dbg_block_mem_wa ()
1161  ,.dbg_block_mem_wa_save ()
1162 `endif
1163  );
1164 
1165 // wire [2:0] dbg_block_mem_wa;
1166 // wire [2:0] dbg_block_mem_wa_save;
1167 
1168 `ifdef USE_XCLK2X
1169  huffman393 i_huffman (
1170  .xclk (xclk), // input
1171  .xclk2x (xclk2x), // input
1172  .en (frame_en), // input
1173  .mclk (mclk), // input system clock to write tables
1174  .tser_we (tser_he), // input - write to a quantization table
1175  .tser_a_not_d (tser_a_not_d), // input - address/not data to tables
1176  .tser_d (tser_d), // input[7:0] - byte-wide data to tables
1177  .di (enc_do[15:0]), // input[15:0] - specially RLL prepared 16-bit data (to FIFO)
1178  .ds (enc_dv), // input - di valid strobe
1179  .rdy (stuffer_rdy), // input - receiver (bit stuffer) is ready to accept data
1180  .do (huff_do[15:0]), // output[15:0] reg
1181  .dl (huff_dl[3:0]), // output[3:0] reg
1182  .dv (huff_dv), // output reg
1183  .flush (flush), // output reg
1184  .last_block (last_block), // output reg
1185 `ifdef DEBUG_RING
1186  .test_lbw (dbg_test_lbw), // output reg ??
1187  .gotLastBlock (dbg_gotLastBlock), // output ?? - unused (was for debug)
1188 `else
1189  .test_lbw (), // output reg ??
1190  .gotLastBlock (), // output ?? - unused (was for debug)
1191 `endif
1192  .clk_flush (hclk), // input
1193  .flush_clk (flush_hclk), // output
1194 `ifdef DEBUG_RING
1195  .fifo_or_full (dbg_fifo_or_full) // FIFO output register full - just for debuging
1196 `else
1197  .fifo_or_full () // FIFO output register full - just for debuging
1198 `endif
1199  );
1200 
1201 
1202  stuffer393 stuffer393_i (
1203 // .rst (rst), // input
1204  .mclk (mclk), // input
1205  .mrst (mrst), // input
1206  .xrst (xrst), // input
1207  .last_block (last_block), // input @negedge xclk2x - use it to copy timestamp from fifo
1208  .ts_pre_stb (ts_pre_stb), // input 1 cycle before timestamp data, @mclk
1209  .ts_data (ts_data), // input[7:0] 8-byte timestamp data (s0,s1,s2,s3,us0,us1,us2,us3==0)
1210  .color_first (color_first), // input valid @xclk - only for sec/usec
1211  .fradv_clk (xclk), // input
1212  .clk (xclk2x), // input clock - uses negedge inside
1213  .en_in (stuffer_en), //
1214  .flush (flush), // input - flush output data (fill byte with 0, long word with FFs)
1215  .abort (force_flush_long), // @ any, extracts 0->1 and flushes
1216  .stb (huff_dv), // input
1217  .dl (huff_dl), // input[3:0] number of bits to send (0 - 16) (0-16??)
1218  .d (huff_do), // input[15:0] data to shift (only lower huff_dl bits are valid)
1219  // outputs valid @negedge xclk2x
1220  .rdy (stuffer_rdy), // output - enable huffman encoder to proceed. Used as CE for many huffman encoder registers
1221  .q (stuffer_do), // output[15:0] reg - output data
1222  .qv (stuffer_dv), // output reg - output data valid
1223  .done (stuffer_done), // output
1224 `ifdef DEBUG_RING
1225  .flushing (dbg_flushing), // output reg Not used?
1226 `else
1227  .flushing (), // output reg Not used?
1228 `endif
1229  .running (stuffer_running) // from registering timestamp until done
1230 `ifdef DEBUG_RING
1231  , .dbg_etrax_dma (etrax_dma)
1232  ,.dbg_ts_rstb (dbg_ts_rstb) // output
1233  ,.dbg_ts_dout (dbg_ts_dout) //output [7:0]
1234 
1235 `endif
1236 `ifdef debug_stuffer
1237  ,.etrax_dma_r(tst_stuf_etrax[3:0]) // [3:0] just for testing
1238  ,.test_cntr(test_cntr[3:0])
1239  ,.test_cntr1(test_cntr1[7:0])
1240 `endif
1241  );
1242 
1243 //cat x393_testbench03-latest.log | grep "COMPRESSOR[32 ]*CHN" > compressors_out32.log
1244  wire eof_written_xclk2xn;
1245  pulse_cross_clock stuffer_done_mclk_i (.rst(xrst2xn), .src_clk(~xclk2x), .dst_clk(mclk), .in_pulse(stuffer_done), .out_pulse(stuffer_done_mclk),.busy());
1246  cmprs_out_fifo cmprs_out_fifo_i (
1247  // source (stuffer) clock domain
1248  .wclk (~xclk2x), // input source clock (2x pixel clock, inverted) - same as stuffer out
1249  .wrst (xrst2xn), // input mostly for simulation
1250 
1251  .we (stuffer_dv), // @ posedge(~xclk2x) input write data from stuffer
1252  .wdata ({stuffer_do[7:0],stuffer_do[15:8]}), // input[15:0] data from stuffer module;
1253  .wa_rst (!stuffer_en), // input reset low address bits when stuffer is disabled (to make sure it is multiple of 32 bytes
1254  .wlast (stuffer_done), // input - written last 32 bytes of a frame (flush FIFO) - stuffer_done (has to be later than we)
1255  .eof_written_wclk (eof_written_xclk2xn), // output - AFI had transferred frame data to the system memory
1256  // AFI clock domain
1257  .rclk (hclk), // @posedge(hclk) input - AFI clock
1258  .rrst (hrst), // input - AFI clock
1259  .rst_fifo (fifo_rst), // input - reset FIFO (set read address to write, reset count)
1260  .ren (fifo_ren), // input - fifo read from AFI channel mux
1261  .rdata (fifo_rdata), // output[63:0] - data to AFI channel mux (latency == 2 from fifo_ren)
1262  .eof (fifo_eof), // output single hclk pulse signalling EOF
1263  .eof_written (eof_written), // input single hclk pulse confirming frame data is written to the system memory
1264  .flush_fifo (fifo_flush), // output level signalling that FIFO has data from the current frame (use short AXI burst if needed)
1265  .fifo_count (fifo_count) // output[7:0] - number of 32-byte chunks available in FIFO
1266  );
1267  pulse_cross_clock eof_written_mclk_i (.rst(xrst2xn), .src_clk(~xclk2x), .dst_clk(mclk), .in_pulse(eof_written_xclk2xn), .out_pulse(eof_written_mclk),.busy());
1268 // pulse_cross_clock eof_written_mclk_i (.rst(xrst2xn), .src_clk(~xclk2x), .dst_clk(mclk), .in_pulse(eof_written_xclk2xn), .out_pulse(eof_written_mclk),.busy());
1269 
1270 
1271  `ifdef DISPLAY_COMPRESSED_DATA
1272  integer dbg_stuffer_word_number;
1273  reg dbg_odd_stuffer_dv;
1274  reg [15:0] dbg_even_stuffer_do;
1275  wire [31:0] dbg_stuffer_do32 = {dbg_even_stuffer_do, stuffer_do};
1276  always @ (negedge xclk2x) begin
1277 
1278  if (stuffer_dv && dbg_odd_stuffer_dv) begin
1279  $display ("COMPRESSOR CHN%d 0x%x -> 0x%x", CMPRS_NUMBER, dbg_stuffer_word_number, dbg_stuffer_do32);
1280  end
1281 
1282  if (stuffer_done) begin
1283  $display ("COMPRESSOR CHN%d ***** DONE *****",CMPRS_NUMBER);
1284  end
1285 
1286  if (stuffer_dv && !dbg_odd_stuffer_dv) dbg_even_stuffer_do = stuffer_do;
1287 
1288  if (!stuffer_en || stuffer_done) dbg_stuffer_word_number = 0;
1289  else if (stuffer_dv && dbg_odd_stuffer_dv) dbg_stuffer_word_number = dbg_stuffer_word_number + 1;
1290 
1291  if (!stuffer_en) dbg_odd_stuffer_dv = 0;
1292  else if (stuffer_dv) dbg_odd_stuffer_dv = ~dbg_odd_stuffer_dv;
1293 
1294  end
1295  `endif
1296 
1297 `else
1298  huffman_stuffer_meta huffman_stuffer_meta_i (
1299  .mclk (mclk), // input
1300  .mrst (mrst), // input
1301  .xclk (xclk), // input
1302  .en_huffman (frame_en), // input
1303  .en_stuffer (stuffer_en), // input
1304  .abort_stuffer (force_flush_long), // input
1305  .tser_we (tser_he), // input
1306  .tser_a_not_d (tser_a_not_d), // input
1307  .tser_d (tser_d), // input[7:0]
1308  .di (enc_do[15:0]), // input[15:0]
1309  .ds (enc_dv), // input
1310  .ts_pre_stb (ts_pre_stb), // input
1311  .ts_data (ts_data), // input[7:0]
1312  .color_first (color_first), // input valid @xclk - only for sec/usec
1313  .data_out (stuffer_do), // output[31:0]
1314  .data_out_valid (stuffer_dv), // output
1315  .done (stuffer_done), // output
1316  .running (stuffer_running), // output
1317  .clk_flush (hclk), // input
1318  .flush_clk (flush_hclk) // output
1319 
1320  `ifdef DEBUG_RING
1321  ,.test_lbw (dbg_test_lbw), // output reg ??
1322  .gotLastBlock (dbg_gotLastBlock), // output ?? - unused (was for debug)
1323  .dbg_etrax_dma (etrax_dma), // output[3:0]
1324  .dbg_ts_rstb (dbg_ts_rstb), // output
1325  .dbg_ts_dout (dbg_ts_dout) //output[7:0]
1326  `endif
1327  );
1328  wire eof_written_xclk;
1330  cmprs_out_fifo32 cmprs_out_fifo_i (
1331  // source (stuffer) clock domain
1332  .wclk (xclk), // input source clock (1x pixel clock, inverted) - same as stuffer out
1333  .wrst (xrst), // input mostly for simulation
1334 
1335  .we (stuffer_dv), // @ posedge(~xclk2x) input write data from stuffer
1336  .wdata ({stuffer_do[7:0],stuffer_do[15:8],stuffer_do[23:16],stuffer_do[31:24]}), // input[15:0] data from stuffer module;
1337  .wa_rst (!stuffer_en), // input reset low address bits when stuffer is disabled (to make sure it is multiple of 32 bytes
1338  .wlast (stuffer_done), // input - written last 32 bytes of a frame (flush FIFO) - stuffer_done (has to be later than we)
1339  .eof_written_wclk (eof_written_xclk), // output - AFI had transferred frame data to the system memory
1340  // AFI clock domain
1341  .rclk (hclk), // @posedge(hclk) input - AFI clock
1342  .rrst (hrst), // input - AFI clock
1343  .rst_fifo (fifo_rst), // input - reset FIFO (set read address to write, reset count)
1344  .ren (fifo_ren), // input - fifo read from AFI channel mux
1345  .rdata (fifo_rdata), // output[63:0] - data to AFI channel mux (latency == 2 from fifo_ren)
1346  .eof (fifo_eof), // output single hclk pulse signalling EOF
1347  .eof_written (eof_written), // input single hclk pulse confirming frame data is written to the system memory
1348  .flush_fifo (fifo_flush), // output level signalling that FIFO has data from the current frame (use short AXI burst if needed)
1349  .fifo_count (fifo_count) // output[7:0] - number of 32-byte chunks available in FIFO
1350  );
1352 
1353  `ifdef DISPLAY_COMPRESSED_DATA
1354  integer stuffer_word_number;
1355  always @ (posedge xclk) begin
1356  if (stuffer_dv) begin
1357  $display ("COMPRESSOR CHN%d 0x%x -> 0x%x", CMPRS_NUMBER, stuffer_word_number, stuffer_do);
1358  end
1359  if (stuffer_done) begin
1360  $display ("COMPRESSOR CHN%d ***** DONE *****",CMPRS_NUMBER);
1361  end
1364  end
1365  `endif
1366 
1367 `endif
1368 
1369 // TODO: Add status module to combine/FF, re-clock status signals
1370 
1371 
1372 endmodule
1373 
1374 
2650CMPRS_CONTROL_REG0
Definition: jp_channel.v:50
[NUM_FRAME_BITS+7:0] 1798status
Definition: cmprs_status.v:52
2658TABLE_CORING_INDEX1
Definition: jp_channel.v:58
[LAST_FRAME_BITS-1:0] 1600frame_number_src
[7:0] 2720cmd_ad
Definition: jp_channel.v:136
2871dbg_ts_rstbwire
Definition: jp_channel.v:403
2643CMPRS_GROUP_ADDR'h600
Definition: jp_channel.v:43
2841set_color_saturation_wwire
Definition: jp_channel.v:347
10332clk
Definition: dly_16.v:44
2644CMPRS_BASE_INC'h10
Definition: jp_channel.v:44
2689CMPRS_CBIT_CMODE_JP4DIFFDIV24'h9
Definition: jp_channel.v:93
2811n255wire[7:0]
Definition: jp_channel.v:288
2747eof_written_mclk
Definition: jp_channel.v:181
2748stuffer_done_mclk
Definition: jp_channel.v:182
2705CMPRS_FRMT_LMARG_BITS5
Definition: jp_channel.v:111
2802limit_diffwire
Definition: jp_channel.v:274
2912stuffer_dowire[31:0]
Definition: jp_channel.v:1087
2702CMPRS_FRMT_MBRM113
Definition: jp_channel.v:108
2667CMPRS_CBIT_DCSUB8
Definition: jp_channel.v:69
2893status_datawire[11:0]
Definition: jp_channel.v:591
[15:0] 2363quant_dc_tdo
2789mb_pre_endwire
Definition: jp_channel.v:250
reg [ 1:0] 1544bayer_shift
2862pages_requestedreg[15:0]
Definition: jp_channel.v:394
2821component_lastinmbwire
Definition: jp_channel.v:304
[WRITE_WIDTH - 1 : 0] 10318wr_data
Definition: debug_slave.v:56
2817color_lastwire
Definition: jp_channel.v:298
[NUM_FRAME_BITS-1:0] 2750frame_num_compressed
Definition: jp_channel.v:188
[ 7:0] 2944n255
Definition: quantizer393.v:73
2884dbg_gotLastBlock_persistreg
Definition: jp_channel.v:418
2910focus_dswire
Definition: jp_channel.v:1053
2701CMPRS_FRMT_MBCM1_BITS13
Definition: jp_channel.v:107
[ 2:0] 2039converter_type
Definition: csconvert.v:51
cmprs_frame_sync_i cmprs_frame_sync
Definition: jp_channel.v:757
signed [OUTPUT_WIDTH-1:0] 3283d_out
Definition: dct2d8x8_chen.v:64
[ 7:0] 2353tser_d
2868dbg_stuffer_ext_runningreg
Definition: jp_channel.v:400
2902tser_a_not_dwire
Definition: jp_channel.v:994
2773n_block_rows_m1wire[CMPRS_FRMT_MBRM1_BITS-1:0]
Definition: jp_channel.v:225
2657TABLE_QUANTIZATION_INDEX0
Definition: jp_channel.v:57
2815color_tnwire[2:0]
Definition: jp_channel.v:296
2706CMPRS_CSAT_CB0
Definition: jp_channel.v:112
reg [ 7:0] 2056n000
Definition: csconvert.v:75
cmprs_status_i cmprs_status
Definition: jp_channel.v:592
reg [12:0] 2364do
2646CMPRS_HIFREQ_REG_BASE'h14
Definition: jp_channel.v:46
[1:0] 1797data_in
Definition: cmprs_status.v:51
csconvert_i csconvert
Definition: jp_channel.v:862
2828enc_dowire[15:0]
Definition: jp_channel.v:318
2783cmprs_fmodewire[1:0]
Definition: jp_channel.v:239
2879dbg_last_block_persistreg
Definition: jp_channel.v:413
reg [CMPRS_FRMT_MBCM1_BITS-1:0] 1552n_blocks_in_row_m1
2860pre_end_cntrreg[15:0]
Definition: jp_channel.v:392
2848quant_dc_tdowire[15:0]
Definition: jp_channel.v:356
2824cmprs_run_mclkwire
Definition: jp_channel.v:310
2662LAST_FRAME_BITS16
Definition: jp_channel.v:63
2655CMPRS_INTERRUPTS5
Definition: jp_channel.v:55
chn_rd_buf_i mcntrl_buf_rd
Definition: jp_channel.v:633
2822cmprs_en_extendwire
Definition: jp_channel.v:308
2790mb_release_bufwire
Definition: jp_channel.v:251
[LAST_FRAME_BITS-1:0] 2734frame_number_src
Definition: jp_channel.v:158
2712CMPRS_TIMEOUT1000
Definition: jp_channel.v:119
2825cmprs_standalonewire
Definition: jp_channel.v:311
2692CMPRS_CBIT_CMODE_MONO44'he
Definition: jp_channel.v:96
2801mb_pre2_first_outwire
Definition: jp_channel.v:271
2836cmd_wewire
Definition: jp_channel.v:341
2901quant_startwire
Definition: jp_channel.v:982
cmprs_macroblock_buf_iface_i cmprs_macroblock_buf_iface
Definition: jp_channel.v:797
2659TABLE_FOCUS_INDEX2
Definition: jp_channel.v:59
2807caddrwwire[7:0]
Definition: jp_channel.v:283
2787tile_widthwire[1:0]
Definition: jp_channel.v:245
2779hdrwire
Definition: jp_channel.v:234
2867page_requestsreg[15:0]
Definition: jp_channel.v:399
dcc_sync393_i dcc_sync393
Definition: jp_channel.v:1097
2839set_status_wwire
Definition: jp_channel.v:345
2855stuffer_rdywire
Definition: jp_channel.v:383
[LAST_FRAME_BITS-1:0] 1603frame_number
cmprs_out_fifo_i cmprs_out_fifo32
Definition: jp_channel.v:1194
2913stuffer_dvwire
Definition: jp_channel.v:1089
2846quant_dowire[12:0]
Definition: jp_channel.v:354
2882dbg_frame_start_hclkwire
Definition: jp_channel.v:416
2835cmd_datawire[31:0]
Definition: jp_channel.v:340
2800mb_pre_first_outwire
Definition: jp_channel.v:270
2696CMPRS_MONO162
Definition: jp_channel.v:101
2768frame_start_xclkwire
Definition: jp_channel.v:218
2770frame_gowire
Definition: jp_channel.v:221
2766hifreqwire[31:0]
Definition: jp_channel.v:214
table_ad_transmit_i table_ad_transmit
Definition: jp_channel.v:1003
reg 2055pre_first_out
Definition: csconvert.v:71
2797buf_pxdwire[7:0]
Definition: jp_channel.v:266
2654CMPRS_CORING_MODE4
Definition: jp_channel.v:54
2809yc_pre_first_outwire
Definition: jp_channel.v:285
reg [CMPRS_FRMT_LMARG_BITS-1:0] 1551left_marg
2774ignore_colorwire
Definition: jp_channel.v:226
[7:0] 2759fifo_count
Definition: jp_channel.v:200
2886dbg_fifo_or_fullwire
Definition: jp_channel.v:420
2642CMPRS_NUMBER0
Definition: jp_channel.v:42
2892dbg_block_mem_wa_savewire[2:0]
Definition: jp_channel.v:426
2889dbg_stb_cntrreg[15:0]
Definition: jp_channel.v:423
2691CMPRS_CBIT_CMODE_MONO14'hb
Definition: jp_channel.v:95
2792start_pagewire[1:0]
Definition: jp_channel.v:254
[2:0] 2317dbg_block_mem_ra
2888dbg_block_mem_rawire[2:0]
Definition: jp_channel.v:422
[ 2:0] 2928tsi
Definition: quantizer393.v:56
i_quant_start dly_16
Definition: jp_channel.v:983
2804signed_cwire[8:0]
Definition: jp_channel.v:280
2672CMPRS_CBIT_FRAMES_BITS1
Definition: jp_channel.v:74
2911finish_dccwire
Definition: jp_channel.v:1084
[ 2:0] 2940coring_num
Definition: quantizer393.v:69
2813yc_avrwire[8:0]
Definition: jp_channel.v:293
2660TABLE_HUFFMAN_INDEX3
Definition: jp_channel.v:60
reg [CMPRS_CORING_BITS-1:0] 1556coring
[ 9:0] 2045m_cr
Definition: csconvert.v:60
2872dbg_ts_doutwire[7:0]
Definition: jp_channel.v:404
2708CMPRS_CSAT_CR12
Definition: jp_channel.v:114
2880dbg_test_lbwwire
Definition: jp_channel.v:414
2798buf_rawire[11:0]
Definition: jp_channel.v:267
[7:0] 2722status_ad
Definition: jp_channel.v:138
2669CMPRS_CBIT_CMODE13
Definition: jp_channel.v:71
[15:0] 2942dcc_data
Definition: quantizer393.v:71
focus_sharp393_i focus_sharp393
Definition: jp_channel.v:1055
[ 2:0] 2305comp_numberi
[ 7:0] 2943n000
Definition: quantizer393.v:72
[NUM_FRAME_BITS - 1:0] 1795frame_num_compressed
Definition: cmprs_status.v:49
[ADDR_MASK2!=0?2:ADDR_MASK1!=0?1:0:0] 9935we
Definition: cmd_deser.v:60
2833stuffer_running_mclk_dreg
Definition: jp_channel.v:326
[63:0] 2729buf_din
Definition: jp_channel.v:148
2859pre_start_cntrreg[15:0]
Definition: jp_channel.v:391
2793macroblock_xwire[6:0]
Definition: jp_channel.v:255
2907tser_fewire
Definition: jp_channel.v:999
[ 1:0] 2047bayer_phase
Definition: csconvert.v:62
[7:0] 2746ts_data
Definition: jp_channel.v:179
2818component_numwire[2:0]
Definition: jp_channel.v:300
reg 2931first_out
Definition: quantizer393.v:59
[WIDTH-1:0] 10336dout
Definition: dly_16.v:48
2687CMPRS_CBIT_CMODE_JP4DIFF4'h7
Definition: jp_channel.v:91
2852dccdatawire[15:0]
Definition: jp_channel.v:362
eof_written_mclk_i pulse_cross_clock
Definition: jp_channel.v:1215
2685CMPRS_CBIT_CMODE_JP44'h5
Definition: jp_channel.v:89
2883dbg_last_DCACwire
Definition: jp_channel.v:417
reg [31:0] 2366hifreq
2903tser_dwire[7:0]
Definition: jp_channel.v:995
signed [INPUT_WIDTH-1:0] 3279xin
Definition: dct2d8x8_chen.v:60
reg 2054cwe
Definition: csconvert.v:70
2909focus_dowire[12:0]
Definition: jp_channel.v:1052
[63:0] 5195data_in
Definition: mcntrl_buf_rd.v:59
2688CMPRS_CBIT_CMODE_JP4DIFFHDR4'h8
Definition: jp_channel.v:92
reg [LAST_FRAME_BITS-1:0] 2740frame_number_finished
Definition: jp_channel.v:168
2856xrst2xnwire
Definition: jp_channel.v:384
2805yaddrwwire[7:0]
Definition: jp_channel.v:281
2887dbg_comp_lastinmbowire
Definition: jp_channel.v:421
2906tser_cewire
Definition: jp_channel.v:998
2895dct_pre_first_outwire
Definition: jp_channel.v:938
2849cmprs_qpagewire[2:0]
Definition: jp_channel.v:357
[FRAME_HEIGHT_BITS-1:0] 2736line_unfinished_dst
Definition: jp_channel.v:163
[2:0] 2318dbg_block_mem_wa
[12:0] 2362quant_d
reg [ 2:0] 1541cmprs_qpage
[FRAME_HEIGHT_BITS-1:0] 1599line_unfinished_src
2878dbg_en_n2xreg
Definition: jp_channel.v:412
2663CMPRS_CBIT_RUN2
Definition: jp_channel.v:65
reg [ 1:0] 1543cmprs_fmode
2763CMPRS_ADDRCMPRS_GROUP_ADDR + CMPRS_NUMBER * CMPRS_BASE_INC
Definition: jp_channel.v:211
2806ywewire
Definition: jp_channel.v:282
2819component_colorwire
Definition: jp_channel.v:301
2834frame_number_startedreg[LAST_FRAME_BITS-1:0]
Definition: jp_channel.v:327
2668CMPRS_CBIT_DCSUB_BITS1
Definition: jp_channel.v:70
[READ_WIDTH - 1 : 0] 10317rd_data
Definition: debug_slave.v:55
2810n000wire[7:0]
Definition: jp_channel.v:287
2827force_flush_longwire
Definition: jp_channel.v:316
2843set_interrupts_wwire
Definition: jp_channel.v:349
2645CMPRS_STATUS_REG_BASE'h10
Definition: jp_channel.v:45
[15:0] 2744statistics_do
Definition: jp_channel.v:175
reg 2052ywe
Definition: csconvert.v:68
2877dbg_en_hclkreg
Definition: jp_channel.v:410
2772n_blocks_in_row_m1wire[CMPRS_FRMT_MBCM1_BITS-1:0]
Definition: jp_channel.v:224
2677CMPRS_CBIT_RUN_RST2'h0
Definition: jp_channel.v:80
[WIDTH-1:0] 10335din
Definition: dly_16.v:47
2786mb_hperwire[4:0]
Definition: jp_channel.v:244
2710CMPRS_CORING_BITS3
Definition: jp_channel.v:116
2876dbg_flush_hclkreg
Definition: jp_channel.v:409
[ 7:0] 2923tser_d
Definition: quantizer393.v:51
2704CMPRS_FRMT_LMARG26
Definition: jp_channel.v:110
2788tile_col_widthwire
Definition: jp_channel.v:246
2837cmd_awire[2:0]
Definition: jp_channel.v:342
2899first_block_dctreg
Definition: jp_channel.v:947
2863pages_gotreg[15:0]
Definition: jp_channel.v:395
2651CMPRS_STATUS_CNTRL1
Definition: jp_channel.v:51
2709CMPRS_CSAT_CR_BITS10
Definition: jp_channel.v:115
2698CMPRS_JP4DIFF4
Definition: jp_channel.v:103
2850coring_numwire[2:0]
Definition: jp_channel.v:358
2808cwewire
Definition: jp_channel.v:284
dct2d8x8_chen_i dct2d8x8_chen
Definition: jp_channel.v:959
2780subtract_dcwire
Definition: jp_channel.v:235
[DATA_WIDTH-1:0] 9934data
Definition: cmd_deser.v:59
2795last_mbwire
Definition: jp_channel.v:260
2799mb_data_outwire[7:0]
Definition: jp_channel.v:269
[1:0] 5193page
Definition: mcntrl_buf_rd.v:57
2038frame_en
Definition: csconvert.v:50
2700CMPRS_FRMT_MBCM10
Definition: jp_channel.v:106
[63:0] 2754fifo_rdata
Definition: jp_channel.v:194
2898first_block_color_afterreg
Definition: jp_channel.v:946
cmprs_pixel_buf_iface_i cmprs_pixel_buf_iface
Definition: jp_channel.v:828
2897first_block_colorwire
Definition: jp_channel.v:945
2781m_cbwire[CMPRS_CSAT_CB_BITS-1:0]
Definition: jp_channel.v:236
2865dbg_mb_release_bufwire
Definition: jp_channel.v:397
cmd_deser_32bit_i cmd_deser
Definition: jp_channel.v:574
2666CMPRS_CBIT_QBANK_BITS3
Definition: jp_channel.v:68
2769stuffer_enwire
Definition: jp_channel.v:219
[ 9:0] 2044m_cb
Definition: csconvert.v:59
2814dct_startwire
Definition: jp_channel.v:295
2900first_block_quantwire
Definition: jp_channel.v:948
reg [15:0] 2314do
2776jp4_dc_improvedwire
Definition: jp_channel.v:229
2873dbg_secwire[31:0]
Definition: jp_channel.v:405
reg 2941dcc_vld
Definition: quantizer393.v:70
[2:0] 2742hfc_sel
Definition: jp_channel.v:173
2782m_crwire[CMPRS_CSAT_CR_BITS-1:0]
Definition: jp_channel.v:237
2653CMPRS_COLOR_SATURATION3
Definition: jp_channel.v:53
[ 2:0] 2938hfc_sel
Definition: quantizer393.v:66
2767frame_enwire
Definition: jp_channel.v:217
2682CMPRS_CBIT_CMODE_JP464'h2
Definition: jp_channel.v:86
2842set_coring_wwire
Definition: jp_channel.v:348
2048pre2_first_in
Definition: csconvert.v:63
2674CMPRS_CBIT_BAYER_BITS2
Definition: jp_channel.v:76
2730page_ready_chn
Definition: jp_channel.v:151
2670CMPRS_CBIT_CMODE_BITS4
Definition: jp_channel.v:72
reg [NUM_CHANNELS-1:0] 11067chn_en
2784mb_w_m1wire[5:0]
Definition: jp_channel.v:242
2791mb_pre_startwire
Definition: jp_channel.v:253
2891dbg_block_mem_wawire[2:0]
Definition: jp_channel.v:425
2676CMPRS_CBIT_FOCUS_BITS2
Definition: jp_channel.v:78
2831reading_framewire
Definition: jp_channel.v:323
[7:0] 9931ad
Definition: cmd_deser.v:56
cmprs_cmd_decode_i cmprs_cmd_decode
Definition: jp_channel.v:651
2661FRAME_HEIGHT_BITS16
Definition: jp_channel.v:62
[1:0] 5190wpage_in
Definition: mcntrl_buf_rd.v:54
2896dct_outwire[12:0]
Definition: jp_channel.v:940
[ADDR_WIDTH-1:0] 9933addr
Definition: cmd_deser.v:58
2693CMPRS_CBIT_FRAMES_SINGLE0
Definition: jp_channel.v:97
[FRAME_HEIGHT_BITS-1:0] 1602line_unfinished
2652CMPRS_FORMAT2
Definition: jp_channel.v:52
reg [15:0] 2295statistics_do
Definition: dcc_sync393.v:50
debug_slave_i debug_slave
Definition: jp_channel.v:523
2885dbg_lastBlock_sentreg
Definition: jp_channel.v:419
2840set_format_wwire
Definition: jp_channel.v:346
2875dbg_flushingwire
Definition: jp_channel.v:408
2684CMPRS_CBIT_CMODE_JPEG204'h4
Definition: jp_channel.v:88
[ 8:0] 2925dci
Definition: quantizer393.v:53
2870etrax_dmawire[3:0]
Definition: jp_channel.v:402
2040ignore_color
Definition: csconvert.v:53
reg [ 7:0] 2053caddrw
Definition: csconvert.v:69
2915eof_written_xclkwire
Definition: jp_channel.v:1192
cmprs_tile_mode_decode_i cmprs_tile_mode_decode
Definition: jp_channel.v:740
2816color_firstwire
Definition: jp_channel.v:297
2820component_firstwire
Definition: jp_channel.v:302
2778scale_diffwire
Definition: jp_channel.v:233
2648CMPRS_HIFREQ_REG_INC1
Definition: jp_channel.v:48
[ 1:0] 2354mode
2823cmprs_en_mclkwire
Definition: jp_channel.v:309
2832frame_started_mclkwire
Definition: jp_channel.v:325
reg [ 7:0] 2051yaddrw
Definition: csconvert.v:67
reg [ 8:0] 2049signed_y
Definition: csconvert.v:65
2874dbg_usecwire[31:0]
Definition: jp_channel.v:406
2735frame_done_src
Definition: jp_channel.v:159
2678CMPRS_CBIT_RUN_STANDALONE2'h2
Definition: jp_channel.v:82
2649CMPRS_MASK'h7f8
Definition: jp_channel.v:49
2738frame_done_dst
Definition: jp_channel.v:165
[1 << LOG2WIDTH_RD-1:0] 5188ext_data_out
Definition: mcntrl_buf_rd.v:49
2794first_mbwire
Definition: jp_channel.v:259
[15:0] 2293dcc_data
Definition: dcc_sync393.v:48
2803signed_ywire[8:0]
Definition: jp_channel.v:279
status_generate_i status_generate
Definition: jp_channel.v:607
2664CMPRS_CBIT_RUN_BITS2
Definition: jp_channel.v:66
2726xfer_reset_page_rd
Definition: jp_channel.v:144
2844set_tables_wwire
Definition: jp_channel.v:350
2671CMPRS_CBIT_FRAMES15
Definition: jp_channel.v:73
2771left_margwire[CMPRS_FRMT_LMARG_BITS-1:0]
Definition: jp_channel.v:223
2764CMPRS_STATUS_REG_ADDRCMPRS_STATUS_REG_BASE + CMPRS_NUMBER * CMPRS_STATUS_REG_INC
Definition: jp_channel.v:212
2904tser_selwire[3:0]
Definition: jp_channel.v:996
2908tser_hewire
Definition: jp_channel.v:1000
2861debug_frame_donereg
Definition: jp_channel.v:393
2675CMPRS_CBIT_FOCUS23
Definition: jp_channel.v:77
2711CMPRS_TIMEOUT_BITS12
Definition: jp_channel.v:118
2829enc_dvwire
Definition: jp_channel.v:319
2679CMPRS_CBIT_RUN_ENABLE2'h3
Definition: jp_channel.v:83
reg [CMPRS_FRMT_MBRM1_BITS-1:0] 1553n_block_rows_m1
reg [ 2:0] 1548converter_type
reg 2294statistics_dv
Definition: dcc_sync393.v:49
2890dbg_zds_cntrreg[15:0]
Definition: jp_channel.v:424
2785mb_h_m1wire[5:0]
Definition: jp_channel.v:243
2656CMPRS_TABLES6
Definition: jp_channel.v:56
2826sigle_frame_bufwire
Definition: jp_channel.v:312
[FRAME_HEIGHT_BITS-1:0] 2733line_unfinished_src
Definition: jp_channel.v:157
2838set_ctrl_reg_wwire
Definition: jp_channel.v:344
2866pages_neededreg[15:0]
Definition: jp_channel.v:398
quantizer393_i quantizer393
Definition: jp_channel.v:1020
dbg_timestamp_to_parallel_i timestamp_to_parallel
Definition: jp_channel.v:440
2699CMPRS_MONO87
Definition: jp_channel.v:104
2905tser_qewire
Definition: jp_channel.v:997
2690CMPRS_CBIT_CMODE_JP4DIFFHDRDIV24'ha
Definition: jp_channel.v:94
2681CMPRS_CBIT_CMODE_MONO64'h1
Definition: jp_channel.v:85
2673CMPRS_CBIT_BAYER20
Definition: jp_channel.v:75
reg [ 8:0] 2050signed_c
Definition: csconvert.v:66
[12:0] 2932di
Definition: quantizer393.v:60
[ALL_BITS-1:0] 10777status
2851dcc_enreg
Definition: jp_channel.v:359
2869dbg_reset_fiforeg
Definition: jp_channel.v:401
reg [15:0] 2936dc_tdo
Definition: quantizer393.v:64
2680CMPRS_CBIT_CMODE_JPEG184'h0
Definition: jp_channel.v:84
2777converter_typewire[2:0]
Definition: jp_channel.v:232
2665CMPRS_CBIT_QBANK6
Definition: jp_channel.v:67
[ 7:0] 2046mb_din
Definition: csconvert.v:61
2695CMPRS_COLOR201
Definition: jp_channel.v:100
reg [ 7:0] 2057n255
Definition: csconvert.v:76
2775bayer_phasewire[1:0]
Definition: jp_channel.v:227
2812yc_nodcwire[9:0]
Definition: jp_channel.v:292
2857debug_fifo_inreg[31:0]
Definition: jp_channel.v:389
reg [CMPRS_CSAT_CB_BITS-1:0] 1554color_sat_cb
2703CMPRS_FRMT_MBRM1_BITS13
Definition: jp_channel.v:109
2916stuffer_word_numberinteger
Definition: jp_channel.v:1218
2043limit_diff
Definition: csconvert.v:58
2881dbg_gotLastBlockwire
Definition: jp_channel.v:415
2732frame_start_dst
Definition: jp_channel.v:154
2864dbg_add_invalidwire[1:0]
Definition: jp_channel.v:396
2858debug_fifo_outreg[31:0]
Definition: jp_channel.v:390
2694CMPRS_COLOR180
Definition: jp_channel.v:99
[14-LOG2WIDTH_RD:0] 5185ext_raddr
Definition: mcntrl_buf_rd.v:46
reg [12:0] 2933do
Definition: quantizer393.v:61
10333rst
Definition: dly_16.v:45
2894dct_last_inwire
Definition: jp_channel.v:937
2845stuffer_runningwire
Definition: jp_channel.v:352
2765CMPRS_HIFREQ_REG_ADDRCMPRS_HIFREQ_REG_BASE + CMPRS_NUMBER * CMPRS_HIFREQ_REG_INC
Definition: jp_channel.v:213
2914stuffer_donewire
Definition: jp_channel.v:1090
2847quant_dswire
Definition: jp_channel.v:355
[LAST_FRAME_BITS-1:0] 2737frame_number_dst
Definition: jp_channel.v:164
2854last_blockwire
Definition: jp_channel.v:382
huffman_stuffer_meta_i huffman_stuffer_meta
Definition: jp_channel.v:1162
reg [CMPRS_CSAT_CR_BITS-1:0] 1555color_sat_cr
2796buf_rdwire[1:0]
Definition: jp_channel.v:265
encoderDCAC393_i encoderDCAC393
Definition: jp_channel.v:1113
[2:0] 2319dbg_block_mem_wa_save
cmprs_buf_average_i cmprs_buf_average
Definition: jp_channel.v:894
2686CMPRS_CBIT_CMODE_JP4DC4'h6
Definition: jp_channel.v:90
2647CMPRS_STATUS_REG_INC1
Definition: jp_channel.v:47
2707CMPRS_CSAT_CB_BITS10
Definition: jp_channel.v:113
2041scale_diff
Definition: csconvert.v:56
2853dccvldwire
Definition: jp_channel.v:363
2830stuffer_running_mclkwire
Definition: jp_channel.v:322
2683CMPRS_CBIT_CMODE_JP46DC4'h3
Definition: jp_channel.v:87
[3:0] 10334dly
Definition: dly_16.v:46