1/***************************************************************************** 2 3 Licensed to Accellera Systems Initiative Inc. (Accellera) under one or 4 more contributor license agreements. See the NOTICE file distributed 5 with this work for additional information regarding copyright ownership. 6 Accellera licenses this file to you under the Apache License, Version 2.0 7 (the "License"); you may not use this file except in compliance with the 8 License. You may obtain a copy of the License at 9 10 http://www.apache.org/licenses/LICENSE-2.0 11 12 Unless required by applicable law or agreed to in writing, software 13 distributed under the License is distributed on an "AS IS" BASIS, 14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 15 implied. See the License for the specific language governing 16 permissions and limitations under the License. 17 18 *****************************************************************************/ 19 20/***************************************************************************** 21 22 sc_trace_file_base.h - Shared internal tracing implementation 23 24 Original Author: Philipp A. Hartmann, OFFIS, 2013-11-15 25 26 CHANGE LOG AT END OF FILE 27 *****************************************************************************/ 28 29/***************************************************************************** 30 31 Acknowledgement: The tracing mechanism is based on the tracing 32 mechanism developed at Infineon (formerly Siemens HL). Though this 33 code is somewhat different, and significantly enhanced, the basics 34 are identical to what was originally contributed by Infineon. The 35 contribution of Infineon in the development of this tracing 36 technology is hereby acknowledged. 37 38 *****************************************************************************/ 39 40#ifndef SC_TRACE_FILE_BASE_H_INCLUDED_ 41#define SC_TRACE_FILE_BASE_H_INCLUDED_ 42 43#include <cstdio> 44 45// use callback-based tracing implementation 46#if defined( SC_ENABLE_SIMULATION_PHASE_CALLBACKS_TRACING ) 47# define SC_TRACING_PHASE_CALLBACKS_ 1 48# include "sysc/kernel/sc_object.h" 49#else 50# define SC_TRACING_PHASE_CALLBACKS_ 0 51#endif 52 53#include "sysc/tracing/sc_trace.h" 54#include "sysc/tracing/sc_tracing_ids.h" 55 56namespace sc_core { 57 58// shared implementation of trace files 59class sc_trace_file_base 60 : public sc_trace_file 61#if SC_TRACING_PHASE_CALLBACKS_ 62 , private sc_object // to be used as callback target 63#endif 64{ 65public: 66 const char* filename() const 67 { return filename_.c_str(); } 68 69 bool delta_cycles() const 70 { return trace_delta_cycles_; } 71 72 // Also trace transitions between delta cycles if flag is true. 73 virtual void delta_cycles(bool flag); 74 75 // set a user-define timescale unit for the trace file 76 virtual void set_time_unit( double v, sc_time_unit tu); 77 78protected: 79 sc_trace_file_base( const char* name, const char* extension ); 80 81 // returns true, iff initialization has been performed 82 bool initialize(); 83 // ensure that file has been opened (needed for early write_comment()) 84 void open_fp(); 85 // perform format specific initialization 86 virtual void do_initialize() = 0; 87 88 // returns true, if new trace objects can still be added 89 // (i.e. trace file is not yet initialized) 90 bool add_trace_check( const std::string& name ) const; 91 92 // Flush results and close file. 93 virtual ~sc_trace_file_base(); 94 95#if SC_TRACING_PHASE_CALLBACKS_ 96private: 97 virtual void simulation_phase_callback(); 98#endif // SC_TRACING_PHASE_CALLBACKS_ 99 100protected: 101 FILE* fp; // pointer to the trace file 102 double timescale_unit; // in seconds 103 bool timescale_set_by_user; // = true means set by user 104 105private: 106 std::string filename_; // name of the file (for reporting) 107 bool initialized_; // tracing started? 108 bool trace_delta_cycles_; // also trace delta transitions? 109 110 static bool tracing_initialized_; // shared setup of tracing implementation 111 112private: // disabled 113 sc_trace_file_base( const sc_trace_file_base& ) /* = delete */; 114 sc_trace_file_base& operator=( const sc_trace_file_base& ) /* = delete */; 115 116}; // class sc_trace_file_base 117 118// ----------------------------------------------------------------------- 119 120// Convert double time to 64-bit integer 121 122void double_to_special_int64( double in, unsigned* high, unsigned* low ); 123 124// obtain formatted time string 125std::string localtime_string(); 126 127} // namespace sc_core 128 129/***************************************************************************** 130 131 MODIFICATION LOG - modifiers, enter your name, affiliation, date and 132 changes you are making here. 133 134 Name, Affiliation, Date: 135 Description of Modification: 136 137 *****************************************************************************/ 138 139#endif // SC_TRACE_FILE_BASE_H_INCLUDED_ 140// Taf! 141