rename fields.text to use standard .txt file extension and add to gitignore
authorJacob Lifshay <programmerjake@gmail.com>
Sun, 5 Apr 2020 21:52:41 +0000 (14:52 -0700)
committerJacob Lifshay <programmerjake@gmail.com>
Sun, 5 Apr 2020 21:52:41 +0000 (14:52 -0700)
src/soc/decoder/.gitignore
src/soc/decoder/power_fields.py

index afed0735dc96c6fc6a05ec52e959b8175f27cee5..32f35a3c028085c3a155c0102678d03481b74ac0 100644 (file)
@@ -1 +1,2 @@
 *.csv
+fields.txt
index e0c01427bf68398f55efd51be155c73d0ceffae8..6fd2508514d0b9bb3d282d34a84cc7f2ba8de1e7 100644 (file)
@@ -5,12 +5,14 @@ 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 = []
@@ -29,6 +31,7 @@ def decode_instructions(form):
             accum.append(l.strip())
     return res
 
+
 def decode_form_header(hdr):
     res = {}
     count = 0
@@ -42,6 +45,7 @@ def decode_form_header(hdr):
         count += len(f) + 1
     return res
 
+
 def find_unique(d, key):
     if key not in d:
         return key
@@ -87,10 +91,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]:
@@ -104,7 +108,7 @@ def decode_form(form):
 
 class DecodeFields:
 
-    def __init__(self, bitkls=BitRange, bitargs=(), fname="fields.text"):
+    def __init__(self, bitkls=BitRange, bitargs=(), fname="fields.txt"):
         self.bitkls = bitkls
         self.bitargs = bitargs
         self.fname = download_wiki_file(fname)
@@ -178,8 +182,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] = []
@@ -192,7 +196,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
 
@@ -220,6 +224,7 @@ class DecodeFields:
 
         return res
 
+
 if __name__ == '__main__':
     dec = DecodeFields()
     dec.create_specs()