From: Luke Kenneth Casson Leighton Date: Sat, 4 Apr 2020 12:52:03 +0000 (+0100) Subject: add "op_" prefix to function names to avoid use of python keywords X-Git-Tag: div_pipeline~1536 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=11363547c27d0d011ac97cbe98747c2cf6310c22;p=soc.git add "op_" prefix to function names to avoid use of python keywords --- diff --git a/src/soc/decoder/pseudo/pywriter.py b/src/soc/decoder/pseudo/pywriter.py index 600c1123..340a8cc9 100644 --- a/src/soc/decoder/pseudo/pywriter.py +++ b/src/soc/decoder/pseudo/pywriter.py @@ -51,7 +51,9 @@ class PyISAWriter(ISA): args = create_args(regs, 'self') # create list of arguments to return retargs = create_args(rused['write_regs']) - f.write(" def %s(%s):\n" % (page.replace(".", "_"), args)) + # write out function. pre-pend "op_" because some instrs are + # also python keywords (cmp). also replace "." with "_" + f.write(" def op_%s(%s):\n" % (page.replace(".", "_"), args)) pycode = pycode.split("\n") pycode = '\n'.join(map(lambda x: " %s" % x, pycode)) pycode = pycode.rstrip() @@ -61,10 +63,10 @@ class PyISAWriter(ISA): else: f.write("\n") # accumulate the instruction info - iinfo = "(%s, %s, %s, %s)" % \ + iinfo = "(op_%s, %s, %s, %s)" % \ (page, rused['read_regs'], rused['uninit_regs'], rused['write_regs']) - iinf += " instrs['%s'] = %s\n" % (pagename, iinfo) + iinf += " instrs['%s'] = %s\n" % (page, iinfo) # write out initialisation of info, for ISACaller to use f.write(" instrs = {}\n") f.write(iinf)