import astor
import ast
-from soc.decoder.power_decoder import create_pdecode
-from nmigen.back.pysim import Simulator, Delay
+from openpower.decoder.power_decoder import create_pdecode
+from nmigen.sim import Simulator, Delay
from nmigen import Module, Signal
-from soc.decoder.pseudo.parser import GardenSnakeCompiler
-from soc.decoder.selectable_int import SelectableInt, selectconcat
-from soc.decoder.isa.caller import GPR, Mem
+from openpower.decoder.pseudo.parser import GardenSnakeCompiler
+from openpower.decoder.selectable_int import SelectableInt, selectconcat
+from openpower.decoder.isa.caller import GPR, Mem
####### Test code #######
RT <- 0x0001_a000_0000_0000
"""
-code = hextest
+SVSTATE_next = """
+SVSTATE_NEXT(5)
+"""
+
+logictest = """
+x <- (y * 5) + 3
+y <- (z + 5) * 3
+"""
+
+XLEN_test = """
+RA[XLEN:XLEN - 1]
+"""
+
+concat_test1 = """
+[0]*16
+"""
+
+concat_test2 = """
+[0]*(XLEN-16)
+"""
+
+concat_test3 = """
+[0]*XLEN
+"""
+
+assign_test = """
+prod[0:63] <- 5
+prod[0:XLEN-1] <- 5
+"""
+
+assign_test2 = """
+prod[0:XLEN-1] <- 5
+"""
+
+assign_test = """
+prod[0:XLEN-1] <- MULS((RA)[XLEN/2:XLEN-1], (RB)[XLEN/2:XLEN-1])
+RT[XLEN/2:XLEN-1] <- prod[0:(XLEN/2)-1]
+RT[0:(XLEN/2)-1] <- undefined(prod[0:(XLEN/2)-1])
+"""
+
+code = assign_test
+#code = concat_test3
+#code = concat_test1
+#code = XLEN_test
+#code = logictest
+#code = SVSTATE_next
+#code = hextest
#code = lswx
#code = testcond
#code = testdo
return hex(reg.value)
-def convert_to_python(pcode, form, incl_carry):
+def convert_to_pure_python(pcode, helper=False):
+
+ gsc = GardenSnakeCompiler(form=None, incl_carry=False, helper=helper)
+
+ tree = gsc.compile(pcode, mode="exec", filename="string")
+ tree = ast.fix_missing_locations(tree)
+ return astor.to_source(tree)
+
+
+def convert_to_python(pcode, form, incl_carry, helper=False):
print("form", form)
- gsc = GardenSnakeCompiler(form=form, incl_carry=incl_carry)
+ gsc = GardenSnakeCompiler(form=form, incl_carry=incl_carry, helper=helper)
tree = gsc.compile(pcode, mode="exec", filename="string")
tree = ast.fix_missing_locations(tree)
gsc.regfile = {}
for i in range(32):
gsc.regfile[i] = i
- gsc.gpr = GPR(gsc.parser.sd, gsc.regfile)
+ gsc.gpr = GPR(None, None, None, gsc.regfile)
gsc.mem = Mem()
_compile = gsc.compile
print("args", args)
print("-->", " ".join(map(str, args)))
- from soc.decoder.helpers import (EXTS64, EXTZ64, ROTL64, ROTL32, MASK,
+ from openpower.decoder.helpers import (EXTS64, EXTZ64, ROTL64, ROTL32, MASK,
trunc_div, trunc_rem)
d = {}