source: trunk/symbol_table/pablo/div2_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: 2.0 KB
Line 
1# demo
2import bitutil as pablo
3
4class Groups():
5        starts = 0
6        follows = 0
7        follows_2 = 0
8        follows_4 = 0
9        follows_6 = 0
10        follows_8 = 0
11        follows_10 = 0
12        follows_12 = 0
13        follows_14 = 0
14        follows_16 = 0
15        follows_0 = 0
16
17def Gen_lgth_groups(markers, groups):
18
19        groups.starts = markers.starts
20        groups.follows = markers.follows
21
22        ### Div2 Strategy ###
23        follows_gt_0 = groups.follows
24        follows_mask_1_2 = pablo.Advance(groups.starts) | pablo.Advance(pablo.Advance(groups.starts))
25
26        # Groups symbols of length 1 and length 2
27        groups.follows_2 = follows_gt_0 & follows_mask_1_2
28        follows_gt_2 = follows_gt_0 &~ follows_mask_1_2
29        follows_mask_3_4 = pablo.Advance(pablo.Advance(follows_mask_1_2))
30
31        # Groups symbols of length 3 and length 4
32        groups.follows_4 = follows_gt_2 & follows_mask_3_4
33        follows_gt_4 = follows_gt_2 &~ follows_mask_3_4
34        follows_mask_5_6 = pablo.Advance(pablo.Advance(follows_mask_3_4))
35
36        # Groups symbols of length 5 and length 6
37        groups.follows_6 = follows_gt_4 & follows_mask_5_6
38        follows_gt_6 = follows_gt_4 &~ follows_mask_5_6
39        follows_mask_7_8 = pablo.Advance(pablo.Advance(follows_mask_5_6))
40
41        # Rinse and repeat
42        groups.follows_8 = follows_gt_6 & follows_mask_7_8
43        follows_gt_8 = follows_gt_6 &~ follows_mask_7_8
44        follows_mask_9_10 = pablo.Advance(pablo.Advance(follows_mask_7_8))
45
46        groups.follows_10 = follows_gt_8 & follows_mask_9_10
47        follows_gt_10 = follows_gt_8 &~ follows_mask_9_10
48        follows_mask_11_12 = pablo.Advance(pablo.Advance(follows_mask_9_10))
49
50        groups.follows_12 = follows_gt_10 & follows_mask_11_12
51        follows_gt_12 = follows_gt_10 &~ follows_mask_11_12
52        follows_mask_13_14 = pablo.Advance(pablo.Advance(follows_mask_11_12))
53
54        groups.follows_14 = follows_gt_12 & follows_mask_13_14
55        follows_gt_14 = follows_gt_12 &~ follows_mask_13_14
56        follows_mask_15_16 = pablo.Advance(pablo.Advance(follows_mask_13_14))
57
58        groups.follows_16 = follows_gt_14 & follows_mask_15_16
59        follows_gt_16 = follows_gt_14 &~ follows_mask_15_16
60
61        groups.follows_0 = follows_gt_16
62
63def Main(markers, groups):
64        Gen_lgth_groups(markers, groups)
Note: See TracBrowser for help on using the repository browser.