-
Notifications
You must be signed in to change notification settings - Fork 6
/
deflate.v
4326 lines (4155 loc) · 162 KB
/
deflate.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// File: deflate.v
// Generated by MyHDL 0.10
// Date: Fri Feb 8 15:30:19 2019
`timescale 1ns/10ps
module deflate (
i_mode,
o_done,
i_data,
o_iprogress,
o_oprogress,
o_byte,
i_waddr,
i_raddr,
clk,
reset
);
// Deflate (de)compress
//
// Ports:
input [2:0] i_mode;
output o_done;
reg o_done;
input [7:0] i_data;
output [23:0] o_iprogress;
reg [23:0] o_iprogress;
output [23:0] o_oprogress;
reg [23:0] o_oprogress;
output [7:0] o_byte;
reg [7:0] o_byte;
input [8:0] i_waddr;
input [8:0] i_raddr;
input clk;
input reset;
reg [18:0] wleaf;
reg [9:0] step;
reg static;
reg [4:0] state;
reg [18:0] stat_leaf;
reg [8:0] spread_i;
reg [9:0] spread;
reg [18:0] rleaf;
reg [14:0] reverse;
reg [3:0] rcount;
reg [1:0] prev_method;
reg [3:0] outcarrybits;
reg [8:0] outcarry;
reg [7:0] orbyte;
reg [8:0] oraddr;
reg [23:0] old_di;
reg [8:0] offset;
reg off2;
reg off1;
reg [7:0] obyte;
reg [7:0] ob1;
reg [8:0] oaddr;
reg [8:0] numLiterals;
reg [5:0] numDistance;
reg [8:0] numCodeLength;
reg nb;
reg [3:0] more;
reg [3:0] mlength;
reg [3:0] minBits;
reg [2:0] method;
reg [3:0] maxBits;
reg [14:0] lwaddr;
reg [14:0] lraddr;
reg [8:0] length;
reg [18:0] leaf;
reg [8:0] lastToken;
reg [15:0] ladler1;
reg [23:0] isize;
wire [7:0] irbyte;
reg [3:0] instantMaxBit;
reg [14:0] instantMask;
reg [8:0] howOften;
reg flush;
reg first_block;
reg final;
reg filled;
reg [3:0] fcount;
reg [18:0] dwleaf;
reg [18:0] drleaf;
reg [2:0] doo;
reg do_init;
reg do_compress;
reg [23:0] do;
reg [14:0] dlwaddr;
reg [14:0] dlraddr;
reg [9:0] dlength;
reg [2:0] dio;
reg [23:0] di;
reg [3:0] d_maxBits;
reg [3:0] d_instantMaxBit;
reg [14:0] d_instantMask;
reg [8:0] cur_static;
reg signed [24:0] cur_search;
reg [4:0] cur_next;
reg [23:0] cur_i;
reg signed [9:0] cur_dist;
reg [3:0] cur_cstatic;
reg [15:0] cur_HF1;
reg [7:0] copy2;
reg [7:0] copy1;
reg [14:0] code;
reg [3:0] bits;
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;
reg [7:0] b4;
reg [7:0] b3;
reg [7:0] b2;
wire [39:0] b15;
wire [31:0] b14;
wire [79:0] b110;
reg [7:0] b10;
reg [7:0] b1;
reg [15:0] adler2;
reg [15:0] adler1;
reg [255:0] cwindow;
reg [7:0] oram [0:512-1];
reg [15:0] nextCode [0:16-1];
reg [18:0] leaves [0:32768-1];
reg [7:0] iram [0:512-1];
reg [3:0] distanceLength [0:32-1];
reg [18:0] d_leaves [0:4096-1];
reg [3:0] codeLength [0:320-1];
reg [8:0] bitLengthCount [0:16-1];
wire smatch [0:32-1];
assign irbyte = 8'd0;
assign b41[32-1:24] = b4;
assign b41[24-1:16] = b3;
assign b41[16-1:8] = b2;
assign b41[8-1:0] = b1;
assign b15[40-1:32] = b1;
assign b15[32-1:24] = b2;
assign b15[24-1:16] = b3;
assign b15[16-1:8] = b4;
assign b15[8-1:0] = b5;
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;
function integer MYHDL39_get4;
input boffset;
input width;
begin: MYHDL109_RETURN
MYHDL39_get4 = ((b41 >>> (dio + boffset)) & ((1 << width) - 1));
disable MYHDL109_RETURN;
end
endfunction
function integer MYHDL40_get4;
input boffset;
input width;
integer width;
begin: MYHDL110_RETURN
MYHDL40_get4 = ((b41 >>> (dio + boffset)) & ((1 << width) - 1));
disable MYHDL110_RETURN;
end
endfunction
task MYHDL41_adv;
input width;
integer width;
integer nshift;
begin: MYHDL111_RETURN
if ((!1'b1)) begin
$finish;
end
nshift = ((dio + width) >>> 3);
o_iprogress <= di;
dio <= ((dio + width) & 7);
di <= ($signed({1'b0, di}) + nshift);
if ((nshift != 0)) begin
filled <= 1'b0;
end
end
endtask
task MYHDL42_adv;
input width;
integer width;
integer nshift;
begin: MYHDL112_RETURN
if ((!1'b1)) begin
$finish;
end
nshift = ((dio + width) >>> 3);
o_iprogress <= di;
dio <= ((dio + width) & 7);
di <= ($signed({1'b0, di}) + nshift);
if ((nshift != 0)) begin
filled <= 1'b0;
end
end
endtask
function integer MYHDL43_get4;
input boffset;
integer boffset;
input width;
integer width;
begin: MYHDL113_RETURN
MYHDL43_get4 = ($signed($signed({1'b0, b41}) >>> ($signed({1'b0, dio}) + boffset)) & ((1 << width) - 1));
disable MYHDL113_RETURN;
end
endfunction
task MYHDL44_adv;
input width;
integer width;
integer nshift;
begin: MYHDL114_RETURN
if ((!1'b1)) begin
$finish;
end
nshift = $signed(($signed({1'b0, dio}) + width) >>> 3);
o_iprogress <= di;
dio <= (($signed({1'b0, dio}) + width) & 7);
di <= ($signed({1'b0, di}) + nshift);
if ((nshift != 0)) begin
filled <= 1'b0;
end
end
endtask
task MYHDL45_adv;
input width;
integer width;
integer nshift;
begin: MYHDL115_RETURN
if ((!1'b1)) begin
$finish;
end
nshift = ((dio + width) >>> 3);
o_iprogress <= di;
dio <= ((dio + width) & 7);
di <= ($signed({1'b0, di}) + nshift);
if ((nshift != 0)) begin
filled <= 1'b0;
end
end
endtask
task MYHDL46_put;
input d;
integer d;
input width;
integer width;
reg pshift;
integer carry;
integer doo_next;
begin: MYHDL116_RETURN
if ((width > 9)) begin
$finish;
end
if (($signed({1'b0, d}) > ((1 << width) - 1))) begin
$finish;
end
obyte <= ((ob1 | (d << doo)) & 255);
oaddr <= do;
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
task MYHDL47_do_flush;
begin: MYHDL117_RETURN
flush <= 1'b0;
ob1 <= 0;
o_oprogress <= (do + 1);
do <= (do + 1);
end
endtask
task MYHDL48_put;
input d;
integer d;
input [4-1:0] width;
reg pshift;
integer carry;
integer doo_next;
begin: MYHDL118_RETURN
if ((width > 9)) begin
$finish;
end
if ((d > ((1 << width) - 1))) begin
$finish;
end
obyte <= (($signed({1'b0, ob1}) | (d << $signed({1'b0, doo}))) & 255);
oaddr <= do;
pshift = ((doo + width) > 8);
if (pshift) begin
carry = ($signed({1'b0, width}) - (8 - $signed({1'b0, doo})));
ob1 <= $signed(d >>> ($signed({1'b0, width}) - carry));
end
else begin
ob1 <= ($signed({1'b0, ob1}) | (d << $signed({1'b0, 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
task MYHDL49_do_flush;
begin: MYHDL119_RETURN
flush <= 1'b0;
ob1 <= 0;
o_oprogress <= (do + 1);
do <= (do + 1);
end
endtask
task MYHDL50_put;
input d;
integer d;
input [4-1:0] width;
reg pshift;
integer carry;
integer doo_next;
begin: MYHDL120_RETURN
if ((width > 9)) begin
$finish;
end
if ((d > ((1 << width) - 1))) begin
$finish;
end
obyte <= (($signed({1'b0, ob1}) | (d << $signed({1'b0, doo}))) & 255);
oaddr <= do;
pshift = ((doo + width) > 8);
if (pshift) begin
carry = ($signed({1'b0, width}) - (8 - $signed({1'b0, doo})));
ob1 <= $signed(d >>> ($signed({1'b0, width}) - carry));
end
else begin
ob1 <= ($signed({1'b0, ob1}) | (d << $signed({1'b0, 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
task MYHDL51_put;
input [9-1:0] d;
input [4-1:0] width;
reg pshift;
integer carry;
integer doo_next;
begin: MYHDL121_RETURN
if ((width > 9)) begin
$finish;
end
if (($signed({1'b0, d}) > ((1 << width) - 1))) begin
$finish;
end
obyte <= ((ob1 | (d << doo)) & 255);
oaddr <= do;
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 MYHDL52_rev_bits;
input [24-1:0] b;
input nb;
integer nb;
integer r;
begin: MYHDL122_RETURN
if ((b >= (1 << nb))) begin
$finish;
$write("too few bits");
$write("\n");
end
if ((nb > 15)) begin
$finish;
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 = r >>> (15 - $signed({1'b0, nb}));
MYHDL52_rev_bits = r;
disable MYHDL122_RETURN;
end
endfunction
task MYHDL53_put;
input d;
integer d;
input width;
integer width;
reg pshift;
integer carry;
integer doo_next;
begin: MYHDL123_RETURN
if ((width > 9)) begin
$finish;
end
if ((d > ((1 << width) - 1))) begin
$finish;
end
obyte <= (($signed({1'b0, ob1}) | (d << $signed({1'b0, doo}))) & 255);
oaddr <= do;
pshift = (($signed({1'b0, doo}) + width) > 8);
if (pshift) begin
carry = (width - (8 - $signed({1'b0, doo})));
ob1 <= $signed(d >>> (width - carry));
end
else begin
ob1 <= ($signed({1'b0, ob1}) | (d << $signed({1'b0, doo})));
end
do <= (do + pshift);
o_oprogress <= (do + pshift);
doo_next = (($signed({1'b0, doo}) + width) & 7);
if ((doo_next == 0)) begin
flush <= 1'b1;
end
doo <= doo_next;
end
endtask
task MYHDL54_put;
input d;
integer d;
input width;
integer width;
reg pshift;
integer carry;
integer doo_next;
begin: MYHDL124_RETURN
if ((width > 9)) begin
$finish;
end
if ((d > ((1 << width) - 1))) begin
$finish;
end
obyte <= (($signed({1'b0, ob1}) | (d << $signed({1'b0, doo}))) & 255);
oaddr <= do;
pshift = ((doo + width) > 8);
if (pshift) begin
carry = ($signed({1'b0, width}) - (8 - $signed({1'b0, doo})));
ob1 <= $signed(d >>> ($signed({1'b0, width}) - carry));
end
else begin
ob1 <= ($signed({1'b0, ob1}) | (d << $signed({1'b0, 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
task MYHDL57_put;
input d;
integer d;
input [4-1:0] width;
reg pshift;
integer carry;
integer doo_next;
begin: MYHDL125_RETURN
if ((width > 9)) begin
$finish;
end
if ((d > ((1 << width) - 1))) begin
$finish;
end
obyte <= (($signed({1'b0, ob1}) | (d << $signed({1'b0, doo}))) & 255);
oaddr <= do;
pshift = ((doo + width) > 8);
if (pshift) begin
carry = ($signed({1'b0, width}) - (8 - $signed({1'b0, doo})));
ob1 <= $signed(d >>> ($signed({1'b0, width}) - carry));
end
else begin
ob1 <= ($signed({1'b0, ob1}) | (d << $signed({1'b0, 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 MYHDL66_get4;
input boffset;
input width;
integer width;
begin: MYHDL126_RETURN
MYHDL66_get4 = ((b41 >>> (dio + boffset)) & ((1 << width) - 1));
disable MYHDL126_RETURN;
end
endfunction
function integer MYHDL67_get4;
input boffset;
input width;
integer width;
begin: MYHDL127_RETURN
MYHDL67_get4 = ((b41 >>> (dio + boffset)) & ((1 << width) - 1));
disable MYHDL127_RETURN;
end
endfunction
function integer MYHDL68_get4;
input boffset;
integer boffset;
input width;
integer width;
begin: MYHDL128_RETURN
MYHDL68_get4 = ((b41 >>> (dio + boffset)) & ((1 << width) - 1));
disable MYHDL128_RETURN;
end
endfunction
function integer MYHDL69_get4;
input boffset;
integer boffset;
input width;
integer width;
begin: MYHDL129_RETURN
MYHDL69_get4 = ((b41 >>> (dio + boffset)) & ((1 << width) - 1));
disable MYHDL129_RETURN;
end
endfunction
function integer MYHDL70_get4;
input boffset;
integer boffset;
input width;
integer width;
begin: MYHDL130_RETURN
MYHDL70_get4 = ((b41 >>> (dio + boffset)) & ((1 << width) - 1));
disable MYHDL130_RETURN;
end
endfunction
function integer MYHDL71_get4;
input boffset;
integer boffset;
input width;
integer width;
begin: MYHDL131_RETURN
MYHDL71_get4 = ((b41 >>> (dio + boffset)) & ((1 << width) - 1));
disable MYHDL131_RETURN;
end
endfunction
task MYHDL72_adv;
input width;
integer width;
integer nshift;
begin: MYHDL132_RETURN
if ((!1'b1)) begin
$finish;
end
nshift = ((dio + width) >>> 3);
o_iprogress <= di;
dio <= ((dio + width) & 7);
di <= ($signed({1'b0, di}) + nshift);
if ((nshift != 0)) begin
filled <= 1'b0;
end
end
endtask
function integer MYHDL73_get4;
input boffset;
input width;
integer width;
begin: MYHDL133_RETURN
MYHDL73_get4 = ((b41 >>> (dio + boffset)) & ((1 << width) - 1));
disable MYHDL133_RETURN;
end
endfunction
task MYHDL74_adv;
input width;
integer width;
integer nshift;
begin: MYHDL134_RETURN
if ((!1'b1)) begin
$finish;
end
nshift = ((dio + width) >>> 3);
o_iprogress <= di;
dio <= ((dio + width) & 7);
di <= ($signed({1'b0, di}) + nshift);
if ((nshift != 0)) begin
filled <= 1'b0;
end
end
endtask
function integer MYHDL75_get4;
input boffset;
input width;
integer width;
begin: MYHDL135_RETURN
MYHDL75_get4 = ((b41 >>> (dio + boffset)) & ((1 << width) - 1));
disable MYHDL135_RETURN;
end
endfunction
function integer MYHDL76_get4;
input boffset;
input width;
integer width;
begin: MYHDL136_RETURN
MYHDL76_get4 = ((b41 >>> (dio + boffset)) & ((1 << width) - 1));
disable MYHDL136_RETURN;
end
endfunction
function integer MYHDL77_get4;
input boffset;
input width;
integer width;
begin: MYHDL137_RETURN
MYHDL77_get4 = ((b41 >>> (dio + boffset)) & ((1 << width) - 1));
disable MYHDL137_RETURN;
end
endfunction
task MYHDL78_adv;
input width;
integer width;
integer nshift;
begin: MYHDL138_RETURN
if ((!1'b1)) begin
$finish;
end
nshift = ((dio + width) >>> 3);
o_iprogress <= di;
dio <= ((dio + width) & 7);
di <= ($signed({1'b0, di}) + nshift);
if ((nshift != 0)) begin
filled <= 1'b0;
end
end
endtask
function integer MYHDL83_rev_bits;
input [16-1:0] b;
input [4-1:0] nb;
integer r;
begin: MYHDL139_RETURN
if ((b >= (1 << nb))) begin
$finish;
$write("too few bits");
$write("\n");
end
if ((nb > 15)) begin
$finish;
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 = r >>> (15 - $signed({1'b0, nb}));
MYHDL83_rev_bits = r;
disable MYHDL139_RETURN;
end
endfunction
function integer MYHDL84_makeLeaf;
input [9-1:0] lcode;
input [4-1:0] lbits;
begin: MYHDL140_RETURN
if ((lcode >= (1 << 15))) begin
$finish;
end
if ((lbits >= (1 << 4))) begin
$finish;
end
MYHDL84_makeLeaf = ((lcode << 4) | lbits);
disable MYHDL140_RETURN;
end
endfunction
function integer MYHDL85_makeLeaf;
input [9-1:0] lcode;
input [4-1:0] lbits;
begin: MYHDL141_RETURN
if ((lcode >= (1 << 15))) begin
$finish;
end
if ((lbits >= (1 << 4))) begin
$finish;
end
MYHDL85_makeLeaf = ((lcode << 4) | lbits);
disable MYHDL141_RETURN;
end
endfunction
function integer MYHDL86_makeLeaf;
input [9-1:0] lcode;
input [4-1:0] lbits;
begin: MYHDL142_RETURN
if ((lcode >= (1 << 15))) begin
$finish;
end
if ((lbits >= (1 << 4))) begin
$finish;
end
MYHDL86_makeLeaf = ((lcode << 4) | lbits);
disable MYHDL142_RETURN;
end
endfunction
function integer MYHDL87_get4;
input boffset;
input [4-1:0] width;
begin: MYHDL143_RETURN
MYHDL87_get4 = ((b41 >>> (dio + boffset)) & ((1 << width) - 1));
disable MYHDL143_RETURN;
end
endfunction
function integer MYHDL88_get_bits;
input [19-1:0] aleaf;
begin: MYHDL144_RETURN
MYHDL88_get_bits = ($signed({1'b0, aleaf}) & ((1 << 4) - 1));
disable MYHDL144_RETURN;
end
endfunction
function integer MYHDL89_get4;
input boffset;
input [4-1:0] width;
begin: MYHDL145_RETURN
MYHDL89_get4 = ((b41 >>> (dio + boffset)) & ((1 << width) - 1));
disable MYHDL145_RETURN;
end
endfunction
function integer MYHDL90_get_bits;
input [19-1:0] aleaf;
begin: MYHDL146_RETURN
MYHDL90_get_bits = ($signed({1'b0, aleaf}) & ((1 << 4) - 1));
disable MYHDL146_RETURN;
end
endfunction
function integer MYHDL91_get_bits;
input [19-1:0] aleaf;
begin: MYHDL147_RETURN
MYHDL91_get_bits = ($signed({1'b0, aleaf}) & ((1 << 4) - 1));
disable MYHDL147_RETURN;
end
endfunction
task MYHDL92_adv;
input width;
integer width;
integer nshift;
begin: MYHDL148_RETURN
if ((!1'b1)) begin
$finish;
end
nshift = $signed(($signed({1'b0, dio}) + width) >>> 3);
o_iprogress <= di;
dio <= (($signed({1'b0, dio}) + width) & 7);
di <= ($signed({1'b0, di}) + nshift);
if ((nshift != 0)) begin
filled <= 1'b0;
end
end
endtask
function integer MYHDL93_get_code;
input [19-1:0] aleaf;
begin: MYHDL149_RETURN
MYHDL93_get_code = (aleaf >>> 4);
disable MYHDL149_RETURN;
end
endfunction
function integer MYHDL94_get4;
input boffset;
integer boffset;
input [4-1:0] width;
begin: MYHDL150_RETURN
MYHDL94_get4 = ($signed($signed({1'b0, b41}) >>> ($signed({1'b0, dio}) + boffset)) & ((1 << width) - 1));
disable MYHDL150_RETURN;
end
endfunction
function integer MYHDL95_get_bits;
input [19-1:0] aleaf;
begin: MYHDL151_RETURN
MYHDL95_get_bits = ($signed({1'b0, aleaf}) & ((1 << 4) - 1));
disable MYHDL151_RETURN;
end
endfunction
function integer MYHDL96_get4;
input boffset;
integer boffset;
input [4-1:0] width;
begin: MYHDL152_RETURN
MYHDL96_get4 = ($signed($signed({1'b0, b41}) >>> ($signed({1'b0, dio}) + boffset)) & ((1 << width) - 1));
disable MYHDL152_RETURN;
end
endfunction
function integer MYHDL97_get_bits;
input [19-1:0] aleaf;
begin: MYHDL153_RETURN
MYHDL97_get_bits = ($signed({1'b0, aleaf}) & ((1 << 4) - 1));
disable MYHDL153_RETURN;
end
endfunction
function integer MYHDL98_get4;
input boffset;
input width;
integer width;
begin: MYHDL154_RETURN
MYHDL98_get4 = ((b41 >>> (dio + boffset)) & ((1 << width) - 1));
disable MYHDL154_RETURN;
end
endfunction
function integer MYHDL99_get_code;
input [19-1:0] aleaf;
begin: MYHDL155_RETURN
MYHDL99_get_code = (aleaf >>> 4);
disable MYHDL155_RETURN;
end
endfunction
function integer MYHDL100_get_bits;
input [19-1:0] aleaf;
begin: MYHDL156_RETURN
MYHDL100_get_bits = ($signed({1'b0, aleaf}) & ((1 << 4) - 1));
disable MYHDL156_RETURN;
end
endfunction
function integer MYHDL101_get4;
input boffset;
integer boffset;
input width;
integer width;
begin: MYHDL157_RETURN
MYHDL101_get4 = ($signed($signed({1'b0, b41}) >>> ($signed({1'b0, dio}) + boffset)) & ((1 << width) - 1));
disable MYHDL157_RETURN;
end
endfunction
function integer MYHDL102_get_bits;
input [19-1:0] aleaf;
begin: MYHDL158_RETURN
MYHDL102_get_bits = ($signed({1'b0, aleaf}) & ((1 << 4) - 1));
disable MYHDL158_RETURN;
end
endfunction
task MYHDL103_adv;
input width;
integer width;
integer nshift;
begin: MYHDL159_RETURN
if ((!1'b1)) begin
$finish;
end
nshift = $signed(($signed({1'b0, dio}) + width) >>> 3);
o_iprogress <= di;
dio <= (($signed({1'b0, dio}) + width) & 7);
di <= ($signed({1'b0, di}) + nshift);
if ((nshift != 0)) begin
filled <= 1'b0;
end
end
endtask
function integer MYHDL104_get4;
input boffset;
input width;
integer width;
begin: MYHDL160_RETURN
MYHDL104_get4 = ((b41 >>> (dio + boffset)) & ((1 << width) - 1));
disable MYHDL160_RETURN;
end
endfunction
function integer MYHDL105_get4;
input boffset;
integer boffset;
input width;
integer width;
begin: MYHDL161_RETURN
MYHDL105_get4 = ($signed($signed({1'b0, b41}) >>> ($signed({1'b0, dio}) + boffset)) & ((1 << width) - 1));
disable MYHDL161_RETURN;
end
endfunction
function integer MYHDL106_rev_bits;
input b;
integer b;
input nb;
integer nb;
integer r;
begin: MYHDL162_RETURN
if ((b >= (1 << nb))) begin
$finish;
$write("too few bits");
$write("\n");
end
if ((nb > 15)) begin
$finish;
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 = r >>> (15 - $signed({1'b0, nb}));
MYHDL106_rev_bits = r;
disable MYHDL162_RETURN;
end
endfunction
function integer MYHDL107_get4;
input boffset;
integer boffset;
input width;
integer width;
begin: MYHDL163_RETURN
MYHDL107_get4 = ($signed($signed({1'b0, b41}) >>> ($signed({1'b0, dio}) + boffset)) & ((1 << width) - 1));
disable MYHDL163_RETURN;
end
endfunction
task MYHDL108_adv;
input width;
integer width;
integer nshift;
begin: MYHDL164_RETURN
if ((!1'b1)) begin
$finish;
end
nshift = $signed(($signed({1'b0, dio}) + width) >>> 3);
o_iprogress <= di;
dio <= (($signed({1'b0, dio}) + width) & 7);
di <= ($signed({1'b0, di}) + nshift);