From 9d70ef40b5e6a73ed5011bd7fe48b24f97e4c9f4 Mon Sep 17 00:00:00 2001
From: Yaman Umuroglu <maltanar@gmail.com>
Date: Fri, 1 May 2020 21:11:11 +0100
Subject: [PATCH] [Util] add helper fxn to get rtlsim trace depth setting

---
 src/finn/util/basic.py | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/finn/util/basic.py b/src/finn/util/basic.py
index 4eb0e6cb8..bc413bf66 100644
--- a/src/finn/util/basic.py
+++ b/src/finn/util/basic.py
@@ -44,6 +44,19 @@ pynq_part_map["Pynq-Z2"] = "xc7z020clg400-1"
 pynq_part_map["ZCU104"] = "xczu7ev-ffvc1156-2-e"
 
 
+def get_rtlsim_trace_depth():
+    """Return the trace depth for rtlsim via PyVerilator. Controllable
+    via the RTLSIM_TRACE_DEPTH environment variable. If the env.var. is
+    undefined, the default value of 1 is returned. A trace depth of 1
+    will only show top-level signals and yield smaller .vcd files.
+    """
+
+    try:
+        return int(os.environ["RTLSIM_TRACE_DEPTH"])
+    except KeyError:
+        return 1
+
+
 def get_num_default_workers():
     """Return the number of workers for parallel transformations. Controllable
     via the NUM_DEFAULT_WORKERS environment variable. If the env.var. is
-- 
GitLab