source: trunk/symbol_table/div2_group_strms.py @ 2043

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

Added div2 pablo equations and demo. Worked out errors in prior version.

File size: 2.2 KB
Line 
1# demo
2import bitutil as pablo
3
4class Groups():
5        starts = 0
6        ends = 0
7        ends_1_2 = 0
8        ends_3_4 = 0
9        ends_5_6 = 0
10        ends_7_8 = 0
11        ends_9_10 = 0
12        ends_11_12 = 0
13        ends_13_14 = 0
14        ends_15_16 = 0
15        ends_gte_17 = 0
16
17def Gen_lgth_groups(groups):
18
19        cursor = groups.starts
20        shift_or_ends = groups.ends | pablo.Advance(groups.ends)
21        temp = groups.ends
22
23        # Group symbols of length 1 and length 2
24        cursor = pablo.Advance(pablo.Advance(cursor))
25        groups.ends_1_2 = cursor & shift_or_ends
26        temp = temp &~ groups.ends_1_2
27
28        # Group symbols of length 3 and length 4
29        cursor = pablo.Advance(pablo.Advance(cursor &~ shift_or_ends))
30        groups.ends_3_4 = cursor & shift_or_ends
31        temp = temp &~ groups.ends_3_4
32
33        # Group symbols of length 5 and length 6
34        cursor = pablo.Advance(pablo.Advance(cursor &~ shift_or_ends))
35        groups.ends_5_6 = cursor & shift_or_ends
36        temp = temp &~ groups.ends_5_6
37
38        # Group symbols of length 7 and length 8
39        cursor = pablo.Advance(pablo.Advance(cursor &~ shift_or_ends))
40        groups.ends_7_8 = cursor & shift_or_ends
41        temp = temp &~ groups.ends_7_8
42
43        # Group symbols of length 9 and length 10
44        cursor = pablo.Advance(pablo.Advance(cursor &~ shift_or_ends))
45        groups.ends_9_10 = cursor & shift_or_ends
46        temp = temp &~ groups.ends_9_10
47
48        # Group symbols of length 11 and length 12
49        cursor = pablo.Advance(pablo.Advance(cursor &~ shift_or_ends))
50        groups.ends_11_12 = cursor & shift_or_ends
51        temp = temp &~ groups.ends_11_12
52
53        # Group symbols of length 13 and length 14
54        cursor = pablo.Advance(pablo.Advance(cursor &~ shift_or_ends))
55        groups.ends_13_14 = cursor & shift_or_ends
56        temp = temp &~ groups.ends_13_14
57
58        # Group symbols of length 15 and length 16
59        cursor = pablo.Advance(pablo.Advance(cursor &~ shift_or_ends))
60        groups.ends_15_16 = cursor & shift_or_ends
61        temp = temp &~ groups.ends_15_16
62
63        # Group symbols of length greater than equal to 17
64        groups.ends_gte_17 = temp
65
66def Main(groups):
67        Gen_lgth_groups(groups)
Note: See TracBrowser for help on using the repository browser.