scc  2024.06
SystemC components library
utilities.cpp
1 /*******************************************************************************
2  * Copyright 2017, 2018 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 #include "utilities.h"
18 
19 namespace sc_core {
20 
21 #ifdef HAS_NO_TIME_TRACE
22 void sc_trace(sc_trace_file* tf, const sc_time& t, const std::string& name) {
23  sc_trace(tf, reinterpret_cast<const sc_core::sc_time::value_type*>(&t), name);
24 }
25 
26 #endif
27 template <> void sc_trace(sc_trace_file* tf, const sc_in<sc_time>& port, const std::string& name) {
28  const sc_signal_in_if<sc_time>* iface = nullptr;
29  if(sc_get_curr_simcontext()->elaboration_done()) {
30  iface = dynamic_cast<const sc_signal_in_if<sc_time>*>(port.get_interface());
31  }
32 
33  if(iface)
34  sc_trace(tf, iface->read(), name);
35  else
36  port.add_trace_internal(tf, name);
37 }
38 
39 template <> void sc_trace(sc_trace_file* tf, const sc_inout<sc_time>& port, const std::string& name) {
40  const sc_signal_in_if<sc_time>* iface = nullptr;
41  if(sc_get_curr_simcontext()->elaboration_done()) {
42  iface = dynamic_cast<const sc_signal_in_if<sc_time>*>(port.get_interface());
43  }
44 
45  if(iface)
46  sc_trace(tf, iface->read(), name);
47  else
48  port.add_trace_internal(tf, name);
49 }
50 } // namespace sc_core