112027Sjungma@eit.uni-kl.de/***************************************************************************** 212027Sjungma@eit.uni-kl.de 312027Sjungma@eit.uni-kl.de Licensed to Accellera Systems Initiative Inc. (Accellera) under one or 412027Sjungma@eit.uni-kl.de more contributor license agreements. See the NOTICE file distributed 512027Sjungma@eit.uni-kl.de with this work for additional information regarding copyright ownership. 612027Sjungma@eit.uni-kl.de Accellera licenses this file to you under the Apache License, Version 2.0 712027Sjungma@eit.uni-kl.de (the "License"); you may not use this file except in compliance with the 812027Sjungma@eit.uni-kl.de License. You may obtain a copy of the License at 912027Sjungma@eit.uni-kl.de 1012027Sjungma@eit.uni-kl.de http://www.apache.org/licenses/LICENSE-2.0 1112027Sjungma@eit.uni-kl.de 1212027Sjungma@eit.uni-kl.de Unless required by applicable law or agreed to in writing, software 1312027Sjungma@eit.uni-kl.de distributed under the License is distributed on an "AS IS" BASIS, 1412027Sjungma@eit.uni-kl.de WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 1512027Sjungma@eit.uni-kl.de implied. See the License for the specific language governing 1612027Sjungma@eit.uni-kl.de permissions and limitations under the License. 1712027Sjungma@eit.uni-kl.de 1812027Sjungma@eit.uni-kl.de *****************************************************************************/ 1912027Sjungma@eit.uni-kl.de 2012027Sjungma@eit.uni-kl.de/***************************************************************************** 2112027Sjungma@eit.uni-kl.de 2212027Sjungma@eit.uni-kl.de sc_trace_file_base.h - Shared internal tracing implementation 2312027Sjungma@eit.uni-kl.de 2412027Sjungma@eit.uni-kl.de Original Author: Philipp A. Hartmann, OFFIS, 2013-11-15 2512027Sjungma@eit.uni-kl.de 2612027Sjungma@eit.uni-kl.de CHANGE LOG AT END OF FILE 2712027Sjungma@eit.uni-kl.de *****************************************************************************/ 2812027Sjungma@eit.uni-kl.de 2912027Sjungma@eit.uni-kl.de/***************************************************************************** 3012027Sjungma@eit.uni-kl.de 3112027Sjungma@eit.uni-kl.de Acknowledgement: The tracing mechanism is based on the tracing 3212027Sjungma@eit.uni-kl.de mechanism developed at Infineon (formerly Siemens HL). Though this 3312027Sjungma@eit.uni-kl.de code is somewhat different, and significantly enhanced, the basics 3412027Sjungma@eit.uni-kl.de are identical to what was originally contributed by Infineon. The 3512027Sjungma@eit.uni-kl.de contribution of Infineon in the development of this tracing 3612027Sjungma@eit.uni-kl.de technology is hereby acknowledged. 3712027Sjungma@eit.uni-kl.de 3812027Sjungma@eit.uni-kl.de *****************************************************************************/ 3912027Sjungma@eit.uni-kl.de 4012027Sjungma@eit.uni-kl.de#ifndef SC_TRACE_FILE_BASE_H_INCLUDED_ 4112027Sjungma@eit.uni-kl.de#define SC_TRACE_FILE_BASE_H_INCLUDED_ 4212027Sjungma@eit.uni-kl.de 4312027Sjungma@eit.uni-kl.de#include <cstdio> 4412027Sjungma@eit.uni-kl.de 4512027Sjungma@eit.uni-kl.de// use callback-based tracing implementation 4612027Sjungma@eit.uni-kl.de#if defined( SC_ENABLE_SIMULATION_PHASE_CALLBACKS_TRACING ) 4712027Sjungma@eit.uni-kl.de# define SC_TRACING_PHASE_CALLBACKS_ 1 4812027Sjungma@eit.uni-kl.de# include "sysc/kernel/sc_object.h" 4912027Sjungma@eit.uni-kl.de#else 5012027Sjungma@eit.uni-kl.de# define SC_TRACING_PHASE_CALLBACKS_ 0 5112027Sjungma@eit.uni-kl.de#endif 5212027Sjungma@eit.uni-kl.de 5312027Sjungma@eit.uni-kl.de#include "sysc/tracing/sc_trace.h" 5412027Sjungma@eit.uni-kl.de#include "sysc/tracing/sc_tracing_ids.h" 5512027Sjungma@eit.uni-kl.de 5612027Sjungma@eit.uni-kl.denamespace sc_core { 5712027Sjungma@eit.uni-kl.de 5812027Sjungma@eit.uni-kl.de// shared implementation of trace files 5912027Sjungma@eit.uni-kl.declass sc_trace_file_base 6012027Sjungma@eit.uni-kl.de : public sc_trace_file 6112027Sjungma@eit.uni-kl.de#if SC_TRACING_PHASE_CALLBACKS_ 6212027Sjungma@eit.uni-kl.de , private sc_object // to be used as callback target 6312027Sjungma@eit.uni-kl.de#endif 6412027Sjungma@eit.uni-kl.de{ 6512027Sjungma@eit.uni-kl.depublic: 6612027Sjungma@eit.uni-kl.de const char* filename() const 6712027Sjungma@eit.uni-kl.de { return filename_.c_str(); } 6812027Sjungma@eit.uni-kl.de 6912027Sjungma@eit.uni-kl.de bool delta_cycles() const 7012027Sjungma@eit.uni-kl.de { return trace_delta_cycles_; } 7112027Sjungma@eit.uni-kl.de 7212027Sjungma@eit.uni-kl.de // Also trace transitions between delta cycles if flag is true. 7312027Sjungma@eit.uni-kl.de virtual void delta_cycles(bool flag); 7412027Sjungma@eit.uni-kl.de 7512027Sjungma@eit.uni-kl.de // set a user-define timescale unit for the trace file 7612027Sjungma@eit.uni-kl.de virtual void set_time_unit( double v, sc_time_unit tu); 7712027Sjungma@eit.uni-kl.de 7812027Sjungma@eit.uni-kl.deprotected: 7912027Sjungma@eit.uni-kl.de sc_trace_file_base( const char* name, const char* extension ); 8012027Sjungma@eit.uni-kl.de 8112027Sjungma@eit.uni-kl.de // returns true, iff initialization has been performed 8212027Sjungma@eit.uni-kl.de bool initialize(); 8312027Sjungma@eit.uni-kl.de // ensure that file has been opened (needed for early write_comment()) 8412027Sjungma@eit.uni-kl.de void open_fp(); 8512027Sjungma@eit.uni-kl.de // perform format specific initialization 8612027Sjungma@eit.uni-kl.de virtual void do_initialize() = 0; 8712027Sjungma@eit.uni-kl.de 8812027Sjungma@eit.uni-kl.de // returns true, if new trace objects can still be added 8912027Sjungma@eit.uni-kl.de // (i.e. trace file is not yet initialized) 9012027Sjungma@eit.uni-kl.de bool add_trace_check( const std::string& name ) const; 9112027Sjungma@eit.uni-kl.de 9212027Sjungma@eit.uni-kl.de // Flush results and close file. 9312027Sjungma@eit.uni-kl.de virtual ~sc_trace_file_base(); 9412027Sjungma@eit.uni-kl.de 9512027Sjungma@eit.uni-kl.de#if SC_TRACING_PHASE_CALLBACKS_ 9612027Sjungma@eit.uni-kl.deprivate: 9712027Sjungma@eit.uni-kl.de virtual void simulation_phase_callback(); 9812027Sjungma@eit.uni-kl.de#endif // SC_TRACING_PHASE_CALLBACKS_ 9912027Sjungma@eit.uni-kl.de 10012027Sjungma@eit.uni-kl.deprotected: 10112027Sjungma@eit.uni-kl.de FILE* fp; // pointer to the trace file 10212027Sjungma@eit.uni-kl.de double timescale_unit; // in seconds 10312027Sjungma@eit.uni-kl.de bool timescale_set_by_user; // = true means set by user 10412027Sjungma@eit.uni-kl.de 10512027Sjungma@eit.uni-kl.deprivate: 10612027Sjungma@eit.uni-kl.de std::string filename_; // name of the file (for reporting) 10712027Sjungma@eit.uni-kl.de bool initialized_; // tracing started? 10812027Sjungma@eit.uni-kl.de bool trace_delta_cycles_; // also trace delta transitions? 10912027Sjungma@eit.uni-kl.de 11012027Sjungma@eit.uni-kl.de static bool tracing_initialized_; // shared setup of tracing implementation 11112027Sjungma@eit.uni-kl.de 11212027Sjungma@eit.uni-kl.deprivate: // disabled 11312027Sjungma@eit.uni-kl.de sc_trace_file_base( const sc_trace_file_base& ) /* = delete */; 11412027Sjungma@eit.uni-kl.de sc_trace_file_base& operator=( const sc_trace_file_base& ) /* = delete */; 11512027Sjungma@eit.uni-kl.de 11612027Sjungma@eit.uni-kl.de}; // class sc_trace_file_base 11712027Sjungma@eit.uni-kl.de 11812027Sjungma@eit.uni-kl.de// ----------------------------------------------------------------------- 11912027Sjungma@eit.uni-kl.de 12012027Sjungma@eit.uni-kl.de// Convert double time to 64-bit integer 12112027Sjungma@eit.uni-kl.de 12212027Sjungma@eit.uni-kl.devoid double_to_special_int64( double in, unsigned* high, unsigned* low ); 12312027Sjungma@eit.uni-kl.de 12412027Sjungma@eit.uni-kl.de// obtain formatted time string 12512027Sjungma@eit.uni-kl.destd::string localtime_string(); 12612027Sjungma@eit.uni-kl.de 12712027Sjungma@eit.uni-kl.de} // namespace sc_core 12812027Sjungma@eit.uni-kl.de 12912027Sjungma@eit.uni-kl.de/***************************************************************************** 13012027Sjungma@eit.uni-kl.de 13112027Sjungma@eit.uni-kl.de MODIFICATION LOG - modifiers, enter your name, affiliation, date and 13212027Sjungma@eit.uni-kl.de changes you are making here. 13312027Sjungma@eit.uni-kl.de 13412027Sjungma@eit.uni-kl.de Name, Affiliation, Date: 13512027Sjungma@eit.uni-kl.de Description of Modification: 13612027Sjungma@eit.uni-kl.de 13712027Sjungma@eit.uni-kl.de *****************************************************************************/ 13812027Sjungma@eit.uni-kl.de 13912027Sjungma@eit.uni-kl.de#endif // SC_TRACE_FILE_BASE_H_INCLUDED_ 14012027Sjungma@eit.uni-kl.de// Taf! 141