WIP: Replace fields in power_decoder with signals of the same name
authorMichael Nolan <mtnolan2640@gmail.com>
Mon, 30 Mar 2020 14:04:42 +0000 (10:04 -0400)
committerMichael Nolan <mtnolan2640@gmail.com>
Mon, 30 Mar 2020 14:06:53 +0000 (10:06 -0400)
src/soc/decoder/power_decoder.py
src/soc/decoder/power_fields.py

index 358372c7c0024ffcb5ab1572c331329e4f3e3ea5..f349e6bb7d34fa3c3f7b57de2515e74d98193b77 100644 (file)
@@ -229,7 +229,7 @@ class PowerDecoder(Elaboratable):
         return [self.opcode_in] + self.op.ports()
 
 
-class TopPowerDecoder(PowerDecoder, DecodeFields):
+class TopPowerDecoder(PowerDecoder):
     """TopPowerDecoder
 
     top-level hierarchical decoder for POWER ISA
@@ -239,11 +239,16 @@ class TopPowerDecoder(PowerDecoder, DecodeFields):
 
     def __init__(self, width, dec):
         PowerDecoder.__init__(self, width, dec)
-        DecodeFields.__init__(self, SignalBitRange, [self.opcode_in])
-        self.create_specs()
+        self.fields = DecodeFields(SignalBitRange, [self.opcode_in])
+        self.fields.create_specs()
         self.raw_opcode_in = Signal.like(self.opcode_in, reset_less=True)
         self.bigendian = Signal(reset_less=True)
 
+        for name in self.fields.common_fields:
+            value = getattr(self.fields, name)
+            sig = Signal(value[0:-1].shape(), reset_less=True, name=name)
+            setattr(self, name, sig)
+
     def elaborate(self, platform):
         m = PowerDecoder.elaborate(self, platform)
         comb = m.d.comb
@@ -254,6 +259,10 @@ class TopPowerDecoder(PowerDecoder, DecodeFields):
         l.reverse()
         raw_le = Cat(*l)
         comb += self.opcode_in.eq(Mux(self.bigendian, raw_be, raw_le))
+        for name in self.fields.common_fields:
+            value = getattr(self.fields, name)
+            sig = getattr(self, name)
+            comb += sig.eq(value[0:-1])
         return m
 
     def ports(self):
index 774af698a3a9b6ac3838701aeec63265127a2992..cf0544d2557cdadcd4ff4bed343c8584f82a72a5 100644 (file)
@@ -122,40 +122,43 @@ class DecodeFields:
         # now add in some commonly-used fields (should be done automatically)
         # note that these should only be ones which are the same on all Forms
         # note: these are from microwatt insn_helpers.vhdl
-        self.RS = self.FormX.RS
-        self.RT = self.FormX.RT
-        self.RA = self.FormX.RA
-        self.RB = self.FormX.RB
-        self.SI = self.FormD.SI
-        self.UI = self.FormD.UI
-        self.L = self.FormD.L
-        self.SH32 = self.FormM.SH
-        self.sh = self.FormMD.sh
-        self.MB32 = self.FormM.MB
-        self.ME32 = self.FormM.ME
-        self.LI = self.FormI.LI
-        self.LK = self.FormI.LK
-        self.AA = self.FormB.AA
-        self.Rc = self.FormX.Rc
-        self.OE = self.FormXO.Rc
-        self.BD = self.FormB.BD
-        self.BF = self.FormX.BF
-        self.CR = self.FormXL.XO # used by further mcrf decoding
-        self.BB = self.FormXL.BB
-        self.BA = self.FormXL.BA
-        self.BT = self.FormXL.BT
-        self.FXM = self.FormXFX.FXM
-        self.BO = self.FormXL.BO
-        self.BI = self.FormXL.BI
-        self.BH = self.FormXL.BH
-        self.D = self.FormD.D
-        self.DS = self.FormDS.DS
-        self.TO = self.FormX.TO
-        self.BC = self.FormA.BC
-        self.SH = self.FormX.SH
-        self.ME = self.FormM.ME
-        self.MB = self.FormM.MB
-        self.SPR = self.FormXFX.SPR
+        self.common_fields = {
+            "RS": self.FormX.RS,
+            "RT": self.FormX.RT,
+            "RA": self.FormX.RA,
+            "RB": self.FormX.RB,
+            "SI": self.FormD.SI,
+            "UI": self.FormD.UI,
+            "L": self.FormD.L,
+            "SH32": self.FormM.SH,
+            "sh": self.FormMD.sh,
+            "MB32": self.FormM.MB,
+            "ME32": self.FormM.ME,
+            "LI": self.FormI.LI,
+            "LK": self.FormI.LK,
+            "AA": self.FormB.AA,
+            "Rc": self.FormX.Rc,
+            "OE": self.FormXO.Rc,
+            "BD": self.FormB.BD,
+            "BF": self.FormX.BF,
+            "CR": self.FormXL.XO,
+            "BB": self.FormXL.BB,
+            "BA": self.FormXL.BA,
+            "BT": self.FormXL.BT,
+            "FXM": self.FormXFX.FXM,
+            "BO": self.FormXL.BO,
+            "BI": self.FormXL.BI,
+            "BH": self.FormXL.BH,
+            "D": self.FormD.D,
+            "DS": self.FormDS.DS,
+            "TO": self.FormX.TO,
+            "BC": self.FormA.BC,
+            "SH": self.FormX.SH,
+            "ME": self.FormM.ME,
+            "MB": self.FormM.MB,
+            "SPR": self.FormXFX.SPR}
+        for k, v in self.common_fields.items():
+            setattr(self, k, v)
 
     def decode_fields(self):
         with open(self.fname) as f: