aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/log.cc
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2016-08-09 19:56:10 +0200
committerClifford Wolf <clifford@clifford.at>2016-08-09 19:56:10 +0200
commit39da8eddaefc078c6f7aba9958c40daec69f33d4 (patch)
tree4abe3329ff31c5f4dd98c3489ede788ff424411c /kernel/log.cc
parent3c6d31fd061fb591a95b08ecfd1d2e50690dfc48 (diff)
downloadyosys-39da8eddaefc078c6f7aba9958c40daec69f33d4.tar.gz
yosys-39da8eddaefc078c6f7aba9958c40daec69f33d4.tar.bz2
yosys-39da8eddaefc078c6f7aba9958c40daec69f33d4.zip
Added log_const() API
Diffstat (limited to 'kernel/log.cc')
-rw-r--r--kernel/log.cc18
1 files changed, 18 insertions, 0 deletions
diff --git a/kernel/log.cc b/kernel/log.cc
index 12dc453dc..229b82746 100644
--- a/kernel/log.cc
+++ b/kernel/log.cc
@@ -414,6 +414,24 @@ const char *log_signal(const RTLIL::SigSpec &sig, bool autoint)
}
}
+const char *log_const(const RTLIL::Const &value, bool autoint)
+{
+ if ((value.flags & RTLIL::CONST_FLAG_STRING) == 0)
+ return log_signal(value, autoint);
+
+ std::string str = "\"" + value.decode_string() + "\"";
+
+ if (string_buf.size() < 100) {
+ string_buf.push_back(str);
+ return string_buf.back().c_str();
+ } else {
+ if (++string_buf_index == 100)
+ string_buf_index = 0;
+ string_buf[string_buf_index] = str;
+ return string_buf[string_buf_index].c_str();
+ }
+}
+
const char *log_id(RTLIL::IdString str)
{
log_id_cache.insert(str);