source: trunk/symbol_table/div2_logbase2_group_strms.py @ 2103

Last change on this file since 2103 was 2103, checked in by ksherdy, 7 years ago

Updated symbol table to represent group 0 as the arbitrary length group.

File size: 1.8 KB
RevLine 
[2098]1import bitutil as pablo
2
3class Groups():
4        starts = 0
5        follows = 0
6        follows_2 = 0
7        follows_4 = 0
8        follows_6 = 0
9        follows_8 = 0
10        follows_16 = 0
[2103]11        follows_0 = 0
[2098]12
13def Gen_lgth_groups(groups):
14
[2101]15        ### Div2 Strategy ###
16        follows_gt_0 = groups.follows
17        follows_mask_1_2 = pablo.Advance(groups.starts) | pablo.Advance(pablo.Advance(groups.starts))
[2098]18
[2101]19        # Groups symbols of length 1 and length 2
20        groups.follows_2 = follows_gt_0 & follows_mask_1_2
21        follows_gt_2 = follows_gt_0 &~ follows_mask_1_2
22        follows_mask_3_4 = pablo.Advance(pablo.Advance(follows_mask_1_2))
[2098]23
[2101]24        # Groups symbols of length 3 and length 4
25        groups.follows_4 = follows_gt_2 & follows_mask_3_4
26        follows_gt_4 = follows_gt_2 &~ follows_mask_3_4
27        follows_mask_5_6 = pablo.Advance(pablo.Advance(follows_mask_3_4))
[2098]28
[2101]29        # Groups symbols of length 5 and length 6
30        groups.follows_6 = follows_gt_4 & follows_mask_5_6
31        follows_gt_6 = follows_gt_4 &~ follows_mask_5_6
32        follows_mask_7_8 = pablo.Advance(pablo.Advance(follows_mask_5_6))
[2098]33
[2101]34        # Groups symbols of length 7 and length 8
35        groups.follows_8 = follows_gt_6 & follows_mask_7_8
36        follows_gt_8 = follows_gt_6 &~ follows_mask_7_8
[2098]37
[2101]38        ### Log2 Strategy ###
[2103]39        # Groups symbols of length 9 to length 16
40
41        follows_mask_1_8 = (follows_mask_1_2 | follows_mask_3_4 | follows_mask_5_6 | follows_mask_7_8)
[2101]42        # Naive Advance
43        follows_mask_9_16 = pablo.Advance(pablo.Advance(pablo.Advance(pablo.Advance(pablo.Advance(pablo.Advance(pablo.Advance(pablo.Advance(follows_mask_1_8))))))))
44        groups.follows_16 = follows_gt_8 & follows_mask_9_16
[2098]45
[2101]46        # Advance 32 and Interpose
[2103]47        #temp32 = pablo.Advance32 (follows_mask_1_8)
48        #groups.follows_16 = follows_gt_8 & interpose32 (follows_mask_1_8, temp32, 8)
[2098]49
[2103]50        follows_gt_16 = follows_gt_8 &~ groups.follows_16
[2098]51
[2101]52        # Groups symbols of length greater than 16
[2103]53        groups.follows_0 = follows_gt_16
[2098]54
55def Main(groups):
56        Gen_lgth_groups(groups)
Note: See TracBrowser for help on using the repository browser.