From efc946018bf3a368d82500c36407a7f4cce7c37b Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Sun, 13 Mar 2022 15:26:14 +0000 Subject: [PATCH] add grevlut.py demo code --- openpower/sv/grevlut.py | 71 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 openpower/sv/grevlut.py diff --git a/openpower/sv/grevlut.py b/openpower/sv/grevlut.py new file mode 100644 index 000000000..3c4cd9279 --- /dev/null +++ b/openpower/sv/grevlut.py @@ -0,0 +1,71 @@ +def lut2(imm, a, b): + idx = b << 1 | a + return (imm>>idx) & 1 + +def dorow(imm8, step_i, chunk_size): + step_o = 0 + for j in range(64): + if (j&chunk_size) == 0: + imm = (imm8 & 0b1111) + else: + imm = (imm8>>4) + a = (step_i>>j)&1 + b = (step_i>>(j ^ chunk_size))&1 + res = lut2(imm, a, b) + #print(j, bin(imm), a, b, res) + step_o |= (res<