make LDSTException fields added from list of fieldnames
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Tue, 6 Oct 2020 15:05:36 +0000 (16:05 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Tue, 6 Oct 2020 15:05:36 +0000 (16:05 +0100)
src/soc/experiment/mem_types.py

index 2d7308585bd20fc759745d2b7b42444baf70b949..c0523483108030d0b8594fa6695f6ab9e7216943 100644 (file)
@@ -8,16 +8,13 @@ from nmigen import Signal
 
 # https://bugs.libre-soc.org/show_bug.cgi?id=465
 class LDSTException(RecordObject):
+    _exc_types = ['alignment', 'instr_fault', 'invalid', 'badtree',
+                 'perm_error', 'rc_error', 'segment_fault',]
     def __init__(self, name=None):
         RecordObject.__init__(self, name=name)
         self.happened = Signal()
-        self.alignment = Signal()
-        self.instr_fault = Signal()
-        self.invalid = Signal()
-        self.badtree = Signal()
-        self.perm_error = Signal()
-        self.rc_error = Signal()
-        self.segment_fault = Signal()
+        for f in self._exc_types:
+            setattr(self, f, Signal())
 
 
 class DCacheToLoadStore1Type(RecordObject):