|
35 | 35 | ]
|
36 | 36 |
|
37 | 37 | o = Optimize()
|
38 |
| -offsets = [BitVec(f'o{i}', 32) for i in range(STATE_CNT)] |
39 |
| -trans_table = [BitVec(f't{i}', 32) for i in range(len(TRANSITIONS))] |
| 38 | +offsets = [BitVec(f"o{i}", 32) for i in range(STATE_CNT)] |
| 39 | +trans_table = [BitVec(f"t{i}", 32) for i in range(len(TRANSITIONS))] |
40 | 40 |
|
41 | 41 | # Add some guiding constraints to make solving faster.
|
42 | 42 | o.add(offsets[0] == 0)
|
43 | 43 | o.add(trans_table[-1] == 0)
|
44 | 44 |
|
45 | 45 | for i in range(len(offsets)):
|
46 |
| - o.add(offsets[i] < 32 - 5) # Do not over-shift. It's not necessary but makes solving faster. |
| 46 | + # Do not over-shift. It's not necessary but makes solving faster. |
| 47 | + o.add(offsets[i] < 32 - 5) |
47 | 48 | for j in range(i):
|
48 | 49 | o.add(offsets[i] != offsets[j])
|
49 | 50 | for trans, (targets, _) in zip(trans_table, TRANSITIONS):
|
|
54 | 55 | goal = Concat(*offsets, *trans_table)
|
55 | 56 | o.minimize(goal)
|
56 | 57 | print(o.check())
|
57 |
| -print('Offset[]= ', [o.model()[i].as_long() for i in offsets]) |
58 |
| -print('Transitions:') |
| 58 | +print("Offset[]= ", [o.model()[i].as_long() for i in offsets]) |
| 59 | +print("Transitions:") |
59 | 60 | for (_, label), v in zip(TRANSITIONS, [o.model()[i].as_long() for i in trans_table]):
|
60 |
| - print(f'{label:14} => {v:#10x}, // {v:032b}') |
| 61 | + print(f"{label:14} => {v:#10x}, // {v:032b}") |
61 | 62 |
|
62 | 63 | # Output should be deterministic:
|
63 | 64 | # sat
|
|
0 commit comments