qualcomm/qbox
Loading...
Searching...
No Matches
timeprinter.h
1/*
2 * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef TIMEPRINTER_H
8#define TIMEPRINTER_H
9#include <systemc>
10#include <scp/report.h>
11#include <cci_configuration>
12
13#include <module_factory_registery.h>
25SC_MODULE (timeprinter) {
26 SCP_LOGGER();
27 cci::cci_param<uint64_t> interval_us;
28 SC_CTOR (timeprinter) : interval_us("interval_us",1000000,"Interval between printing in microseconds")
29 {
30 SC_THREAD(print_time_stamp);
31 }
32
33 void print_time_stamp()
34 {
35 auto startRT = std::chrono::high_resolution_clock::now();
36
37 while (1) {
38 sc_core::sc_time now = sc_core::sc_time(std::chrono::duration_cast<std::chrono::microseconds>(
39 std::chrono::high_resolution_clock::now() - startRT)
40 .count(),
41 sc_core::SC_US);
42
43 SCP_INFO(())("time stamp real time: {:.6}s", now.to_seconds());
44 sc_core::wait(interval_us, sc_core::SC_US);
45 }
46 }
47};
48
49extern "C" void module_register();
50
51#endif // TIMEPRINTER_H