tracefile.cc revision 13245
113245Sgabeblack@google.com/* 213245Sgabeblack@google.com * Copyright 2018 Google, Inc. 313245Sgabeblack@google.com * 413245Sgabeblack@google.com * Redistribution and use in source and binary forms, with or without 513245Sgabeblack@google.com * modification, are permitted provided that the following conditions are 613245Sgabeblack@google.com * met: redistributions of source code must retain the above copyright 713245Sgabeblack@google.com * notice, this list of conditions and the following disclaimer; 813245Sgabeblack@google.com * redistributions in binary form must reproduce the above copyright 913245Sgabeblack@google.com * notice, this list of conditions and the following disclaimer in the 1013245Sgabeblack@google.com * documentation and/or other materials provided with the distribution; 1113245Sgabeblack@google.com * neither the name of the copyright holders nor the names of its 1213245Sgabeblack@google.com * contributors may be used to endorse or promote products derived from 1313245Sgabeblack@google.com * this software without specific prior written permission. 1413245Sgabeblack@google.com * 1513245Sgabeblack@google.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1613245Sgabeblack@google.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1713245Sgabeblack@google.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1813245Sgabeblack@google.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 1913245Sgabeblack@google.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2013245Sgabeblack@google.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2113245Sgabeblack@google.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2213245Sgabeblack@google.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2313245Sgabeblack@google.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2413245Sgabeblack@google.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2513245Sgabeblack@google.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2613245Sgabeblack@google.com * 2713245Sgabeblack@google.com * Authors: Gabe Black 2813245Sgabeblack@google.com */ 2913245Sgabeblack@google.com 3013245Sgabeblack@google.com#include "systemc/utils/tracefile.hh" 3113245Sgabeblack@google.com 3213245Sgabeblack@google.com#include <ctime> 3313245Sgabeblack@google.com#include <iomanip> 3413245Sgabeblack@google.com 3513245Sgabeblack@google.com#include "base/logging.hh" 3613245Sgabeblack@google.com#include "base/output.hh" 3713245Sgabeblack@google.com#include "sim/core.hh" 3813245Sgabeblack@google.com#include "systemc/ext/core/sc_main.hh" 3913245Sgabeblack@google.com#include "systemc/ext/utils/functions.hh" 4013245Sgabeblack@google.com 4113245Sgabeblack@google.comnamespace sc_gem5 4213245Sgabeblack@google.com{ 4313245Sgabeblack@google.com 4413245Sgabeblack@google.comTraceFile::TraceFile(const std::string &name) : 4513245Sgabeblack@google.com _os(simout.create(name, true, true)), timeUnitTicks(0), 4613245Sgabeblack@google.com timeUnitValue(1.0), timeUnitUnit(::sc_core::SC_PS), _traceDeltas(false) 4713245Sgabeblack@google.com{} 4813245Sgabeblack@google.com 4913245Sgabeblack@google.comTraceFile::~TraceFile() 5013245Sgabeblack@google.com{ 5113245Sgabeblack@google.com simout.close(_os); 5213245Sgabeblack@google.com} 5313245Sgabeblack@google.com 5413245Sgabeblack@google.comstd::ostream &TraceFile::stream() { return *_os->stream(); } 5513245Sgabeblack@google.com 5613245Sgabeblack@google.comvoid 5713245Sgabeblack@google.comTraceFile::set_time_unit(double d, ::sc_core::sc_time_unit tu) 5813245Sgabeblack@google.com{ 5913245Sgabeblack@google.com timeUnitValue = d; 6013245Sgabeblack@google.com timeUnitUnit = tu; 6113245Sgabeblack@google.com} 6213245Sgabeblack@google.com 6313245Sgabeblack@google.comvoid 6413245Sgabeblack@google.comTraceFile::finalizeTime() 6513245Sgabeblack@google.com{ 6613245Sgabeblack@google.com timeUnitTicks = ::sc_core::sc_time(timeUnitValue, timeUnitUnit).value(); 6713245Sgabeblack@google.com} 6813245Sgabeblack@google.com 6913245Sgabeblack@google.com} // namespace sc_gem5 70