config: Clean up core timing model discovery
authorAndreas Sandberg <andreas.sandberg@arm.com>
Mon, 26 Jun 2017 15:18:56 +0000 (16:18 +0100)
committerAndreas Sandberg <andreas.sandberg@arm.com>
Mon, 3 Jul 2017 09:47:19 +0000 (09:47 +0000)
Instead of hard-coding timing models in CpuConfig.py, use
introspection to find them in the cores.arm model package.

Change-Id: I6642dc9cbc3f5beeeec748e716c9426c233d51ea
Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com>
Reviewed-by: Gabor Dozsa <gabor.dozsa@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/3944
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
Maintainer: Jason Lowe-Power <jason@lowepower.com>

configs/common/CpuConfig.py
configs/common/cores/arm/__init__.py

index 4def9fdda405a220de7079128b4be8fa2bf1df95..731ba4f2693b542214ba15ae4a00d9a1f4e39506 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (c) 2012 ARM Limited
+# Copyright (c) 2012, 2017 ARM Limited
 # All rights reserved.
 #
 # The license below extends only to copyright in the software and shall
@@ -110,28 +110,11 @@ def config_etrace(cpu_cls, cpu_list, options):
         fatal("%s does not support data dependency tracing. Use a CPU model of"
               " type or inherited from DerivO3CPU.", cpu_cls)
 
-# The ARM detailed CPU is special in the sense that it doesn't exist
-# in the normal object hierarchy, so we have to add it manually.
-try:
-    from cores.arm.O3_ARM_v7a import O3_ARM_v7a_3
-    _cpu_classes["O3_ARM_v7a_3"] = O3_ARM_v7a_3
-except:
-    pass
-
-# The calibrated ex5-model cores
-try:
-    from cores.arm.ex5_LITTLE import ex5_LITTLE
-    _cpu_classes["ex5_LITTLE"] = ex5_LITTLE
-except:
-    pass
-
-try:
-    from cores.arm.ex5_big import ex5_big
-    _cpu_classes["ex5_big"] = ex5_big
-except:
-    pass
-
-
 # Add all CPUs in the object hierarchy.
 for name, cls in inspect.getmembers(m5.objects, is_cpu_class):
     _cpu_classes[name] = cls
+
+import cores.arm
+for mod_name, module in inspect.getmembers(cores.arm, inspect.ismodule):
+    for name, cls in inspect.getmembers(module, is_cpu_class):
+        _cpu_classes[name] = cls
index 7a2173eab2ea559b5f3b74ebf0c57510c0a98cfd..96388f7319a0952daf9dedb7c4468e62d1222ac9 100644 (file)
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #
 # Authors: Andreas Sandberg
+
+from pkgutil import iter_modules
+from importlib import import_module
+
+_cpu_modules = [
+    name for _, name, ispkg in iter_modules(__path__) if not ispkg
+]
+
+for c in _cpu_modules:
+    import_module("." + c, package=__package__)
+
+__all__ = _cpu_modules