scc  2022.4.0
SystemC components library
tracer_base.h
1 /*******************************************************************************
2  * Copyright 2019 MINRES Technologies GmbH
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *******************************************************************************/
16 
17 #ifndef _SCC_TRACER_BASE_H_
18 #define _SCC_TRACER_BASE_H_
19 
20 #include "utilities.h"
21 #include <sysc/tracing/sc_trace.h>
22 #include <type_traits>
23 
29 namespace scc {
35 enum class trace_types : unsigned {
36  NONE = 0x0,
37  SIGNALS = 0x1,
38  PORTS = 0x2,
39  SOCKETS = 0x4,
40  VARIABLES = 0x8,
41  ALL = 0xff
42 };
52  return static_cast<trace_types>(static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs));
53 }
63  return static_cast<trace_types>(static_cast<unsigned>(lhs) & static_cast<unsigned>(rhs));
64 }
78 class tracer_base : public sc_core::sc_module {
79 public:
86  tracer_base(const sc_core::sc_module_name& nm)
87  : sc_core::sc_module(nm) {}
96  tracer_base(const sc_core::sc_module_name& nm, sc_core::sc_trace_file* tf, bool owned = true)
97  : sc_core::sc_module(nm)
98  , trf(tf) {}
111  void set_trace_types(trace_types t) { types_to_trace = t; }
118  const sc_core::sc_trace_file* get_trace_file() const { return trf; }
125  sc_core::sc_trace_file* get_trace_file() { return trf; }
133  void set_trace_file(sc_core::sc_trace_file* trf) { this->trf = trf; }
134 
135 protected:
136  static std::string get_name();
137 
140 
141  virtual void descend(const sc_core::sc_object*, bool trace_all);
142 
143  static void try_trace(sc_core::sc_trace_file* trace_file, const sc_core::sc_object* object, trace_types t);
144 
145  sc_core::sc_trace_file* trf{nullptr};
146 
147  trace_types types_to_trace{trace_types::ALL};
148 };
149 
150 } // namespace scc // end of scc-sysc
152 #endif /* _SCC_TRACER_BASE_H_ */
base class for automatic tracer
Definition: tracer_base.h:78
const sc_core::sc_trace_file * get_trace_file() const
get the tracefile used by this tracer
Definition: tracer_base.h:118
bool default_trace_enable
the default for tracing if no attribute is configured
Definition: tracer_base.h:139
tracer_base(const sc_core::sc_module_name &nm, sc_core::sc_trace_file *tf, bool owned=true)
named constructor with trace file
Definition: tracer_base.h:96
void set_trace_file(sc_core::sc_trace_file *trf)
set the trace file of this tracer
Definition: tracer_base.h:133
tracer_base(const sc_core::sc_module_name &nm)
named constructor
Definition: tracer_base.h:86
void set_trace_types(trace_types t)
set the types to trace
Definition: tracer_base.h:111
~tracer_base()
destructor
Definition: tracer_base.h:104
SCC SystemC utilities.
trace_types
identifies the various type to be traced
Definition: tracer_base.h:35
trace_types operator&(trace_types lhs, trace_types rhs)
operator overload to allow boolean and operations on trace_types
Definition: tracer_base.h:62
trace_types operator|(trace_types lhs, trace_types rhs)
operator overload to allow boolean or operations on trace_types
Definition: tracer_base.h:51