42 // TODO:Clean up even more - remove signals that are not related to calculating/subtracting averages 44 parameter CMPRS_COLOR18 =
0,
// JPEG 4:2:0 with 18x18 overlapping tiles for de-bayer 45 parameter CMPRS_COLOR20 =
1,
// JPEG 4:2:0 with 18x18 overlapping tiles for de-bayer (not implemented) 46 parameter CMPRS_MONO16 =
2,
// JPEG 4:2:0 with 16x16 non-overlapping tiles, color components zeroed 47 parameter CMPRS_JP4 =
3,
// JP4 mode with 16x16 macroblocks 49 parameter CMPRS_MONO8 =
7 // Regular JPEG monochrome with 8x8 macroblocks (not yet implemented) 51 input xclk,
// global clock input, compressor single clock rate 54 input pre_first_in,
// marks the first input pixel from the external memory buffer 55 input yc_pre_first_out,
// pre first output from color converter(s) to the Y/C buffers (was pre_first_out) 58 input hdr,
// valid @ pre_first_in 59 input subtract_dc_in,
// valid @ pre_first_in: enable subtracting of DC component 60 input first_mb_in,
// valid @ pre_first_in - reading first macroblock 61 input last_mb_in,
// valid @ pre_first_in - reading last macroblock 69 output [
9:
0]
do,
// [9:0] data out (4:2:0) (signed, average=0) 71 output [
8:
0]
avr,
// [8:0] DC (average value) - RAM output, no register. For Y components 9'h080..9'h07f, for C - 9'h100..9'h0ff! 72 output dv,
// out data valid (will go high for at least 64 cycles) 73 output ds,
// single-cycle mark of the first_r pixel in a 64 (8x8) - pixel block 74 output [
2:
0]
tn,
// [2:0] tile number 0..3 - Y, 4 - Cb, 5 - Cr (valid with start) 75 output reg first,
// sending first_r MCU (valid @ ds) 76 output reg last,
// sending last_r MCU (valid @ ds) 77 // below signals valid at ds ( 1 later than tn, first_r, last_r) 78 output [
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 80 output component_first,
// first_r this component in a frame (DC absolute, otherwise - difference to previous) 88 wire [
5:
0]
component_firstsS;
// first_r this component in a frame (DC absolute, otherwise - difference to previous) 94 reg [
5:
0]
component_firsts;
// first_r this component in a frame (DC absolute, otherwise - difference to previous) 96 // Y and C components buffer filled in by color conversion module 98 reg [
1:
0]
wpage;
// page (0/1) where data is being written to (both Y and CbCr) 99 reg [
1:
0]
rpage;
// page (0/1) from where data is sent out ( both Y and CbCr) 100 reg [
8:
0]
raddr;
// output address of buffer memories (MSB selects Y(0)/CbCr(1)) 103 wire [
1:
0]
y_ren;
// read enable for Y buffer ([0] - ren, [1] - regen) 104 wire [
1:
0]
c_ren;
// read enable for C buffer ([0] - ren, [1] - regen) 107 wire [
8:
0]
y_out;
// data output from Y block buffer, valid @ 108 wire [
8:
0]
c_out;
// data output from C block buffer, valid @ 117 // Copied from old code - check/fix it 119 reg [
1:
0]
accCen;
// individual accumulator enable (includes clearing) 121 reg [
1:
0]
accCfirst;
// add to zero, instead of to acc @ acc*en 122 reg [
8:
0]
preAccY,
preAccC;
// registered data from color converters, matching acc selection latency 128 wire [
1:
0]
pre_accCdone;
// need to make sure that pre_accCdone do_r not happen with pre_accYdone 131 // reg [3:0] accYdone; // only bit 0 is used as a start of output 132 reg accYdone;
// only bit 0 is used as a start of output 137 reg avr_we;
// Write to memory that stores average value 138 reg [
8:
0]
avermem[
0:
15];
// average values memory - 2 pages (MSB) of 6 block values 140 reg [
3:
0]
avr_ra;
// read address for "average" memory 141 reg [
8:
0]
avr_r;
// registered output data from average memory (simultaneouis with regsitered buffer data) 142 // truncating average values 149 reg dv_pre3;
//3 cycles ahead of dv (data valid) 150 reg ds_pre3;
//3 cycles ahead of ds (data strobe - first cycle of dv) 153 reg raddr_updateBlock;
// first_r in block, after last_r also. Should be when *_r match the currently selected converter for the macroblock 154 reg ccv_out_start_d;
// ccv_out_start delayed by 1 clock to match time of raddr_updateBlock 157 reg ccv_out_start;
// find the best way to calculate (maybe just a common counter with different presets) 158 // active 1 clk before start or reading blocks 160 // accCntr* counters after the first value will be set to 1 (was 0 before) 171 // assign output signals 172 assign avr =
avr_r;
// avermem[avr_ra[3:0]]; 175 // component_num,component_color,component_first for different converters vs tn (1 bit per tn (0..5) 180 // Calculate average values for each block, count them to know when all 64 are ready, store trunctaed result in 9*16 memory 221 // accYdone[3:0] <= pre_accYdone[3:0] & accYrun[3:0]; 226 // Delay write addresses to find write address of the block for which average value is recorded 248 // first <= pre_first_mb; 253 // read buffers timing 254 // Is it that raddr[8:7] == 2'b11 means "disable 259 // Reading output data and combining with the average values 282 // generate blobk type data 283 // Shift registers - generating block attributes to be used later in compressor 285 if (
ccv_out_start_d)
begin // ccv_out_start_d valid with raddr_updateBlock 302 // when to start reading out data from the buffer 318 // delay from the start of data output from color converter to copy subtract_dc to be valid when average values are set 331 )
cmprs_tile_mode2_decode_i (
354 .
REGISTERS (
1),
// will need to delay output strobe(s) by 1 361 .
ren (
y_ren[
0]),
// input // TODO: modify to read only when needed 367 .
web (
4'hf),
// input[7:0] 372 .
REGISTERS (
1),
// will need to delay output strobe(s) by 1 379 .
ren (
c_ren[
0]),
// input // TODO: modify to read only when needed 385 .
web (
4'hf),
// input[7:0]
1401component_numsHSwire[5:0]
cmprs_tile_mode2_decode_i cmprs_tile_mode2_decode
reg [5:0] 1828component_colors
1400component_numsMSwire[5:0]
1407component_colorsreg[5:0]
1474converter_type_rreg[2:0]
[9 << LOG2WIDTH_WR-3-1:0] 11679data_in
1447pre_accYdonewire[3:0]
reg [5:0] 1827component_numsH
[0:15] 1460avermemreg[8:0]
1399component_numsLSwire[5:0]
1440cs_first_out_latewire
i_CrCb_buff ram18p_var_w_var_r
[9 << LOG2WIDTH_RD-3-1:0] 11674data_out
1408component_firstsreg[5:0]
1406component_numsHreg[5:0]
reg 1398component_lastinmb
reg [5:0] 1826component_numsM
reg [5:0] 1825component_numsL
1404component_numsLreg[5:0]
1405component_numsMreg[5:0]
reg [5:0] 1829component_first
[13-LOG2WIDTH_RD:0] 11671raddr
1402component_colorsSwire[5:0]
1403component_firstsSwire[5:0]
1448pre_accCdonewire[1:0]
[13-LOG2WIDTH_WR:0] 11676waddr