gen/fhdl: add Display for debug in simulation
authorFlorent Kermarrec <florent@enjoy-digital.fr>
Fri, 29 Apr 2016 21:03:43 +0000 (23:03 +0200)
committerFlorent Kermarrec <florent@enjoy-digital.fr>
Fri, 29 Apr 2016 21:03:43 +0000 (23:03 +0200)
litex/gen/fhdl/structure.py
litex/gen/fhdl/verilog.py

index 959b6ce99fc9b59bdeea548d616d9f9f8340d55b..60bd2b8bc1bb86fc83bc4e8af15faf8262abba37 100644 (file)
@@ -718,3 +718,8 @@ class _Fragment:
         self.specials |= other.specials
         self.clock_domains += other.clock_domains
         return self
+
+class Display:
+    def __init__(self, s, *args):
+        self.s = s
+        self.args = args
index 78a0aa88b648cc2315dde249721e5bb5137cac47..4a647dd1bcd8abbf273602d68f4dcc6622573c8f 100644 (file)
@@ -118,6 +118,15 @@ def _printexpr(ns, node):
 def _printnode(ns, at, level, node):
     if node is None:
         return ""
+    elif isinstance(node, Display):
+        s = "\"" + node.s + "\\r\""
+        for arg in node.args:
+            s += ", "
+            if isinstance(arg, Signal):
+                s += ns.get_name(arg)
+            else:
+                s += str(arg)
+        return "\t"*level + "$display(" + s + ");\n"
     elif isinstance(node, _Assign):
         if at == _AT_BLOCKING:
             assignment = " = "