scc 2025.09
SystemC components library
perf_estimator.h
1/*******************************************************************************
2 * Copyright 2018, 2020 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_PERFORMANCETRACER_H_
18#define _SCC_PERFORMANCETRACER_H_
19
20#include <boost/date_time/posix_time/posix_time.hpp>
21#include <systemc>
22#include <tuple>
23
29namespace scc {
39class perf_estimator : public sc_core::sc_module {
41 struct time_stamp {
42 boost::posix_time::ptime wall_clock_stamp;
43 double proc_clock_stamp;
44 time_stamp()
45 : wall_clock_stamp(boost::posix_time::microsec_clock::universal_time())
46 , proc_clock_stamp(get_cpu_time()) {}
47 time_stamp& operator=(const time_stamp& o) {
48 wall_clock_stamp = o.wall_clock_stamp;
49 proc_clock_stamp = o.proc_clock_stamp;
50 return *this;
51 }
52 void set() {
53 wall_clock_stamp = boost::posix_time::microsec_clock::universal_time();
54 proc_clock_stamp = get_cpu_time();
55 }
56
57 private:
58 static double get_cpu_time();
59 };
60
61public:
68 : perf_estimator(sc_core::SC_ZERO_TIME) {}
69
75 perf_estimator(sc_core::sc_time heart_beat)
76 : perf_estimator(sc_core::sc_gen_unique_name("$$$perf_estimator$$$", true), heart_beat) {}
77
82 virtual ~perf_estimator();
89 void set_cycle_time(sc_core::sc_time cycle_period) { this->cycle_period = cycle_period; };
90
91protected:
92 perf_estimator(const sc_core::sc_module_name& nm, sc_core::sc_time heart_beat);
94 void end_of_elaboration() override;
95 void start_of_simulation() override;
96 void end_of_simulation() override;
98 time_stamp soc;
99 time_stamp eoe;
100 time_stamp sos;
101 time_stamp eos;
102 sc_core::sc_time beat_delay, cycle_period;
103 void beat();
104 long get_memory();
105 long max_memory{0};
106};
107
108} /* namespace scc */ // end of scc-sysc
110#endif /* _SCC_PERFORMANCETRACER_H_ */
void set_cycle_time(sc_core::sc_time cycle_period)
set the cycle time for cylces per second calculation
perf_estimator()
default constructor creating an unnamed perf_estimator
void end_of_elaboration() override
SystemC callbacks.
perf_estimator(sc_core::sc_time heart_beat)
default constructor creating an unnamed perf_estimator having a heart beat
virtual ~perf_estimator()
destructor
time_stamp soc
the recorded time stamps
SCC TLM utilities.