clean up DivPipeCoreConfig API
authorJacob Lifshay <programmerjake@gmail.com>
Mon, 13 Jul 2020 02:45:11 +0000 (19:45 -0700)
committerJacob Lifshay <programmerjake@gmail.com>
Mon, 13 Jul 2020 02:45:11 +0000 (19:45 -0700)
src/ieee754/div_rem_sqrt_rsqrt/core.py

index c407626603de89602a84ebed4016d3fc16f3f00f..e2042cfd6f42d3c0ce0cf049de065010c92004b1 100644 (file)
@@ -69,14 +69,17 @@ class DivPipeCoreConfig:
         self.fract_width = fract_width
         self.log2_radix = log2_radix
         if supported is None:
-            supported = [DP.SqrtRem, DP.UDivRem, DP.RSqrtRem]
+            supported = frozenset(DP)
+        else:
+            supported = frozenset(supported)
         self.supported = supported
         print(f"{self}: n_stages={self.n_stages}")
 
     def __repr__(self):
         """ Get repr. """
         return f"DivPipeCoreConfig({self.bit_width}, " \
-            + f"{self.fract_width}, {self.log2_radix})"
+            + f"{self.fract_width}, {self.log2_radix}, "\
+            + f"supported={self.supported})"
 
     @property
     def n_stages(self):
@@ -150,7 +153,7 @@ class DivPipeCoreInterstageData:
         """ Create a ``DivPipeCoreInterstageData`` instance. """
         self.core_config = core_config
         bw = core_config.bit_width
-        if core_config.supported == [DP.UDivRem]:
+        if core_config.supported == {DP.UDivRem}:
             self.compare_len = bw * 2
         else:
             self.compare_len = bw * 3
@@ -197,7 +200,7 @@ class DivPipeCoreOutputData:
         """ Create a ``DivPipeCoreOutputData`` instance. """
         self.core_config = core_config
         bw = core_config.bit_width
-        if core_config.supported == [DP.UDivRem]:
+        if core_config.supported == {DP.UDivRem}:
             self.compare_len = bw * 2
         else:
             self.compare_len = bw * 3
@@ -225,7 +228,7 @@ class DivPipeCoreSetupStage(Elaboratable):
         self.i = self.ispec()
         self.o = self.ospec()
         bw = core_config.bit_width
-        if core_config.supported == [DP.UDivRem]:
+        if core_config.supported == {DP.UDivRem}:
             self.compare_len = bw * 2
         else:
             self.compare_len = bw * 3
@@ -281,7 +284,7 @@ class Trial(Elaboratable):
         self.current_shift = current_shift
         self.log2_radix = log2_radix
         bw = core_config.bit_width
-        if core_config.supported == [DP.UDivRem]:
+        if core_config.supported == {DP.UDivRem}:
             self.compare_len = bw * 2
         else:
             self.compare_len = bw * 3
@@ -370,7 +373,7 @@ class DivPipeCoreCalculateStage(Elaboratable):
         assert stage_index in range(core_config.n_stages)
         self.core_config = core_config
         bw = core_config.bit_width
-        if core_config.supported == [DP.UDivRem]:
+        if core_config.supported == {DP.UDivRem}:
             self.compare_len = bw * 2
         else:
             self.compare_len = bw * 3