From: Jacob Lifshay Date: Sun, 5 Apr 2020 21:59:55 +0000 (-0700) Subject: Revert "rename fields.text to use standard .txt file extension and add to gitignore" X-Git-Tag: div_pipeline~1454 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2a17c51769a344128f406851d65116c478a19328;p=soc.git Revert "rename fields.text to use standard .txt file extension and add to gitignore" server doesn't work with .txt files This reverts commit 334c2ed237e3cb5fe66a782afaa2354d577841ba. --- diff --git a/src/soc/decoder/.gitignore b/src/soc/decoder/.gitignore index 32f35a3c..afed0735 100644 --- a/src/soc/decoder/.gitignore +++ b/src/soc/decoder/.gitignore @@ -1,2 +1 @@ *.csv -fields.txt diff --git a/src/soc/decoder/power_fields.py b/src/soc/decoder/power_fields.py index 6fd25085..e0c01427 100644 --- a/src/soc/decoder/power_fields.py +++ b/src/soc/decoder/power_fields.py @@ -5,14 +5,12 @@ from soc.decoder.power_enums import download_wiki_file class BitRange(OrderedDict): """BitRange: remaps from straight indices (0,1,2..) to bit numbers """ - def __getitem__(self, subscript): if isinstance(subscript, slice): return list(self)[subscript] else: return self[subscript] - def decode_instructions(form): res = {} accum = [] @@ -31,7 +29,6 @@ def decode_instructions(form): accum.append(l.strip()) return res - def decode_form_header(hdr): res = {} count = 0 @@ -45,7 +42,6 @@ def decode_form_header(hdr): count += len(f) + 1 return res - def find_unique(d, key): if key not in d: return key @@ -91,10 +87,10 @@ def decode_form(form): fields = {} falternate = {} for l in res: - for k, (start, end) in l.items(): + for k, (start,end) in l.items(): if k in fields: if (start, end) == fields[k]: - continue # already in and matching for this Form + continue # already in and matching for this Form if k in falternate: alternate = "%s_%d" % (k, falternate[k]) if (start, end) == fields[alternate]: @@ -108,7 +104,7 @@ def decode_form(form): class DecodeFields: - def __init__(self, bitkls=BitRange, bitargs=(), fname="fields.txt"): + def __init__(self, bitkls=BitRange, bitargs=(), fname="fields.text"): self.bitkls = bitkls self.bitargs = bitargs self.fname = download_wiki_file(fname) @@ -182,8 +178,8 @@ class DecodeFields: if not reading_data: assert l[0] == '#' heading = l[1:].strip() - # if heading.startswith('1.6.28'): # skip instr fields for now - # break + #if heading.startswith('1.6.28'): # skip instr fields for now + #break heading = heading.split(' ')[-1] reading_data = True forms[heading] = [] @@ -196,7 +192,7 @@ class DecodeFields: i = decode_instructions(form) for form, field in i.items(): inst[form] = self.decode_instruction_fields(field) - # else: + #else: # res[hdr] = decode_form(form) return res, inst @@ -224,7 +220,6 @@ class DecodeFields: return res - if __name__ == '__main__': dec = DecodeFields() dec.create_specs()