Commit 3e02afed authored by Adam P. Goucher's avatar Adam P. Goucher

Better rulestring verification

parent 32e4151c
......@@ -4,14 +4,22 @@ from _iwriter import iwriter
family = 2
mantissa = {0, 1}
def number_of_states(rulestring):
return int(rulestring[1:rulestring.index('b')])
def bitplanes(rulestring):
bplanes = int(rulestring[1:rulestring.index('b')])
bplanes = 2 if (bplanes == 3) else len(bin(bplanes - 3))
return bplanes
nstates = number_of_states(rulestring)
return (2 if (nstates == 3) else len(bin(nstates - 3)))
def create_rule(rulestring):
nstates = number_of_states(rulestring)
if (nstates < 3):
raise ValueError("Number of states must be at least 3")
logstring = rulestring[rulestring.index('b'):]
for iset in [['sse2'], ['sse2', 'avx'], ['sse2', 'avx', 'avx2']]:
with open('ll_%s_%s.asm' % (iset[-1], logstring), 'w') as f:
......@@ -31,7 +39,7 @@ def create_rule(rulestring):
iw.write_function(rulestring, 20, 16)
iw.write_iterator()
gwrite_leaf_iterator(f, int(rulestring[1:rulestring.index('b')]))
gwrite_leaf_iterator(f, nstates)
f.write('}\n')
class genewriter(iwriter):
......@@ -99,8 +107,6 @@ def gwrite_leaf_iterator(f, nstates):
f.write(' carry &= outleaf[%d+i];\n' % (4 * i + 8))
if (c == '1'):
f.write(' outleaf[%d+i] |= outleaf2[i];\n' % (4 * i + 8))
# else:
# f.write(' outleaf[%d+i] &= outleaf2[i];\n' % (4 * i + 8))
f.write(' outleaf[4+i] ^= carry;\n')
for i, c in enumerate(br):
f.write(' outleaf[%d+i] ^= carry;\n' % (4 * i + 8))
......
......@@ -6,5 +6,5 @@
genus_list = []
genus_list.append({'name': 'lifelike', 'regex': 'b0?1?2?3?4?5?6?7?8?s0?1?2?3?4?5?6?7?8?'})
genus_list.append({'name': 'generations', 'regex': 'g[1-9][0-9]*b1?2?3?4?5?6?7?8?s0?1?2?3?4?5?6?7?8?'})
genus_list.append({'name': 'isotropic', 'regex': 'b[0-9ceaiknjqrytwz-]*s[0-9ceaiknjqrytwz-]*'})
genus_list.append({'name': 'isotropic', 'regex': 'b[1-9ceaiknjqrytwz-]*s[0-9ceaiknjqrytwz-]*'})
genus_list.append({'name': 'ltl', 'regex': 'r[234567]b[1-9][0-9]*t[1-9][0-9]*s[1-9][0-9]*t[1-9][0-9]*'})
......@@ -13,6 +13,9 @@ def mantissa(rulestring):
def create_rule(rulestring):
if ('b0' in rulestring) and (rulestring[-1] == '8'):
raise ValueError('B0 and S8 are incompatible; please invert states.')
logstring = rulestring[rulestring.index('b'):]
for iset in [['sse2'], ['sse2', 'avx'], ['sse2', 'avx', 'avx2']]:
with open('ll_%s_%s.asm' % (iset[-1], logstring), 'w') as f:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment