add INT, SPR and CR regfiles
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Mon, 25 May 2020 13:43:15 +0000 (14:43 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Mon, 25 May 2020 13:43:21 +0000 (14:43 +0100)
src/soc/decoder/power_enums.py
src/soc/regfile/regfiles.py

index d8a78e992a243b0b1e083bb19cf8e33fa66feb73..05e23f8e8ee1f0bddc412c48f1cc08bf6fe6b6de 100644 (file)
@@ -267,3 +267,11 @@ XER_bits = {
     'OV32': 44,
     'CA32': 45
     }
+
+if __name__ == '__main__':
+    # find out what the heck is in SPR enum :)
+    print ("sprs", len(SPR))
+    print (dir(SPR))
+    print (dir(Enum))
+    for x in SPR:
+        print (x, x.value)
index b848ea47cb85ca3ba4987a9b99009657d1ef93fb..d6f3a8dd79930d1286c72a42328363d9b9b8e9f3 100644 (file)
@@ -17,3 +17,56 @@ Links:
 """
 
 # TODO
+
+from soc.regfile import RegFile, RegFileArray
+from soc.decoder.power_enums import SPR
+
+
+# Integer Regfile
+class IntRegs(RegFileArray):
+    """IntRegs
+
+    * QTY 32of 64-bit registers
+    * 3R1W
+    * Array-based unary-indexed (not binary-indexed)
+    * write-through capability (read on same cycle as write)
+    """
+    def __init__(self):
+        super().__init__(64, 32)
+        self.w_ports = [self.write_port("dest")]
+        self.r_ports = [self.write_port("src1"),
+                        self.write_port("src2"),
+                        self.write_port("src3")]
+
+
+# CR Regfile
+class CRRegs(RegFileArray):
+    """Condition Code Registers (CR0-7)
+
+    * QTY 8of 8-bit registers
+    * 8R8W (!) with additional 1R1W for the "full" width
+    * Array-based unary-indexed (not binary-indexed)
+    * write-through capability (read on same cycle as write)
+    """
+    def __init__(self):
+        super().__init__(4, 8)
+        self.w_ports = [self.write_port("dest")]
+        self.r_ports = [self.write_port("src1"),
+                        self.write_port("src2"),
+                        self.write_port("src3")]
+
+
+# SPR Regfile
+class SPRRegs(RegFile):
+    """SPRRegs
+
+    * QTY len(SPRs) 64-bit registers
+    * 1R1W
+    * binary-indexed but REQUIRES MAPPING
+    * write-through capability (read on same cycle as write)
+    """
+    def __init__(self):
+        n_sprs = len(SPR)
+        super().__init__(64, n_sprs)
+        self.w_ports = [self.write_port("dest")]
+        self.r_ports = [self.write_port("src")]