From: Michael Nolan Date: Wed, 6 May 2020 14:43:27 +0000 (-0400) Subject: Add ability to patch generated isa files X-Git-Tag: div_pipeline~1373 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1a3fcbd9a4be0cd1bc53555340790d0506251ead;p=soc.git Add ability to patch generated isa files --- diff --git a/src/soc/decoder/isa/branch.patch b/src/soc/decoder/isa/branch.patch new file mode 100644 index 00000000..ac79f515 --- /dev/null +++ b/src/soc/decoder/isa/branch.patch @@ -0,0 +1,11 @@ +--- branch.py.orig 2020-05-06 10:27:17.096835546 -0400 ++++ branch.py 2020-05-06 10:27:40.353752508 -0400 +@@ -141,7 +141,7 @@ + M = 32 + if ~BO[2]: + CTR = CTR - 1 +- ctr_ok = BO[2] | (CTR[M:64] != 0) ^ BO[3] ++ ctr_ok = BO[2] | SelectableInt((CTR[M:64] != 0), bits=1) ^ BO[3] + cond_ok = BO[0] | ~(CR[BI + 32] ^ BO[1]) + if ctr_ok & cond_ok: + NIA = concat(LR[0:62], SelectableInt(value=0x0, bits=2)) diff --git a/src/soc/decoder/pseudo/pywriter.py b/src/soc/decoder/pseudo/pywriter.py index abdf9940..3cb6bef1 100644 --- a/src/soc/decoder/pseudo/pywriter.py +++ b/src/soc/decoder/pseudo/pywriter.py @@ -2,6 +2,8 @@ import os import sys +import shutil +import subprocess from soc.decoder.pseudo.pagereader import ISA from soc.decoder.power_pseudo import convert_to_python from soc.decoder.orderedset import OrderedSet @@ -86,6 +88,21 @@ class PyISAWriter(ISA): f.write(" %s_instrs = {}\n" % pagename) f.write(iinf) + def patch_if_needed(self, source): + isadir = get_isasrc_dir() + fname = os.path.join(isadir, "%s.py" % source) + patchname = os.path.join(isadir, "%s.patch" % source) + + try: + with open(patchname, 'r') as patch: + newfname = fname + '.orig' + shutil.copyfile(fname, newfname) + subprocess.check_call(['patch', fname], + stdin=patch) + except: + pass + + def write_isa_class(self): isadir = get_isasrc_dir() fname = os.path.join(isadir, "all.py") @@ -115,4 +132,5 @@ if __name__ == '__main__': sources = sys.argv[1:] for source in sources: isa.write_pysource(source) + isa.patch_if_needed(source) isa.write_isa_class()