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

Subversion Repositories jpegencode

[/] [jpegencode/] [trunk/] [cb_huff.v] - Blame information for rev 3

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 davidklun
/////////////////////////////////////////////////////////////////////
2
////                                                             ////
3
////  JPEG Encoder Core - Verilog                                ////
4
////                                                             ////
5
////  Author: David Lundgren                                     ////
6
////          davidklun@gmail.com                                ////
7
////                                                             ////
8
/////////////////////////////////////////////////////////////////////
9
////                                                             ////
10
//// Copyright (C) 2009 David Lundgren                           ////
11
////                  davidklun@gmail.com                        ////
12
////                                                             ////
13
//// This source file may be used and distributed without        ////
14
//// restriction provided that this copyright statement is not   ////
15
//// removed from the file and that any derivative work contains ////
16
//// the original copyright notice and the associated disclaimer.////
17
////                                                             ////
18
////     THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY     ////
19
//// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED   ////
20
//// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS   ////
21
//// FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR      ////
22
//// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,         ////
23
//// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    ////
24
//// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE   ////
25
//// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR        ////
26
//// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF  ////
27
//// LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT  ////
28
//// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT  ////
29
//// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE         ////
30
//// POSSIBILITY OF SUCH DAMAGE.                                 ////
31
////                                                             ////
32
/////////////////////////////////////////////////////////////////////
33
 
34
/* This module is the Huffman encoder.  It takes in the quantized outputs
35
from the quantizer, and creates the Huffman codes from these value.  The
36
output from this module is the jpeg code of the actual pixel data.  The jpeg
37
file headers will need to be generated separately.  The Huffman codes are constant,
38
and they can be changed by changing the parameters in this module. */
39
 
40
`timescale 1ns / 100ps
41
 
42
module cb_huff(clk, rst, enable,
43
Cb11, Cb12, Cb13, Cb14, Cb15, Cb16, Cb17, Cb18, Cb21, Cb22, Cb23, Cb24, Cb25, Cb26, Cb27, Cb28,
44
Cb31, Cb32, Cb33, Cb34, Cb35, Cb36, Cb37, Cb38, Cb41, Cb42, Cb43, Cb44, Cb45, Cb46, Cb47, Cb48,
45
Cb51, Cb52, Cb53, Cb54, Cb55, Cb56, Cb57, Cb58, Cb61, Cb62, Cb63, Cb64, Cb65, Cb66, Cb67, Cb68,
46
Cb71, Cb72, Cb73, Cb74, Cb75, Cb76, Cb77, Cb78, Cb81, Cb82, Cb83, Cb84, Cb85, Cb86, Cb87, Cb88,
47
JPEG_bitstream, data_ready, output_reg_count, end_of_block_empty);
48
input           clk;
49
input           rst;
50
input           enable;
51
input  [10:0]  Cb11, Cb12, Cb13, Cb14, Cb15, Cb16, Cb17, Cb18, Cb21, Cb22, Cb23, Cb24;
52
input  [10:0]  Cb25, Cb26, Cb27, Cb28, Cb31, Cb32, Cb33, Cb34, Cb35, Cb36, Cb37, Cb38;
53
input  [10:0]  Cb41, Cb42, Cb43, Cb44, Cb45, Cb46, Cb47, Cb48, Cb51, Cb52, Cb53, Cb54;
54
input  [10:0]  Cb55, Cb56, Cb57, Cb58, Cb61, Cb62, Cb63, Cb64, Cb65, Cb66, Cb67, Cb68;
55
input  [10:0]  Cb71, Cb72, Cb73, Cb74, Cb75, Cb76, Cb77, Cb78, Cb81, Cb82, Cb83, Cb84;
56
input  [10:0]  Cb85, Cb86, Cb87, Cb88;
57
output  [31:0]   JPEG_bitstream;
58
output  data_ready;
59
output          [4:0] output_reg_count;
60
output  end_of_block_empty;
61
 
62
 
63
reg             [7:0] block_counter;
64
reg             [11:0]  Cb11_amp, Cb11_1_pos, Cb11_1_neg, Cb11_diff;
65
reg             [11:0]  Cb11_previous, Cb11_1;
66
reg             [10:0]  Cb12_amp, Cb12_pos, Cb12_neg;
67
reg             [10:0]  Cb21_pos, Cb21_neg, Cb31_pos, Cb31_neg, Cb22_pos, Cb22_neg;
68
reg             [10:0]  Cb13_pos, Cb13_neg, Cb14_pos, Cb14_neg, Cb15_pos, Cb15_neg;
69
reg             [10:0]  Cb16_pos, Cb16_neg, Cb17_pos, Cb17_neg, Cb18_pos, Cb18_neg;
70
reg             [10:0]  Cb23_pos, Cb23_neg, Cb24_pos, Cb24_neg, Cb25_pos, Cb25_neg;
71
reg             [10:0]  Cb26_pos, Cb26_neg, Cb27_pos, Cb27_neg, Cb28_pos, Cb28_neg;
72
reg             [10:0]  Cb32_pos, Cb32_neg;
73
reg             [10:0]  Cb33_pos, Cb33_neg, Cb34_pos, Cb34_neg, Cb35_pos, Cb35_neg;
74
reg             [10:0]  Cb36_pos, Cb36_neg, Cb37_pos, Cb37_neg, Cb38_pos, Cb38_neg;
75
reg             [10:0]  Cb41_pos, Cb41_neg, Cb42_pos, Cb42_neg;
76
reg             [10:0]  Cb43_pos, Cb43_neg, Cb44_pos, Cb44_neg, Cb45_pos, Cb45_neg;
77
reg             [10:0]  Cb46_pos, Cb46_neg, Cb47_pos, Cb47_neg, Cb48_pos, Cb48_neg;
78
reg             [10:0]  Cb51_pos, Cb51_neg, Cb52_pos, Cb52_neg;
79
reg             [10:0]  Cb53_pos, Cb53_neg, Cb54_pos, Cb54_neg, Cb55_pos, Cb55_neg;
80
reg             [10:0]  Cb56_pos, Cb56_neg, Cb57_pos, Cb57_neg, Cb58_pos, Cb58_neg;
81
reg             [10:0]  Cb61_pos, Cb61_neg, Cb62_pos, Cb62_neg;
82
reg             [10:0]  Cb63_pos, Cb63_neg, Cb64_pos, Cb64_neg, Cb65_pos, Cb65_neg;
83
reg             [10:0]  Cb66_pos, Cb66_neg, Cb67_pos, Cb67_neg, Cb68_pos, Cb68_neg;
84
reg             [10:0]  Cb71_pos, Cb71_neg, Cb72_pos, Cb72_neg;
85
reg             [10:0]  Cb73_pos, Cb73_neg, Cb74_pos, Cb74_neg, Cb75_pos, Cb75_neg;
86
reg             [10:0]  Cb76_pos, Cb76_neg, Cb77_pos, Cb77_neg, Cb78_pos, Cb78_neg;
87
reg             [10:0]  Cb81_pos, Cb81_neg, Cb82_pos, Cb82_neg;
88
reg             [10:0]  Cb83_pos, Cb83_neg, Cb84_pos, Cb84_neg, Cb85_pos, Cb85_neg;
89
reg             [10:0]  Cb86_pos, Cb86_neg, Cb87_pos, Cb87_neg, Cb88_pos, Cb88_neg;
90
reg             [3:0]    Cb11_bits_pos, Cb11_bits_neg, Cb11_bits, Cb11_bits_1;
91
reg             [3:0]    Cb12_bits_pos, Cb12_bits_neg, Cb12_bits, Cb12_bits_1;
92
reg             [3:0]    Cb12_bits_2, Cb12_bits_3;
93
reg             Cb11_msb, Cb12_msb, Cb12_msb_1, data_ready;
94
reg             enable_1, enable_2, enable_3, enable_4, enable_5, enable_6;
95
reg             enable_7, enable_8, enable_9, enable_10, enable_11, enable_12;
96
reg             enable_13, enable_module, enable_latch_7, enable_latch_8;
97
reg             Cb12_et_zero, rollover, rollover_1, rollover_2, rollover_3;
98
reg             rollover_4, rollover_5, rollover_6, rollover_7;
99
reg             Cb21_et_zero, Cb21_msb, Cb31_et_zero, Cb31_msb;
100
reg             Cb22_et_zero, Cb22_msb, Cb13_et_zero, Cb13_msb;
101
reg             Cb14_et_zero, Cb14_msb, Cb15_et_zero, Cb15_msb;
102
reg             Cb16_et_zero, Cb16_msb, Cb17_et_zero, Cb17_msb;
103
reg             Cb18_et_zero, Cb18_msb;
104
reg             Cb23_et_zero, Cb23_msb, Cb24_et_zero, Cb24_msb;
105
reg             Cb25_et_zero, Cb25_msb, Cb26_et_zero, Cb26_msb;
106
reg             Cb27_et_zero, Cb27_msb, Cb28_et_zero, Cb28_msb;
107
reg             Cb32_et_zero, Cb32_msb, Cb33_et_zero, Cb33_msb;
108
reg             Cb34_et_zero, Cb34_msb, Cb35_et_zero, Cb35_msb;
109
reg             Cb36_et_zero, Cb36_msb, Cb37_et_zero, Cb37_msb;
110
reg             Cb38_et_zero, Cb38_msb;
111
reg             Cb41_et_zero, Cb41_msb, Cb42_et_zero, Cb42_msb;
112
reg             Cb43_et_zero, Cb43_msb, Cb44_et_zero, Cb44_msb;
113
reg             Cb45_et_zero, Cb45_msb, Cb46_et_zero, Cb46_msb;
114
reg             Cb47_et_zero, Cb47_msb, Cb48_et_zero, Cb48_msb;
115
reg             Cb51_et_zero, Cb51_msb, Cb52_et_zero, Cb52_msb;
116
reg             Cb53_et_zero, Cb53_msb, Cb54_et_zero, Cb54_msb;
117
reg             Cb55_et_zero, Cb55_msb, Cb56_et_zero, Cb56_msb;
118
reg             Cb57_et_zero, Cb57_msb, Cb58_et_zero, Cb58_msb;
119
reg             Cb61_et_zero, Cb61_msb, Cb62_et_zero, Cb62_msb;
120
reg             Cb63_et_zero, Cb63_msb, Cb64_et_zero, Cb64_msb;
121
reg             Cb65_et_zero, Cb65_msb, Cb66_et_zero, Cb66_msb;
122
reg             Cb67_et_zero, Cb67_msb, Cb68_et_zero, Cb68_msb;
123
reg             Cb71_et_zero, Cb71_msb, Cb72_et_zero, Cb72_msb;
124
reg             Cb73_et_zero, Cb73_msb, Cb74_et_zero, Cb74_msb;
125
reg             Cb75_et_zero, Cb75_msb, Cb76_et_zero, Cb76_msb;
126
reg             Cb77_et_zero, Cb77_msb, Cb78_et_zero, Cb78_msb;
127
reg             Cb81_et_zero, Cb81_msb, Cb82_et_zero, Cb82_msb;
128
reg             Cb83_et_zero, Cb83_msb, Cb84_et_zero, Cb84_msb;
129
reg             Cb85_et_zero, Cb85_msb, Cb86_et_zero, Cb86_msb;
130
reg             Cb87_et_zero, Cb87_msb, Cb88_et_zero, Cb88_msb;
131
reg     Cb12_et_zero_1, Cb12_et_zero_2, Cb12_et_zero_3, Cb12_et_zero_4, Cb12_et_zero_5;
132
reg             [10:0] Cb_DC [11:0];
133
reg     [3:0] Cb_DC_code_length [11:0];
134
reg             [15:0] Cb_AC [161:0];
135
reg     [4:0] Cb_AC_code_length [161:0];
136
reg     [7:0] Cb_AC_run_code [250:0];
137
reg             [10:0] Cb11_Huff, Cb11_Huff_1, Cb11_Huff_2;
138
reg             [15:0] Cb12_Huff, Cb12_Huff_1, Cb12_Huff_2;
139
reg             [3:0] Cb11_Huff_count, Cb11_Huff_shift, Cb11_Huff_shift_1, Cb11_amp_shift, Cb12_amp_shift;
140
reg             [3:0] Cb12_Huff_shift, Cb12_Huff_shift_1, zero_run_length, zrl_1, zrl_2, zrl_3;
141
reg             [4:0] Cb12_Huff_count, Cb12_Huff_count_1;
142
reg             [4:0] output_reg_count, Cb11_output_count, old_orc_1, old_orc_2;
143
reg             [4:0] old_orc_3, old_orc_4, old_orc_5, old_orc_6, Cb12_oc_1;
144
reg             [4:0] orc_3, orc_4, orc_5, orc_6, orc_7, orc_8;
145
reg             [4:0] Cb12_output_count;
146
reg     [4:0] Cb12_edge, Cb12_edge_1, Cb12_edge_2, Cb12_edge_3, Cb12_edge_4;
147
reg             [31:0]   JPEG_bitstream, JPEG_bs, JPEG_bs_1, JPEG_bs_2, JPEG_bs_3, JPEG_bs_4, JPEG_bs_5;
148
reg             [31:0]   JPEG_Cb12_bs, JPEG_Cb12_bs_1, JPEG_Cb12_bs_2, JPEG_Cb12_bs_3, JPEG_Cb12_bs_4;
149
reg             [31:0]   JPEG_ro_bs, JPEG_ro_bs_1, JPEG_ro_bs_2, JPEG_ro_bs_3, JPEG_ro_bs_4;
150
reg             [21:0]   Cb11_JPEG_LSBs_3;
151
reg             [10:0]   Cb11_JPEG_LSBs, Cb11_JPEG_LSBs_1, Cb11_JPEG_LSBs_2;
152
reg             [9:0]    Cb12_JPEG_LSBs, Cb12_JPEG_LSBs_1, Cb12_JPEG_LSBs_2, Cb12_JPEG_LSBs_3;
153
reg             [25:0]   Cb11_JPEG_bits, Cb11_JPEG_bits_1, Cb12_JPEG_bits, Cb12_JPEG_LSBs_4;
154
reg             [7:0]    Cb12_code_entry;
155
reg             third_8_all_0s, fourth_8_all_0s, fifth_8_all_0s, sixth_8_all_0s, seventh_8_all_0s;
156
reg             eighth_8_all_0s, end_of_block, end_of_block_output, code_15_0, zrl_et_15;
157
reg             end_of_block_empty;
158
 
159
wire    [7:0]    code_index = { zrl_2, Cb12_bits };
160
 
161
 
162
 
163
always @(posedge clk)
164
begin
165
        if (rst) begin
166
                third_8_all_0s <= 0; fourth_8_all_0s <= 0;
167
                fifth_8_all_0s <= 0; sixth_8_all_0s <= 0; seventh_8_all_0s <= 0;
168
                eighth_8_all_0s <= 0;
169
                end
170
        else if (enable_1) begin
171
                third_8_all_0s <= Cb25_et_zero & Cb34_et_zero & Cb43_et_zero & Cb52_et_zero
172
                                          & Cb61_et_zero & Cb71_et_zero & Cb62_et_zero & Cb53_et_zero;
173
                fourth_8_all_0s <= Cb44_et_zero & Cb35_et_zero & Cb26_et_zero & Cb17_et_zero
174
                                          & Cb18_et_zero & Cb27_et_zero & Cb36_et_zero & Cb45_et_zero;
175
                fifth_8_all_0s <= Cb54_et_zero & Cb63_et_zero & Cb72_et_zero & Cb81_et_zero
176
                                          & Cb82_et_zero & Cb73_et_zero & Cb64_et_zero & Cb55_et_zero;
177
                sixth_8_all_0s <= Cb46_et_zero & Cb37_et_zero & Cb28_et_zero & Cb38_et_zero
178
                                          & Cb47_et_zero & Cb56_et_zero & Cb65_et_zero & Cb74_et_zero;
179
                seventh_8_all_0s <= Cb83_et_zero & Cb84_et_zero & Cb75_et_zero & Cb66_et_zero
180
                                          & Cb57_et_zero & Cb48_et_zero & Cb58_et_zero & Cb67_et_zero;
181
                eighth_8_all_0s <= Cb76_et_zero & Cb85_et_zero & Cb86_et_zero & Cb77_et_zero
182
                                          & Cb68_et_zero & Cb78_et_zero & Cb87_et_zero & Cb88_et_zero;
183
                end
184
end
185
 
186
 
187
/* end_of_block checks to see if there are any nonzero elements left in the block
188
If there aren't any nonzero elements left, then the last bits in the JPEG stream
189
will be the end of block code.  The purpose of this register is to determine if the
190
zero run length code 15-0 should be used or not.  It should be used if there are 15 or more
191
zeros in a row, followed by a nonzero value.  If there are only zeros left in the block,
192
then end_of_block will be 1.  If there are any nonzero values left in the block, end_of_block
193
will be 0. */
194
 
195
always @(posedge clk)
196
begin
197
        if (rst)
198
                end_of_block <= 0;
199
        else if (enable)
200
                end_of_block <= 0;
201
        else if (enable_module & block_counter < 32)
202
                end_of_block <= third_8_all_0s & fourth_8_all_0s & fifth_8_all_0s
203
                                        & sixth_8_all_0s & seventh_8_all_0s & eighth_8_all_0s;
204
        else if (enable_module & block_counter < 48)
205
                end_of_block <= fifth_8_all_0s & sixth_8_all_0s & seventh_8_all_0s
206
                                        & eighth_8_all_0s;
207
        else if (enable_module & block_counter <= 64)
208
                end_of_block <= seventh_8_all_0s & eighth_8_all_0s;
209
        else if (enable_module & block_counter > 64)
210
                end_of_block <= 1;
211
end
212
 
213
always @(posedge clk)
214
begin
215
        if (rst) begin
216
                block_counter <= 0;
217
                end
218
        else if (enable) begin
219
                block_counter <= 0;
220
                end
221
        else if (enable_module) begin
222
                block_counter <= block_counter + 1;
223
                end
224
end
225
 
226
always @(posedge clk)
227
begin
228
        if (rst) begin
229
                output_reg_count <= 0;
230
                end
231
        else if (end_of_block_output) begin
232
                output_reg_count <= 0;
233
                end
234
        else if (enable_6) begin
235
                output_reg_count <= output_reg_count + Cb11_output_count;
236
                end
237
        else if (enable_latch_7) begin
238
                output_reg_count <= output_reg_count + Cb12_oc_1;
239
                end
240
end
241
 
242
always @(posedge clk)
243
begin
244
        if (rst) begin
245
                old_orc_1 <= 0;
246
                end
247
        else if (end_of_block_output) begin
248
                old_orc_1 <= 0;
249
                end
250
        else if (enable_module) begin
251
                old_orc_1 <= output_reg_count;
252
                end
253
end
254
 
255
always @(posedge clk)
256
begin
257
        if (rst) begin
258
                rollover <= 0; rollover_1 <= 0; rollover_2 <= 0;
259
                rollover_3 <= 0; rollover_4 <= 0; rollover_5 <= 0;
260
                rollover_6 <= 0; rollover_7 <= 0;
261
                old_orc_2 <= 0;
262
                orc_3 <= 0; orc_4 <= 0; orc_5 <= 0; orc_6 <= 0;
263
                orc_7 <= 0; orc_8 <= 0; data_ready <= 0;
264
                end_of_block_output <= 0; end_of_block_empty <= 0;
265
                end
266
        else if (enable_module) begin
267
                rollover <= (old_orc_1 > output_reg_count);
268
                rollover_1 <= rollover;
269
                rollover_2 <= rollover_1;
270
                rollover_3 <= rollover_2;
271
                rollover_4 <= rollover_3;
272
                rollover_5 <= rollover_4;
273
                rollover_6 <= rollover_5;
274
                rollover_7 <= rollover_6;
275
                old_orc_2 <= old_orc_1;
276
                orc_3 <= old_orc_2;
277
                orc_4 <= orc_3; orc_5 <= orc_4;
278
                orc_6 <= orc_5; orc_7 <= orc_6;
279
                orc_8 <= orc_7;
280
                data_ready <= rollover_6 | block_counter == 77;
281
                end_of_block_output <= block_counter == 77;
282
                end_of_block_empty <= rollover_7 & block_counter == 77 & output_reg_count == 0;
283
                end
284
end
285
 
286
 
287
 
288
always @(posedge clk)
289
begin
290
        if (rst) begin
291
                JPEG_bs_5 <= 0;
292
                end
293
        else if (enable_module) begin
294
                JPEG_bs_5[31] <= (rollover_6 & orc_7 > 0) ? JPEG_ro_bs_4[31] : JPEG_bs_4[31];
295
                JPEG_bs_5[30] <= (rollover_6 & orc_7 > 1) ? JPEG_ro_bs_4[30] : JPEG_bs_4[30];
296
                JPEG_bs_5[29] <= (rollover_6 & orc_7 > 2) ? JPEG_ro_bs_4[29] : JPEG_bs_4[29];
297
                JPEG_bs_5[28] <= (rollover_6 & orc_7 > 3) ? JPEG_ro_bs_4[28] : JPEG_bs_4[28];
298
                JPEG_bs_5[27] <= (rollover_6 & orc_7 > 4) ? JPEG_ro_bs_4[27] : JPEG_bs_4[27];
299
                JPEG_bs_5[26] <= (rollover_6 & orc_7 > 5) ? JPEG_ro_bs_4[26] : JPEG_bs_4[26];
300
                JPEG_bs_5[25] <= (rollover_6 & orc_7 > 6) ? JPEG_ro_bs_4[25] : JPEG_bs_4[25];
301
                JPEG_bs_5[24] <= (rollover_6 & orc_7 > 7) ? JPEG_ro_bs_4[24] : JPEG_bs_4[24];
302
                JPEG_bs_5[23] <= (rollover_6 & orc_7 > 8) ? JPEG_ro_bs_4[23] : JPEG_bs_4[23];
303
                JPEG_bs_5[22] <= (rollover_6 & orc_7 > 9) ? JPEG_ro_bs_4[22] : JPEG_bs_4[22];
304
                JPEG_bs_5[21] <= (rollover_6 & orc_7 > 10) ? JPEG_ro_bs_4[21] : JPEG_bs_4[21];
305
                JPEG_bs_5[20] <= (rollover_6 & orc_7 > 11) ? JPEG_ro_bs_4[20] : JPEG_bs_4[20];
306
                JPEG_bs_5[19] <= (rollover_6 & orc_7 > 12) ? JPEG_ro_bs_4[19] : JPEG_bs_4[19];
307
                JPEG_bs_5[18] <= (rollover_6 & orc_7 > 13) ? JPEG_ro_bs_4[18] : JPEG_bs_4[18];
308
                JPEG_bs_5[17] <= (rollover_6 & orc_7 > 14) ? JPEG_ro_bs_4[17] : JPEG_bs_4[17];
309
                JPEG_bs_5[16] <= (rollover_6 & orc_7 > 15) ? JPEG_ro_bs_4[16] : JPEG_bs_4[16];
310
                JPEG_bs_5[15] <= (rollover_6 & orc_7 > 16) ? JPEG_ro_bs_4[15] : JPEG_bs_4[15];
311
                JPEG_bs_5[14] <= (rollover_6 & orc_7 > 17) ? JPEG_ro_bs_4[14] : JPEG_bs_4[14];
312
                JPEG_bs_5[13] <= (rollover_6 & orc_7 > 18) ? JPEG_ro_bs_4[13] : JPEG_bs_4[13];
313
                JPEG_bs_5[12] <= (rollover_6 & orc_7 > 19) ? JPEG_ro_bs_4[12] : JPEG_bs_4[12];
314
                JPEG_bs_5[11] <= (rollover_6 & orc_7 > 20) ? JPEG_ro_bs_4[11] : JPEG_bs_4[11];
315
                JPEG_bs_5[10] <= (rollover_6 & orc_7 > 21) ? JPEG_ro_bs_4[10] : JPEG_bs_4[10];
316
                JPEG_bs_5[9] <= (rollover_6 & orc_7 > 22) ? JPEG_ro_bs_4[9] : JPEG_bs_4[9];
317
                JPEG_bs_5[8] <= (rollover_6 & orc_7 > 23) ? JPEG_ro_bs_4[8] : JPEG_bs_4[8];
318
                JPEG_bs_5[7] <= (rollover_6 & orc_7 > 24) ? JPEG_ro_bs_4[7] : JPEG_bs_4[7];
319
                JPEG_bs_5[6] <= (rollover_6 & orc_7 > 25) ? JPEG_ro_bs_4[6] : JPEG_bs_4[6];
320
                JPEG_bs_5[5] <= (rollover_6 & orc_7 > 26) ? JPEG_ro_bs_4[5] : JPEG_bs_4[5];
321
                JPEG_bs_5[4] <= (rollover_6 & orc_7 > 27) ? JPEG_ro_bs_4[4] : JPEG_bs_4[4];
322
                JPEG_bs_5[3] <= (rollover_6 & orc_7 > 28) ? JPEG_ro_bs_4[3] : JPEG_bs_4[3];
323
                JPEG_bs_5[2] <= (rollover_6 & orc_7 > 29) ? JPEG_ro_bs_4[2] : JPEG_bs_4[2];
324
                JPEG_bs_5[1] <= (rollover_6 & orc_7 > 30) ? JPEG_ro_bs_4[1] : JPEG_bs_4[1];
325
                JPEG_bs_5[0] <= JPEG_bs_4[0];
326
                end
327
end
328
 
329
always @(posedge clk)
330
begin
331
        if (rst) begin
332
                JPEG_bs_4 <= 0; JPEG_ro_bs_4 <= 0;
333
                end
334
        else if (enable_module) begin
335
                JPEG_bs_4 <= (old_orc_6 == 1) ? JPEG_bs_3 >> 1 : JPEG_bs_3;
336
                JPEG_ro_bs_4 <= (Cb12_edge_4 <= 1) ? JPEG_ro_bs_3 << 1 : JPEG_ro_bs_3;
337
                end
338
end
339
 
340
always @(posedge clk)
341
begin
342
        if (rst) begin
343
                JPEG_bs_3 <= 0; old_orc_6 <= 0; JPEG_ro_bs_3 <= 0;
344
                Cb12_edge_4 <= 0;
345
                end
346
        else if (enable_module) begin
347
                JPEG_bs_3 <= (old_orc_5 >= 2) ? JPEG_bs_2 >> 2 : JPEG_bs_2;
348
                old_orc_6 <= (old_orc_5 >= 2) ? old_orc_5 - 2 : old_orc_5;
349
                JPEG_ro_bs_3 <= (Cb12_edge_3 <= 2) ? JPEG_ro_bs_2 << 2 : JPEG_ro_bs_2;
350
                Cb12_edge_4 <= (Cb12_edge_3 <= 2) ? Cb12_edge_3 : Cb12_edge_3 - 2;
351
                end
352
end
353
 
354
always @(posedge clk)
355
begin
356
        if (rst) begin
357
                JPEG_bs_2 <= 0; old_orc_5 <= 0; JPEG_ro_bs_2 <= 0;
358
                Cb12_edge_3 <= 0;
359
                end
360
        else if (enable_module) begin
361
                JPEG_bs_2 <= (old_orc_4 >= 4) ? JPEG_bs_1 >> 4 : JPEG_bs_1;
362
                old_orc_5 <= (old_orc_4 >= 4) ? old_orc_4 - 4 : old_orc_4;
363
                JPEG_ro_bs_2 <= (Cb12_edge_2 <= 4) ? JPEG_ro_bs_1 << 4 : JPEG_ro_bs_1;
364
                Cb12_edge_3 <= (Cb12_edge_2 <= 4) ? Cb12_edge_2 : Cb12_edge_2 - 4;
365
                end
366
end
367
 
368
always @(posedge clk)
369
begin
370
        if (rst) begin
371
                JPEG_bs_1 <= 0; old_orc_4 <= 0; JPEG_ro_bs_1 <= 0;
372
                Cb12_edge_2 <= 0;
373
                end
374
        else if (enable_module) begin
375
                JPEG_bs_1 <= (old_orc_3 >= 8) ? JPEG_bs >> 8 : JPEG_bs;
376
                old_orc_4 <= (old_orc_3 >= 8) ? old_orc_3 - 8 : old_orc_3;
377
                JPEG_ro_bs_1 <= (Cb12_edge_1 <= 8) ? JPEG_ro_bs << 8 : JPEG_ro_bs;
378
                Cb12_edge_2 <= (Cb12_edge_1 <= 8) ? Cb12_edge_1 : Cb12_edge_1 - 8;
379
                end
380
end
381
 
382
always @(posedge clk)
383
begin
384
        if (rst) begin
385
                JPEG_bs <= 0; old_orc_3 <= 0; JPEG_ro_bs <= 0;
386
                Cb12_edge_1 <= 0; Cb11_JPEG_bits_1 <= 0;
387
                end
388
        else if (enable_module) begin
389
                JPEG_bs <= (old_orc_2 >= 16) ? Cb11_JPEG_bits >> 10 : Cb11_JPEG_bits << 6;
390
                old_orc_3 <= (old_orc_2 >= 16) ? old_orc_2 - 16 : old_orc_2;
391
                JPEG_ro_bs <= (Cb12_edge <= 16) ? Cb11_JPEG_bits_1 << 16 : Cb11_JPEG_bits_1;
392
                Cb12_edge_1 <= (Cb12_edge <= 16) ? Cb12_edge : Cb12_edge - 16;
393
                Cb11_JPEG_bits_1 <= Cb11_JPEG_bits;
394
                end
395
end
396
 
397
always @(posedge clk)
398
begin
399
        if (rst) begin
400
                Cb12_JPEG_bits <= 0; Cb12_edge <= 0;
401
                end
402
        else if (enable_module) begin
403
                Cb12_JPEG_bits[25] <= (Cb12_Huff_shift_1 >= 16) ? Cb12_JPEG_LSBs_4[25] : Cb12_Huff_2[15];
404
                Cb12_JPEG_bits[24] <= (Cb12_Huff_shift_1 >= 15) ? Cb12_JPEG_LSBs_4[24] : Cb12_Huff_2[14];
405
                Cb12_JPEG_bits[23] <= (Cb12_Huff_shift_1 >= 14) ? Cb12_JPEG_LSBs_4[23] : Cb12_Huff_2[13];
406
                Cb12_JPEG_bits[22] <= (Cb12_Huff_shift_1 >= 13) ? Cb12_JPEG_LSBs_4[22] : Cb12_Huff_2[12];
407
                Cb12_JPEG_bits[21] <= (Cb12_Huff_shift_1 >= 12) ? Cb12_JPEG_LSBs_4[21] : Cb12_Huff_2[11];
408
                Cb12_JPEG_bits[20] <= (Cb12_Huff_shift_1 >= 11) ? Cb12_JPEG_LSBs_4[20] : Cb12_Huff_2[10];
409
                Cb12_JPEG_bits[19] <= (Cb12_Huff_shift_1 >= 10) ? Cb12_JPEG_LSBs_4[19] : Cb12_Huff_2[9];
410
                Cb12_JPEG_bits[18] <= (Cb12_Huff_shift_1 >= 9) ? Cb12_JPEG_LSBs_4[18] : Cb12_Huff_2[8];
411
                Cb12_JPEG_bits[17] <= (Cb12_Huff_shift_1 >= 8) ? Cb12_JPEG_LSBs_4[17] : Cb12_Huff_2[7];
412
                Cb12_JPEG_bits[16] <= (Cb12_Huff_shift_1 >= 7) ? Cb12_JPEG_LSBs_4[16] : Cb12_Huff_2[6];
413
                Cb12_JPEG_bits[15] <= (Cb12_Huff_shift_1 >= 6) ? Cb12_JPEG_LSBs_4[15] : Cb12_Huff_2[5];
414
                Cb12_JPEG_bits[14] <= (Cb12_Huff_shift_1 >= 5) ? Cb12_JPEG_LSBs_4[14] : Cb12_Huff_2[4];
415
                Cb12_JPEG_bits[13] <= (Cb12_Huff_shift_1 >= 4) ? Cb12_JPEG_LSBs_4[13] : Cb12_Huff_2[3];
416
                Cb12_JPEG_bits[12] <= (Cb12_Huff_shift_1 >= 3) ? Cb12_JPEG_LSBs_4[12] : Cb12_Huff_2[2];
417
                Cb12_JPEG_bits[11] <= (Cb12_Huff_shift_1 >= 2) ? Cb12_JPEG_LSBs_4[11] : Cb12_Huff_2[1];
418
                Cb12_JPEG_bits[10] <= (Cb12_Huff_shift_1 >= 1) ? Cb12_JPEG_LSBs_4[10] : Cb12_Huff_2[0];
419
                Cb12_JPEG_bits[9:0] <= Cb12_JPEG_LSBs_4[9:0];
420
                Cb12_edge <= old_orc_2 + 26; // 26 is the size of Cb11_JPEG_bits
421
                end
422
end
423
 
424
always @(posedge clk)
425
begin
426
        if (rst) begin
427
                Cb11_JPEG_bits <= 0;
428
                end
429
        else if (enable_7) begin
430
                Cb11_JPEG_bits[25] <= (Cb11_Huff_shift_1 >= 11) ? Cb11_JPEG_LSBs_3[21] : Cb11_Huff_2[10];
431
                Cb11_JPEG_bits[24] <= (Cb11_Huff_shift_1 >= 10) ? Cb11_JPEG_LSBs_3[20] : Cb11_Huff_2[9];
432
                Cb11_JPEG_bits[23] <= (Cb11_Huff_shift_1 >= 9) ? Cb11_JPEG_LSBs_3[19] : Cb11_Huff_2[8];
433
                Cb11_JPEG_bits[22] <= (Cb11_Huff_shift_1 >= 8) ? Cb11_JPEG_LSBs_3[18] : Cb11_Huff_2[7];
434
                Cb11_JPEG_bits[21] <= (Cb11_Huff_shift_1 >= 7) ? Cb11_JPEG_LSBs_3[17] : Cb11_Huff_2[6];
435
                Cb11_JPEG_bits[20] <= (Cb11_Huff_shift_1 >= 6) ? Cb11_JPEG_LSBs_3[16] : Cb11_Huff_2[5];
436
                Cb11_JPEG_bits[19] <= (Cb11_Huff_shift_1 >= 5) ? Cb11_JPEG_LSBs_3[15] : Cb11_Huff_2[4];
437
                Cb11_JPEG_bits[18] <= (Cb11_Huff_shift_1 >= 4) ? Cb11_JPEG_LSBs_3[14] : Cb11_Huff_2[3];
438
                Cb11_JPEG_bits[17] <= (Cb11_Huff_shift_1 >= 3) ? Cb11_JPEG_LSBs_3[13] : Cb11_Huff_2[2];
439
                Cb11_JPEG_bits[16] <= (Cb11_Huff_shift_1 >= 2) ? Cb11_JPEG_LSBs_3[12] : Cb11_Huff_2[1];
440
                Cb11_JPEG_bits[15] <= (Cb11_Huff_shift_1 >= 1) ? Cb11_JPEG_LSBs_3[11] : Cb11_Huff_2[0];
441
                Cb11_JPEG_bits[14:4] <= Cb11_JPEG_LSBs_3[10:0];
442
                end
443
        else if (enable_latch_8) begin
444
                Cb11_JPEG_bits <= Cb12_JPEG_bits;
445
                end
446
end
447
 
448
 
449
always @(posedge clk)
450
begin
451
        if (rst) begin
452
                Cb12_oc_1 <= 0; Cb12_JPEG_LSBs_4 <= 0;
453
                Cb12_Huff_2 <= 0; Cb12_Huff_shift_1 <= 0;
454
                end
455
        else if (enable_module) begin
456
                Cb12_oc_1 <= (Cb12_et_zero_5 & !code_15_0 & block_counter != 67) ? 0 :
457
                        Cb12_bits_3 + Cb12_Huff_count_1;
458
                Cb12_JPEG_LSBs_4 <= Cb12_JPEG_LSBs_3 << Cb12_Huff_shift;
459
                Cb12_Huff_2 <= Cb12_Huff_1;
460
                Cb12_Huff_shift_1 <= Cb12_Huff_shift;
461
                end
462
end
463
 
464
always @(posedge clk)
465
begin
466
        if (rst) begin
467
                Cb11_JPEG_LSBs_3 <= 0; Cb11_Huff_2 <= 0;
468
                Cb11_Huff_shift_1 <= 0;
469
                end
470
        else if (enable_6) begin
471
                Cb11_JPEG_LSBs_3 <= Cb11_JPEG_LSBs_2 << Cb11_Huff_shift;
472
                Cb11_Huff_2 <= Cb11_Huff_1;
473
                Cb11_Huff_shift_1 <= Cb11_Huff_shift;
474
                end
475
end
476
 
477
 
478
always @(posedge clk)
479
begin
480
        if (rst) begin
481
                Cb12_Huff_shift <= 0;
482
                Cb12_Huff_1 <= 0; Cb12_JPEG_LSBs_3 <= 0; Cb12_bits_3 <= 0;
483
                Cb12_Huff_count_1 <= 0; Cb12_et_zero_5 <= 0; code_15_0 <= 0;
484
                end
485
        else if (enable_module) begin
486
                Cb12_Huff_shift <= 16 - Cb12_Huff_count;
487
                Cb12_Huff_1 <= Cb12_Huff;
488
                Cb12_JPEG_LSBs_3 <= Cb12_JPEG_LSBs_2;
489
                Cb12_bits_3 <= Cb12_bits_2;
490
                Cb12_Huff_count_1 <= Cb12_Huff_count;
491
                Cb12_et_zero_5 <= Cb12_et_zero_4;
492
                code_15_0 <= zrl_et_15 & !end_of_block;
493
                end
494
end
495
 
496
always @(posedge clk)
497
begin
498
        if (rst) begin
499
                Cb11_output_count <= 0; Cb11_JPEG_LSBs_2 <= 0; Cb11_Huff_shift <= 0;
500
                Cb11_Huff_1 <= 0;
501
                end
502
        else if (enable_5) begin
503
                Cb11_output_count <= Cb11_bits_1 + Cb11_Huff_count;
504
                Cb11_JPEG_LSBs_2 <= Cb11_JPEG_LSBs_1 << Cb11_amp_shift;
505
                Cb11_Huff_shift <= 11 - Cb11_Huff_count;
506
                Cb11_Huff_1 <= Cb11_Huff;
507
                end
508
end
509
 
510
 
511
always @(posedge clk)
512
begin
513
        if (rst) begin
514
                Cb12_JPEG_LSBs_2 <= 0;
515
                Cb12_Huff <= 0; Cb12_Huff_count <= 0; Cb12_bits_2 <= 0;
516
                Cb12_et_zero_4 <= 0; zrl_et_15 <= 0; zrl_3 <= 0;
517
                end
518
        else if (enable_module) begin
519
                Cb12_JPEG_LSBs_2 <= Cb12_JPEG_LSBs_1 << Cb12_amp_shift;
520
                Cb12_Huff <= Cb_AC[Cb12_code_entry];
521
                Cb12_Huff_count <= Cb_AC_code_length[Cb12_code_entry];
522
                Cb12_bits_2 <= Cb12_bits_1;
523
                Cb12_et_zero_4 <= Cb12_et_zero_3;
524
                zrl_et_15 <= zrl_3 == 15;
525
                zrl_3 <= zrl_2;
526
                end
527
end
528
 
529
always @(posedge clk)
530
begin
531
        if (rst) begin
532
                Cb11_Huff <= 0; Cb11_Huff_count <= 0; Cb11_amp_shift <= 0;
533
                Cb11_JPEG_LSBs_1 <= 0; Cb11_bits_1 <= 0;
534
                end
535
        else if (enable_4) begin
536
                Cb11_Huff[10:0] <= Cb_DC[Cb11_bits];
537
                Cb11_Huff_count <= Cb_DC_code_length[Cb11_bits];
538
                Cb11_amp_shift <= 11 - Cb11_bits;
539
                Cb11_JPEG_LSBs_1 <= Cb11_JPEG_LSBs;
540
                Cb11_bits_1 <= Cb11_bits;
541
                end
542
end
543
 
544
always @(posedge clk)
545
begin
546
        if (rst) begin
547
                Cb12_code_entry <= 0; Cb12_JPEG_LSBs_1 <= 0; Cb12_amp_shift <= 0;
548
                Cb12_bits_1 <= 0; Cb12_et_zero_3 <= 0; zrl_2 <= 0;
549
                end
550
        else if (enable_module) begin
551
                Cb12_code_entry <= Cb_AC_run_code[code_index];
552
                Cb12_JPEG_LSBs_1 <= Cb12_JPEG_LSBs;
553
                Cb12_amp_shift <= 10 - Cb12_bits;
554
                Cb12_bits_1 <= Cb12_bits;
555
                Cb12_et_zero_3 <= Cb12_et_zero_2;
556
                zrl_2 <= zrl_1;
557
                end
558
end
559
 
560
always @(posedge clk)
561
begin
562
        if (rst) begin
563
                Cb11_bits <= 0; Cb11_JPEG_LSBs <= 0;
564
                end
565
        else if (enable_3) begin
566
                Cb11_bits <= Cb11_msb ? Cb11_bits_neg : Cb11_bits_pos;
567
                Cb11_JPEG_LSBs <= Cb11_amp[10:0]; // The top bit of Cb11_amp is the sign bit
568
                end
569
end
570
 
571
always @(posedge clk)
572
begin
573
        if (rst) begin
574
                Cb12_bits <= 0; Cb12_JPEG_LSBs <= 0; zrl_1 <= 0;
575
                Cb12_et_zero_2 <= 0;
576
                end
577
        else if (enable_module) begin
578
                Cb12_bits <= Cb12_msb_1 ? Cb12_bits_neg : Cb12_bits_pos;
579
                Cb12_JPEG_LSBs <= Cb12_amp[9:0]; // The top bit of Cb12_amp is the sign bit
580
                zrl_1 <= block_counter == 62 & Cb12_et_zero ? 0 : zero_run_length;
581
                Cb12_et_zero_2 <= Cb12_et_zero_1;
582
                end
583
end
584
 
585
// Cb11_amp is the amplitude that will be represented in bits in the 
586
// JPEG code, following the run length code
587
always @(posedge clk)
588
begin
589
        if (rst) begin
590
                Cb11_amp <= 0;
591
                end
592
        else if (enable_2) begin
593
                Cb11_amp <= Cb11_msb ? Cb11_1_neg : Cb11_1_pos;
594
                end
595
end
596
 
597
 
598
always @(posedge clk)
599
begin
600
        if (rst)
601
                zero_run_length <= 0;
602
        else if (enable)
603
                zero_run_length <= 0;
604
        else if (enable_module)
605
                zero_run_length <= Cb12_et_zero ? zero_run_length + 1: 0;
606
end
607
 
608
always @(posedge clk)
609
begin
610
        if (rst) begin
611
                Cb12_amp <= 0;
612
                Cb12_et_zero_1 <= 0; Cb12_msb_1 <= 0;
613
                end
614
        else if (enable_module) begin
615
                Cb12_amp <= Cb12_msb ? Cb12_neg : Cb12_pos;
616
                Cb12_et_zero_1 <= Cb12_et_zero;
617
                Cb12_msb_1 <= Cb12_msb;
618
                end
619
end
620
 
621
always @(posedge clk)
622
begin
623
        if (rst) begin
624
                Cb11_1_pos <= 0; Cb11_1_neg <= 0; Cb11_msb <= 0;
625
                Cb11_previous <= 0;
626
                end
627
        else if (enable_1) begin
628
                Cb11_1_pos <= Cb11_diff;
629
                Cb11_1_neg <= Cb11_diff - 1;
630
                Cb11_msb <= Cb11_diff[11];
631
                Cb11_previous <= Cb11_1;
632
                end
633
end
634
 
635
always @(posedge clk)
636
begin
637
        if (rst) begin
638
                Cb12_pos <= 0; Cb12_neg <= 0; Cb12_msb <= 0; Cb12_et_zero <= 0;
639
                Cb13_pos <= 0; Cb13_neg <= 0; Cb13_msb <= 0; Cb13_et_zero <= 0;
640
                Cb14_pos <= 0; Cb14_neg <= 0; Cb14_msb <= 0; Cb14_et_zero <= 0;
641
                Cb15_pos <= 0; Cb15_neg <= 0; Cb15_msb <= 0; Cb15_et_zero <= 0;
642
                Cb16_pos <= 0; Cb16_neg <= 0; Cb16_msb <= 0; Cb16_et_zero <= 0;
643
                Cb17_pos <= 0; Cb17_neg <= 0; Cb17_msb <= 0; Cb17_et_zero <= 0;
644
                Cb18_pos <= 0; Cb18_neg <= 0; Cb18_msb <= 0; Cb18_et_zero <= 0;
645
                Cb21_pos <= 0; Cb21_neg <= 0; Cb21_msb <= 0; Cb21_et_zero <= 0;
646
                Cb22_pos <= 0; Cb22_neg <= 0; Cb22_msb <= 0; Cb22_et_zero <= 0;
647
                Cb23_pos <= 0; Cb23_neg <= 0; Cb23_msb <= 0; Cb23_et_zero <= 0;
648
                Cb24_pos <= 0; Cb24_neg <= 0; Cb24_msb <= 0; Cb24_et_zero <= 0;
649
                Cb25_pos <= 0; Cb25_neg <= 0; Cb25_msb <= 0; Cb25_et_zero <= 0;
650
                Cb26_pos <= 0; Cb26_neg <= 0; Cb26_msb <= 0; Cb26_et_zero <= 0;
651
                Cb27_pos <= 0; Cb27_neg <= 0; Cb27_msb <= 0; Cb27_et_zero <= 0;
652
                Cb28_pos <= 0; Cb28_neg <= 0; Cb28_msb <= 0; Cb28_et_zero <= 0;
653
                Cb31_pos <= 0; Cb31_neg <= 0; Cb31_msb <= 0; Cb31_et_zero <= 0;
654
                Cb32_pos <= 0; Cb32_neg <= 0; Cb32_msb <= 0; Cb32_et_zero <= 0;
655
                Cb33_pos <= 0; Cb33_neg <= 0; Cb33_msb <= 0; Cb33_et_zero <= 0;
656
                Cb34_pos <= 0; Cb34_neg <= 0; Cb34_msb <= 0; Cb34_et_zero <= 0;
657
                Cb35_pos <= 0; Cb35_neg <= 0; Cb35_msb <= 0; Cb35_et_zero <= 0;
658
                Cb36_pos <= 0; Cb36_neg <= 0; Cb36_msb <= 0; Cb36_et_zero <= 0;
659
                Cb37_pos <= 0; Cb37_neg <= 0; Cb37_msb <= 0; Cb37_et_zero <= 0;
660
                Cb38_pos <= 0; Cb38_neg <= 0; Cb38_msb <= 0; Cb38_et_zero <= 0;
661
                Cb41_pos <= 0; Cb41_neg <= 0; Cb41_msb <= 0; Cb41_et_zero <= 0;
662
                Cb42_pos <= 0; Cb42_neg <= 0; Cb42_msb <= 0; Cb42_et_zero <= 0;
663
                Cb43_pos <= 0; Cb43_neg <= 0; Cb43_msb <= 0; Cb43_et_zero <= 0;
664
                Cb44_pos <= 0; Cb44_neg <= 0; Cb44_msb <= 0; Cb44_et_zero <= 0;
665
                Cb45_pos <= 0; Cb45_neg <= 0; Cb45_msb <= 0; Cb45_et_zero <= 0;
666
                Cb46_pos <= 0; Cb46_neg <= 0; Cb46_msb <= 0; Cb46_et_zero <= 0;
667
                Cb47_pos <= 0; Cb47_neg <= 0; Cb47_msb <= 0; Cb47_et_zero <= 0;
668
                Cb48_pos <= 0; Cb48_neg <= 0; Cb48_msb <= 0; Cb48_et_zero <= 0;
669
                Cb51_pos <= 0; Cb51_neg <= 0; Cb51_msb <= 0; Cb51_et_zero <= 0;
670
                Cb52_pos <= 0; Cb52_neg <= 0; Cb52_msb <= 0; Cb52_et_zero <= 0;
671
                Cb53_pos <= 0; Cb53_neg <= 0; Cb53_msb <= 0; Cb53_et_zero <= 0;
672
                Cb54_pos <= 0; Cb54_neg <= 0; Cb54_msb <= 0; Cb54_et_zero <= 0;
673
                Cb55_pos <= 0; Cb55_neg <= 0; Cb55_msb <= 0; Cb55_et_zero <= 0;
674
                Cb56_pos <= 0; Cb56_neg <= 0; Cb56_msb <= 0; Cb56_et_zero <= 0;
675
                Cb57_pos <= 0; Cb57_neg <= 0; Cb57_msb <= 0; Cb57_et_zero <= 0;
676
                Cb58_pos <= 0; Cb58_neg <= 0; Cb58_msb <= 0; Cb58_et_zero <= 0;
677
                Cb61_pos <= 0; Cb61_neg <= 0; Cb61_msb <= 0; Cb61_et_zero <= 0;
678
                Cb62_pos <= 0; Cb62_neg <= 0; Cb62_msb <= 0; Cb62_et_zero <= 0;
679
                Cb63_pos <= 0; Cb63_neg <= 0; Cb63_msb <= 0; Cb63_et_zero <= 0;
680
                Cb64_pos <= 0; Cb64_neg <= 0; Cb64_msb <= 0; Cb64_et_zero <= 0;
681
                Cb65_pos <= 0; Cb65_neg <= 0; Cb65_msb <= 0; Cb65_et_zero <= 0;
682
                Cb66_pos <= 0; Cb66_neg <= 0; Cb66_msb <= 0; Cb66_et_zero <= 0;
683
                Cb67_pos <= 0; Cb67_neg <= 0; Cb67_msb <= 0; Cb67_et_zero <= 0;
684
                Cb68_pos <= 0; Cb68_neg <= 0; Cb68_msb <= 0; Cb68_et_zero <= 0;
685
                Cb71_pos <= 0; Cb71_neg <= 0; Cb71_msb <= 0; Cb71_et_zero <= 0;
686
                Cb72_pos <= 0; Cb72_neg <= 0; Cb72_msb <= 0; Cb72_et_zero <= 0;
687
                Cb73_pos <= 0; Cb73_neg <= 0; Cb73_msb <= 0; Cb73_et_zero <= 0;
688
                Cb74_pos <= 0; Cb74_neg <= 0; Cb74_msb <= 0; Cb74_et_zero <= 0;
689
                Cb75_pos <= 0; Cb75_neg <= 0; Cb75_msb <= 0; Cb75_et_zero <= 0;
690
                Cb76_pos <= 0; Cb76_neg <= 0; Cb76_msb <= 0; Cb76_et_zero <= 0;
691
                Cb77_pos <= 0; Cb77_neg <= 0; Cb77_msb <= 0; Cb77_et_zero <= 0;
692
                Cb78_pos <= 0; Cb78_neg <= 0; Cb78_msb <= 0; Cb78_et_zero <= 0;
693
                Cb81_pos <= 0; Cb81_neg <= 0; Cb81_msb <= 0; Cb81_et_zero <= 0;
694
                Cb82_pos <= 0; Cb82_neg <= 0; Cb82_msb <= 0; Cb82_et_zero <= 0;
695
                Cb83_pos <= 0; Cb83_neg <= 0; Cb83_msb <= 0; Cb83_et_zero <= 0;
696
                Cb84_pos <= 0; Cb84_neg <= 0; Cb84_msb <= 0; Cb84_et_zero <= 0;
697
                Cb85_pos <= 0; Cb85_neg <= 0; Cb85_msb <= 0; Cb85_et_zero <= 0;
698
                Cb86_pos <= 0; Cb86_neg <= 0; Cb86_msb <= 0; Cb86_et_zero <= 0;
699
                Cb87_pos <= 0; Cb87_neg <= 0; Cb87_msb <= 0; Cb87_et_zero <= 0;
700
                Cb88_pos <= 0; Cb88_neg <= 0; Cb88_msb <= 0; Cb88_et_zero <= 0;
701
                end
702
        else if (enable) begin
703
                Cb12_pos <= Cb12;
704
                Cb12_neg <= Cb12 - 1;
705
                Cb12_msb <= Cb12[10];
706
                Cb12_et_zero <= !(|Cb12);
707
                Cb13_pos <= Cb13;
708
                Cb13_neg <= Cb13 - 1;
709
                Cb13_msb <= Cb13[10];
710
                Cb13_et_zero <= !(|Cb13);
711
                Cb14_pos <= Cb14;
712
                Cb14_neg <= Cb14 - 1;
713
                Cb14_msb <= Cb14[10];
714
                Cb14_et_zero <= !(|Cb14);
715
                Cb15_pos <= Cb15;
716
                Cb15_neg <= Cb15 - 1;
717
                Cb15_msb <= Cb15[10];
718
                Cb15_et_zero <= !(|Cb15);
719
                Cb16_pos <= Cb16;
720
                Cb16_neg <= Cb16 - 1;
721
                Cb16_msb <= Cb16[10];
722
                Cb16_et_zero <= !(|Cb16);
723
                Cb17_pos <= Cb17;
724
                Cb17_neg <= Cb17 - 1;
725
                Cb17_msb <= Cb17[10];
726
                Cb17_et_zero <= !(|Cb17);
727
                Cb18_pos <= Cb18;
728
                Cb18_neg <= Cb18 - 1;
729
                Cb18_msb <= Cb18[10];
730
                Cb18_et_zero <= !(|Cb18);
731
                Cb21_pos <= Cb21;
732
                Cb21_neg <= Cb21 - 1;
733
                Cb21_msb <= Cb21[10];
734
                Cb21_et_zero <= !(|Cb21);
735
                Cb22_pos <= Cb22;
736
                Cb22_neg <= Cb22 - 1;
737
                Cb22_msb <= Cb22[10];
738
                Cb22_et_zero <= !(|Cb22);
739
                Cb23_pos <= Cb23;
740
                Cb23_neg <= Cb23 - 1;
741
                Cb23_msb <= Cb23[10];
742
                Cb23_et_zero <= !(|Cb23);
743
                Cb24_pos <= Cb24;
744
                Cb24_neg <= Cb24 - 1;
745
                Cb24_msb <= Cb24[10];
746
                Cb24_et_zero <= !(|Cb24);
747
                Cb25_pos <= Cb25;
748
                Cb25_neg <= Cb25 - 1;
749
                Cb25_msb <= Cb25[10];
750
                Cb25_et_zero <= !(|Cb25);
751
                Cb26_pos <= Cb26;
752
                Cb26_neg <= Cb26 - 1;
753
                Cb26_msb <= Cb26[10];
754
                Cb26_et_zero <= !(|Cb26);
755
                Cb27_pos <= Cb27;
756
                Cb27_neg <= Cb27 - 1;
757
                Cb27_msb <= Cb27[10];
758
                Cb27_et_zero <= !(|Cb27);
759
                Cb28_pos <= Cb28;
760
                Cb28_neg <= Cb28 - 1;
761
                Cb28_msb <= Cb28[10];
762
                Cb28_et_zero <= !(|Cb28);
763
                Cb31_pos <= Cb31;
764
                Cb31_neg <= Cb31 - 1;
765
                Cb31_msb <= Cb31[10];
766
                Cb31_et_zero <= !(|Cb31);
767
                Cb32_pos <= Cb32;
768
                Cb32_neg <= Cb32 - 1;
769
                Cb32_msb <= Cb32[10];
770
                Cb32_et_zero <= !(|Cb32);
771
                Cb33_pos <= Cb33;
772
                Cb33_neg <= Cb33 - 1;
773
                Cb33_msb <= Cb33[10];
774
                Cb33_et_zero <= !(|Cb33);
775
                Cb34_pos <= Cb34;
776
                Cb34_neg <= Cb34 - 1;
777
                Cb34_msb <= Cb34[10];
778
                Cb34_et_zero <= !(|Cb34);
779
                Cb35_pos <= Cb35;
780
                Cb35_neg <= Cb35 - 1;
781
                Cb35_msb <= Cb35[10];
782
                Cb35_et_zero <= !(|Cb35);
783
                Cb36_pos <= Cb36;
784
                Cb36_neg <= Cb36 - 1;
785
                Cb36_msb <= Cb36[10];
786
                Cb36_et_zero <= !(|Cb36);
787
                Cb37_pos <= Cb37;
788
                Cb37_neg <= Cb37 - 1;
789
                Cb37_msb <= Cb37[10];
790
                Cb37_et_zero <= !(|Cb37);
791
                Cb38_pos <= Cb38;
792
                Cb38_neg <= Cb38 - 1;
793
                Cb38_msb <= Cb38[10];
794
                Cb38_et_zero <= !(|Cb38);
795
                Cb41_pos <= Cb41;
796
                Cb41_neg <= Cb41 - 1;
797
                Cb41_msb <= Cb41[10];
798
                Cb41_et_zero <= !(|Cb41);
799
                Cb42_pos <= Cb42;
800
                Cb42_neg <= Cb42 - 1;
801
                Cb42_msb <= Cb42[10];
802
                Cb42_et_zero <= !(|Cb42);
803
                Cb43_pos <= Cb43;
804
                Cb43_neg <= Cb43 - 1;
805
                Cb43_msb <= Cb43[10];
806
                Cb43_et_zero <= !(|Cb43);
807
                Cb44_pos <= Cb44;
808
                Cb44_neg <= Cb44 - 1;
809
                Cb44_msb <= Cb44[10];
810
                Cb44_et_zero <= !(|Cb44);
811
                Cb45_pos <= Cb45;
812
                Cb45_neg <= Cb45 - 1;
813
                Cb45_msb <= Cb45[10];
814
                Cb45_et_zero <= !(|Cb45);
815
                Cb46_pos <= Cb46;
816
                Cb46_neg <= Cb46 - 1;
817
                Cb46_msb <= Cb46[10];
818
                Cb46_et_zero <= !(|Cb46);
819
                Cb47_pos <= Cb47;
820
                Cb47_neg <= Cb47 - 1;
821
                Cb47_msb <= Cb47[10];
822
                Cb47_et_zero <= !(|Cb47);
823
                Cb48_pos <= Cb48;
824
                Cb48_neg <= Cb48 - 1;
825
                Cb48_msb <= Cb48[10];
826
                Cb48_et_zero <= !(|Cb48);
827
                Cb51_pos <= Cb51;
828
                Cb51_neg <= Cb51 - 1;
829
                Cb51_msb <= Cb51[10];
830
                Cb51_et_zero <= !(|Cb51);
831
                Cb52_pos <= Cb52;
832
                Cb52_neg <= Cb52 - 1;
833
                Cb52_msb <= Cb52[10];
834
                Cb52_et_zero <= !(|Cb52);
835
                Cb53_pos <= Cb53;
836
                Cb53_neg <= Cb53 - 1;
837
                Cb53_msb <= Cb53[10];
838
                Cb53_et_zero <= !(|Cb53);
839
                Cb54_pos <= Cb54;
840
                Cb54_neg <= Cb54 - 1;
841
                Cb54_msb <= Cb54[10];
842
                Cb54_et_zero <= !(|Cb54);
843
                Cb55_pos <= Cb55;
844
                Cb55_neg <= Cb55 - 1;
845
                Cb55_msb <= Cb55[10];
846
                Cb55_et_zero <= !(|Cb55);
847
                Cb56_pos <= Cb56;
848
                Cb56_neg <= Cb56 - 1;
849
                Cb56_msb <= Cb56[10];
850
                Cb56_et_zero <= !(|Cb56);
851
                Cb57_pos <= Cb57;
852
                Cb57_neg <= Cb57 - 1;
853
                Cb57_msb <= Cb57[10];
854
                Cb57_et_zero <= !(|Cb57);
855
                Cb58_pos <= Cb58;
856
                Cb58_neg <= Cb58 - 1;
857
                Cb58_msb <= Cb58[10];
858
                Cb58_et_zero <= !(|Cb58);
859
                Cb61_pos <= Cb61;
860
                Cb61_neg <= Cb61 - 1;
861
                Cb61_msb <= Cb61[10];
862
                Cb61_et_zero <= !(|Cb61);
863
                Cb62_pos <= Cb62;
864
                Cb62_neg <= Cb62 - 1;
865
                Cb62_msb <= Cb62[10];
866
                Cb62_et_zero <= !(|Cb62);
867
                Cb63_pos <= Cb63;
868
                Cb63_neg <= Cb63 - 1;
869
                Cb63_msb <= Cb63[10];
870
                Cb63_et_zero <= !(|Cb63);
871
                Cb64_pos <= Cb64;
872
                Cb64_neg <= Cb64 - 1;
873
                Cb64_msb <= Cb64[10];
874
                Cb64_et_zero <= !(|Cb64);
875
                Cb65_pos <= Cb65;
876
                Cb65_neg <= Cb65 - 1;
877
                Cb65_msb <= Cb65[10];
878
                Cb65_et_zero <= !(|Cb65);
879
                Cb66_pos <= Cb66;
880
                Cb66_neg <= Cb66 - 1;
881
                Cb66_msb <= Cb66[10];
882
                Cb66_et_zero <= !(|Cb66);
883
                Cb67_pos <= Cb67;
884
                Cb67_neg <= Cb67 - 1;
885
                Cb67_msb <= Cb67[10];
886
                Cb67_et_zero <= !(|Cb67);
887
                Cb68_pos <= Cb68;
888
                Cb68_neg <= Cb68 - 1;
889
                Cb68_msb <= Cb68[10];
890
                Cb68_et_zero <= !(|Cb68);
891
                Cb71_pos <= Cb71;
892
                Cb71_neg <= Cb71 - 1;
893
                Cb71_msb <= Cb71[10];
894
                Cb71_et_zero <= !(|Cb71);
895
                Cb72_pos <= Cb72;
896
                Cb72_neg <= Cb72 - 1;
897
                Cb72_msb <= Cb72[10];
898
                Cb72_et_zero <= !(|Cb72);
899
                Cb73_pos <= Cb73;
900
                Cb73_neg <= Cb73 - 1;
901
                Cb73_msb <= Cb73[10];
902
                Cb73_et_zero <= !(|Cb73);
903
                Cb74_pos <= Cb74;
904
                Cb74_neg <= Cb74 - 1;
905
                Cb74_msb <= Cb74[10];
906
                Cb74_et_zero <= !(|Cb74);
907
                Cb75_pos <= Cb75;
908
                Cb75_neg <= Cb75 - 1;
909
                Cb75_msb <= Cb75[10];
910
                Cb75_et_zero <= !(|Cb75);
911
                Cb76_pos <= Cb76;
912
                Cb76_neg <= Cb76 - 1;
913
                Cb76_msb <= Cb76[10];
914
                Cb76_et_zero <= !(|Cb76);
915
                Cb77_pos <= Cb77;
916
                Cb77_neg <= Cb77 - 1;
917
                Cb77_msb <= Cb77[10];
918
                Cb77_et_zero <= !(|Cb77);
919
                Cb78_pos <= Cb78;
920
                Cb78_neg <= Cb78 - 1;
921
                Cb78_msb <= Cb78[10];
922
                Cb78_et_zero <= !(|Cb78);
923
                Cb81_pos <= Cb81;
924
                Cb81_neg <= Cb81 - 1;
925
                Cb81_msb <= Cb81[10];
926
                Cb81_et_zero <= !(|Cb81);
927
                Cb82_pos <= Cb82;
928
                Cb82_neg <= Cb82 - 1;
929
                Cb82_msb <= Cb82[10];
930
                Cb82_et_zero <= !(|Cb82);
931
                Cb83_pos <= Cb83;
932
                Cb83_neg <= Cb83 - 1;
933
                Cb83_msb <= Cb83[10];
934
                Cb83_et_zero <= !(|Cb83);
935
                Cb84_pos <= Cb84;
936
                Cb84_neg <= Cb84 - 1;
937
                Cb84_msb <= Cb84[10];
938
                Cb84_et_zero <= !(|Cb84);
939
                Cb85_pos <= Cb85;
940
                Cb85_neg <= Cb85 - 1;
941
                Cb85_msb <= Cb85[10];
942
                Cb85_et_zero <= !(|Cb85);
943
                Cb86_pos <= Cb86;
944
                Cb86_neg <= Cb86 - 1;
945
                Cb86_msb <= Cb86[10];
946
                Cb86_et_zero <= !(|Cb86);
947
                Cb87_pos <= Cb87;
948
                Cb87_neg <= Cb87 - 1;
949
                Cb87_msb <= Cb87[10];
950
                Cb87_et_zero <= !(|Cb87);
951
                Cb88_pos <= Cb88;
952
                Cb88_neg <= Cb88 - 1;
953
                Cb88_msb <= Cb88[10];
954
                Cb88_et_zero <= !(|Cb88);
955
                end
956
        else if (enable_module) begin
957
                Cb12_pos <= Cb21_pos;
958
                Cb12_neg <= Cb21_neg;
959
                Cb12_msb <= Cb21_msb;
960
                Cb12_et_zero <= Cb21_et_zero;
961
                Cb21_pos <= Cb31_pos;
962
                Cb21_neg <= Cb31_neg;
963
                Cb21_msb <= Cb31_msb;
964
                Cb21_et_zero <= Cb31_et_zero;
965
                Cb31_pos <= Cb22_pos;
966
                Cb31_neg <= Cb22_neg;
967
                Cb31_msb <= Cb22_msb;
968
                Cb31_et_zero <= Cb22_et_zero;
969
                Cb22_pos <= Cb13_pos;
970
                Cb22_neg <= Cb13_neg;
971
                Cb22_msb <= Cb13_msb;
972
                Cb22_et_zero <= Cb13_et_zero;
973
                Cb13_pos <= Cb14_pos;
974
                Cb13_neg <= Cb14_neg;
975
                Cb13_msb <= Cb14_msb;
976
                Cb13_et_zero <= Cb14_et_zero;
977
                Cb14_pos <= Cb23_pos;
978
                Cb14_neg <= Cb23_neg;
979
                Cb14_msb <= Cb23_msb;
980
                Cb14_et_zero <= Cb23_et_zero;
981
                Cb23_pos <= Cb32_pos;
982
                Cb23_neg <= Cb32_neg;
983
                Cb23_msb <= Cb32_msb;
984
                Cb23_et_zero <= Cb32_et_zero;
985
                Cb32_pos <= Cb41_pos;
986
                Cb32_neg <= Cb41_neg;
987
                Cb32_msb <= Cb41_msb;
988
                Cb32_et_zero <= Cb41_et_zero;
989
                Cb41_pos <= Cb51_pos;
990
                Cb41_neg <= Cb51_neg;
991
                Cb41_msb <= Cb51_msb;
992
                Cb41_et_zero <= Cb51_et_zero;
993
                Cb51_pos <= Cb42_pos;
994
                Cb51_neg <= Cb42_neg;
995
                Cb51_msb <= Cb42_msb;
996
                Cb51_et_zero <= Cb42_et_zero;
997
                Cb42_pos <= Cb33_pos;
998
                Cb42_neg <= Cb33_neg;
999
                Cb42_msb <= Cb33_msb;
1000
                Cb42_et_zero <= Cb33_et_zero;
1001
                Cb33_pos <= Cb24_pos;
1002
                Cb33_neg <= Cb24_neg;
1003
                Cb33_msb <= Cb24_msb;
1004
                Cb33_et_zero <= Cb24_et_zero;
1005
                Cb24_pos <= Cb15_pos;
1006
                Cb24_neg <= Cb15_neg;
1007
                Cb24_msb <= Cb15_msb;
1008
                Cb24_et_zero <= Cb15_et_zero;
1009
                Cb15_pos <= Cb16_pos;
1010
                Cb15_neg <= Cb16_neg;
1011
                Cb15_msb <= Cb16_msb;
1012
                Cb15_et_zero <= Cb16_et_zero;
1013
                Cb16_pos <= Cb25_pos;
1014
                Cb16_neg <= Cb25_neg;
1015
                Cb16_msb <= Cb25_msb;
1016
                Cb16_et_zero <= Cb25_et_zero;
1017
                Cb25_pos <= Cb34_pos;
1018
                Cb25_neg <= Cb34_neg;
1019
                Cb25_msb <= Cb34_msb;
1020
                Cb25_et_zero <= Cb34_et_zero;
1021
                Cb34_pos <= Cb43_pos;
1022
                Cb34_neg <= Cb43_neg;
1023
                Cb34_msb <= Cb43_msb;
1024
                Cb34_et_zero <= Cb43_et_zero;
1025
                Cb43_pos <= Cb52_pos;
1026
                Cb43_neg <= Cb52_neg;
1027
                Cb43_msb <= Cb52_msb;
1028
                Cb43_et_zero <= Cb52_et_zero;
1029
                Cb52_pos <= Cb61_pos;
1030
                Cb52_neg <= Cb61_neg;
1031
                Cb52_msb <= Cb61_msb;
1032
                Cb52_et_zero <= Cb61_et_zero;
1033
                Cb61_pos <= Cb71_pos;
1034
                Cb61_neg <= Cb71_neg;
1035
                Cb61_msb <= Cb71_msb;
1036
                Cb61_et_zero <= Cb71_et_zero;
1037
                Cb71_pos <= Cb62_pos;
1038
                Cb71_neg <= Cb62_neg;
1039
                Cb71_msb <= Cb62_msb;
1040
                Cb71_et_zero <= Cb62_et_zero;
1041
                Cb62_pos <= Cb53_pos;
1042
                Cb62_neg <= Cb53_neg;
1043
                Cb62_msb <= Cb53_msb;
1044
                Cb62_et_zero <= Cb53_et_zero;
1045
                Cb53_pos <= Cb44_pos;
1046
                Cb53_neg <= Cb44_neg;
1047
                Cb53_msb <= Cb44_msb;
1048
                Cb53_et_zero <= Cb44_et_zero;
1049
                Cb44_pos <= Cb35_pos;
1050
                Cb44_neg <= Cb35_neg;
1051
                Cb44_msb <= Cb35_msb;
1052
                Cb44_et_zero <= Cb35_et_zero;
1053
                Cb35_pos <= Cb26_pos;
1054
                Cb35_neg <= Cb26_neg;
1055
                Cb35_msb <= Cb26_msb;
1056
                Cb35_et_zero <= Cb26_et_zero;
1057
                Cb26_pos <= Cb17_pos;
1058
                Cb26_neg <= Cb17_neg;
1059
                Cb26_msb <= Cb17_msb;
1060
                Cb26_et_zero <= Cb17_et_zero;
1061
                Cb17_pos <= Cb18_pos;
1062
                Cb17_neg <= Cb18_neg;
1063
                Cb17_msb <= Cb18_msb;
1064
                Cb17_et_zero <= Cb18_et_zero;
1065
                Cb18_pos <= Cb27_pos;
1066
                Cb18_neg <= Cb27_neg;
1067
                Cb18_msb <= Cb27_msb;
1068
                Cb18_et_zero <= Cb27_et_zero;
1069
                Cb27_pos <= Cb36_pos;
1070
                Cb27_neg <= Cb36_neg;
1071
                Cb27_msb <= Cb36_msb;
1072
                Cb27_et_zero <= Cb36_et_zero;
1073
                Cb36_pos <= Cb45_pos;
1074
                Cb36_neg <= Cb45_neg;
1075
                Cb36_msb <= Cb45_msb;
1076
                Cb36_et_zero <= Cb45_et_zero;
1077
                Cb45_pos <= Cb54_pos;
1078
                Cb45_neg <= Cb54_neg;
1079
                Cb45_msb <= Cb54_msb;
1080
                Cb45_et_zero <= Cb54_et_zero;
1081
                Cb54_pos <= Cb63_pos;
1082
                Cb54_neg <= Cb63_neg;
1083
                Cb54_msb <= Cb63_msb;
1084
                Cb54_et_zero <= Cb63_et_zero;
1085
                Cb63_pos <= Cb72_pos;
1086
                Cb63_neg <= Cb72_neg;
1087
                Cb63_msb <= Cb72_msb;
1088
                Cb63_et_zero <= Cb72_et_zero;
1089
                Cb72_pos <= Cb81_pos;
1090
                Cb72_neg <= Cb81_neg;
1091
                Cb72_msb <= Cb81_msb;
1092
                Cb72_et_zero <= Cb81_et_zero;
1093
                Cb81_pos <= Cb82_pos;
1094
                Cb81_neg <= Cb82_neg;
1095
                Cb81_msb <= Cb82_msb;
1096
                Cb81_et_zero <= Cb82_et_zero;
1097
                Cb82_pos <= Cb73_pos;
1098
                Cb82_neg <= Cb73_neg;
1099
                Cb82_msb <= Cb73_msb;
1100
                Cb82_et_zero <= Cb73_et_zero;
1101
                Cb73_pos <= Cb64_pos;
1102
                Cb73_neg <= Cb64_neg;
1103
                Cb73_msb <= Cb64_msb;
1104
                Cb73_et_zero <= Cb64_et_zero;
1105
                Cb64_pos <= Cb55_pos;
1106
                Cb64_neg <= Cb55_neg;
1107
                Cb64_msb <= Cb55_msb;
1108
                Cb64_et_zero <= Cb55_et_zero;
1109
                Cb55_pos <= Cb46_pos;
1110
                Cb55_neg <= Cb46_neg;
1111
                Cb55_msb <= Cb46_msb;
1112
                Cb55_et_zero <= Cb46_et_zero;
1113
                Cb46_pos <= Cb37_pos;
1114
                Cb46_neg <= Cb37_neg;
1115
                Cb46_msb <= Cb37_msb;
1116
                Cb46_et_zero <= Cb37_et_zero;
1117
                Cb37_pos <= Cb28_pos;
1118
                Cb37_neg <= Cb28_neg;
1119
                Cb37_msb <= Cb28_msb;
1120
                Cb37_et_zero <= Cb28_et_zero;
1121
                Cb28_pos <= Cb38_pos;
1122
                Cb28_neg <= Cb38_neg;
1123
                Cb28_msb <= Cb38_msb;
1124
                Cb28_et_zero <= Cb38_et_zero;
1125
                Cb38_pos <= Cb47_pos;
1126
                Cb38_neg <= Cb47_neg;
1127
                Cb38_msb <= Cb47_msb;
1128
                Cb38_et_zero <= Cb47_et_zero;
1129
                Cb47_pos <= Cb56_pos;
1130
                Cb47_neg <= Cb56_neg;
1131
                Cb47_msb <= Cb56_msb;
1132
                Cb47_et_zero <= Cb56_et_zero;
1133
                Cb56_pos <= Cb65_pos;
1134
                Cb56_neg <= Cb65_neg;
1135
                Cb56_msb <= Cb65_msb;
1136
                Cb56_et_zero <= Cb65_et_zero;
1137
                Cb65_pos <= Cb74_pos;
1138
                Cb65_neg <= Cb74_neg;
1139
                Cb65_msb <= Cb74_msb;
1140
                Cb65_et_zero <= Cb74_et_zero;
1141
                Cb74_pos <= Cb83_pos;
1142
                Cb74_neg <= Cb83_neg;
1143
                Cb74_msb <= Cb83_msb;
1144
                Cb74_et_zero <= Cb83_et_zero;
1145
                Cb83_pos <= Cb84_pos;
1146
                Cb83_neg <= Cb84_neg;
1147
                Cb83_msb <= Cb84_msb;
1148
                Cb83_et_zero <= Cb84_et_zero;
1149
                Cb84_pos <= Cb75_pos;
1150
                Cb84_neg <= Cb75_neg;
1151
                Cb84_msb <= Cb75_msb;
1152
                Cb84_et_zero <= Cb75_et_zero;
1153
                Cb75_pos <= Cb66_pos;
1154
                Cb75_neg <= Cb66_neg;
1155
                Cb75_msb <= Cb66_msb;
1156
                Cb75_et_zero <= Cb66_et_zero;
1157
                Cb66_pos <= Cb57_pos;
1158
                Cb66_neg <= Cb57_neg;
1159
                Cb66_msb <= Cb57_msb;
1160
                Cb66_et_zero <= Cb57_et_zero;
1161
                Cb57_pos <= Cb48_pos;
1162
                Cb57_neg <= Cb48_neg;
1163
                Cb57_msb <= Cb48_msb;
1164
                Cb57_et_zero <= Cb48_et_zero;
1165
                Cb48_pos <= Cb58_pos;
1166
                Cb48_neg <= Cb58_neg;
1167
                Cb48_msb <= Cb58_msb;
1168
                Cb48_et_zero <= Cb58_et_zero;
1169
                Cb58_pos <= Cb67_pos;
1170
                Cb58_neg <= Cb67_neg;
1171
                Cb58_msb <= Cb67_msb;
1172
                Cb58_et_zero <= Cb67_et_zero;
1173
                Cb67_pos <= Cb76_pos;
1174
                Cb67_neg <= Cb76_neg;
1175
                Cb67_msb <= Cb76_msb;
1176
                Cb67_et_zero <= Cb76_et_zero;
1177
                Cb76_pos <= Cb85_pos;
1178
                Cb76_neg <= Cb85_neg;
1179
                Cb76_msb <= Cb85_msb;
1180
                Cb76_et_zero <= Cb85_et_zero;
1181
                Cb85_pos <= Cb86_pos;
1182
                Cb85_neg <= Cb86_neg;
1183
                Cb85_msb <= Cb86_msb;
1184
                Cb85_et_zero <= Cb86_et_zero;
1185
                Cb86_pos <= Cb77_pos;
1186
                Cb86_neg <= Cb77_neg;
1187
                Cb86_msb <= Cb77_msb;
1188
                Cb86_et_zero <= Cb77_et_zero;
1189
                Cb77_pos <= Cb68_pos;
1190
                Cb77_neg <= Cb68_neg;
1191
                Cb77_msb <= Cb68_msb;
1192
                Cb77_et_zero <= Cb68_et_zero;
1193
                Cb68_pos <= Cb78_pos;
1194
                Cb68_neg <= Cb78_neg;
1195
                Cb68_msb <= Cb78_msb;
1196
                Cb68_et_zero <= Cb78_et_zero;
1197
                Cb78_pos <= Cb87_pos;
1198
                Cb78_neg <= Cb87_neg;
1199
                Cb78_msb <= Cb87_msb;
1200
                Cb78_et_zero <= Cb87_et_zero;
1201
                Cb87_pos <= Cb88_pos;
1202
                Cb87_neg <= Cb88_neg;
1203
                Cb87_msb <= Cb88_msb;
1204
                Cb87_et_zero <= Cb88_et_zero;
1205
                Cb88_pos <= 0;
1206
                Cb88_neg <= 0;
1207
                Cb88_msb <= 0;
1208
                Cb88_et_zero <= 1;
1209
                end
1210
end
1211
 
1212
always @(posedge clk)
1213
begin
1214
        if (rst) begin
1215
                Cb11_diff <= 0; Cb11_1 <= 0;
1216
                end
1217
        else if (enable) begin // Need to sign extend Cb11 to 12 bits
1218
                Cb11_diff <= {Cb11[10], Cb11} - Cb11_previous;
1219
                Cb11_1 <= Cb11[10] ? { 1'b1, Cb11 } : { 1'b0, Cb11 };
1220
                end
1221
end
1222
 
1223
always @(posedge clk)
1224
begin
1225
        if (rst)
1226
                Cb11_bits_pos <= 0;
1227
        else if (Cb11_1_pos[10] == 1)
1228
                Cb11_bits_pos <= 11;
1229
        else if (Cb11_1_pos[9] == 1)
1230
                Cb11_bits_pos <= 10;
1231
        else if (Cb11_1_pos[8] == 1)
1232
                Cb11_bits_pos <= 9;
1233
        else if (Cb11_1_pos[7] == 1)
1234
                Cb11_bits_pos <= 8;
1235
        else if (Cb11_1_pos[6] == 1)
1236
                Cb11_bits_pos <= 7;
1237
        else if (Cb11_1_pos[5] == 1)
1238
                Cb11_bits_pos <= 6;
1239
        else if (Cb11_1_pos[4] == 1)
1240
                Cb11_bits_pos <= 5;
1241
        else if (Cb11_1_pos[3] == 1)
1242
                Cb11_bits_pos <= 4;
1243
        else if (Cb11_1_pos[2] == 1)
1244
                Cb11_bits_pos <= 3;
1245
        else if (Cb11_1_pos[1] == 1)
1246
                Cb11_bits_pos <= 2;
1247
        else if (Cb11_1_pos[0] == 1)
1248
                Cb11_bits_pos <= 1;
1249
        else
1250
                Cb11_bits_pos <= 0;
1251
end
1252
 
1253
always @(posedge clk)
1254
begin
1255
        if (rst)
1256
                Cb11_bits_neg <= 0;
1257
        else if (Cb11_1_neg[10] == 0)
1258
                Cb11_bits_neg <= 11;
1259
        else if (Cb11_1_neg[9] == 0)
1260
                Cb11_bits_neg <= 10;
1261
        else if (Cb11_1_neg[8] == 0)
1262
                Cb11_bits_neg <= 9;
1263
        else if (Cb11_1_neg[7] == 0)
1264
                Cb11_bits_neg <= 8;
1265
        else if (Cb11_1_neg[6] == 0)
1266
                Cb11_bits_neg <= 7;
1267
        else if (Cb11_1_neg[5] == 0)
1268
                Cb11_bits_neg <= 6;
1269
        else if (Cb11_1_neg[4] == 0)
1270
                Cb11_bits_neg <= 5;
1271
        else if (Cb11_1_neg[3] == 0)
1272
                Cb11_bits_neg <= 4;
1273
        else if (Cb11_1_neg[2] == 0)
1274
                Cb11_bits_neg <= 3;
1275
        else if (Cb11_1_neg[1] == 0)
1276
                Cb11_bits_neg <= 2;
1277
        else if (Cb11_1_neg[0] == 0)
1278
                Cb11_bits_neg <= 1;
1279
        else
1280
                Cb11_bits_neg <= 0;
1281
end
1282
 
1283
 
1284
always @(posedge clk)
1285
begin
1286
        if (rst)
1287
                Cb12_bits_pos <= 0;
1288
        else if (Cb12_pos[9] == 1)
1289
                Cb12_bits_pos <= 10;
1290
        else if (Cb12_pos[8] == 1)
1291
                Cb12_bits_pos <= 9;
1292
        else if (Cb12_pos[7] == 1)
1293
                Cb12_bits_pos <= 8;
1294
        else if (Cb12_pos[6] == 1)
1295
                Cb12_bits_pos <= 7;
1296
        else if (Cb12_pos[5] == 1)
1297
                Cb12_bits_pos <= 6;
1298
        else if (Cb12_pos[4] == 1)
1299
                Cb12_bits_pos <= 5;
1300
        else if (Cb12_pos[3] == 1)
1301
                Cb12_bits_pos <= 4;
1302
        else if (Cb12_pos[2] == 1)
1303
                Cb12_bits_pos <= 3;
1304
        else if (Cb12_pos[1] == 1)
1305
                Cb12_bits_pos <= 2;
1306
        else if (Cb12_pos[0] == 1)
1307
                Cb12_bits_pos <= 1;
1308
        else
1309
                Cb12_bits_pos <= 0;
1310
end
1311
 
1312
always @(posedge clk)
1313
begin
1314
        if (rst)
1315
                Cb12_bits_neg <= 0;
1316
        else if (Cb12_neg[9] == 0)
1317
                Cb12_bits_neg <= 10;
1318
        else if (Cb12_neg[8] == 0)
1319
                Cb12_bits_neg <= 9;
1320
        else if (Cb12_neg[7] == 0)
1321
                Cb12_bits_neg <= 8;
1322
        else if (Cb12_neg[6] == 0)
1323
                Cb12_bits_neg <= 7;
1324
        else if (Cb12_neg[5] == 0)
1325
                Cb12_bits_neg <= 6;
1326
        else if (Cb12_neg[4] == 0)
1327
                Cb12_bits_neg <= 5;
1328
        else if (Cb12_neg[3] == 0)
1329
                Cb12_bits_neg <= 4;
1330
        else if (Cb12_neg[2] == 0)
1331
                Cb12_bits_neg <= 3;
1332
        else if (Cb12_neg[1] == 0)
1333
                Cb12_bits_neg <= 2;
1334
        else if (Cb12_neg[0] == 0)
1335
                Cb12_bits_neg <= 1;
1336
        else
1337
                Cb12_bits_neg <= 0;
1338
end
1339
 
1340
always @(posedge clk)
1341
begin
1342
        if (rst) begin
1343
                enable_module <= 0;
1344
                end
1345
        else if (enable) begin
1346
                enable_module <= 1;
1347
                end
1348
end
1349
 
1350
always @(posedge clk)
1351
begin
1352
        if (rst) begin
1353
                enable_latch_7 <= 0;
1354
                end
1355
        else if (block_counter == 68)  begin
1356
                enable_latch_7 <= 0;
1357
                end
1358
        else if (enable_6) begin
1359
                enable_latch_7 <= 1;
1360
                end
1361
end
1362
 
1363
always @(posedge clk)
1364
begin
1365
        if (rst) begin
1366
                enable_latch_8 <= 0;
1367
                end
1368
        else if (enable_7) begin
1369
                enable_latch_8 <= 1;
1370
                end
1371
end
1372
 
1373
always @(posedge clk)
1374
begin
1375
        if (rst) begin
1376
                enable_1 <= 0; enable_2 <= 0; enable_3 <= 0;
1377
                enable_4 <= 0; enable_5 <= 0; enable_6 <= 0;
1378
                enable_7 <= 0; enable_8 <= 0; enable_9 <= 0;
1379
                enable_10 <= 0; enable_11 <= 0; enable_12 <= 0;
1380
                enable_13 <= 0;
1381
                end
1382
        else begin
1383
                enable_1 <= enable; enable_2 <= enable_1; enable_3 <= enable_2;
1384
                enable_4 <= enable_3; enable_5 <= enable_4; enable_6 <= enable_5;
1385
                enable_7 <= enable_6; enable_8 <= enable_7; enable_9 <= enable_8;
1386
                enable_10 <= enable_9; enable_11 <= enable_10; enable_12 <= enable_11;
1387
                enable_13 <= enable_12;
1388
                end
1389
end
1390
 
1391
/* These Cb DC and AC code lengths, run lengths, and bit codes
1392
were created from the Huffman table entries in the JPEG file header.
1393
For different Huffman tables for different images, these values
1394
below will need to be changed.  I created a matlab file to automatically
1395
create these entries from the already encoded JPEG image. This matlab program
1396
won't be any help if you're starting from scratch with a .tif or other
1397
raw image file format.  The values below come from a Huffman table, they
1398
do not actually create the Huffman table based on the probabilities of
1399
each code created from the image data.  Cbou will need another program to
1400
create the optimal Huffman table, or you can go with a generic Huffman table,
1401
which will have slightly less than the best compression.*/
1402
 
1403
always @(posedge clk)
1404
begin
1405
Cb_DC_code_length[0] <= 2;
1406
Cb_DC_code_length[1] <= 2;
1407
Cb_DC_code_length[2] <= 2;
1408
Cb_DC_code_length[3] <= 3;
1409
Cb_DC_code_length[4] <= 4;
1410
Cb_DC_code_length[5] <= 5;
1411
Cb_DC_code_length[6] <= 6;
1412
Cb_DC_code_length[7] <= 7;
1413
Cb_DC_code_length[8] <= 8;
1414
Cb_DC_code_length[9] <= 9;
1415
Cb_DC_code_length[10] <= 10;
1416
Cb_DC_code_length[11] <= 11;
1417
Cb_DC[0] <= 11'b00000000000;
1418
Cb_DC[1] <= 11'b01000000000;
1419
Cb_DC[2] <= 11'b10000000000;
1420
Cb_DC[3] <= 11'b11000000000;
1421
Cb_DC[4] <= 11'b11100000000;
1422
Cb_DC[5] <= 11'b11110000000;
1423
Cb_DC[6] <= 11'b11111000000;
1424
Cb_DC[7] <= 11'b11111100000;
1425
Cb_DC[8] <= 11'b11111110000;
1426
Cb_DC[9] <= 11'b11111111000;
1427
Cb_DC[10] <= 11'b11111111100;
1428
Cb_DC[11] <= 11'b11111111110;
1429
Cb_AC_code_length[0] <= 2;
1430
Cb_AC_code_length[1] <= 2;
1431
Cb_AC_code_length[2] <= 3;
1432
Cb_AC_code_length[3] <= 4;
1433
Cb_AC_code_length[4] <= 4;
1434
Cb_AC_code_length[5] <= 4;
1435
Cb_AC_code_length[6] <= 5;
1436
Cb_AC_code_length[7] <= 5;
1437
Cb_AC_code_length[8] <= 5;
1438
Cb_AC_code_length[9] <= 6;
1439
Cb_AC_code_length[10] <= 6;
1440
Cb_AC_code_length[11] <= 7;
1441
Cb_AC_code_length[12] <= 7;
1442
Cb_AC_code_length[13] <= 7;
1443
Cb_AC_code_length[14] <= 7;
1444
Cb_AC_code_length[15] <= 8;
1445
Cb_AC_code_length[16] <= 8;
1446
Cb_AC_code_length[17] <= 8;
1447
Cb_AC_code_length[18] <= 9;
1448
Cb_AC_code_length[19] <= 9;
1449
Cb_AC_code_length[20] <= 9;
1450
Cb_AC_code_length[21] <= 9;
1451
Cb_AC_code_length[22] <= 9;
1452
Cb_AC_code_length[23] <= 10;
1453
Cb_AC_code_length[24] <= 10;
1454
Cb_AC_code_length[25] <= 10;
1455
Cb_AC_code_length[26] <= 10;
1456
Cb_AC_code_length[27] <= 10;
1457
Cb_AC_code_length[28] <= 11;
1458
Cb_AC_code_length[29] <= 11;
1459
Cb_AC_code_length[30] <= 11;
1460
Cb_AC_code_length[31] <= 11;
1461
Cb_AC_code_length[32] <= 12;
1462
Cb_AC_code_length[33] <= 12;
1463
Cb_AC_code_length[34] <= 12;
1464
Cb_AC_code_length[35] <= 12;
1465
Cb_AC_code_length[36] <= 15;
1466
Cb_AC_code_length[37] <= 16;
1467
Cb_AC_code_length[38] <= 16;
1468
Cb_AC_code_length[39] <= 16;
1469
Cb_AC_code_length[40] <= 16;
1470
Cb_AC_code_length[41] <= 16;
1471
Cb_AC_code_length[42] <= 16;
1472
Cb_AC_code_length[43] <= 16;
1473
Cb_AC_code_length[44] <= 16;
1474
Cb_AC_code_length[45] <= 16;
1475
Cb_AC_code_length[46] <= 16;
1476
Cb_AC_code_length[47] <= 16;
1477
Cb_AC_code_length[48] <= 16;
1478
Cb_AC_code_length[49] <= 16;
1479
Cb_AC_code_length[50] <= 16;
1480
Cb_AC_code_length[51] <= 16;
1481
Cb_AC_code_length[52] <= 16;
1482
Cb_AC_code_length[53] <= 16;
1483
Cb_AC_code_length[54] <= 16;
1484
Cb_AC_code_length[55] <= 16;
1485
Cb_AC_code_length[56] <= 16;
1486
Cb_AC_code_length[57] <= 16;
1487
Cb_AC_code_length[58] <= 16;
1488
Cb_AC_code_length[59] <= 16;
1489
Cb_AC_code_length[60] <= 16;
1490
Cb_AC_code_length[61] <= 16;
1491
Cb_AC_code_length[62] <= 16;
1492
Cb_AC_code_length[63] <= 16;
1493
Cb_AC_code_length[64] <= 16;
1494
Cb_AC_code_length[65] <= 16;
1495
Cb_AC_code_length[66] <= 16;
1496
Cb_AC_code_length[67] <= 16;
1497
Cb_AC_code_length[68] <= 16;
1498
Cb_AC_code_length[69] <= 16;
1499
Cb_AC_code_length[70] <= 16;
1500
Cb_AC_code_length[71] <= 16;
1501
Cb_AC_code_length[72] <= 16;
1502
Cb_AC_code_length[73] <= 16;
1503
Cb_AC_code_length[74] <= 16;
1504
Cb_AC_code_length[75] <= 16;
1505
Cb_AC_code_length[76] <= 16;
1506
Cb_AC_code_length[77] <= 16;
1507
Cb_AC_code_length[78] <= 16;
1508
Cb_AC_code_length[79] <= 16;
1509
Cb_AC_code_length[80] <= 16;
1510
Cb_AC_code_length[81] <= 16;
1511
Cb_AC_code_length[82] <= 16;
1512
Cb_AC_code_length[83] <= 16;
1513
Cb_AC_code_length[84] <= 16;
1514
Cb_AC_code_length[85] <= 16;
1515
Cb_AC_code_length[86] <= 16;
1516
Cb_AC_code_length[87] <= 16;
1517
Cb_AC_code_length[88] <= 16;
1518
Cb_AC_code_length[89] <= 16;
1519
Cb_AC_code_length[90] <= 16;
1520
Cb_AC_code_length[91] <= 16;
1521
Cb_AC_code_length[92] <= 16;
1522
Cb_AC_code_length[93] <= 16;
1523
Cb_AC_code_length[94] <= 16;
1524
Cb_AC_code_length[95] <= 16;
1525
Cb_AC_code_length[96] <= 16;
1526
Cb_AC_code_length[97] <= 16;
1527
Cb_AC_code_length[98] <= 16;
1528
Cb_AC_code_length[99] <= 16;
1529
Cb_AC_code_length[100] <= 16;
1530
Cb_AC_code_length[101] <= 16;
1531
Cb_AC_code_length[102] <= 16;
1532
Cb_AC_code_length[103] <= 16;
1533
Cb_AC_code_length[104] <= 16;
1534
Cb_AC_code_length[105] <= 16;
1535
Cb_AC_code_length[106] <= 16;
1536
Cb_AC_code_length[107] <= 16;
1537
Cb_AC_code_length[108] <= 16;
1538
Cb_AC_code_length[109] <= 16;
1539
Cb_AC_code_length[110] <= 16;
1540
Cb_AC_code_length[111] <= 16;
1541
Cb_AC_code_length[112] <= 16;
1542
Cb_AC_code_length[113] <= 16;
1543
Cb_AC_code_length[114] <= 16;
1544
Cb_AC_code_length[115] <= 16;
1545
Cb_AC_code_length[116] <= 16;
1546
Cb_AC_code_length[117] <= 16;
1547
Cb_AC_code_length[118] <= 16;
1548
Cb_AC_code_length[119] <= 16;
1549
Cb_AC_code_length[120] <= 16;
1550
Cb_AC_code_length[121] <= 16;
1551
Cb_AC_code_length[122] <= 16;
1552
Cb_AC_code_length[123] <= 16;
1553
Cb_AC_code_length[124] <= 16;
1554
Cb_AC_code_length[125] <= 16;
1555
Cb_AC_code_length[126] <= 16;
1556
Cb_AC_code_length[127] <= 16;
1557
Cb_AC_code_length[128] <= 16;
1558
Cb_AC_code_length[129] <= 16;
1559
Cb_AC_code_length[130] <= 16;
1560
Cb_AC_code_length[131] <= 16;
1561
Cb_AC_code_length[132] <= 16;
1562
Cb_AC_code_length[133] <= 16;
1563
Cb_AC_code_length[134] <= 16;
1564
Cb_AC_code_length[135] <= 16;
1565
Cb_AC_code_length[136] <= 16;
1566
Cb_AC_code_length[137] <= 16;
1567
Cb_AC_code_length[138] <= 16;
1568
Cb_AC_code_length[139] <= 16;
1569
Cb_AC_code_length[140] <= 16;
1570
Cb_AC_code_length[141] <= 16;
1571
Cb_AC_code_length[142] <= 16;
1572
Cb_AC_code_length[143] <= 16;
1573
Cb_AC_code_length[144] <= 16;
1574
Cb_AC_code_length[145] <= 16;
1575
Cb_AC_code_length[146] <= 16;
1576
Cb_AC_code_length[147] <= 16;
1577
Cb_AC_code_length[148] <= 16;
1578
Cb_AC_code_length[149] <= 16;
1579
Cb_AC_code_length[150] <= 16;
1580
Cb_AC_code_length[151] <= 16;
1581
Cb_AC_code_length[152] <= 16;
1582
Cb_AC_code_length[153] <= 16;
1583
Cb_AC_code_length[154] <= 16;
1584
Cb_AC_code_length[155] <= 16;
1585
Cb_AC_code_length[156] <= 16;
1586
Cb_AC_code_length[157] <= 16;
1587
Cb_AC_code_length[158] <= 16;
1588
Cb_AC_code_length[159] <= 16;
1589
Cb_AC_code_length[160] <= 16;
1590
Cb_AC_code_length[161] <= 16;
1591
Cb_AC[0] <= 16'b0000000000000000;
1592
Cb_AC[1] <= 16'b0100000000000000;
1593
Cb_AC[2] <= 16'b1000000000000000;
1594
Cb_AC[3] <= 16'b1010000000000000;
1595
Cb_AC[4] <= 16'b1011000000000000;
1596
Cb_AC[5] <= 16'b1100000000000000;
1597
Cb_AC[6] <= 16'b1101000000000000;
1598
Cb_AC[7] <= 16'b1101100000000000;
1599
Cb_AC[8] <= 16'b1110000000000000;
1600
Cb_AC[9] <= 16'b1110100000000000;
1601
Cb_AC[10] <= 16'b1110110000000000;
1602
Cb_AC[11] <= 16'b1111000000000000;
1603
Cb_AC[12] <= 16'b1111001000000000;
1604
Cb_AC[13] <= 16'b1111010000000000;
1605
Cb_AC[14] <= 16'b1111011000000000;
1606
Cb_AC[15] <= 16'b1111100000000000;
1607
Cb_AC[16] <= 16'b1111100100000000;
1608
Cb_AC[17] <= 16'b1111101000000000;
1609
Cb_AC[18] <= 16'b1111101100000000;
1610
Cb_AC[19] <= 16'b1111101110000000;
1611
Cb_AC[20] <= 16'b1111110000000000;
1612
Cb_AC[21] <= 16'b1111110010000000;
1613
Cb_AC[22] <= 16'b1111110100000000;
1614
Cb_AC[23] <= 16'b1111110110000000;
1615
Cb_AC[24] <= 16'b1111110111000000;
1616
Cb_AC[25] <= 16'b1111111000000000;
1617
Cb_AC[26] <= 16'b1111111001000000;
1618
Cb_AC[27] <= 16'b1111111010000000;
1619
Cb_AC[28] <= 16'b1111111011000000;
1620
Cb_AC[29] <= 16'b1111111011100000;
1621
Cb_AC[30] <= 16'b1111111100000000;
1622
Cb_AC[31] <= 16'b1111111100100000;
1623
Cb_AC[32] <= 16'b1111111101000000;
1624
Cb_AC[33] <= 16'b1111111101010000;
1625
Cb_AC[34] <= 16'b1111111101100000;
1626
Cb_AC[35] <= 16'b1111111101110000;
1627
Cb_AC[36] <= 16'b1111111110000000;
1628
Cb_AC[37] <= 16'b1111111110000010;
1629
Cb_AC[38] <= 16'b1111111110000011;
1630
Cb_AC[39] <= 16'b1111111110000100;
1631
Cb_AC[40] <= 16'b1111111110000101;
1632
Cb_AC[41] <= 16'b1111111110000110;
1633
Cb_AC[42] <= 16'b1111111110000111;
1634
Cb_AC[43] <= 16'b1111111110001000;
1635
Cb_AC[44] <= 16'b1111111110001001;
1636
Cb_AC[45] <= 16'b1111111110001010;
1637
Cb_AC[46] <= 16'b1111111110001011;
1638
Cb_AC[47] <= 16'b1111111110001100;
1639
Cb_AC[48] <= 16'b1111111110001101;
1640
Cb_AC[49] <= 16'b1111111110001110;
1641
Cb_AC[50] <= 16'b1111111110001111;
1642
Cb_AC[51] <= 16'b1111111110010000;
1643
Cb_AC[52] <= 16'b1111111110010001;
1644
Cb_AC[53] <= 16'b1111111110010010;
1645
Cb_AC[54] <= 16'b1111111110010011;
1646
Cb_AC[55] <= 16'b1111111110010100;
1647
Cb_AC[56] <= 16'b1111111110010101;
1648
Cb_AC[57] <= 16'b1111111110010110;
1649
Cb_AC[58] <= 16'b1111111110010111;
1650
Cb_AC[59] <= 16'b1111111110011000;
1651
Cb_AC[60] <= 16'b1111111110011001;
1652
Cb_AC[61] <= 16'b1111111110011010;
1653
Cb_AC[62] <= 16'b1111111110011011;
1654
Cb_AC[63] <= 16'b1111111110011100;
1655
Cb_AC[64] <= 16'b1111111110011101;
1656
Cb_AC[65] <= 16'b1111111110011110;
1657
Cb_AC[66] <= 16'b1111111110011111;
1658
Cb_AC[67] <= 16'b1111111110100000;
1659
Cb_AC[68] <= 16'b1111111110100001;
1660
Cb_AC[69] <= 16'b1111111110100010;
1661
Cb_AC[70] <= 16'b1111111110100011;
1662
Cb_AC[71] <= 16'b1111111110100100;
1663
Cb_AC[72] <= 16'b1111111110100101;
1664
Cb_AC[73] <= 16'b1111111110100110;
1665
Cb_AC[74] <= 16'b1111111110100111;
1666
Cb_AC[75] <= 16'b1111111110101000;
1667
Cb_AC[76] <= 16'b1111111110101001;
1668
Cb_AC[77] <= 16'b1111111110101010;
1669
Cb_AC[78] <= 16'b1111111110101011;
1670
Cb_AC[79] <= 16'b1111111110101100;
1671
Cb_AC[80] <= 16'b1111111110101101;
1672
Cb_AC[81] <= 16'b1111111110101110;
1673
Cb_AC[82] <= 16'b1111111110101111;
1674
Cb_AC[83] <= 16'b1111111110110000;
1675
Cb_AC[84] <= 16'b1111111110110001;
1676
Cb_AC[85] <= 16'b1111111110110010;
1677
Cb_AC[86] <= 16'b1111111110110011;
1678
Cb_AC[87] <= 16'b1111111110110100;
1679
Cb_AC[88] <= 16'b1111111110110101;
1680
Cb_AC[89] <= 16'b1111111110110110;
1681
Cb_AC[90] <= 16'b1111111110110111;
1682
Cb_AC[91] <= 16'b1111111110111000;
1683
Cb_AC[92] <= 16'b1111111110111001;
1684
Cb_AC[93] <= 16'b1111111110111010;
1685
Cb_AC[94] <= 16'b1111111110111011;
1686
Cb_AC[95] <= 16'b1111111110111100;
1687
Cb_AC[96] <= 16'b1111111110111101;
1688
Cb_AC[97] <= 16'b1111111110111110;
1689
Cb_AC[98] <= 16'b1111111110111111;
1690
Cb_AC[99] <= 16'b1111111111000000;
1691
Cb_AC[100] <= 16'b1111111111000001;
1692
Cb_AC[101] <= 16'b1111111111000010;
1693
Cb_AC[102] <= 16'b1111111111000011;
1694
Cb_AC[103] <= 16'b1111111111000100;
1695
Cb_AC[104] <= 16'b1111111111000101;
1696
Cb_AC[105] <= 16'b1111111111000110;
1697
Cb_AC[106] <= 16'b1111111111000111;
1698
Cb_AC[107] <= 16'b1111111111001000;
1699
Cb_AC[108] <= 16'b1111111111001001;
1700
Cb_AC[109] <= 16'b1111111111001010;
1701
Cb_AC[110] <= 16'b1111111111001011;
1702
Cb_AC[111] <= 16'b1111111111001100;
1703
Cb_AC[112] <= 16'b1111111111001101;
1704
Cb_AC[113] <= 16'b1111111111001110;
1705
Cb_AC[114] <= 16'b1111111111001111;
1706
Cb_AC[115] <= 16'b1111111111010000;
1707
Cb_AC[116] <= 16'b1111111111010001;
1708
Cb_AC[117] <= 16'b1111111111010010;
1709
Cb_AC[118] <= 16'b1111111111010011;
1710
Cb_AC[119] <= 16'b1111111111010100;
1711
Cb_AC[120] <= 16'b1111111111010101;
1712
Cb_AC[121] <= 16'b1111111111010110;
1713
Cb_AC[122] <= 16'b1111111111010111;
1714
Cb_AC[123] <= 16'b1111111111011000;
1715
Cb_AC[124] <= 16'b1111111111011001;
1716
Cb_AC[125] <= 16'b1111111111011010;
1717
Cb_AC[126] <= 16'b1111111111011011;
1718
Cb_AC[127] <= 16'b1111111111011100;
1719
Cb_AC[128] <= 16'b1111111111011101;
1720
Cb_AC[129] <= 16'b1111111111011110;
1721
Cb_AC[130] <= 16'b1111111111011111;
1722
Cb_AC[131] <= 16'b1111111111100000;
1723
Cb_AC[132] <= 16'b1111111111100001;
1724
Cb_AC[133] <= 16'b1111111111100010;
1725
Cb_AC[134] <= 16'b1111111111100011;
1726
Cb_AC[135] <= 16'b1111111111100100;
1727
Cb_AC[136] <= 16'b1111111111100101;
1728
Cb_AC[137] <= 16'b1111111111100110;
1729
Cb_AC[138] <= 16'b1111111111100111;
1730
Cb_AC[139] <= 16'b1111111111101000;
1731
Cb_AC[140] <= 16'b1111111111101001;
1732
Cb_AC[141] <= 16'b1111111111101010;
1733
Cb_AC[142] <= 16'b1111111111101011;
1734
Cb_AC[143] <= 16'b1111111111101100;
1735
Cb_AC[144] <= 16'b1111111111101101;
1736
Cb_AC[145] <= 16'b1111111111101110;
1737
Cb_AC[146] <= 16'b1111111111101111;
1738
Cb_AC[147] <= 16'b1111111111110000;
1739
Cb_AC[148] <= 16'b1111111111110001;
1740
Cb_AC[149] <= 16'b1111111111110010;
1741
Cb_AC[150] <= 16'b1111111111110011;
1742
Cb_AC[151] <= 16'b1111111111110100;
1743
Cb_AC[152] <= 16'b1111111111110101;
1744
Cb_AC[153] <= 16'b1111111111110110;
1745
Cb_AC[154] <= 16'b1111111111110111;
1746
Cb_AC[155] <= 16'b1111111111111000;
1747
Cb_AC[156] <= 16'b1111111111111001;
1748
Cb_AC[157] <= 16'b1111111111111010;
1749
Cb_AC[158] <= 16'b1111111111111011;
1750
Cb_AC[159] <= 16'b1111111111111100;
1751
Cb_AC[160] <= 16'b1111111111111101;
1752
Cb_AC[161] <= 16'b1111111111111110;
1753
Cb_AC_run_code[1] <= 0;
1754
Cb_AC_run_code[2] <= 1;
1755
Cb_AC_run_code[3] <= 2;
1756
Cb_AC_run_code[0] <= 3;
1757
Cb_AC_run_code[4] <= 4;
1758
Cb_AC_run_code[17] <= 5;
1759
Cb_AC_run_code[5] <= 6;
1760
Cb_AC_run_code[18] <= 7;
1761
Cb_AC_run_code[33] <= 8;
1762
Cb_AC_run_code[49] <= 9;
1763
Cb_AC_run_code[65] <= 10;
1764
Cb_AC_run_code[6] <= 11;
1765
Cb_AC_run_code[19] <= 12;
1766
Cb_AC_run_code[81] <= 13;
1767
Cb_AC_run_code[97] <= 14;
1768
Cb_AC_run_code[7] <= 15;
1769
Cb_AC_run_code[34] <= 16;
1770
Cb_AC_run_code[113] <= 17;
1771
Cb_AC_run_code[20] <= 18;
1772
Cb_AC_run_code[50] <= 19;
1773
Cb_AC_run_code[129] <= 20;
1774
Cb_AC_run_code[145] <= 21;
1775
Cb_AC_run_code[161] <= 22;
1776
Cb_AC_run_code[8] <= 23;
1777
Cb_AC_run_code[35] <= 24;
1778
Cb_AC_run_code[66] <= 25;
1779
Cb_AC_run_code[177] <= 26;
1780
Cb_AC_run_code[193] <= 27;
1781
Cb_AC_run_code[21] <= 28;
1782
Cb_AC_run_code[82] <= 29;
1783
Cb_AC_run_code[209] <= 30;
1784
Cb_AC_run_code[240] <= 31;
1785
Cb_AC_run_code[36] <= 32;
1786
Cb_AC_run_code[51] <= 33;
1787
Cb_AC_run_code[98] <= 34;
1788
Cb_AC_run_code[114] <= 35;
1789
Cb_AC_run_code[130] <= 36;
1790
Cb_AC_run_code[9] <= 37;
1791
Cb_AC_run_code[10] <= 38;
1792
Cb_AC_run_code[22] <= 39;
1793
Cb_AC_run_code[23] <= 40;
1794
Cb_AC_run_code[24] <= 41;
1795
Cb_AC_run_code[25] <= 42;
1796
Cb_AC_run_code[26] <= 43;
1797
Cb_AC_run_code[37] <= 44;
1798
Cb_AC_run_code[38] <= 45;
1799
Cb_AC_run_code[39] <= 46;
1800
Cb_AC_run_code[40] <= 47;
1801
Cb_AC_run_code[41] <= 48;
1802
Cb_AC_run_code[42] <= 49;
1803
Cb_AC_run_code[52] <= 50;
1804
Cb_AC_run_code[53] <= 51;
1805
Cb_AC_run_code[54] <= 52;
1806
Cb_AC_run_code[55] <= 53;
1807
Cb_AC_run_code[56] <= 54;
1808
Cb_AC_run_code[57] <= 55;
1809
Cb_AC_run_code[58] <= 56;
1810
Cb_AC_run_code[67] <= 57;
1811
Cb_AC_run_code[68] <= 58;
1812
Cb_AC_run_code[69] <= 59;
1813
Cb_AC_run_code[70] <= 60;
1814
Cb_AC_run_code[71] <= 61;
1815
Cb_AC_run_code[72] <= 62;
1816
Cb_AC_run_code[73] <= 63;
1817
Cb_AC_run_code[74] <= 64;
1818
Cb_AC_run_code[83] <= 65;
1819
Cb_AC_run_code[84] <= 66;
1820
Cb_AC_run_code[85] <= 67;
1821
Cb_AC_run_code[86] <= 68;
1822
Cb_AC_run_code[87] <= 69;
1823
Cb_AC_run_code[88] <= 70;
1824
Cb_AC_run_code[89] <= 71;
1825
Cb_AC_run_code[90] <= 72;
1826
Cb_AC_run_code[99] <= 73;
1827
Cb_AC_run_code[100] <= 74;
1828
Cb_AC_run_code[101] <= 75;
1829
Cb_AC_run_code[102] <= 76;
1830
Cb_AC_run_code[103] <= 77;
1831
Cb_AC_run_code[104] <= 78;
1832
Cb_AC_run_code[105] <= 79;
1833
Cb_AC_run_code[106] <= 80;
1834
Cb_AC_run_code[115] <= 81;
1835
Cb_AC_run_code[116] <= 82;
1836
Cb_AC_run_code[117] <= 83;
1837
Cb_AC_run_code[118] <= 84;
1838
Cb_AC_run_code[119] <= 85;
1839
Cb_AC_run_code[120] <= 86;
1840
Cb_AC_run_code[121] <= 87;
1841
Cb_AC_run_code[122] <= 88;
1842
Cb_AC_run_code[131] <= 89;
1843
Cb_AC_run_code[132] <= 90;
1844
Cb_AC_run_code[133] <= 91;
1845
Cb_AC_run_code[134] <= 92;
1846
Cb_AC_run_code[135] <= 93;
1847
Cb_AC_run_code[136] <= 94;
1848
Cb_AC_run_code[137] <= 95;
1849
Cb_AC_run_code[138] <= 96;
1850
Cb_AC_run_code[146] <= 97;
1851
Cb_AC_run_code[147] <= 98;
1852
Cb_AC_run_code[148] <= 99;
1853
Cb_AC_run_code[149] <= 100;
1854
Cb_AC_run_code[150] <= 101;
1855
Cb_AC_run_code[151] <= 102;
1856
Cb_AC_run_code[152] <= 103;
1857
Cb_AC_run_code[153] <= 104;
1858
Cb_AC_run_code[154] <= 105;
1859
Cb_AC_run_code[162] <= 106;
1860
Cb_AC_run_code[163] <= 107;
1861
Cb_AC_run_code[164] <= 108;
1862
Cb_AC_run_code[165] <= 109;
1863
Cb_AC_run_code[166] <= 110;
1864
Cb_AC_run_code[167] <= 111;
1865
Cb_AC_run_code[168] <= 112;
1866
Cb_AC_run_code[169] <= 113;
1867
Cb_AC_run_code[170] <= 114;
1868
Cb_AC_run_code[178] <= 115;
1869
Cb_AC_run_code[179] <= 116;
1870
Cb_AC_run_code[180] <= 117;
1871
Cb_AC_run_code[181] <= 118;
1872
Cb_AC_run_code[182] <= 119;
1873
Cb_AC_run_code[183] <= 120;
1874
Cb_AC_run_code[184] <= 121;
1875
Cb_AC_run_code[185] <= 122;
1876
Cb_AC_run_code[186] <= 123;
1877
Cb_AC_run_code[194] <= 124;
1878
Cb_AC_run_code[195] <= 125;
1879
Cb_AC_run_code[196] <= 126;
1880
Cb_AC_run_code[197] <= 127;
1881
Cb_AC_run_code[198] <= 128;
1882
Cb_AC_run_code[199] <= 129;
1883
Cb_AC_run_code[200] <= 130;
1884
Cb_AC_run_code[201] <= 131;
1885
Cb_AC_run_code[202] <= 132;
1886
Cb_AC_run_code[210] <= 133;
1887
Cb_AC_run_code[211] <= 134;
1888
Cb_AC_run_code[212] <= 135;
1889
Cb_AC_run_code[213] <= 136;
1890
Cb_AC_run_code[214] <= 137;
1891
Cb_AC_run_code[215] <= 138;
1892
Cb_AC_run_code[216] <= 139;
1893
Cb_AC_run_code[217] <= 140;
1894
Cb_AC_run_code[218] <= 141;
1895
Cb_AC_run_code[225] <= 142;
1896
Cb_AC_run_code[226] <= 143;
1897
Cb_AC_run_code[227] <= 144;
1898
Cb_AC_run_code[228] <= 145;
1899
Cb_AC_run_code[229] <= 146;
1900
Cb_AC_run_code[230] <= 147;
1901
Cb_AC_run_code[231] <= 148;
1902
Cb_AC_run_code[232] <= 149;
1903
Cb_AC_run_code[233] <= 150;
1904
Cb_AC_run_code[234] <= 151;
1905
Cb_AC_run_code[241] <= 152;
1906
Cb_AC_run_code[242] <= 153;
1907
Cb_AC_run_code[243] <= 154;
1908
Cb_AC_run_code[244] <= 155;
1909
Cb_AC_run_code[245] <= 156;
1910
Cb_AC_run_code[246] <= 157;
1911
Cb_AC_run_code[247] <= 158;
1912
Cb_AC_run_code[248] <= 159;
1913
Cb_AC_run_code[249] <= 160;
1914
Cb_AC_run_code[250] <= 161;
1915
        Cb_AC_run_code[16] <= 0;
1916
        Cb_AC_run_code[32] <= 0;
1917
        Cb_AC_run_code[48] <= 0;
1918
        Cb_AC_run_code[64] <= 0;
1919
        Cb_AC_run_code[80] <= 0;
1920
        Cb_AC_run_code[96] <= 0;
1921
        Cb_AC_run_code[112] <= 0;
1922
        Cb_AC_run_code[128] <= 0;
1923
        Cb_AC_run_code[144] <= 0;
1924
        Cb_AC_run_code[160] <= 0;
1925
        Cb_AC_run_code[176] <= 0;
1926
        Cb_AC_run_code[192] <= 0;
1927
        Cb_AC_run_code[208] <= 0;
1928
        Cb_AC_run_code[224] <= 0;
1929
 
1930
end
1931
 
1932
 
1933
 
1934
always @(posedge clk)
1935
begin
1936
        if (rst)
1937
                JPEG_bitstream[31] <= 0;
1938
        else if (enable_module && rollover_7)
1939
                JPEG_bitstream[31] <= JPEG_bs_5[31];
1940
        else if (enable_module && orc_8 == 0)
1941
                JPEG_bitstream[31] <= JPEG_bs_5[31];
1942
end
1943
 
1944
always @(posedge clk)
1945
begin
1946
        if (rst)
1947
                JPEG_bitstream[30] <= 0;
1948
        else if (enable_module && rollover_7)
1949
                JPEG_bitstream[30] <= JPEG_bs_5[30];
1950
        else if (enable_module && orc_8 <= 1)
1951
                JPEG_bitstream[30] <= JPEG_bs_5[30];
1952
end
1953
 
1954
always @(posedge clk)
1955
begin
1956
        if (rst)
1957
                JPEG_bitstream[29] <= 0;
1958
        else if (enable_module && rollover_7)
1959
                JPEG_bitstream[29] <= JPEG_bs_5[29];
1960
        else if (enable_module && orc_8 <= 2)
1961
                JPEG_bitstream[29] <= JPEG_bs_5[29];
1962
end
1963
 
1964
always @(posedge clk)
1965
begin
1966
        if (rst)
1967
                JPEG_bitstream[28] <= 0;
1968
        else if (enable_module && rollover_7)
1969
                JPEG_bitstream[28] <= JPEG_bs_5[28];
1970
        else if (enable_module && orc_8 <= 3)
1971
                JPEG_bitstream[28] <= JPEG_bs_5[28];
1972
end
1973
 
1974
always @(posedge clk)
1975
begin
1976
        if (rst)
1977
                JPEG_bitstream[27] <= 0;
1978
        else if (enable_module && rollover_7)
1979
                JPEG_bitstream[27] <= JPEG_bs_5[27];
1980
        else if (enable_module && orc_8 <= 4)
1981
                JPEG_bitstream[27] <= JPEG_bs_5[27];
1982
end
1983
 
1984
always @(posedge clk)
1985
begin
1986
        if (rst)
1987
                JPEG_bitstream[26] <= 0;
1988
        else if (enable_module && rollover_7)
1989
                JPEG_bitstream[26] <= JPEG_bs_5[26];
1990
        else if (enable_module && orc_8 <= 5)
1991
                JPEG_bitstream[26] <= JPEG_bs_5[26];
1992
end
1993
 
1994
always @(posedge clk)
1995
begin
1996
        if (rst)
1997
                JPEG_bitstream[25] <= 0;
1998
        else if (enable_module && rollover_7)
1999
                JPEG_bitstream[25] <= JPEG_bs_5[25];
2000
        else if (enable_module && orc_8 <= 6)
2001
                JPEG_bitstream[25] <= JPEG_bs_5[25];
2002
end
2003
 
2004
always @(posedge clk)
2005
begin
2006
        if (rst)
2007
                JPEG_bitstream[24] <= 0;
2008
        else if (enable_module && rollover_7)
2009
                JPEG_bitstream[24] <= JPEG_bs_5[24];
2010
        else if (enable_module && orc_8 <= 7)
2011
                JPEG_bitstream[24] <= JPEG_bs_5[24];
2012
end
2013
 
2014
always @(posedge clk)
2015
begin
2016
        if (rst)
2017
                JPEG_bitstream[23] <= 0;
2018
        else if (enable_module && rollover_7)
2019
                JPEG_bitstream[23] <= JPEG_bs_5[23];
2020
        else if (enable_module && orc_8 <= 8)
2021
                JPEG_bitstream[23] <= JPEG_bs_5[23];
2022
end
2023
 
2024
always @(posedge clk)
2025
begin
2026
        if (rst)
2027
                JPEG_bitstream[22] <= 0;
2028
        else if (enable_module && rollover_7)
2029
                JPEG_bitstream[22] <= JPEG_bs_5[22];
2030
        else if (enable_module && orc_8 <= 9)
2031
                JPEG_bitstream[22] <= JPEG_bs_5[22];
2032
end
2033
 
2034
always @(posedge clk)
2035
begin
2036
        if (rst)
2037
                JPEG_bitstream[21] <= 0;
2038
        else if (enable_module && rollover_7)
2039
                JPEG_bitstream[21] <= JPEG_bs_5[21];
2040
        else if (enable_module && orc_8 <= 10)
2041
                JPEG_bitstream[21] <= JPEG_bs_5[21];
2042
end
2043
 
2044
always @(posedge clk)
2045
begin
2046
        if (rst)
2047
                JPEG_bitstream[20] <= 0;
2048
        else if (enable_module && rollover_7)
2049
                JPEG_bitstream[20] <= JPEG_bs_5[20];
2050
        else if (enable_module && orc_8 <= 11)
2051
                JPEG_bitstream[20] <= JPEG_bs_5[20];
2052
end
2053
 
2054
always @(posedge clk)
2055
begin
2056
        if (rst)
2057
                JPEG_bitstream[19] <= 0;
2058
        else if (enable_module && rollover_7)
2059
                JPEG_bitstream[19] <= JPEG_bs_5[19];
2060
        else if (enable_module && orc_8 <= 12)
2061
                JPEG_bitstream[19] <= JPEG_bs_5[19];
2062
end
2063
 
2064
always @(posedge clk)
2065
begin
2066
        if (rst)
2067
                JPEG_bitstream[18] <= 0;
2068
        else if (enable_module && rollover_7)
2069
                JPEG_bitstream[18] <= JPEG_bs_5[18];
2070
        else if (enable_module && orc_8 <= 13)
2071
                JPEG_bitstream[18] <= JPEG_bs_5[18];
2072
end
2073
 
2074
always @(posedge clk)
2075
begin
2076
        if (rst)
2077
                JPEG_bitstream[17] <= 0;
2078
        else if (enable_module && rollover_7)
2079
                JPEG_bitstream[17] <= JPEG_bs_5[17];
2080
        else if (enable_module && orc_8 <= 14)
2081
                JPEG_bitstream[17] <= JPEG_bs_5[17];
2082
end
2083
 
2084
always @(posedge clk)
2085
begin
2086
        if (rst)
2087
                JPEG_bitstream[16] <= 0;
2088
        else if (enable_module && rollover_7)
2089
                JPEG_bitstream[16] <= JPEG_bs_5[16];
2090
        else if (enable_module && orc_8 <= 15)
2091
                JPEG_bitstream[16] <= JPEG_bs_5[16];
2092
end
2093
 
2094
always @(posedge clk)
2095
begin
2096
        if (rst)
2097
                JPEG_bitstream[15] <= 0;
2098
        else if (enable_module && rollover_7)
2099
                JPEG_bitstream[15] <= JPEG_bs_5[15];
2100
        else if (enable_module && orc_8 <= 16)
2101
                JPEG_bitstream[15] <= JPEG_bs_5[15];
2102
end
2103
 
2104
always @(posedge clk)
2105
begin
2106
        if (rst)
2107
                JPEG_bitstream[14] <= 0;
2108
        else if (enable_module && rollover_7)
2109
                JPEG_bitstream[14] <= JPEG_bs_5[14];
2110
        else if (enable_module && orc_8 <= 17)
2111
                JPEG_bitstream[14] <= JPEG_bs_5[14];
2112
end
2113
 
2114
always @(posedge clk)
2115
begin
2116
        if (rst)
2117
                JPEG_bitstream[13] <= 0;
2118
        else if (enable_module && rollover_7)
2119
                JPEG_bitstream[13] <= JPEG_bs_5[13];
2120
        else if (enable_module && orc_8 <= 18)
2121
                JPEG_bitstream[13] <= JPEG_bs_5[13];
2122
end
2123
 
2124
always @(posedge clk)
2125
begin
2126
        if (rst)
2127
                JPEG_bitstream[12] <= 0;
2128
        else if (enable_module && rollover_7)
2129
                JPEG_bitstream[12] <= JPEG_bs_5[12];
2130
        else if (enable_module && orc_8 <= 19)
2131
                JPEG_bitstream[12] <= JPEG_bs_5[12];
2132
end
2133
 
2134
always @(posedge clk)
2135
begin
2136
        if (rst)
2137
                JPEG_bitstream[11] <= 0;
2138
        else if (enable_module && rollover_7)
2139
                JPEG_bitstream[11] <= JPEG_bs_5[11];
2140
        else if (enable_module && orc_8 <= 20)
2141
                JPEG_bitstream[11] <= JPEG_bs_5[11];
2142
end
2143
 
2144
always @(posedge clk)
2145
begin
2146
        if (rst)
2147
                JPEG_bitstream[10] <= 0;
2148
        else if (enable_module && rollover_7)
2149
                JPEG_bitstream[10] <= JPEG_bs_5[10];
2150
        else if (enable_module && orc_8 <= 21)
2151
                JPEG_bitstream[10] <= JPEG_bs_5[10];
2152
end
2153
 
2154
always @(posedge clk)
2155
begin
2156
        if (rst)
2157
                JPEG_bitstream[9] <= 0;
2158
        else if (enable_module && rollover_7)
2159
                JPEG_bitstream[9] <= JPEG_bs_5[9];
2160
        else if (enable_module && orc_8 <= 22)
2161
                JPEG_bitstream[9] <= JPEG_bs_5[9];
2162
end
2163
 
2164
always @(posedge clk)
2165
begin
2166
        if (rst)
2167
                JPEG_bitstream[8] <= 0;
2168
        else if (enable_module && rollover_7)
2169
                JPEG_bitstream[8] <= JPEG_bs_5[8];
2170
        else if (enable_module && orc_8 <= 23)
2171
                JPEG_bitstream[8] <= JPEG_bs_5[8];
2172
end
2173
 
2174
always @(posedge clk)
2175
begin
2176
        if (rst)
2177
                JPEG_bitstream[7] <= 0;
2178
        else if (enable_module && rollover_7)
2179
                JPEG_bitstream[7] <= JPEG_bs_5[7];
2180
        else if (enable_module && orc_8 <= 24)
2181
                JPEG_bitstream[7] <= JPEG_bs_5[7];
2182
end
2183
 
2184
always @(posedge clk)
2185
begin
2186
        if (rst)
2187
                JPEG_bitstream[6] <= 0;
2188
        else if (enable_module && rollover_7)
2189
                JPEG_bitstream[6] <= JPEG_bs_5[6];
2190
        else if (enable_module && orc_8 <= 25)
2191
                JPEG_bitstream[6] <= JPEG_bs_5[6];
2192
end
2193
 
2194
always @(posedge clk)
2195
begin
2196
        if (rst)
2197
                JPEG_bitstream[5] <= 0;
2198
        else if (enable_module && rollover_7)
2199
                JPEG_bitstream[5] <= JPEG_bs_5[5];
2200
        else if (enable_module && orc_8 <= 26)
2201
                JPEG_bitstream[5] <= JPEG_bs_5[5];
2202
end
2203
 
2204
always @(posedge clk)
2205
begin
2206
        if (rst)
2207
                JPEG_bitstream[4] <= 0;
2208
        else if (enable_module && rollover_7)
2209
                JPEG_bitstream[4] <= JPEG_bs_5[4];
2210
        else if (enable_module && orc_8 <= 27)
2211
                JPEG_bitstream[4] <= JPEG_bs_5[4];
2212
end
2213
 
2214
always @(posedge clk)
2215
begin
2216
        if (rst)
2217
                JPEG_bitstream[3] <= 0;
2218
        else if (enable_module && rollover_7)
2219
                JPEG_bitstream[3] <= JPEG_bs_5[3];
2220
        else if (enable_module && orc_8 <= 28)
2221
                JPEG_bitstream[3] <= JPEG_bs_5[3];
2222
end
2223
 
2224
always @(posedge clk)
2225
begin
2226
        if (rst)
2227
                JPEG_bitstream[2] <= 0;
2228
        else if (enable_module && rollover_7)
2229
                JPEG_bitstream[2] <= JPEG_bs_5[2];
2230
        else if (enable_module && orc_8 <= 29)
2231
                JPEG_bitstream[2] <= JPEG_bs_5[2];
2232
end
2233
 
2234
always @(posedge clk)
2235
begin
2236
        if (rst)
2237
                JPEG_bitstream[1] <= 0;
2238
        else if (enable_module && rollover_7)
2239
                JPEG_bitstream[1] <= JPEG_bs_5[1];
2240
        else if (enable_module && orc_8 <= 30)
2241
                JPEG_bitstream[1] <= JPEG_bs_5[1];
2242
end
2243
 
2244
always @(posedge clk)
2245
begin
2246
        if (rst)
2247
                JPEG_bitstream[0] <= 0;
2248
        else if (enable_module && rollover_7)
2249
                JPEG_bitstream[0] <= JPEG_bs_5[0];
2250
        else if (enable_module && orc_8 <= 31)
2251
                JPEG_bitstream[0] <= JPEG_bs_5[0];
2252
end
2253
endmodule

powered by: WebSVN 2.1.0

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