source: trunk/symbol_table/pablo/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.8 KB
Line 
1import bitutil as pablo
2
3class Groups():
4        starts = 0
5        follows = 0
6        follows_1 = 0
7        follows_2 = 0
8        follows_4 = 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                starts = groups.starts
19                remaining_follows = groups.follows
20
21                # Group symbols of length 1
22                starts_1 = pablo.Advance(starts)
23                groups.follows_1 = starts_1 & remaining_follows
24                remaining_follows = remaining_follows & ~groups.follows_1
25
26                # Group symbols of length 2
27                starts_2 = pablo.Advance(starts_1)
28                groups.follows_2 = starts_2 & remaining_follows
29                remaining_follows = remaining_follows & ~groups.follows_2
30
31                # Group symbols of length 3 to 4
32                temp = starts_1 | starts_2
33                temp32 = pablo.Advance32(temp)
34                #starts_3_to_4 = pablo.Advance(pablo.Advance(temp))
35                starts_3_to_4 = interpose32 (temp, temp32, 2)
36                groups.follows_4 = starts_3_to_4 & remaining_follows
37                remaining_follows = remaining_follows & ~groups.follows_4
38
39                # Group symbols of length 5 to 8
40                temp = temp | starts_3_to_4
41                temp32 = pablo.Advance32(temp)
42                #starts_5_to_8 = pablo.Advance(pablo.Advance(pablo.Advance(pablo.Advance(temp))))
43                starts_5_to_8 = interpose32 (temp, temp32, 4)
44                groups.follows_8 = starts_5_to_8 & remaining_follows
45                remaining_follows = remaining_follows & ~groups.follows_8
46
47                # Group symbols of length 9 to 16
48                temp = temp | starts_5_to_8
49                temp32 = pablo.Advance32 (temp)
50                #starts_9_16 = pablo.Advance(pablo.Advance(pablo.Advance(pablo.Advance(pablo.Advance(pablo.Advance(pablo.Advance(pablo.Advance(temp))))))))
51                starts_9_16 = interpose32 (temp, temp32, 8)
52                groups.follows_16 = starts_9_16 & remaining_follows
53                remaining_follows = remaining_follows & ~groups.follows_16
54
55                # Group symbols of length 17 and longer
56                groups.follows_0 = remaining_follows
57
58def Main(markers, groups):
59                Gen_lgth_groups(markers, groups)
Note: See TracBrowser for help on using the repository browser.