summaryrefslogtreecommitdiff
path: root/src/systemc/utils/tracefile.cc
diff options
context:
space:
mode:
authorGabe Black <gabeblack@google.com>2018-09-20 02:57:54 -0700
committerGabe Black <gabeblack@google.com>2018-10-16 00:26:15 +0000
commit3d29513196e7d59e1b8f9da120089bac17e8771d (patch)
tree600c99d37f34fd7ec07b7221fb41f14848b4938c /src/systemc/utils/tracefile.cc
parenta503a24d97b29ef246330e95dab77669a0a4256c (diff)
downloadgem5-3d29513196e7d59e1b8f9da120089bac17e8771d.tar.xz
systemc: Implement general and VCD trace support.
This doesn't include WIF trace support, but does make allowances for adding it in the future. Change-Id: Ifb62f40a7d8a13e94463930a44ac4b1cf41e3009 Reviewed-on: https://gem5-review.googlesource.com/c/12826 Reviewed-by: Gabe Black <gabeblack@google.com> Maintainer: Gabe Black <gabeblack@google.com>
Diffstat (limited to 'src/systemc/utils/tracefile.cc')
-rw-r--r--src/systemc/utils/tracefile.cc69
1 files changed, 69 insertions, 0 deletions
diff --git a/src/systemc/utils/tracefile.cc b/src/systemc/utils/tracefile.cc
new file mode 100644
index 000000000..20091c307
--- /dev/null
+++ b/src/systemc/utils/tracefile.cc
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2018 Google, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Authors: Gabe Black
+ */
+
+#include "systemc/utils/tracefile.hh"
+
+#include <ctime>
+#include <iomanip>
+
+#include "base/logging.hh"
+#include "base/output.hh"
+#include "sim/core.hh"
+#include "systemc/ext/core/sc_main.hh"
+#include "systemc/ext/utils/functions.hh"
+
+namespace sc_gem5
+{
+
+TraceFile::TraceFile(const std::string &name) :
+ _os(simout.create(name, true, true)), timeUnitTicks(0),
+ timeUnitValue(1.0), timeUnitUnit(::sc_core::SC_PS), _traceDeltas(false)
+{}
+
+TraceFile::~TraceFile()
+{
+ simout.close(_os);
+}
+
+std::ostream &TraceFile::stream() { return *_os->stream(); }
+
+void
+TraceFile::set_time_unit(double d, ::sc_core::sc_time_unit tu)
+{
+ timeUnitValue = d;
+ timeUnitUnit = tu;
+}
+
+void
+TraceFile::finalizeTime()
+{
+ timeUnitTicks = ::sc_core::sc_time(timeUnitValue, timeUnitUnit).value();
+}
+
+} // namespace sc_gem5