OpenCores
URL https://opencores.org/ocsvn/hdl-deflate/hdl-deflate/trunk

Subversion Repositories hdl-deflate

[/] [hdl-deflate/] [trunk/] [deflate.v] - Diff between revs 2 and 5

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 2 Rev 5
Line 1... Line 1...
// File: deflate.v
// File: deflate.v
// Generated by MyHDL 0.10
// Generated by MyHDL 0.10
// Date: Thu Dec 20 18:23:02 2018
// Date: Sun Dec 23 19:31:53 2018
 
 
 
 
`timescale 1ns/10ps
`timescale 1ns/10ps
 
 
module deflate (
module deflate (
Line 41... Line 41...
reg [8:0] spread_i;
reg [8:0] spread_i;
reg [9:0] spread;
reg [9:0] spread;
reg [9:0] reverse;
reg [9:0] reverse;
reg [7:0] orbyte;
reg [7:0] orbyte;
reg [12:0] oraddr;
reg [12:0] oraddr;
 
reg [12:0] old_di;
reg [12:0] offset;
reg [12:0] offset;
reg [7:0] obyte;
reg [7:0] obyte;
reg [7:0] ob1;
reg [7:0] ob1;
reg [12:0] oaddr;
reg [12:0] oaddr;
reg [8:0] numLiterals;
reg [8:0] numLiterals;
Line 79... Line 80...
reg cur_next;
reg cur_next;
reg [12:0] cur_i;
reg [12:0] cur_i;
reg signed [7:0] cur_dist;
reg signed [7:0] cur_dist;
reg [12:0] cur_cstatic;
reg [12:0] cur_cstatic;
reg [9:0] cur_HF1;
reg [9:0] cur_HF1;
 
reg [7:0] copy2;
reg [7:0] copy1;
reg [7:0] copy1;
reg [14:0] code;
reg [14:0] code;
reg [3:0] bits;
reg [3:0] bits;
reg [8:0] b_numCodeLength;
reg [8:0] b_numCodeLength;
 
reg [7:0] b9;
 
reg [7:0] b8;
 
reg [7:0] b7;
 
reg [7:0] b6;
 
reg [7:0] b5;
wire [31:0] b41;
wire [31:0] b41;
reg [7:0] b4;
reg [7:0] b4;
reg [7:0] b3;
reg [7:0] b3;
reg [7:0] b2;
reg [7:0] b2;
 
wire [31:0] b14;
 
wire [79:0] b110;
 
reg [7:0] b10;
reg [7:0] b1;
reg [7:0] b1;
reg [15:0] adler2;
reg [15:0] adler2;
reg [15:0] adler1;
reg [15:0] adler1;
 
reg [255:0] cwindow;
reg [7:0] oram [0:8192-1];
reg [7:0] oram [0:8192-1];
reg [9:0] nextCode [0:15-1];
reg [9:0] nextCode [0:15-1];
reg [18:0] leaves [0:512-1];
reg [18:0] leaves [0:512-1];
reg [7:0] iram [0:128-1];
reg [7:0] iram [0:128-1];
reg [3:0] distanceLength [0:32-1];
reg [3:0] distanceLength [0:32-1];
reg [18:0] d_leaves [0:128-1];
reg [18:0] d_leaves [0:128-1];
reg [8:0] code_bits [0:288-1];
reg [8:0] code_bits [0:288-1];
reg [3:0] codeLength [0:290-1];
reg [3:0] codeLength [0:290-1];
reg [8:0] bitLengthCount [0:16-1];
reg [8:0] bitLengthCount [0:16-1];
 
wire smatch [0:32-1];
 
 
assign b41[32-1:24] = b4;
assign b41[32-1:24] = b4;
assign b41[24-1:16] = b3;
assign b41[24-1:16] = b3;
assign b41[16-1:8] = b2;
assign b41[16-1:8] = b2;
assign b41[8-1:0] = b1;
assign b41[8-1:0] = b1;
 
assign b14[32-1:24] = b1;
 
assign b14[24-1:16] = b2;
 
assign b14[16-1:8] = b3;
 
assign b14[8-1:0] = b4;
 
assign b110[80-1:72] = b1;
 
assign b110[72-1:64] = b2;
 
assign b110[64-1:56] = b3;
 
assign b110[56-1:48] = b4;
 
assign b110[48-1:40] = b5;
 
assign b110[40-1:32] = b6;
 
assign b110[32-1:24] = b7;
 
assign b110[24-1:16] = b8;
 
assign b110[16-1:8] = b9;
 
assign b110[8-1:0] = b10;
 
 
task MYHDL3_adv;
task MYHDL3_adv;
    input width;
    input width;
    integer width;
    integer width;
    integer nshift;
    integer nshift;
begin: MYHDL77_RETURN
begin: MYHDL113_RETURN
    nshift = ((dio + width) >>> 3);
    nshift = ((dio + width) >>> 3);
    o_iprogress <= di;
    o_iprogress <= di;
    dio <= ((dio + width) & 7);
    dio <= ((dio + width) & 7);
    di <= ($signed({1'b0, di}) + nshift);
    di <= ($signed({1'b0, di}) + nshift);
    if ((nshift != 0)) begin
    if ((nshift != 0)) begin
Line 123... Line 149...
endtask
endtask
 
 
function integer MYHDL4_get4;
function integer MYHDL4_get4;
    input boffset;
    input boffset;
    input width;
    input width;
begin: MYHDL78_RETURN
begin: MYHDL114_RETURN
    if ((nb != 4)) begin
    if ((nb != 4)) begin
        $write("----NB----");
        $write("----NB----");
        $write("\n");
        $write("\n");
        $finish;
        $finish;
    end
    end
    MYHDL4_get4 = ((b41 >>> (dio + boffset)) & ((1 << width) - 1));
    MYHDL4_get4 = ((b41 >>> (dio + boffset)) & ((1 << width) - 1));
    disable MYHDL78_RETURN;
    disable MYHDL114_RETURN;
end
end
endfunction
endfunction
 
 
function integer MYHDL5_get4;
function integer MYHDL5_get4;
    input boffset;
    input boffset;
    input width;
    input width;
    integer width;
    integer width;
begin: MYHDL79_RETURN
begin: MYHDL115_RETURN
    if ((nb != 4)) begin
    if ((nb != 4)) begin
        $write("----NB----");
        $write("----NB----");
        $write("\n");
        $write("\n");
        $finish;
        $finish;
    end
    end
    MYHDL5_get4 = ((b41 >>> (dio + boffset)) & ((1 << width) - 1));
    MYHDL5_get4 = ((b41 >>> (dio + boffset)) & ((1 << width) - 1));
    disable MYHDL79_RETURN;
    disable MYHDL115_RETURN;
end
end
endfunction
endfunction
 
 
task MYHDL6_adv;
task MYHDL6_adv;
    input width;
    input width;
    integer width;
    integer width;
    integer nshift;
    integer nshift;
begin: MYHDL80_RETURN
begin: MYHDL116_RETURN
    nshift = ((dio + width) >>> 3);
    nshift = ((dio + width) >>> 3);
    o_iprogress <= di;
    o_iprogress <= di;
    dio <= ((dio + width) & 7);
    dio <= ((dio + width) & 7);
    di <= ($signed({1'b0, di}) + nshift);
    di <= ($signed({1'b0, di}) + nshift);
    if ((nshift != 0)) begin
    if ((nshift != 0)) begin
Line 168... Line 194...
 
 
task MYHDL7_adv;
task MYHDL7_adv;
    input width;
    input width;
    integer width;
    integer width;
    integer nshift;
    integer nshift;
begin: MYHDL81_RETURN
begin: MYHDL117_RETURN
    nshift = ((dio + width) >>> 3);
    nshift = ((dio + width) >>> 3);
    o_iprogress <= di;
    o_iprogress <= di;
    dio <= ((dio + width) & 7);
    dio <= ((dio + width) & 7);
    di <= ($signed({1'b0, di}) + nshift);
    di <= ($signed({1'b0, di}) + nshift);
    if ((nshift != 0)) begin
    if ((nshift != 0)) begin
Line 184... Line 210...
function integer MYHDL8_get4;
function integer MYHDL8_get4;
    input boffset;
    input boffset;
    integer boffset;
    integer boffset;
    input width;
    input width;
    integer width;
    integer width;
begin: MYHDL82_RETURN
begin: MYHDL118_RETURN
    if ((nb != 4)) begin
    if ((nb != 4)) begin
        $write("----NB----");
        $write("----NB----");
        $write("\n");
        $write("\n");
        $finish;
        $finish;
    end
    end
    MYHDL8_get4 = ($signed($signed({1'b0, b41}) >>> ($signed({1'b0, dio}) + boffset)) & ((1 << width) - 1));
    MYHDL8_get4 = ($signed($signed({1'b0, b41}) >>> ($signed({1'b0, dio}) + boffset)) & ((1 << width) - 1));
    disable MYHDL82_RETURN;
    disable MYHDL118_RETURN;
end
end
endfunction
endfunction
 
 
task MYHDL9_adv;
task MYHDL9_adv;
    input width;
    input width;
    integer width;
    integer width;
    integer nshift;
    integer nshift;
begin: MYHDL83_RETURN
begin: MYHDL119_RETURN
    nshift = $signed(($signed({1'b0, dio}) + width) >>> 3);
    nshift = $signed(($signed({1'b0, dio}) + width) >>> 3);
    o_iprogress <= di;
    o_iprogress <= di;
    dio <= (($signed({1'b0, dio}) + width) & 7);
    dio <= (($signed({1'b0, dio}) + width) & 7);
    di <= ($signed({1'b0, di}) + nshift);
    di <= ($signed({1'b0, di}) + nshift);
    if ((nshift != 0)) begin
    if ((nshift != 0)) begin
Line 215... Line 241...
function integer MYHDL10_put;
function integer MYHDL10_put;
    input d;
    input d;
    integer d;
    integer d;
    input width;
    input width;
    integer width;
    integer width;
begin: MYHDL84_RETURN
begin: MYHDL120_RETURN
    if ((width > 9)) begin
    if ((width > 9)) begin
        $finish;
        $finish;
    end
    end
    if (($signed({1'b0, d}) > ((1 << width) - 1))) begin
    if (($signed({1'b0, d}) > ((1 << width) - 1))) begin
        $finish;
        $finish;
    end
    end
    MYHDL10_put = ((ob1 | (d << doo)) & 255);
    MYHDL10_put = ((ob1 | (d << doo)) & 255);
    disable MYHDL84_RETURN;
    disable MYHDL120_RETURN;
end
end
endfunction
endfunction
 
 
task MYHDL11_put_adv;
task MYHDL11_put_adv;
    input d;
    input d;
Line 235... Line 261...
    input width;
    input width;
    integer width;
    integer width;
    reg pshift;
    reg pshift;
    integer carry;
    integer carry;
    integer doo_next;
    integer doo_next;
begin: MYHDL85_RETURN
begin: MYHDL121_RETURN
    if ((width > 9)) begin
    if ((width > 9)) begin
        $finish;
        $finish;
    end
    end
    if (($signed({1'b0, d}) > ((1 << width) - 1))) begin
    if (($signed({1'b0, d}) > ((1 << width) - 1))) begin
        $finish;
        $finish;
Line 261... Line 287...
    doo <= doo_next;
    doo <= doo_next;
end
end
endtask
endtask
 
 
task MYHDL12_do_flush;
task MYHDL12_do_flush;
begin: MYHDL86_RETURN
begin: MYHDL122_RETURN
    flush <= 1'b0;
    flush <= 1'b0;
    ob1 <= 0;
    ob1 <= 0;
    o_oprogress <= (do + 1);
    o_oprogress <= (do + 1);
    do <= (do + 1);
    do <= (do + 1);
end
end
endtask
endtask
 
 
function integer MYHDL13_put;
function integer MYHDL13_put;
    input [9-1:0] d;
    input [9-1:0] d;
    input [4-1:0] width;
    input [4-1:0] width;
begin: MYHDL87_RETURN
begin: MYHDL123_RETURN
    if ((width > 9)) begin
    if ((width > 9)) begin
        $finish;
        $finish;
    end
    end
    if (($signed({1'b0, d}) > ((1 << width) - 1))) begin
    if (($signed({1'b0, d}) > ((1 << width) - 1))) begin
        $finish;
        $finish;
    end
    end
    MYHDL13_put = ((ob1 | (d << doo)) & 255);
    MYHDL13_put = ((ob1 | (d << doo)) & 255);
    disable MYHDL87_RETURN;
    disable MYHDL123_RETURN;
end
end
endfunction
endfunction
 
 
task MYHDL14_put_adv;
task MYHDL14_put_adv;
    input [9-1:0] d;
    input [9-1:0] d;
    input [4-1:0] width;
    input [4-1:0] width;
    reg pshift;
    reg pshift;
    integer carry;
    integer carry;
    integer doo_next;
    integer doo_next;
begin: MYHDL88_RETURN
begin: MYHDL124_RETURN
    if ((width > 9)) begin
    if ((width > 9)) begin
        $finish;
        $finish;
    end
    end
    if (($signed({1'b0, d}) > ((1 << width) - 1))) begin
    if (($signed({1'b0, d}) > ((1 << width) - 1))) begin
        $finish;
        $finish;
Line 316... Line 342...
    doo <= doo_next;
    doo <= doo_next;
end
end
endtask
endtask
 
 
task MYHDL15_do_flush;
task MYHDL15_do_flush;
begin: MYHDL89_RETURN
begin: MYHDL125_RETURN
    flush <= 1'b0;
    flush <= 1'b0;
    ob1 <= 0;
    ob1 <= 0;
    o_oprogress <= (do + 1);
    o_oprogress <= (do + 1);
    do <= (do + 1);
    do <= (do + 1);
end
end
Line 329... Line 355...
function integer MYHDL16_rev_bits;
function integer MYHDL16_rev_bits;
    input [13-1:0] b;
    input [13-1:0] b;
    input nb;
    input nb;
    integer nb;
    integer nb;
    integer r;
    integer r;
begin: MYHDL90_RETURN
begin: MYHDL126_RETURN
    if ((b >= (1 << nb))) begin
    if ((b >= (1 << nb))) begin
        $finish;
        $finish;
        $write("too few bits");
        $write("too few bits");
        $write("\n");
        $write("\n");
    end
    end
    r = (((((((((((((((((b >>> 14) & 1) << 0) | (((b >>> 13) & 1) << 1)) | (((b >>> 12) & 1) << 2)) | (((b >>> 11) & 1) << 3)) | (((b >>> 10) & 1) << 4)) | (((b >>> 9) & 1) << 5)) | (((b >>> 8) & 1) << 6)) | (((b >>> 7) & 1) << 7)) | (((b >>> 6) & 1) << 8)) | (((b >>> 5) & 1) << 9)) | (((b >>> 4) & 1) << 10)) | (((b >>> 3) & 1) << 11)) | (((b >>> 2) & 1) << 12)) | (((b >>> 1) & 1) << 13)) | (((b >>> 0) & 1) << 14));
    r = (((((((((((((((((b >>> 14) & 1) << 0) | (((b >>> 13) & 1) << 1)) | (((b >>> 12) & 1) << 2)) | (((b >>> 11) & 1) << 3)) | (((b >>> 10) & 1) << 4)) | (((b >>> 9) & 1) << 5)) | (((b >>> 8) & 1) << 6)) | (((b >>> 7) & 1) << 7)) | (((b >>> 6) & 1) << 8)) | (((b >>> 5) & 1) << 9)) | (((b >>> 4) & 1) << 10)) | (((b >>> 3) & 1) << 11)) | (((b >>> 2) & 1) << 12)) | (((b >>> 1) & 1) << 13)) | (((b >>> 0) & 1) << 14));
    r = r >>> (15 - $signed({1'b0, nb}));
    r = r >>> (15 - $signed({1'b0, nb}));
    MYHDL16_rev_bits = r;
    MYHDL16_rev_bits = r;
    disable MYHDL90_RETURN;
    disable MYHDL126_RETURN;
end
end
endfunction
endfunction
 
 
function integer MYHDL17_put;
function integer MYHDL17_put;
    input d;
    input d;
    integer d;
    integer d;
    input width;
    input width;
    integer width;
    integer width;
begin: MYHDL91_RETURN
begin: MYHDL127_RETURN
    if ((width > 9)) begin
    if ((width > 9)) begin
        $finish;
        $finish;
    end
    end
    if ((d > ((1 << width) - 1))) begin
    if ((d > ((1 << width) - 1))) begin
        $finish;
        $finish;
    end
    end
    MYHDL17_put = (($signed({1'b0, ob1}) | (d << $signed({1'b0, doo}))) & 255);
    MYHDL17_put = (($signed({1'b0, ob1}) | (d << $signed({1'b0, doo}))) & 255);
    disable MYHDL91_RETURN;
    disable MYHDL127_RETURN;
end
end
endfunction
endfunction
 
 
task MYHDL18_put_adv;
task MYHDL18_put_adv;
    input d;
    input d;
Line 367... Line 393...
    input width;
    input width;
    integer width;
    integer width;
    reg pshift;
    reg pshift;
    integer carry;
    integer carry;
    integer doo_next;
    integer doo_next;
begin: MYHDL92_RETURN
begin: MYHDL128_RETURN
    if ((width > 9)) begin
    if ((width > 9)) begin
        $finish;
        $finish;
    end
    end
    if ((d > ((1 << width) - 1))) begin
    if ((d > ((1 << width) - 1))) begin
        $finish;
        $finish;
Line 392... Line 418...
    end
    end
    doo <= doo_next;
    doo <= doo_next;
end
end
endtask
endtask
 
 
function integer MYHDL19_put;
function integer MYHDL21_put;
    input [9-1:0] d;
    input [9-1:0] d;
    input [4-1:0] width;
    input [4-1:0] width;
begin: MYHDL93_RETURN
begin: MYHDL129_RETURN
    if ((width > 9)) begin
    if ((width > 9)) begin
        $finish;
        $finish;
    end
    end
    if (($signed({1'b0, d}) > ((1 << width) - 1))) begin
    if (($signed({1'b0, d}) > ((1 << width) - 1))) begin
        $finish;
        $finish;
    end
    end
    MYHDL19_put = ((ob1 | (d << doo)) & 255);
    MYHDL21_put = ((ob1 | (d << doo)) & 255);
    disable MYHDL93_RETURN;
    disable MYHDL129_RETURN;
end
end
endfunction
endfunction
 
 
task MYHDL20_put_adv;
task MYHDL22_put_adv;
    input [9-1:0] d;
    input [9-1:0] d;
    input [4-1:0] width;
    input [4-1:0] width;
    reg pshift;
    reg pshift;
    integer carry;
    integer carry;
    integer doo_next;
    integer doo_next;
begin: MYHDL94_RETURN
begin: MYHDL130_RETURN
    if ((width > 9)) begin
    if ((width > 9)) begin
        $finish;
        $finish;
    end
    end
    if (($signed({1'b0, d}) > ((1 << width) - 1))) begin
    if (($signed({1'b0, d}) > ((1 << width) - 1))) begin
        $finish;
        $finish;
Line 438... Line 464...
    end
    end
    doo <= doo_next;
    doo <= doo_next;
end
end
endtask
endtask
 
 
function integer MYHDL21_put;
function integer MYHDL23_put;
    input [9-1:0] d;
    input [9-1:0] d;
    input [4-1:0] width;
    input [4-1:0] width;
begin: MYHDL95_RETURN
begin: MYHDL131_RETURN
    if ((width > 9)) begin
    if ((width > 9)) begin
        $finish;
        $finish;
    end
    end
    if (($signed({1'b0, d}) > ((1 << width) - 1))) begin
    if (($signed({1'b0, d}) > ((1 << width) - 1))) begin
        $finish;
        $finish;
    end
    end
    MYHDL21_put = ((ob1 | (d << doo)) & 255);
    MYHDL23_put = ((ob1 | (d << doo)) & 255);
    disable MYHDL95_RETURN;
    disable MYHDL131_RETURN;
end
end
endfunction
endfunction
 
 
task MYHDL22_put_adv;
task MYHDL24_put_adv;
    input [9-1:0] d;
    input [9-1:0] d;
    input [4-1:0] width;
    input [4-1:0] width;
    reg pshift;
    reg pshift;
    integer carry;
    integer carry;
    integer doo_next;
    integer doo_next;
begin: MYHDL96_RETURN
begin: MYHDL132_RETURN
    if ((width > 9)) begin
    if ((width > 9)) begin
        $finish;
        $finish;
    end
    end
    if (($signed({1'b0, d}) > ((1 << width) - 1))) begin
    if (($signed({1'b0, d}) > ((1 << width) - 1))) begin
        $finish;
        $finish;
Line 484... Line 510...
    end
    end
    doo <= doo_next;
    doo <= doo_next;
end
end
endtask
endtask
 
 
function integer MYHDL31_get4;
function integer MYHDL25_put;
 
    input [9-1:0] d;
 
    input [4-1:0] width;
 
begin: MYHDL133_RETURN
 
    if ((width > 9)) begin
 
        $finish;
 
    end
 
    if (($signed({1'b0, d}) > ((1 << width) - 1))) begin
 
        $finish;
 
    end
 
    MYHDL25_put = ((ob1 | (d << doo)) & 255);
 
    disable MYHDL133_RETURN;
 
end
 
endfunction
 
 
 
task MYHDL26_put_adv;
 
    input [9-1:0] d;
 
    input [4-1:0] width;
 
    reg pshift;
 
    integer carry;
 
    integer doo_next;
 
begin: MYHDL134_RETURN
 
    if ((width > 9)) begin
 
        $finish;
 
    end
 
    if (($signed({1'b0, d}) > ((1 << width) - 1))) begin
 
        $finish;
 
    end
 
    pshift = ((doo + width) > 8);
 
    if (pshift) begin
 
        carry = ($signed({1'b0, width}) - (8 - $signed({1'b0, doo})));
 
        ob1 <= $signed($signed({1'b0, d}) >>> ($signed({1'b0, width}) - carry));
 
    end
 
    else begin
 
        ob1 <= (ob1 | (d << doo));
 
    end
 
    do <= (do + pshift);
 
    o_oprogress <= (do + pshift);
 
    doo_next = ((doo + width) & 7);
 
    if ((doo_next == 0)) begin
 
        flush <= 1'b1;
 
    end
 
    doo <= doo_next;
 
end
 
endtask
 
 
 
function integer MYHDL35_get4;
    input boffset;
    input boffset;
    input width;
    input width;
    integer width;
    integer width;
begin: MYHDL97_RETURN
begin: MYHDL135_RETURN
    if ((nb != 4)) begin
    if ((nb != 4)) begin
        $write("----NB----");
        $write("----NB----");
        $write("\n");
        $write("\n");
        $finish;
        $finish;
    end
    end
    MYHDL31_get4 = ((b41 >>> (dio + boffset)) & ((1 << width) - 1));
    MYHDL35_get4 = ((b41 >>> (dio + boffset)) & ((1 << width) - 1));
    disable MYHDL97_RETURN;
    disable MYHDL135_RETURN;
end
end
endfunction
endfunction
 
 
function integer MYHDL32_get4;
function integer MYHDL36_get4;
    input boffset;
    input boffset;
    input width;
    input width;
    integer width;
    integer width;
begin: MYHDL98_RETURN
begin: MYHDL136_RETURN
    if ((nb != 4)) begin
    if ((nb != 4)) begin
        $write("----NB----");
        $write("----NB----");
        $write("\n");
        $write("\n");
        $finish;
        $finish;
    end
    end
    MYHDL32_get4 = ((b41 >>> (dio + boffset)) & ((1 << width) - 1));
    MYHDL36_get4 = ((b41 >>> (dio + boffset)) & ((1 << width) - 1));
    disable MYHDL98_RETURN;
    disable MYHDL136_RETURN;
end
end
endfunction
endfunction
 
 
function integer MYHDL33_get4;
function integer MYHDL37_get4;
    input boffset;
    input boffset;
    integer boffset;
    integer boffset;
    input width;
    input width;
    integer width;
    integer width;
begin: MYHDL99_RETURN
begin: MYHDL137_RETURN
    if ((nb != 4)) begin
    if ((nb != 4)) begin
        $write("----NB----");
        $write("----NB----");
        $write("\n");
        $write("\n");
        $finish;
        $finish;
    end
    end
    MYHDL33_get4 = ((b41 >>> (dio + boffset)) & ((1 << width) - 1));
    MYHDL37_get4 = ((b41 >>> (dio + boffset)) & ((1 << width) - 1));
    disable MYHDL99_RETURN;
    disable MYHDL137_RETURN;
end
end
endfunction
endfunction
 
 
function integer MYHDL34_get4;
function integer MYHDL38_get4;
    input boffset;
    input boffset;
    integer boffset;
    integer boffset;
    input width;
    input width;
    integer width;
    integer width;
begin: MYHDL100_RETURN
begin: MYHDL138_RETURN
    if ((nb != 4)) begin
    if ((nb != 4)) begin
        $write("----NB----");
        $write("----NB----");
        $write("\n");
        $write("\n");
        $finish;
        $finish;
    end
    end
    MYHDL34_get4 = ((b41 >>> (dio + boffset)) & ((1 << width) - 1));
    MYHDL38_get4 = ((b41 >>> (dio + boffset)) & ((1 << width) - 1));
    disable MYHDL100_RETURN;
    disable MYHDL138_RETURN;
end
end
endfunction
endfunction
 
 
function integer MYHDL35_get4;
function integer MYHDL39_get4;
    input boffset;
    input boffset;
    integer boffset;
    integer boffset;
    input width;
    input width;
    integer width;
    integer width;
begin: MYHDL101_RETURN
begin: MYHDL139_RETURN
    if ((nb != 4)) begin
    if ((nb != 4)) begin
        $write("----NB----");
        $write("----NB----");
        $write("\n");
        $write("\n");
        $finish;
        $finish;
    end
    end
    MYHDL35_get4 = ((b41 >>> (dio + boffset)) & ((1 << width) - 1));
    MYHDL39_get4 = ((b41 >>> (dio + boffset)) & ((1 << width) - 1));
    disable MYHDL101_RETURN;
    disable MYHDL139_RETURN;
end
end
endfunction
endfunction
 
 
function integer MYHDL36_get4;
function integer MYHDL40_get4;
    input boffset;
    input boffset;
    integer boffset;
    integer boffset;
    input width;
    input width;
    integer width;
    integer width;
begin: MYHDL102_RETURN
begin: MYHDL140_RETURN
    if ((nb != 4)) begin
    if ((nb != 4)) begin
        $write("----NB----");
        $write("----NB----");
        $write("\n");
        $write("\n");
        $finish;
        $finish;
    end
    end
    MYHDL36_get4 = ((b41 >>> (dio + boffset)) & ((1 << width) - 1));
    MYHDL40_get4 = ((b41 >>> (dio + boffset)) & ((1 << width) - 1));
    disable MYHDL102_RETURN;
    disable MYHDL140_RETURN;
end
end
endfunction
endfunction
 
 
task MYHDL37_adv;
task MYHDL41_adv;
    input width;
    input width;
    integer width;
    integer width;
    integer nshift;
    integer nshift;
begin: MYHDL103_RETURN
begin: MYHDL141_RETURN
    nshift = ((dio + width) >>> 3);
    nshift = ((dio + width) >>> 3);
    o_iprogress <= di;
    o_iprogress <= di;
    dio <= ((dio + width) & 7);
    dio <= ((dio + width) & 7);
    di <= ($signed({1'b0, di}) + nshift);
    di <= ($signed({1'b0, di}) + nshift);
    if ((nshift != 0)) begin
    if ((nshift != 0)) begin
        filled <= 1'b0;
        filled <= 1'b0;
    end
    end
end
end
endtask
endtask
 
 
function integer MYHDL38_get4;
function integer MYHDL42_get4;
    input boffset;
    input boffset;
    input width;
    input width;
    integer width;
    integer width;
begin: MYHDL104_RETURN
begin: MYHDL142_RETURN
    if ((nb != 4)) begin
    if ((nb != 4)) begin
        $write("----NB----");
        $write("----NB----");
        $write("\n");
        $write("\n");
        $finish;
        $finish;
    end
    end
    MYHDL38_get4 = ((b41 >>> (dio + boffset)) & ((1 << width) - 1));
    MYHDL42_get4 = ((b41 >>> (dio + boffset)) & ((1 << width) - 1));
    disable MYHDL104_RETURN;
    disable MYHDL142_RETURN;
end
end
endfunction
endfunction
 
 
task MYHDL39_adv;
task MYHDL43_adv;
    input width;
    input width;
    integer width;
    integer width;
    integer nshift;
    integer nshift;
begin: MYHDL105_RETURN
begin: MYHDL143_RETURN
    nshift = ((dio + width) >>> 3);
    nshift = ((dio + width) >>> 3);
    o_iprogress <= di;
    o_iprogress <= di;
    dio <= ((dio + width) & 7);
    dio <= ((dio + width) & 7);
    di <= ($signed({1'b0, di}) + nshift);
    di <= ($signed({1'b0, di}) + nshift);
    if ((nshift != 0)) begin
    if ((nshift != 0)) begin
        filled <= 1'b0;
        filled <= 1'b0;
    end
    end
end
end
endtask
endtask
 
 
function integer MYHDL40_get4;
function integer MYHDL44_get4;
    input boffset;
    input boffset;
    input width;
    input width;
    integer width;
    integer width;
begin: MYHDL106_RETURN
begin: MYHDL144_RETURN
    if ((nb != 4)) begin
    if ((nb != 4)) begin
        $write("----NB----");
        $write("----NB----");
        $write("\n");
        $write("\n");
        $finish;
        $finish;
    end
    end
    MYHDL40_get4 = ((b41 >>> (dio + boffset)) & ((1 << width) - 1));
    MYHDL44_get4 = ((b41 >>> (dio + boffset)) & ((1 << width) - 1));
    disable MYHDL106_RETURN;
    disable MYHDL144_RETURN;
end
end
endfunction
endfunction
 
 
function integer MYHDL41_get4;
function integer MYHDL45_get4;
    input boffset;
    input boffset;
    input width;
    input width;
    integer width;
    integer width;
begin: MYHDL107_RETURN
begin: MYHDL145_RETURN
    if ((nb != 4)) begin
    if ((nb != 4)) begin
        $write("----NB----");
        $write("----NB----");
        $write("\n");
        $write("\n");
        $finish;
        $finish;
    end
    end
    MYHDL41_get4 = ((b41 >>> (dio + boffset)) & ((1 << width) - 1));
    MYHDL45_get4 = ((b41 >>> (dio + boffset)) & ((1 << width) - 1));
    disable MYHDL107_RETURN;
    disable MYHDL145_RETURN;
end
end
endfunction
endfunction
 
 
function integer MYHDL42_get4;
function integer MYHDL46_get4;
    input boffset;
    input boffset;
    input width;
    input width;
    integer width;
    integer width;
begin: MYHDL108_RETURN
begin: MYHDL146_RETURN
    if ((nb != 4)) begin
    if ((nb != 4)) begin
        $write("----NB----");
        $write("----NB----");
        $write("\n");
        $write("\n");
        $finish;
        $finish;
    end
    end
    MYHDL42_get4 = ((b41 >>> (dio + boffset)) & ((1 << width) - 1));
    MYHDL46_get4 = ((b41 >>> (dio + boffset)) & ((1 << width) - 1));
    disable MYHDL108_RETURN;
    disable MYHDL146_RETURN;
end
end
endfunction
endfunction
 
 
task MYHDL43_adv;
task MYHDL47_adv;
    input width;
    input width;
    integer width;
    integer width;
    integer nshift;
    integer nshift;
begin: MYHDL109_RETURN
begin: MYHDL147_RETURN
    nshift = ((dio + width) >>> 3);
    nshift = ((dio + width) >>> 3);
    o_iprogress <= di;
    o_iprogress <= di;
    dio <= ((dio + width) & 7);
    dio <= ((dio + width) & 7);
    di <= ($signed({1'b0, di}) + nshift);
    di <= ($signed({1'b0, di}) + nshift);
    if ((nshift != 0)) begin
    if ((nshift != 0)) begin
        filled <= 1'b0;
        filled <= 1'b0;
    end
    end
end
end
endtask
endtask
 
 
function integer MYHDL50_rev_bits;
function integer MYHDL54_rev_bits;
    input [10-1:0] b;
    input [10-1:0] b;
    input [4-1:0] nb;
    input [4-1:0] nb;
    integer r;
    integer r;
begin: MYHDL110_RETURN
begin: MYHDL148_RETURN
    if ((b >= (1 << nb))) begin
    if ((b >= (1 << nb))) begin
        $finish;
        $finish;
        $write("too few bits");
        $write("too few bits");
        $write("\n");
        $write("\n");
    end
    end
    r = (((((((((((((((((b >>> 14) & 1) << 0) | (((b >>> 13) & 1) << 1)) | (((b >>> 12) & 1) << 2)) | (((b >>> 11) & 1) << 3)) | (((b >>> 10) & 1) << 4)) | (((b >>> 9) & 1) << 5)) | (((b >>> 8) & 1) << 6)) | (((b >>> 7) & 1) << 7)) | (((b >>> 6) & 1) << 8)) | (((b >>> 5) & 1) << 9)) | (((b >>> 4) & 1) << 10)) | (((b >>> 3) & 1) << 11)) | (((b >>> 2) & 1) << 12)) | (((b >>> 1) & 1) << 13)) | (((b >>> 0) & 1) << 14));
    r = (((((((((((((((((b >>> 14) & 1) << 0) | (((b >>> 13) & 1) << 1)) | (((b >>> 12) & 1) << 2)) | (((b >>> 11) & 1) << 3)) | (((b >>> 10) & 1) << 4)) | (((b >>> 9) & 1) << 5)) | (((b >>> 8) & 1) << 6)) | (((b >>> 7) & 1) << 7)) | (((b >>> 6) & 1) << 8)) | (((b >>> 5) & 1) << 9)) | (((b >>> 4) & 1) << 10)) | (((b >>> 3) & 1) << 11)) | (((b >>> 2) & 1) << 12)) | (((b >>> 1) & 1) << 13)) | (((b >>> 0) & 1) << 14));
    r = r >>> (15 - $signed({1'b0, nb}));
    r = r >>> (15 - $signed({1'b0, nb}));
    MYHDL50_rev_bits = r;
    MYHDL54_rev_bits = r;
    disable MYHDL110_RETURN;
    disable MYHDL148_RETURN;
end
end
endfunction
endfunction
 
 
function integer MYHDL51_makeLeaf;
function integer MYHDL55_makeLeaf;
    input [9-1:0] lcode;
    input [9-1:0] lcode;
    input [4-1:0] lbits;
    input [4-1:0] lbits;
begin: MYHDL111_RETURN
begin: MYHDL149_RETURN
    if ((lcode >= (1 << 10))) begin
    if ((lcode >= (1 << 10))) begin
        $finish;
        $finish;
    end
    end
    if ((lbits >= (1 << 9))) begin
    if ((lbits >= (1 << 9))) begin
        $finish;
        $finish;
    end
    end
    MYHDL51_makeLeaf = ((lcode << 9) | lbits);
    MYHDL55_makeLeaf = ((lcode << 9) | lbits);
    disable MYHDL111_RETURN;
    disable MYHDL149_RETURN;
end
end
endfunction
endfunction
 
 
function integer MYHDL52_makeLeaf;
function integer MYHDL56_makeLeaf;
    input [9-1:0] lcode;
    input [9-1:0] lcode;
    input [4-1:0] lbits;
    input [4-1:0] lbits;
begin: MYHDL112_RETURN
begin: MYHDL150_RETURN
    if ((lcode >= (1 << 10))) begin
    if ((lcode >= (1 << 10))) begin
        $finish;
        $finish;
    end
    end
    if ((lbits >= (1 << 9))) begin
    if ((lbits >= (1 << 9))) begin
        $finish;
        $finish;
    end
    end
    MYHDL52_makeLeaf = ((lcode << 9) | lbits);
    MYHDL56_makeLeaf = ((lcode << 9) | lbits);
    disable MYHDL112_RETURN;
    disable MYHDL150_RETURN;
end
end
endfunction
endfunction
 
 
function integer MYHDL53_makeLeaf;
function integer MYHDL57_makeLeaf;
    input [9-1:0] lcode;
    input [9-1:0] lcode;
    input [4-1:0] lbits;
    input [4-1:0] lbits;
begin: MYHDL113_RETURN
begin: MYHDL151_RETURN
    if ((lcode >= (1 << 10))) begin
    if ((lcode >= (1 << 10))) begin
        $finish;
        $finish;
    end
    end
    if ((lbits >= (1 << 9))) begin
    if ((lbits >= (1 << 9))) begin
        $finish;
        $finish;
    end
    end
    MYHDL53_makeLeaf = ((lcode << 9) | lbits);
    MYHDL57_makeLeaf = ((lcode << 9) | lbits);
    disable MYHDL113_RETURN;
    disable MYHDL151_RETURN;
end
end
endfunction
endfunction
 
 
function integer MYHDL54_get4;
function integer MYHDL58_get4;
    input boffset;
    input boffset;
    input [5-1:0] width;
    input [5-1:0] width;
begin: MYHDL114_RETURN
begin: MYHDL152_RETURN
    if ((nb != 4)) begin
    if ((nb != 4)) begin
        $write("----NB----");
        $write("----NB----");
        $write("\n");
        $write("\n");
        $finish;
        $finish;
    end
    end
    MYHDL54_get4 = ((b41 >>> (dio + boffset)) & ((1 << width) - 1));
    MYHDL58_get4 = ((b41 >>> (dio + boffset)) & ((1 << width) - 1));
    disable MYHDL114_RETURN;
    disable MYHDL152_RETURN;
end
end
endfunction
endfunction
 
 
function integer MYHDL55_get_bits;
function integer MYHDL59_get_bits;
    input [19-1:0] aleaf;
    input [19-1:0] aleaf;
begin: MYHDL115_RETURN
begin: MYHDL153_RETURN
    MYHDL55_get_bits = ($signed({1'b0, aleaf}) & ((1 << 9) - 1));
    MYHDL59_get_bits = ($signed({1'b0, aleaf}) & ((1 << 9) - 1));
    disable MYHDL115_RETURN;
    disable MYHDL153_RETURN;
end
end
endfunction
endfunction
 
 
function integer MYHDL56_get_bits;
function integer MYHDL60_get_bits;
    input [19-1:0] aleaf;
    input [19-1:0] aleaf;
begin: MYHDL116_RETURN
begin: MYHDL154_RETURN
    MYHDL56_get_bits = ($signed({1'b0, aleaf}) & ((1 << 9) - 1));
    MYHDL60_get_bits = ($signed({1'b0, aleaf}) & ((1 << 9) - 1));
    disable MYHDL116_RETURN;
    disable MYHDL154_RETURN;
end
end
endfunction
endfunction
 
 
task MYHDL57_adv;
task MYHDL61_adv;
    input width;
    input width;
    integer width;
    integer width;
    integer nshift;
    integer nshift;
begin: MYHDL117_RETURN
begin: MYHDL155_RETURN
    nshift = $signed(($signed({1'b0, dio}) + width) >>> 3);
    nshift = $signed(($signed({1'b0, dio}) + width) >>> 3);
    o_iprogress <= di;
    o_iprogress <= di;
    dio <= (($signed({1'b0, dio}) + width) & 7);
    dio <= (($signed({1'b0, dio}) + width) & 7);
    di <= ($signed({1'b0, di}) + nshift);
    di <= ($signed({1'b0, di}) + nshift);
    if ((nshift != 0)) begin
    if ((nshift != 0)) begin
        filled <= 1'b0;
        filled <= 1'b0;
    end
    end
end
end
endtask
endtask
 
 
function integer MYHDL58_get_code;
function integer MYHDL62_get_code;
    input [19-1:0] aleaf;
    input [19-1:0] aleaf;
begin: MYHDL118_RETURN
begin: MYHDL156_RETURN
    MYHDL58_get_code = (aleaf >>> 9);
    MYHDL62_get_code = (aleaf >>> 9);
    disable MYHDL118_RETURN;
    disable MYHDL156_RETURN;
end
end
endfunction
endfunction
 
 
function integer MYHDL59_get_code;
function integer MYHDL63_get_code;
    input [19-1:0] aleaf;
    input [19-1:0] aleaf;
begin: MYHDL119_RETURN
begin: MYHDL157_RETURN
    MYHDL59_get_code = (aleaf >>> 9);
    MYHDL63_get_code = (aleaf >>> 9);
    disable MYHDL119_RETURN;
    disable MYHDL157_RETURN;
end
end
endfunction
endfunction
 
 
function integer MYHDL60_get4;
function integer MYHDL64_get4;
    input boffset;
    input boffset;
    integer boffset;
    integer boffset;
    input [5-1:0] width;
    input [5-1:0] width;
begin: MYHDL120_RETURN
begin: MYHDL158_RETURN
    if ((nb != 4)) begin
    if ((nb != 4)) begin
        $write("----NB----");
        $write("----NB----");
        $write("\n");
        $write("\n");
        $finish;
        $finish;
    end
    end
    MYHDL60_get4 = ($signed($signed({1'b0, b41}) >>> ($signed({1'b0, dio}) + boffset)) & ((1 << width) - 1));
    MYHDL64_get4 = ($signed($signed({1'b0, b41}) >>> ($signed({1'b0, dio}) + boffset)) & ((1 << width) - 1));
    disable MYHDL120_RETURN;
    disable MYHDL158_RETURN;
end
end
endfunction
endfunction
 
 
function integer MYHDL61_get_bits;
function integer MYHDL65_get_bits;
    input [19-1:0] aleaf;
    input [19-1:0] aleaf;
begin: MYHDL121_RETURN
begin: MYHDL159_RETURN
    MYHDL61_get_bits = ($signed({1'b0, aleaf}) & ((1 << 9) - 1));
    MYHDL65_get_bits = ($signed({1'b0, aleaf}) & ((1 << 9) - 1));
    disable MYHDL121_RETURN;
    disable MYHDL159_RETURN;
end
end
endfunction
endfunction
 
 
function integer MYHDL62_get4;
function integer MYHDL66_get4;
    input boffset;
    input boffset;
    input width;
    input width;
    integer width;
    integer width;
begin: MYHDL122_RETURN
begin: MYHDL160_RETURN
    if ((nb != 4)) begin
    if ((nb != 4)) begin
        $write("----NB----");
        $write("----NB----");
        $write("\n");
        $write("\n");
        $finish;
        $finish;
    end
    end
    MYHDL62_get4 = ((b41 >>> (dio + boffset)) & ((1 << width) - 1));
    MYHDL66_get4 = ((b41 >>> (dio + boffset)) & ((1 << width) - 1));
    disable MYHDL122_RETURN;
    disable MYHDL160_RETURN;
end
end
endfunction
endfunction
 
 
function integer MYHDL63_get_code;
function integer MYHDL67_get_code;
    input [19-1:0] aleaf;
    input [19-1:0] aleaf;
begin: MYHDL123_RETURN
begin: MYHDL161_RETURN
    MYHDL63_get_code = (aleaf >>> 9);
    MYHDL67_get_code = (aleaf >>> 9);
    disable MYHDL123_RETURN;
    disable MYHDL161_RETURN;
end
end
endfunction
endfunction
 
 
function integer MYHDL64_get_bits;
function integer MYHDL68_get_bits;
    input [19-1:0] aleaf;
    input [19-1:0] aleaf;
begin: MYHDL124_RETURN
begin: MYHDL162_RETURN
    MYHDL64_get_bits = ($signed({1'b0, aleaf}) & ((1 << 9) - 1));
    MYHDL68_get_bits = ($signed({1'b0, aleaf}) & ((1 << 9) - 1));
    disable MYHDL124_RETURN;
    disable MYHDL162_RETURN;
end
end
endfunction
endfunction
 
 
function integer MYHDL65_get4;
function integer MYHDL69_get4;
    input boffset;
    input boffset;
    integer boffset;
    integer boffset;
    input width;
    input width;
    integer width;
    integer width;
begin: MYHDL125_RETURN
begin: MYHDL163_RETURN
    if ((nb != 4)) begin
    if ((nb != 4)) begin
        $write("----NB----");
        $write("----NB----");
        $write("\n");
        $write("\n");
        $finish;
        $finish;
    end
    end
    MYHDL65_get4 = ($signed($signed({1'b0, b41}) >>> ($signed({1'b0, dio}) + boffset)) & ((1 << width) - 1));
    MYHDL69_get4 = ($signed($signed({1'b0, b41}) >>> ($signed({1'b0, dio}) + boffset)) & ((1 << width) - 1));
    disable MYHDL125_RETURN;
    disable MYHDL163_RETURN;
end
end
endfunction
endfunction
 
 
function integer MYHDL66_get_bits;
function integer MYHDL70_get_bits;
    input [19-1:0] aleaf;
    input [19-1:0] aleaf;
begin: MYHDL126_RETURN
begin: MYHDL164_RETURN
    MYHDL66_get_bits = ($signed({1'b0, aleaf}) & ((1 << 9) - 1));
    MYHDL70_get_bits = ($signed({1'b0, aleaf}) & ((1 << 9) - 1));
    disable MYHDL126_RETURN;
    disable MYHDL164_RETURN;
end
end
endfunction
endfunction
 
 
task MYHDL67_adv;
task MYHDL71_adv;
    input width;
    input width;
    integer width;
    integer width;
    integer nshift;
    integer nshift;
begin: MYHDL127_RETURN
begin: MYHDL165_RETURN
    nshift = $signed(($signed({1'b0, dio}) + width) >>> 3);
    nshift = $signed(($signed({1'b0, dio}) + width) >>> 3);
    o_iprogress <= di;
    o_iprogress <= di;
    dio <= (($signed({1'b0, dio}) + width) & 7);
    dio <= (($signed({1'b0, dio}) + width) & 7);
    di <= ($signed({1'b0, di}) + nshift);
    di <= ($signed({1'b0, di}) + nshift);
    if ((nshift != 0)) begin
    if ((nshift != 0)) begin
        filled <= 1'b0;
        filled <= 1'b0;
    end
    end
end
end
endtask
endtask
 
 
function integer MYHDL68_get4;
function integer MYHDL72_get4;
    input boffset;
    input boffset;
    input width;
    input width;
    integer width;
    integer width;
begin: MYHDL128_RETURN
begin: MYHDL166_RETURN
    if ((nb != 4)) begin
    if ((nb != 4)) begin
        $write("----NB----");
        $write("----NB----");
        $write("\n");
        $write("\n");
        $finish;
        $finish;
    end
    end
    MYHDL68_get4 = ((b41 >>> (dio + boffset)) & ((1 << width) - 1));
    MYHDL72_get4 = ((b41 >>> (dio + boffset)) & ((1 << width) - 1));
    disable MYHDL128_RETURN;
    disable MYHDL166_RETURN;
end
end
endfunction
endfunction
 
 
function integer MYHDL69_get4;
function integer MYHDL73_get4;
    input boffset;
    input boffset;
    integer boffset;
    integer boffset;
    input width;
    input width;
    integer width;
    integer width;
begin: MYHDL129_RETURN
begin: MYHDL167_RETURN
    if ((nb != 4)) begin
    if ((nb != 4)) begin
        $write("----NB----");
        $write("----NB----");
        $write("\n");
        $write("\n");
        $finish;
        $finish;
    end
    end
    MYHDL69_get4 = ($signed($signed({1'b0, b41}) >>> ($signed({1'b0, dio}) + boffset)) & ((1 << width) - 1));
    MYHDL73_get4 = ($signed($signed({1'b0, b41}) >>> ($signed({1'b0, dio}) + boffset)) & ((1 << width) - 1));
    disable MYHDL129_RETURN;
    disable MYHDL167_RETURN;
end
end
endfunction
endfunction
 
 
function integer MYHDL70_rev_bits;
function integer MYHDL74_rev_bits;
    input b;
    input b;
    integer b;
    integer b;
    input nb;
    input nb;
    integer nb;
    integer nb;
    integer r;
    integer r;
begin: MYHDL130_RETURN
begin: MYHDL168_RETURN
    if ((b >= (1 << nb))) begin
    if ((b >= (1 << nb))) begin
        $finish;
        $finish;
        $write("too few bits");
        $write("too few bits");
        $write("\n");
        $write("\n");
    end
    end
    r = (((((((((((((((((b >>> 14) & 1) << 0) | (((b >>> 13) & 1) << 1)) | (((b >>> 12) & 1) << 2)) | (((b >>> 11) & 1) << 3)) | (((b >>> 10) & 1) << 4)) | (((b >>> 9) & 1) << 5)) | (((b >>> 8) & 1) << 6)) | (((b >>> 7) & 1) << 7)) | (((b >>> 6) & 1) << 8)) | (((b >>> 5) & 1) << 9)) | (((b >>> 4) & 1) << 10)) | (((b >>> 3) & 1) << 11)) | (((b >>> 2) & 1) << 12)) | (((b >>> 1) & 1) << 13)) | (((b >>> 0) & 1) << 14));
    r = (((((((((((((((((b >>> 14) & 1) << 0) | (((b >>> 13) & 1) << 1)) | (((b >>> 12) & 1) << 2)) | (((b >>> 11) & 1) << 3)) | (((b >>> 10) & 1) << 4)) | (((b >>> 9) & 1) << 5)) | (((b >>> 8) & 1) << 6)) | (((b >>> 7) & 1) << 7)) | (((b >>> 6) & 1) << 8)) | (((b >>> 5) & 1) << 9)) | (((b >>> 4) & 1) << 10)) | (((b >>> 3) & 1) << 11)) | (((b >>> 2) & 1) << 12)) | (((b >>> 1) & 1) << 13)) | (((b >>> 0) & 1) << 14));
    r = r >>> (15 - $signed({1'b0, nb}));
    r = r >>> (15 - $signed({1'b0, nb}));
    MYHDL70_rev_bits = r;
    MYHDL74_rev_bits = r;
    disable MYHDL130_RETURN;
    disable MYHDL168_RETURN;
end
end
endfunction
endfunction
 
 
function integer MYHDL71_get4;
function integer MYHDL75_get4;
    input boffset;
    input boffset;
    integer boffset;
    integer boffset;
    input width;
    input width;
    integer width;
    integer width;
begin: MYHDL131_RETURN
begin: MYHDL169_RETURN
    if ((nb != 4)) begin
    if ((nb != 4)) begin
        $write("----NB----");
        $write("----NB----");
        $write("\n");
        $write("\n");
        $finish;
        $finish;
    end
    end
    MYHDL71_get4 = ($signed($signed({1'b0, b41}) >>> ($signed({1'b0, dio}) + boffset)) & ((1 << width) - 1));
    MYHDL75_get4 = ($signed($signed({1'b0, b41}) >>> ($signed({1'b0, dio}) + boffset)) & ((1 << width) - 1));
    disable MYHDL131_RETURN;
    disable MYHDL169_RETURN;
end
end
endfunction
endfunction
 
 
task MYHDL72_adv;
task MYHDL76_adv;
    input width;
    input width;
    integer width;
    integer width;
    integer nshift;
    integer nshift;
begin: MYHDL132_RETURN
begin: MYHDL170_RETURN
    nshift = $signed(($signed({1'b0, dio}) + width) >>> 3);
    nshift = $signed(($signed({1'b0, dio}) + width) >>> 3);
    o_iprogress <= di;
    o_iprogress <= di;
    dio <= (($signed({1'b0, dio}) + width) & 7);
    dio <= (($signed({1'b0, dio}) + width) & 7);
    di <= ($signed({1'b0, di}) + nshift);
    di <= ($signed({1'b0, di}) + nshift);
    if ((nshift != 0)) begin
    if ((nshift != 0)) begin
        filled <= 1'b0;
        filled <= 1'b0;
    end
    end
end
end
endtask
endtask
 
 
task MYHDL73_adv;
task MYHDL77_adv;
    input width;
    input width;
    integer width;
    integer width;
    integer nshift;
    integer nshift;
begin: MYHDL133_RETURN
begin: MYHDL171_RETURN
    nshift = ((dio + width) >>> 3);
    nshift = ((dio + width) >>> 3);
    o_iprogress <= di;
    o_iprogress <= di;
    dio <= ((dio + width) & 7);
    dio <= ((dio + width) & 7);
    di <= ($signed({1'b0, di}) + nshift);
    di <= ($signed({1'b0, di}) + nshift);
    if ((nshift != 0)) begin
    if ((nshift != 0)) begin
Line 1026... Line 1098...
    integer nextdist;
    integer nextdist;
    integer copydist;
    integer copydist;
    integer extra_dist;
    integer extra_dist;
    integer extra_bits;
    integer extra_bits;
    integer outcode;
    integer outcode;
 
    reg found;
 
    integer fmatch;
 
    integer si;
 
    integer distance;
    integer lencode;
    integer lencode;
    integer match;
    integer match;
    integer distance;
 
    integer stat_i;
    integer stat_i;
    integer clo_i;
    integer clo_i;
    integer n_adv;
    integer n_adv;
    integer dbl_i;
    integer dbl_i;
    integer dbl;
    integer dbl;
Line 1061... Line 1136...
        o_done <= 1'b0;
        o_done <= 1'b0;
    end
    end
    else begin
    else begin
        case (state)
        case (state)
            5'b00000: begin
            5'b00000: begin
                case (i_mode)
                if ((1'b1 && (i_mode == 4))) begin
                    'h4: begin
 
                        $write("STARTC");
                        $write("STARTC");
                        $write("\n");
                        $write("\n");
                        do_compress <= 1'b1;
                        do_compress <= 1'b1;
                        method <= 1;
                        method <= 1;
                        o_done <= 1'b0;
                        o_done <= 1'b0;
Line 1078... Line 1152...
                        doo <= 0;
                        doo <= 0;
                        filled <= 1'b1;
                        filled <= 1'b1;
                        cur_static <= 0;
                        cur_static <= 0;
                        state <= 5'b01110;
                        state <= 5'b01110;
                    end
                    end
                    'h5: begin
                else if ((i_mode == 5)) begin
                        do_compress <= 1'b0;
                        do_compress <= 1'b0;
                        o_done <= 1'b0;
                        o_done <= 1'b0;
                        o_iprogress <= 0;
                        o_iprogress <= 0;
                        o_oprogress <= 0;
                        o_oprogress <= 0;
                        di <= 0;
                        di <= 0;
Line 1090... Line 1164...
                        do <= 0;
                        do <= 0;
                        doo <= 0;
                        doo <= 0;
                        filled <= 1'b1;
                        filled <= 1'b1;
                        state <= 5'b00001;
                        state <= 5'b00001;
                    end
                    end
                    default: begin
                else begin
                        // pass
                        // pass
                    end
                    end
                endcase
 
            end
            end
            5'b00001: begin
            5'b00001: begin
                if ((!filled)) begin
                if ((!filled)) begin
                    filled <= 1'b1;
                    filled <= 1'b1;
                end
                end
Line 1178... Line 1251...
                    endcase
                    endcase
                end
                end
            end
            end
            5'b10110: begin
            5'b10110: begin
                no_adv = 0;
                no_adv = 0;
                if ((!filled)) begin
                if ((!1'b1)) begin
 
                    // pass
 
                end
 
                else if ((!filled)) begin
                    no_adv = 1;
                    no_adv = 1;
                    filled <= 1'b1;
                    filled <= 1'b1;
                end
                end
                else if ((nb < 4)) begin
                else if ((nb < 4)) begin
                    no_adv = 1;
                    no_adv = 1;
Line 1306... Line 1382...
                if ((!no_adv)) begin
                if ((!no_adv)) begin
                    cur_cstatic <= (cur_cstatic + 1);
                    cur_cstatic <= (cur_cstatic + 1);
                end
                end
            end
            end
            5'b11000: begin
            5'b11000: begin
                if (flush) begin
                if ((!1'b1)) begin
 
                    // pass
 
                end
 
                else if (flush) begin
                    MYHDL15_do_flush;
                    MYHDL15_do_flush;
                end
                end
                else begin
                else begin
                    case ((cur_i + 1))
                    case ((cur_i + 1))
                        0: nextdist = 1;
                        0: nextdist = 1;
Line 1409... Line 1488...
                        cur_i <= (cur_i + 1);
                        cur_i <= (cur_i + 1);
                    end
                    end
                end
                end
            end
            end
            5'b11001: begin
            5'b11001: begin
                if ((cur_i < di)) begin
                if ((!1'b1)) begin
 
                    // pass
 
                end
 
                else if ((cur_i < di)) begin
                    bdata = iram[(cur_i & 127)];
                    bdata = iram[(cur_i & 127)];
                    adler1_next = ((adler1 + bdata) % 65521);
                    adler1_next = ((adler1 + bdata) % 65521);
                    adler1 <= adler1_next;
                    adler1 <= adler1_next;
                    adler2 <= ((adler2 + ladler1) % 65521);
                    adler2 <= ((adler2 + ladler1) % 65521);
                    ladler1 <= adler1_next;
                    ladler1 <= adler1_next;
Line 1422... Line 1504...
                else begin
                else begin
                    state <= 5'b10110;
                    state <= 5'b10110;
                end
                end
            end
            end
            5'b10111: begin
            5'b10111: begin
                if ((!filled)) begin
                if ((!1'b1)) begin
 
                    // pass
 
                end
 
                else if ((!filled)) begin
                    filled <= 1'b1;
                    filled <= 1'b1;
                end
                end
                else if ((nb < 4)) begin
                else if ((nb < 4)) begin
                    // pass
                    // pass
                end
                end
                else begin
                else begin
                    if (((cur_search >= 0) && (cur_search >= ($signed({1'b0, di}) - 32)) && ($signed({1'b0, di}) < ($signed({1'b0, isize}) - 3)))) begin
                    if (((cur_search >= 0) && (cur_search >= ($signed({1'b0, di}) - 32)) && ($signed({1'b0, di}) < ($signed({1'b0, isize}) - 3)))) begin
                        if (((iram[(cur_search & 127)] == b1) && (iram[((cur_search + 1) & 127)] == b2) && (iram[((cur_search + 2) & 127)] == b3))) begin
                        //                         
 
                        if (1'b1) begin
 
                            found = 0;
 
                            fmatch = 0;
 
                            begin: MYHDL19_BREAK
 
                            for (si=0; si<32; si=si+1) begin
 
                                if (smatch[si]) begin
 
                                    $write("fmatch");
 
                                    $write(" ");
 
                                    $write("%0d", si);
 
                                    $write("\n");
 
                                    fmatch = si;
 
                                    found = 1;
 
                                    disable MYHDL19_BREAK;
 
                                end
 
                            end
 
                            end
 
                            if (((!found) || ((($signed({1'b0, di}) - fmatch) - 1) < 0))) begin
 
                                cur_search <= (-1);
 
                            end
 
                            else begin
 
                                distance = (fmatch + 1);
 
                                fmatch = (($signed({1'b0, di}) - fmatch) + 2);
 
                                lencode = 257;
 
                                match = 3;
 
                                if ((($signed({1'b0, di}) < ($signed({1'b0, isize}) - 4)) && (iram[(fmatch & 127)] == b4))) begin
 
                                    lencode = 258;
 
                                    match = 4;
 
                                    if ((($signed({1'b0, di}) < ($signed({1'b0, isize}) - 5)) && (iram[((fmatch + 1) & 127)] == b5))) begin
 
                                        lencode = 259;
 
                                        match = 5;
 
                                        if ((1'b1 && ($signed({1'b0, di}) < ($signed({1'b0, isize}) - 6)) && (iram[((fmatch + 2) & 127)] == b6))) begin
 
                                            lencode = 260;
 
                                            match = 6;
 
                                            if ((($signed({1'b0, di}) < ($signed({1'b0, isize}) - 7)) && (iram[((fmatch + 3) & 127)] == b7))) begin
 
                                                lencode = 261;
 
                                                match = 7;
 
                                                if ((($signed({1'b0, di}) < ($signed({1'b0, isize}) - 8)) && (iram[((fmatch + 4) & 127)] == b8))) begin
 
                                                    lencode = 262;
 
                                                    match = 8;
 
                                                    if ((($signed({1'b0, di}) < ($signed({1'b0, isize}) - 9)) && (iram[((fmatch + 5) & 127)] == b9))) begin
 
                                                        lencode = 263;
 
                                                        match = 9;
 
                                                        if ((($signed({1'b0, di}) < ($signed({1'b0, isize}) - 10)) && (iram[((fmatch + 6) & 127)] == b10))) begin
 
                                                            lencode = 264;
 
                                                            match = 10;
 
                                                        end
 
                                                    end
 
                                                end
 
                                            end
 
                                        end
 
                                    end
 
                                end
 
                                $write("fast:");
 
                                $write(" ");
 
                                $write("%0d", distance);
 
                                $write(" ");
 
                                $write("%h", di);
 
                                $write(" ");
 
                                $write("%h", isize);
 
                                $write(" ");
 
                                $write("%0d", match);
 
                                $write("\n");
 
                                outlen = codeLength[lencode];
 
                                outbits = code_bits[lencode];
 
                                oaddr <= do;
 
                                obyte <= MYHDL21_put(outbits, outlen);
 
                                MYHDL22_put_adv(outbits, outlen);
 
                                cur_dist <= distance;
 
                                cur_i <= 0;
 
                                di <= (di + match);
 
                                cur_cstatic <= ((cur_cstatic + match) - 1);
 
                                length <= match;
 
                                state <= 5'b11000;
 
                            end
 
                        end
 
                        else if (((iram[(cur_search & 127)] == b1) && (iram[((cur_search + 1) & 127)] == b2) && (iram[((cur_search + 2) & 127)] == b3))) begin
                            lencode = 257;
                            lencode = 257;
                            match = 3;
                            match = 3;
                            if ((($signed({1'b0, di}) < ($signed({1'b0, isize}) - 4)) && (iram[((cur_search + 3) & 127)] == b4))) begin
                            if ((($signed({1'b0, di}) < ($signed({1'b0, isize}) - 4)) && (iram[((cur_search + 3) & 127)] == b4))) begin
                                lencode = 258;
                                lencode = 258;
                                match = 4;
                                match = 4;
                                if ((($signed({1'b0, di}) < ($signed({1'b0, isize}) - 5)) && (iram[((cur_search + 4) & 127)] == iram[((di + 4) & 127)]))) begin
                                if ((($signed({1'b0, di}) < ($signed({1'b0, isize}) - 5)) && (iram[((cur_search + 4) & 127)] == iram[((di + 4) & 127)]))) begin
                                    lencode = 259;
                                    lencode = 259;
                                    match = 5;
                                    match = 5;
 
                                    if ((1'b1 && ($signed({1'b0, di}) < ($signed({1'b0, isize}) - 6)) && (iram[((cur_search + 5) & 127)] == iram[((di + 5) & 127)]))) begin
 
                                        lencode = 260;
 
                                        match = 6;
 
                                        if ((($signed({1'b0, di}) < ($signed({1'b0, isize}) - 7)) && (iram[((cur_search + 6) & 127)] == iram[((di + 6) & 127)]))) begin
 
                                            lencode = 261;
 
                                            match = 7;
 
                                            if ((($signed({1'b0, di}) < ($signed({1'b0, isize}) - 8)) && (iram[((cur_search + 7) & 127)] == iram[((di + 7) & 127)]))) begin
 
                                                lencode = 262;
 
                                                match = 8;
 
                                                if ((($signed({1'b0, di}) < ($signed({1'b0, isize}) - 9)) && (iram[((cur_search + 8) & 127)] == iram[((di + 8) & 127)]))) begin
 
                                                    lencode = 263;
 
                                                    match = 9;
 
                                                    if ((($signed({1'b0, di}) < ($signed({1'b0, isize}) - 10)) && (iram[((cur_search + 9) & 127)] == iram[((di + 9) & 127)]))) begin
 
                                                        lencode = 264;
 
                                                        match = 10;
 
                                                    end
 
                                                end
 
                                            end
 
                                        end
 
                                    end
                                end
                                end
                            end
                            end
                            // if di < isize - 6 and                                             iram[cur_search+5 & IBS] == iram[di + 5 & IBS]:
 
                            //     lencode = 260
 
                            //     match = 6
 
                            //     if di < isize - 7 and                                                 iram[cur_search+6 & IBS] == iram[di + 6 & IBS]:
 
                            //         lencode = 261
 
                            //         match = 7
 
                            //         if di < isize - 8 and                                                     iram[cur_search+7 & IBS] == iram[di + 7 & IBS]:
 
                            //             lencode = 262
 
                            //             match = 8
 
                            //             if di < isize - 9 and                                                         iram[cur_search+8 & IBS] == iram[di + 8 & IBS]:
 
                            //                 lencode = 263
 
                            //                 match = 9
 
                            //                 if di < isize - 10 and                                                             iram[cur_search+9 & IBS] == iram[di + 9 & IBS]:
 
                            //                     lencode = 264
 
                            //                     match = 10
 
                            $write("found:");
                            $write("found:");
                            $write(" ");
                            $write(" ");
                            $write("%h", cur_search);
                            $write("%h", cur_search);
                            $write(" ");
                            $write(" ");
                            $write("%h", di);
                            $write("%h", di);
Line 1469... Line 1635...
                            $write("%0d", match);
                            $write("%0d", match);
                            $write("\n");
                            $write("\n");
                            outlen = codeLength[lencode];
                            outlen = codeLength[lencode];
                            outbits = code_bits[lencode];
                            outbits = code_bits[lencode];
                            oaddr <= do;
                            oaddr <= do;
                            obyte <= MYHDL19_put(outbits, outlen);
                            obyte <= MYHDL23_put(outbits, outlen);
                            MYHDL20_put_adv(outbits, outlen);
                            MYHDL24_put_adv(outbits, outlen);
                            distance = ($signed({1'b0, di}) - cur_search);
                            distance = ($signed({1'b0, di}) - cur_search);
                            cur_dist <= distance;
                            cur_dist <= distance;
                            cur_i <= 0;
                            cur_i <= 0;
                            di <= (di + match);
                            di <= (di + match);
                            cur_cstatic <= ((cur_cstatic + match) - 1);
                            cur_cstatic <= ((cur_cstatic + match) - 1);
Line 1489... Line 1655...
                        bdata = iram[di];
                        bdata = iram[di];
                        di <= (di + 1);
                        di <= (di + 1);
                        outlen = codeLength[bdata];
                        outlen = codeLength[bdata];
                        outbits = code_bits[bdata];
                        outbits = code_bits[bdata];
                        oaddr <= do;
                        oaddr <= do;
                        obyte <= MYHDL21_put(outbits, outlen);
                        obyte <= MYHDL25_put(outbits, outlen);
                        MYHDL22_put_adv(outbits, outlen);
                        MYHDL26_put_adv(outbits, outlen);
                        state <= 5'b10110;
                        state <= 5'b10110;
                    end
                    end
                end
                end
            end
            end
            5'b01110: begin
            5'b01110: begin
Line 1534... Line 1700...
                end
                end
                else if ((nb < 4)) begin
                else if ((nb < 4)) begin
                    // pass
                    // pass
                end
                end
                else if ((numLiterals == 0)) begin
                else if ((numLiterals == 0)) begin
                    numLiterals <= (257 + MYHDL31_get4(0, 5));
                    numLiterals <= (257 + MYHDL35_get4(0, 5));
                    $write("NL:");
                    $write("NL:");
                    $write(" ");
                    $write(" ");
                    $write("%0d", (257 + MYHDL32_get4(0, 5)));
                    $write("%0d", (257 + MYHDL36_get4(0, 5)));
                    $write("\n");
                    $write("\n");
                    numDistance <= (1 + MYHDL33_get4(5, 5));
                    numDistance <= (1 + MYHDL37_get4(5, 5));
                    $write("ND:");
                    $write("ND:");
                    $write(" ");
                    $write(" ");
                    $write("%0d", (1 + MYHDL34_get4(5, 5)));
                    $write("%0d", (1 + MYHDL38_get4(5, 5)));
                    $write("\n");
                    $write("\n");
                    b_numCodeLength <= (4 + MYHDL35_get4(10, 4));
                    b_numCodeLength <= (4 + MYHDL39_get4(10, 4));
                    $write("NCL:");
                    $write("NCL:");
                    $write(" ");
                    $write(" ");
                    $write("%0d", (4 + MYHDL36_get4(10, 4)));
                    $write("%0d", (4 + MYHDL40_get4(10, 4)));
                    $write("\n");
                    $write("\n");
                    numCodeLength <= 0;
                    numCodeLength <= 0;
                    MYHDL37_adv(14);
                    MYHDL41_adv(14);
                end
                end
                else begin
                else begin
                    if ((numCodeLength < 19)) begin
                    if ((numCodeLength < 19)) begin
                        case (numCodeLength)
                        case (numCodeLength)
                            0: clo_i = 16;
                            0: clo_i = 16;
Line 1576... Line 1742...
                            16: clo_i = 14;
                            16: clo_i = 14;
                            17: clo_i = 1;
                            17: clo_i = 1;
                            default: clo_i = 15;
                            default: clo_i = 15;
                        endcase
                        endcase
                        if ((numCodeLength < b_numCodeLength)) begin
                        if ((numCodeLength < b_numCodeLength)) begin
                            codeLength[clo_i] <= MYHDL38_get4(0, 3);
                            codeLength[clo_i] <= MYHDL42_get4(0, 3);
                            MYHDL39_adv(3);
                            MYHDL43_adv(3);
                        end
                        end
                        else begin
                        else begin
                            codeLength[clo_i] <= 0;
                            codeLength[clo_i] <= 0;
                        end
                        end
                        numCodeLength <= (numCodeLength + 1);
                        numCodeLength <= (numCodeLength + 1);
Line 1605... Line 1771...
                    if ((code < 16)) begin
                    if ((code < 16)) begin
                        howOften <= 1;
                        howOften <= 1;
                        lastToken <= code;
                        lastToken <= code;
                    end
                    end
                    else if ((code == 16)) begin
                    else if ((code == 16)) begin
                        howOften <= (3 + MYHDL40_get4(0, 2));
                        howOften <= (3 + MYHDL44_get4(0, 2));
                        n_adv = 2;
                        n_adv = 2;
                    end
                    end
                    else if ((code == 17)) begin
                    else if ((code == 17)) begin
                        howOften <= (3 + MYHDL41_get4(0, 3));
                        howOften <= (3 + MYHDL45_get4(0, 3));
                        lastToken <= 0;
                        lastToken <= 0;
                        n_adv = 3;
                        n_adv = 3;
                    end
                    end
                    else if ((code == 18)) begin
                    else if ((code == 18)) begin
                        howOften <= (11 + MYHDL42_get4(0, 7));
                        howOften <= (11 + MYHDL46_get4(0, 7));
                        lastToken <= 0;
                        lastToken <= 0;
                        n_adv = 7;
                        n_adv = 7;
                    end
                    end
                    else begin
                    else begin
                        $finish;
                        $finish;
                    end
                    end
                    if ((n_adv != 0)) begin
                    if ((n_adv != 0)) begin
                        MYHDL43_adv(n_adv);
                        MYHDL47_adv(n_adv);
                    end
                    end
                    state <= 5'b00100;
                    state <= 5'b00100;
                end
                end
                else begin
                else begin
                    $write("FILL UP");
                    $write("FILL UP");
Line 1800... Line 1966...
                            canonical = nextCode[bits];
                            canonical = nextCode[bits];
                            nextCode[bits] <= (nextCode[bits] + 1);
                            nextCode[bits] <= (nextCode[bits] + 1);
                            if ((bits > 15)) begin
                            if ((bits > 15)) begin
                                $finish;
                                $finish;
                            end
                            end
                            reverse <= MYHDL50_rev_bits(canonical, bits);
                            reverse <= MYHDL54_rev_bits(canonical, bits);
                            leaf <= MYHDL51_makeLeaf(spread_i, bits);
                            leaf <= MYHDL55_makeLeaf(spread_i, bits);
                            state <= 5'b01101;
                            state <= 5'b01101;
                        end
                        end
                        5'b01101: begin
                        5'b01101: begin
                            if ((method == 4)) begin
                            if ((method == 4)) begin
                                d_leaves[reverse] <= leaf;
                                d_leaves[reverse] <= leaf;
Line 1881... Line 2047...
                                cur_i <= 0;
                                cur_i <= 0;
                            end
                            end
                        end
                        end
                        5'b10010: begin
                        5'b10010: begin
                            if ((method == 4)) begin
                            if ((method == 4)) begin
                                d_leaves[spread] <= MYHDL52_makeLeaf(spread_i, codeLength[spread_i]);
                                d_leaves[spread] <= MYHDL56_makeLeaf(spread_i, codeLength[spread_i]);
                            end
                            end
                            else begin
                            else begin
                                lwaddr <= spread;
                                lwaddr <= spread;
                                wleaf <= MYHDL53_makeLeaf(spread_i, codeLength[spread_i]);
                                wleaf <= MYHDL57_makeLeaf(spread_i, codeLength[spread_i]);
                            end
                            end
                            aim = instantMask;
                            aim = instantMask;
                            if ((method == 4)) begin
                            if ((method == 4)) begin
                                aim = d_instantMask;
                                aim = d_instantMask;
                            end
                            end
Line 1907... Line 2073...
                            end
                            end
                            else if ((nb < 4)) begin
                            else if ((nb < 4)) begin
                                // pass
                                // pass
                            end
                            end
                            else if ((cur_next == 0)) begin
                            else if ((cur_next == 0)) begin
                                cto = MYHDL54_get4(0, maxBits);
                                cto = MYHDL58_get4(0, maxBits);
                                cur_next <= 1;
                                cur_next <= 1;
                                mask = ((1 << instantMaxBit) - 1);
                                mask = ((1 << instantMaxBit) - 1);
                                leaf <= leaves[(cto & mask)];
                                leaf <= leaves[(cto & mask)];
                            end
                            end
                            else begin
                            else begin
                                if ((MYHDL55_get_bits(leaf) < 1)) begin
                                if ((MYHDL59_get_bits(leaf) < 1)) begin
                                    $write("< 1 bits: ");
                                    $write("< 1 bits: ");
                                    $write("\n");
                                    $write("\n");
                                    $finish;
                                    $finish;
                                end
                                end
                                MYHDL57_adv(MYHDL56_get_bits(leaf));
                                MYHDL61_adv(MYHDL60_get_bits(leaf));
                                if ((MYHDL58_get_code(leaf) == 0)) begin
                                if ((MYHDL62_get_code(leaf) == 0)) begin
                                    $write("leaf 0");
                                    $write("leaf 0");
                                    $write("\n");
                                    $write("\n");
                                end
                                end
                                code <= MYHDL59_get_code(leaf);
                                code <= MYHDL63_get_code(leaf);
                                if ((method == 2)) begin
                                if ((method == 2)) begin
                                    state <= 5'b00011;
                                    state <= 5'b00011;
                                end
                                end
                                else begin
                                else begin
                                    state <= 5'b10100;
                                    state <= 5'b10100;
Line 1972... Line 2138...
                                    25: extraLength = 5;
                                    25: extraLength = 5;
                                    26: extraLength = 5;
                                    26: extraLength = 5;
                                    27: extraLength = 5;
                                    27: extraLength = 5;
                                    default: extraLength = 0;
                                    default: extraLength = 0;
                                endcase
                                endcase
                                cto = MYHDL60_get4(extraLength, d_maxBits);
                                cto = MYHDL64_get4(extraLength, d_maxBits);
                                mask = ((1 << d_instantMaxBit) - 1);
                                mask = ((1 << d_instantMaxBit) - 1);
                                leaf <= d_leaves[(cto & mask)];
                                leaf <= d_leaves[(cto & mask)];
                                state <= 5'b10000;
                                state <= 5'b10000;
                            end
                            end
                        end
                        end
                        5'b10000: begin
                        5'b10000: begin
                            if ((MYHDL61_get_bits(leaf) == 0)) begin
                            if ((MYHDL65_get_bits(leaf) == 0)) begin
                                $finish;
                                $finish;
                            end
                            end
                            token = (code - 257);
                            token = (code - 257);
                            case (token)
                            case (token)
                                0: tlength = 3;
                                0: tlength = 3;
Line 2045... Line 2211...
                                25: extraLength = 5;
                                25: extraLength = 5;
                                26: extraLength = 5;
                                26: extraLength = 5;
                                27: extraLength = 5;
                                27: extraLength = 5;
                                default: extraLength = 0;
                                default: extraLength = 0;
                            endcase
                            endcase
                            tlength = tlength + MYHDL62_get4(0, extraLength);
                            tlength = tlength + MYHDL66_get4(0, extraLength);
                            distanceCode = MYHDL63_get_code(leaf);
                            distanceCode = MYHDL67_get_code(leaf);
                            case (distanceCode)
                            case (distanceCode)
                                0: distance = 1;
                                0: distance = 1;
                                1: distance = 2;
                                1: distance = 2;
                                2: distance = 3;
                                2: distance = 3;
                                3: distance = 4;
                                3: distance = 4;
Line 2096... Line 2262...
                                11: moreBits = 10;
                                11: moreBits = 10;
                                12: moreBits = 11;
                                12: moreBits = 11;
                                13: moreBits = 12;
                                13: moreBits = 12;
                                default: moreBits = 13;
                                default: moreBits = 13;
                            endcase
                            endcase
                            mored = MYHDL65_get4((extraLength + MYHDL64_get_bits(leaf)), moreBits);
                            mored = MYHDL69_get4((extraLength + MYHDL68_get_bits(leaf)), moreBits);
                            distance = distance + mored;
                            distance = distance + mored;
                            MYHDL67_adv(((moreBits + extraLength) + MYHDL66_get_bits(leaf)));
                            MYHDL71_adv(((moreBits + extraLength) + MYHDL70_get_bits(leaf)));
                            offset <= ($signed({1'b0, do}) - distance);
                            offset <= ($signed({1'b0, do}) - distance);
                            length <= tlength;
                            length <= tlength;
                            cur_i <= 0;
                            cur_i <= 0;
                            oraddr <= offset;
                            oraddr <= ($signed({1'b0, do}) - distance);
                            state <= 5'b10101;
                            state <= 5'b10101;
                        end
                        end
                        default: begin
                        default: begin
                            if ((state == 5'b10100)) begin
                            if ((state == 5'b10100)) begin
                                if ((!filled)) begin
                                if ((!filled)) begin
                                    filled <= 1'b1;
                                    filled <= 1'b1;
                                end
                                end
                                else if ((nb < 4)) begin
                                else if ((nb < 4)) begin
                                    // pass
                                    // pass
                                end
                                end
                                else if (($signed({1'b0, di}) > ($signed({1'b0, isize}) - 3))) begin
                                else if ((di > isize)) begin
                                    state <= 5'b00000;
                                    state <= 5'b00000;
                                    o_done <= 1'b1;
                                    o_done <= 1'b1;
                                    $write("NO EOF ");
                                    $write("NO EOF ");
                                    $write(" ");
                                    $write(" ");
                                    $write("%h", di);
                                    $write("%h", di);
Line 2215... Line 2381...
                                                25: extraLength = 5;
                                                25: extraLength = 5;
                                                26: extraLength = 5;
                                                26: extraLength = 5;
                                                27: extraLength = 5;
                                                27: extraLength = 5;
                                                default: extraLength = 0;
                                                default: extraLength = 0;
                                            endcase
                                            endcase
                                            tlength = tlength + MYHDL68_get4(0, extraLength);
                                            tlength = tlength + MYHDL72_get4(0, extraLength);
                                            t = MYHDL69_get4(extraLength, 5);
                                            t = MYHDL73_get4(extraLength, 5);
                                            distanceCode = MYHDL70_rev_bits(t, 5);
                                            distanceCode = MYHDL74_rev_bits(t, 5);
                                            case (distanceCode)
                                            case (distanceCode)
                                                0: distance = 1;
                                                0: distance = 1;
                                                1: distance = 2;
                                                1: distance = 2;
                                                2: distance = 3;
                                                2: distance = 3;
                                                3: distance = 4;
                                                3: distance = 4;
Line 2267... Line 2433...
                                                11: moreBits = 10;
                                                11: moreBits = 10;
                                                12: moreBits = 11;
                                                12: moreBits = 11;
                                                13: moreBits = 12;
                                                13: moreBits = 12;
                                                default: moreBits = 13;
                                                default: moreBits = 13;
                                            endcase
                                            endcase
                                            distance = distance + MYHDL71_get4((extraLength + 5), moreBits);
                                            distance = distance + MYHDL75_get4((extraLength + 5), moreBits);
                                            MYHDL72_adv(((extraLength + 5) + moreBits));
                                            MYHDL76_adv(((extraLength + 5) + moreBits));
                                            offset <= ($signed({1'b0, do}) - distance);
                                            offset <= ($signed({1'b0, do}) - distance);
                                            length <= tlength;
                                            length <= tlength;
                                            cur_i <= 0;
                                            cur_i <= 0;
                                            oraddr <= offset;
                                            oraddr <= ($signed({1'b0, do}) - distance);
                                            state <= 5'b10101;
                                            state <= 5'b10101;
                                        end
                                        end
                                        else begin
                                        else begin
                                            state <= 5'b01111;
                                            state <= 5'b01111;
                                        end
                                        end
Line 2294... Line 2460...
                                    end
                                    end
                                    else if ((method == 0)) begin
                                    else if ((method == 0)) begin
                                        if ((cur_i < length)) begin
                                        if ((cur_i < length)) begin
                                            oaddr <= do;
                                            oaddr <= do;
                                            obyte <= b3;
                                            obyte <= b3;
                                            MYHDL73_adv(8);
                                            MYHDL77_adv(8);
                                            cur_i <= (cur_i + 1);
                                            cur_i <= (cur_i + 1);
                                            do <= (do + 1);
                                            do <= (do + 1);
                                            o_oprogress <= (do + 1);
                                            o_oprogress <= (do + 1);
                                        end
                                        end
                                        else if ((!final)) begin
                                        else if ((!final)) begin
Line 2308... Line 2474...
                                            o_oprogress <= do;
                                            o_oprogress <= do;
                                            o_done <= 1'b1;
                                            o_done <= 1'b1;
                                            state <= 5'b00000;
                                            state <= 5'b00000;
                                        end
                                        end
                                    end
                                    end
                                    else if ((cur_i < (length + 1))) begin
                                    else if ((cur_i < (length + 2))) begin
                                        oraddr <= (offset + cur_i);
                                        oraddr <= (offset + cur_i);
                                        if ((cur_i == 1)) begin
                                        if ((cur_i == 1)) begin
                                            copy1 <= orbyte;
                                            copy1 <= orbyte;
                                        end
                                        end
 
                                        if ((cur_i == 3)) begin
 
                                            copy2 <= orbyte;
 
                                        end
                                        if ((cur_i > 1)) begin
                                        if ((cur_i > 1)) begin
                                            if (((offset + cur_i) == (do + 1))) begin
                                            if (((offset + cur_i) == (do + 1))) begin
                                                obyte <= copy1;
                                                obyte <= copy1;
                                            end
                                            end
                                            else begin
                                            else begin
 
                                                if (((cur_i == 3) || ((offset + cur_i) != do))) begin
                                                obyte <= orbyte;
                                                obyte <= orbyte;
                                            end
                                            end
                                            oaddr <= do;
                                                else begin
                                            o_oprogress <= (do + 1);
                                                    if ((cur_i > 2)) begin
                                            do <= (do + 1);
                                                        if ((cur_i & 1)) begin
                                        end
                                                            obyte <= copy2;
                                        cur_i <= (cur_i + 1);
 
                                    end
                                    end
                                    else begin
                                    else begin
                                        oaddr <= do;
 
                                        if (((offset + cur_i) == (do + 1))) begin
 
                                            obyte <= copy1;
                                            obyte <= copy1;
                                        end
                                        end
 
                                                    end
                                        else begin
                                        else begin
                                            obyte <= orbyte;
                                                        obyte <= copy1;
                                        end
                                        end
                                        do <= (do + 1);
                                                end
 
                                            end
 
                                            oaddr <= do;
                                        o_oprogress <= (do + 1);
                                        o_oprogress <= (do + 1);
 
                                            do <= (do + 1);
 
                                        end
 
                                        cur_i <= (cur_i + 1);
 
                                    end
 
                                    else begin
                                        cur_next <= 0;
                                        cur_next <= 0;
                                        state <= 5'b10011;
                                        state <= 5'b10011;
                                    end
                                    end
                                end
                                end
                                else begin
                                else begin
Line 2356... Line 2531...
    end
    end
end
end
 
 
 
 
always @(posedge clk) begin: DEFLATE_FILL_BUF
always @(posedge clk) begin: DEFLATE_FILL_BUF
 
    integer shift;
    if ((!reset)) begin
    if ((!reset)) begin
        $write("FILL RESET");
        $write("FILL RESET");
        $write("\n");
        $write("\n");
        nb <= 0;
        nb <= 0;
        b1 <= 0;
        b1 <= 0;
        b2 <= 0;
        b2 <= 0;
        b3 <= 0;
        b3 <= 0;
        b4 <= 0;
        b4 <= 0;
 
        old_di <= 0;
    end
    end
    else begin
    else begin
        if ((isize < 4)) begin
        if ((isize < 4)) begin
            // pass
            // pass
        end
        end
        else if (((i_mode == 4) || (i_mode == 5))) begin
        else if (((i_mode == 4) || (i_mode == 5))) begin
            nb <= 0;
            nb <= 0;
 
            old_di <= 0;
        end
        end
        else begin
        else begin
 
            // if do_compress:
 
            //     print("FILL", di, old_di, nb, b1, b2, b3, b4)
 
            if (1'b1) begin
 
                shift = (($signed({1'b0, di}) - $signed({1'b0, old_di})) * 8);
 
                // if shift != 0:
 
                //     print("shift", shift, cwindow, b1, b2, b3, b4)
 
                if ((shift <= 32)) begin
 
                    cwindow <= (($signed({1'b0, cwindow}) << shift) | $signed($signed({1'b0, b14}) >>> (32 - shift)));
 
                end
 
                else if ((shift == 40)) begin
 
                    cwindow <= ((($signed({1'b0, cwindow}) << shift) | (b14 << 8)) | b5);
 
                end
 
                else if (1'b1) begin
 
                    cwindow <= (($signed({1'b0, cwindow}) << shift) | $signed($signed({1'b0, b110}) >>> (80 - shift)));
 
                end
 
            end
 
            if ((old_di == di)) begin
            nb <= 4;
            nb <= 4;
 
            end
 
            old_di <= di;
            b1 <= iram[(di & 127)];
            b1 <= iram[(di & 127)];
            b2 <= iram[((di + 1) & 127)];
            b2 <= iram[((di + 1) & 127)];
            b3 <= iram[((di + 2) & 127)];
            b3 <= iram[((di + 2) & 127)];
            b4 <= iram[((di + 3) & 127)];
            b4 <= iram[((di + 3) & 127)];
 
            b5 <= iram[((di + 4) & 127)];
 
            if (1'b1) begin
 
                b6 <= iram[((di + 5) & 127)];
 
                b7 <= iram[((di + 6) & 127)];
 
                b8 <= iram[((di + 7) & 127)];
 
                b9 <= iram[((di + 8) & 127)];
 
                b10 <= iram[((di + 9) & 127)];
 
            end
        end
        end
    end
    end
end
end
 
 
 
 
Line 2393... Line 2598...
 
 
always @(posedge clk) begin: DEFLATE_ORAMREAD
always @(posedge clk) begin: DEFLATE_ORAMREAD
    orbyte <= oram[oraddr];
    orbyte <= oram[oraddr];
end
end
 
 
 
 
 
 
 
assign smatch[0] = ((({cwindow, b1, b2} >>> (8 * 0)) & 16777215) == (b14 >>> 8));
 
 
 
 
 
 
 
assign smatch[1] = ((({cwindow, b1, b2} >>> (8 * 1)) & 16777215) == (b14 >>> 8));
 
 
 
 
 
 
 
assign smatch[2] = ((({cwindow, b1, b2} >>> (8 * 2)) & 16777215) == (b14 >>> 8));
 
 
 
 
 
 
 
assign smatch[3] = ((({cwindow, b1, b2} >>> (8 * 3)) & 16777215) == (b14 >>> 8));
 
 
 
 
 
 
 
assign smatch[4] = ((({cwindow, b1, b2} >>> (8 * 4)) & 16777215) == (b14 >>> 8));
 
 
 
 
 
 
 
assign smatch[5] = ((({cwindow, b1, b2} >>> (8 * 5)) & 16777215) == (b14 >>> 8));
 
 
 
 
 
 
 
assign smatch[6] = ((({cwindow, b1, b2} >>> (8 * 6)) & 16777215) == (b14 >>> 8));
 
 
 
 
 
 
 
assign smatch[7] = ((({cwindow, b1, b2} >>> (8 * 7)) & 16777215) == (b14 >>> 8));
 
 
 
 
 
 
 
assign smatch[8] = ((({cwindow, b1, b2} >>> (8 * 8)) & 16777215) == (b14 >>> 8));
 
 
 
 
 
 
 
assign smatch[9] = ((({cwindow, b1, b2} >>> (8 * 9)) & 16777215) == (b14 >>> 8));
 
 
 
 
 
 
 
assign smatch[10] = ((({cwindow, b1, b2} >>> (8 * 10)) & 16777215) == (b14 >>> 8));
 
 
 
 
 
 
 
assign smatch[11] = ((({cwindow, b1, b2} >>> (8 * 11)) & 16777215) == (b14 >>> 8));
 
 
 
 
 
 
 
assign smatch[12] = ((({cwindow, b1, b2} >>> (8 * 12)) & 16777215) == (b14 >>> 8));
 
 
 
 
 
 
 
assign smatch[13] = ((({cwindow, b1, b2} >>> (8 * 13)) & 16777215) == (b14 >>> 8));
 
 
 
 
 
 
 
assign smatch[14] = ((({cwindow, b1, b2} >>> (8 * 14)) & 16777215) == (b14 >>> 8));
 
 
 
 
 
 
 
assign smatch[15] = ((({cwindow, b1, b2} >>> (8 * 15)) & 16777215) == (b14 >>> 8));
 
 
 
 
 
 
 
assign smatch[16] = ((({cwindow, b1, b2} >>> (8 * 16)) & 16777215) == (b14 >>> 8));
 
 
 
 
 
 
 
assign smatch[17] = ((({cwindow, b1, b2} >>> (8 * 17)) & 16777215) == (b14 >>> 8));
 
 
 
 
 
 
 
assign smatch[18] = ((({cwindow, b1, b2} >>> (8 * 18)) & 16777215) == (b14 >>> 8));
 
 
 
 
 
 
 
assign smatch[19] = ((({cwindow, b1, b2} >>> (8 * 19)) & 16777215) == (b14 >>> 8));
 
 
 
 
 
 
 
assign smatch[20] = ((({cwindow, b1, b2} >>> (8 * 20)) & 16777215) == (b14 >>> 8));
 
 
 
 
 
 
 
assign smatch[21] = ((({cwindow, b1, b2} >>> (8 * 21)) & 16777215) == (b14 >>> 8));
 
 
 
 
 
 
 
assign smatch[22] = ((({cwindow, b1, b2} >>> (8 * 22)) & 16777215) == (b14 >>> 8));
 
 
 
 
 
 
 
assign smatch[23] = ((({cwindow, b1, b2} >>> (8 * 23)) & 16777215) == (b14 >>> 8));
 
 
 
 
 
 
 
assign smatch[24] = ((({cwindow, b1, b2} >>> (8 * 24)) & 16777215) == (b14 >>> 8));
 
 
 
 
 
 
 
assign smatch[25] = ((({cwindow, b1, b2} >>> (8 * 25)) & 16777215) == (b14 >>> 8));
 
 
 
 
 
 
 
assign smatch[26] = ((({cwindow, b1, b2} >>> (8 * 26)) & 16777215) == (b14 >>> 8));
 
 
 
 
 
 
 
assign smatch[27] = ((({cwindow, b1, b2} >>> (8 * 27)) & 16777215) == (b14 >>> 8));
 
 
 
 
 
 
 
assign smatch[28] = ((({cwindow, b1, b2} >>> (8 * 28)) & 16777215) == (b14 >>> 8));
 
 
 
 
 
 
 
assign smatch[29] = ((({cwindow, b1, b2} >>> (8 * 29)) & 16777215) == (b14 >>> 8));
 
 
 
 
 
 
 
assign smatch[30] = ((({cwindow, b1, b2} >>> (8 * 30)) & 16777215) == (b14 >>> 8));
 
 
 
 
 
 
 
assign smatch[31] = ((({cwindow, b1, b2} >>> (8 * 31)) & 16777215) == (b14 >>> 8));
 
 
endmodule
endmodule
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

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