SimObject: change naming of vectors so there are the same numbers of digits.
authorNathan Binkert <nate@binkert.org>
Sat, 6 Dec 2008 22:18:18 +0000 (14:18 -0800)
committerNathan Binkert <nate@binkert.org>
Sat, 6 Dec 2008 22:18:18 +0000 (14:18 -0800)
i.e. we used to have Foo0, Foo1, ..., Foo10, Foo11, ..., Foo100
now we have Foo000, Foo001, ..., Foo010, Foo011, ..., Foo100

src/python/m5/SimObject.py

index ac81582f35508da1e1b96b4156b030b418031c14..868f969a611846d469eebbd8fdd19bd2f31e305f 100644 (file)
@@ -27,7 +27,9 @@
 # Authors: Steve Reinhardt
 #          Nathan Binkert
 
-import sys, types
+import math
+import sys
+import types
 
 import proxy
 import m5
@@ -627,8 +629,9 @@ class SimObject(object):
             if len(value) == 1:
                 value[0]._maybe_set_parent(self, attr)
             else:
+                width = int(math.ceil(math.log(len(value))/math.log(10)))
                 for i,v in enumerate(value):
-                    v._maybe_set_parent(self, "%s%d" % (attr, i))
+                    v._maybe_set_parent(self, "%s%0*d" % (attr, width, i))
 
         self._values[attr] = value