source: trunk/symbol_table/log2_group_strms.py @ 2067

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

Set up log2 Makefile, Macro, derived class...

File size: 1.7 KB
Line 
1# demo
2import bitutil as pablo
3
4class Groups():
5        starts = 0
6        ends = 0
7        ends_1 = 0
8        ends_2 = 0
9        ends_4 = 0
10        ends_8 = 0
11        ends_16 = 0
12        ends_gte_17 = 0
13
14def Gen_lgth_groups(groups):
15
16    starts = groups.starts
17    remaining_ends = groups.ends
18
19    # Group symbols of length 1
20    starts_1 = pablo.Advance(starts)
21    groups.ends_1 = starts_1 & remaining_ends
22    remaining_ends = remaining_ends & ~groups.ends_1
23
24    # Group symbols of length 2
25    starts_2 = pablo.Advance(starts_1)
26    groups.ends_2 = starts_2 & remaining_ends
27    remaining_ends = remaining_ends & ~groups.ends_2
28
29    # Group symbols of length 3 to 4
30    temp = starts_1 | starts_2
31    #temp32 = pablo.Advance32(temp)
32    starts_3_to_4 = pablo.Advance(pablo.Advance(temp))
33    #starts_3_to_4 = interpose32 (temp, temp32, 2)
34    groups.ends_4 = starts_3_to_4 & remaining_ends
35    remaining_ends = remaining_ends & ~groups.ends_4
36
37    # Group symbols of length 5 to 8
38    temp = temp | starts_3_to_4
39    #temp32 = pablo.Advance32(temp)
40    starts_5_to_8 = pablo.Advance(pablo.Advance(pablo.Advance(pablo.Advance(temp))))
41    #starts_5_to_8 = interpose32 (temp, temp32, 4)
42    groups.ends_8 = starts_5_to_8 & remaining_ends
43    remaining_ends = remaining_ends & ~groups.ends_8
44
45    # Group symbols of length 9 to 16
46    temp = temp | starts_5_to_8
47    #temp32 = pablo.Advance32 (temp)
48    starts_9_16 = pablo.Advance(pablo.Advance(pablo.Advance(pablo.Advance(pablo.Advance(pablo.Advance(pablo.Advance(pablo.Advance(temp))))))))
49    #starts_9_16 = interpose32 (temp, temp32, 8)
50    groups.ends_16 = starts_9_16 & remaining_ends
51    remaining_ends = remaining_ends & ~groups.ends_16
52
53    # Group symbols of length 17 and longer
54    groups.ends_gte_17 = remaining_ends
55
56def Main(groups):
57        Gen_lgth_groups(groups)
Note: See TracBrowser for help on using the repository browser.