source: trunk/symbol_table/pablo/logbase2_group_strms.py @ 2174

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

Moved pablo src to pablo dir.

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