source: trunk/symbol_table/pablo/div2_logbase2_group_strms.py @ 2185

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

Fixed template glue.

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