From: Luke Kenneth Casson Leighton Date: Fri, 14 Feb 2020 11:16:41 +0000 (+0000) Subject: add code which prints tables for shift X-Git-Tag: convert-csv-opcode-to-binary~3428 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1ec12c6320e15562919057e476606ef41a109a85;p=libreriscv.git add code which prints tables for shift --- diff --git a/3d_gpu/architecture/dynamic_simd/shift.mdwn b/3d_gpu/architecture/dynamic_simd/shift.mdwn index a4be80f7c..337cd4b19 100644 --- a/3d_gpu/architecture/dynamic_simd/shift.mdwn +++ b/3d_gpu/architecture/dynamic_simd/shift.mdwn @@ -115,6 +115,43 @@ For o3: if p1&~p2: o3 |= a3b2[7:0] if p2: o3 |= a3b3[7:0] +Code that prints the above: + + def decoderange(col, k): + xs = (col-k)*8 + return "%d:%d" % (xs+7, xs) + + def decodelist(l): + res = [] + for (idx, sgn) in l: + sgn = " " if sgn else "~" + res.append("%sp%d" % (sgn, idx)) + return '&'.join(res) + + N = 4 + M = 4 + + for col in range(M): + r = decoderange(col, 0) + print "if True: o%d = a0b0[%s]" % (col, r) + for i in range(1,col+1): + l = [] + for j in range(i): + l.append([j, False]) + k = 0 + s = decodelist(l) + r = decoderange(col, i) + print "if %s: o%d |= a%db%d[%s]" % (s, col, i, k, r) + k += 1 + while l: + l[0][1] = True + s = decodelist(l) + r = decoderange(col, i) + print "if %s: o%d |= a%db%d[%s]" % (s, col, i, k, r) + k += 1 + del l[0] + print + ## Note One important part to remember is that the upper bits of the shift amount need to specifically *ignored* rather than assuming that they are zeros, this is because, for shift instructions: `a << b` actually is `a << (b % bit_len(a))`