soc: support constants without value
authorSebastien Bourdeauducq <sb@m-labs.hk>
Sun, 28 Jun 2015 19:35:37 +0000 (21:35 +0200)
committerSebastien Bourdeauducq <sb@m-labs.hk>
Sun, 28 Jun 2015 19:35:37 +0000 (21:35 +0200)
misoclib/soc/__init__.py
misoclib/soc/cpuif.py

index 217ce1378eaa78cb86fc935a4282b5fe0b1c13f4..ef7c454549c2d3d23d216114eeb9a1ab8bc8f608 100644 (file)
@@ -165,7 +165,7 @@ class SoC(Module):
     def get_csr_regions(self):
         return self._csr_regions
 
-    def add_constant(self, name, value):
+    def add_constant(self, name, value=None):
         self._constants.append((name, value))
 
     def get_constants(self):
index 626bdd603eb8183ac00be21bdce2021c321850ab..256612f02f26f2cc0739613220d4baed188bf4a4 100644 (file)
@@ -92,7 +92,10 @@ def get_csr_header(regions, constants, with_access_functions=True):
 
     r += "\n/* constants */\n"
     for name, value in constants:
-        r += "#define " + name + " " + str(value) + "\n"
+        r += "#define " + name
+        if value is not None:
+            r += " " + str(value)
+        r += "\n"
 
     r += "\n#endif\n"
     return r