fhdl.structure: do not permit clock domain names that start with numbers
authorRobert Jordens <jordens@gmail.com>
Sun, 17 Aug 2014 20:56:33 +0000 (14:56 -0600)
committerSebastien Bourdeauducq <sb@m-labs.hk>
Mon, 18 Aug 2014 03:01:56 +0000 (11:01 +0800)
migen/fhdl/structure.py

index 4525266e6134b826ab0486a590f4ecd4f95abd0d..09342f544529eeeaf4bf4605233b3554bc85bb60 100644 (file)
@@ -511,8 +511,10 @@ class ClockDomain:
                self.name = tracer.get_obj_var_name(name)
                if self.name is None:
                        raise ValueError("Cannot extract clock domain name from code, need to specify.")
-               if len(self.name) > 3 and self.name[:3] == "cd_":
+               if self.name.startswith("cd_"):
                        self.name = self.name[3:]
+               if self.name[0].isdigit():
+                       raise ValueError("Clock domain name cannot start with a number.")
                self.clk = Signal(name_override=self.name + "_clk")
                if reset_less:
                        self.rst = None